Skip to content

Commit

Permalink
fix(all): Now keyword, autostart dialog, prod size optimization.
Browse files Browse the repository at this point in the history
  • Loading branch information
rodrigorodriguez committed Nov 22, 2020
1 parent ec1ec20 commit a17f21e
Show file tree
Hide file tree
Showing 7 changed files with 2,411 additions and 1,566 deletions.
1 change: 1 addition & 0 deletions deploy.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ IF EXIST "%DEPLOYMENT_TARGET%\deploy\default.gbui\package.json" (
echo [General Bots Deployer] Building default.gbui...
call :ExecuteCmd !NPM_CMD! run build
IF !ERRORLEVEL! NEQ 0 goto error
RMDIR /s /q "%DEPLOYMENT_TARGET%\deploy\default.gbui\node_modules"
popd
)

Expand Down
3,848 changes: 2,338 additions & 1,510 deletions package-lock.json

Large diffs are not rendered by default.

75 changes: 37 additions & 38 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,16 +48,15 @@
"commit": "git-cz"
},
"dependencies": {
"@azure/ms-rest-js": "2.0.4",
"node-cron": "2.0.3",
"@microsoft/microsoft-graph-client": "2.0.0",
"@semantic-release/changelog": "^5.0.1",
"@semantic-release/exec": "^5.0.0",
"@semantic-release/git": "^9.0.0",
"@azure/ms-rest-js": "2.1.0",
"@microsoft/microsoft-graph-client": "2.1.1",
"@semantic-release/changelog": "5.0.1",
"@semantic-release/exec": "5.0.0",
"@semantic-release/git": "9.0.0",
"@types/validator": "13.1.0",
"adal-node": "0.2.1",
"any-shell-escape": "^0.1.1",
"async-promises": "0.2.2",
"any-shell-escape": "0.1.1",
"async-promises": "0.2.3",
"azure-arm-cognitiveservices": "3.0.0",
"azure-arm-resource": "7.4.0",
"azure-arm-search": "1.3.0-preview",
Expand All @@ -66,29 +65,28 @@
"azure-search-client": "3.1.5",
"bluebird": "3.7.2",
"body-parser": "1.19.0",
"botbuilder": "4.7.0",
"botbuilder-ai": "4.7.0",
"botbuilder-dialogs": "4.7.0",
"botframework-connector": "4.7.0",
"botlib": "1.6.7",
"botbuilder": "4.11.0",
"botbuilder-ai": "4.11.0",
"botbuilder-dialogs": "4.11.0",
"botframework-connector": "4.11.0",
"botlib": "1.7.0",
"cli-spinner": "0.2.10",
"core-js": "^3.6.5",
"dotenv-extended": "2.8.0",
"exceljs": "4.1.0",
"core-js": "3.7.0",
"dotenv-extended": "2.9.0",
"exceljs": "4.2.0",
"express": "4.17.1",
"express-remove-route": "1.0.0",
"ffmpeg-static": "4.2.5",
"google-libphonenumber": "3.2.10",
"ibm-watson": "^5.6.2",
"js-beautify": "1.11.0",
"marked": "1.1.0",
"microsoft-cognitiveservices-speech-sdk": "^1.13.1",
"ffmpeg-static": "4.2.7",
"google-libphonenumber": "3.2.15",
"ibm-watson": "5.7.1",
"js-beautify": "1.13.0",
"marked": "1.2.5",
"microsoft-cognitiveservices-speech-sdk": "1.14.1",
"ms-rest-azure": "3.0.0",
"nexmo": "2.8.0",
"ngrok": "3.2.7",
"npm": "6.14.6",
"nexmo": "2.9.1",
"node-cron": "2.0.3",
"opn": "6.0.0",
"phone": "^2.4.14",
"phone": "2.4.17",
"pragmatismo-io-framework": "1.0.20",
"prism-media": "1.2.2",
"public-ip": "4.0.2",
Expand All @@ -98,37 +96,38 @@
"request-promise-native": "1.0.8",
"rimraf": "3.0.2",
"safe-buffer": "5.2.1",
"scanf": "1.1.1",
"scanf": "1.1.2",
"sequelize": "5.21.5",
"sequelize-typescript": "1.1.0",
"simple-commit-message": "^4.0.13",
"simple-git": "2.12.0",
"sppull": "2.6.5",
"simple-git": "2.23.0",
"sppull": "2.6.7",
"strict-password-generator": "1.1.2",
"swagger-client": "2.1.18",
"tedious": "8.3.0",
"tedious": "9.2.1",
"textract": "2.5.0",
"typescript": "3.9.6",
"typescript": "4.1.2",
"url-join": "4.0.1",
"vbscript-to-typescript": "1.0.8",
"walk-promise": "0.2.0",
"washyourmouthoutwithsoap": "1.0.2"
},
"devDependencies": {
"typedoc": "0.17.8",
"ngrok": "3.3.0",
"typedoc": "0.19.2",
"simple-commit-message": "4.0.13",
"@types/url-join": "4.0.0",
"@types/winston": "2.4.4",
"ban-sensitive-files": "1.9.7",
"commitizen": "4.1.2",
"cz-conventional-changelog": "3.2.0",
"ban-sensitive-files": "1.9.14",
"commitizen": "4.2.2",
"cz-conventional-changelog": "3.3.0",
"dependency-check": "4.1.0",
"git-issues": "1.3.1",
"license-checker": "25.0.1",
"nsp": "3.2.1",
"prettier-standard": "16.4.1",
"semantic-release": "17.1.1",
"semantic-release": "17.2.4",
"travis-deploy-once": "5.0.11",
"ts-node": "8.10.2",
"ts-node": "9.0.0",
"tslint": "6.1.2"
},
"eslintConfig": {
Expand Down
3 changes: 0 additions & 3 deletions packages/core.gbapp/services/GBConversationalService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -208,9 +208,6 @@ export class GBConversationalService {
public static async getTextFromAudioBuffer(speechKey, cloudRegion, buffer, locale): Promise<string> {
return new Promise<string>(async (resolve, reject) => {
try {
let subscriptionKey = speechKey;
let serviceRegion = cloudRegion;

const oggFile = new Readable();
oggFile._read = () => {}; // _read is required but you can noop it
oggFile.push(buffer);
Expand Down
10 changes: 7 additions & 3 deletions packages/core.gbapp/services/GBDeployer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -541,12 +541,16 @@ export class GBDeployer implements IGBDeployer {
public setupDefaultGBUI() {
const root = 'packages/default.gbui';
const npm = urlJoin(process.env.PWD, 'node_modules', '.bin', 'npm');
if (!Fs.existsSync(`${root}/build`)) {
GBLog.info(`Preparing default.gbui (it may take some additional time for the first time)...`);
if (!Fs.existsSync(`${root}/build`) && process.env.DISABLE_WEB !== 'true'){
GBLog.info(`Installing modules default.gbui (It may take a few minutes)...`);
Fs.writeFileSync(`${root}/.env`, 'SKIP_PREFLIGHT_CHECK=true');
child_process.execSync(`${npm} install`, { cwd: root });
GBLog.info(`Transpiling default.gbui...`);
child_process.execSync(`${npm} run build`, { cwd: root });
GBLog.info(`Cleaning default.gbui node_modules...`);
}
const nodeModules = urlJoin(root, 'node_modules');
rimraf.sync(nodeModules);
}

private async deployDataPackages(
Expand All @@ -565,7 +569,7 @@ export class GBDeployer implements IGBDeployer {

const instances = await core.loadInstances();
await CollectionUtil.asyncForEach(instances, async instance => {
this.mountGBKBAssets(`${instance.botId}.gbkb`,
this.mountGBKBAssets(`${instance.botId}.gbkb`,
instance.botId, `${instance.botId}.gbkb`);
});

Expand Down
22 changes: 19 additions & 3 deletions packages/core.gbapp/services/GBMinService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,16 @@ export class GBMinService {
id,
`Olá! Seja bem-vinda(o)!\nMe chamo ${activeMin.instance.title}. Como posso ajudar? Pode me falar que eu te ouço, me manda um aúdio.`
);
res.end();

let startDialog = activeMin.core.getParam(activeMin.instance, 'Start Dialog', null);
GBLog.info(`Auto start dialog is now being called: ${startDialog}...`);
if (startDialog) {
req.body.messages[0].body = `/${startDialog}`;
await (activeMin as any).whatsAppDirectLine.received(req, res);
}
else {
res.end();
}
} else {
// User wants to switch bots.
if (toSwitchMin !== undefined) {
Expand All @@ -181,7 +190,14 @@ export class GBMinService {
id,
`Agora falando com ${activeMin.instance.title}...`
);
res.end();
let startDialog = activeMin.core.getParam(activeMin.instance, 'Start Dialog', null);
if (startDialog) {
GBLog.info(`Auto start dialog is now being called: ${startDialog}...`); req.body.messages[0].body = `/${startDialog}`;
await (activeMin as any).whatsAppDirectLine.received(req, res);
}
else {
res.end();
}
} else {
activeMin = GBServer.globals.minInstances.filter(p => p.instance.instanceId === user.instanceId)[0];
if (activeMin === undefined) {
Expand Down Expand Up @@ -794,7 +810,7 @@ export class GBMinService {
if (hasBadWord) {
return await step.beginDialog('/pleaseNoBadWords');
}

// Translates the input text if is turned on instance params.


Expand Down
18 changes: 9 additions & 9 deletions packages/core.gbapp/services/GBVMService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,11 +152,10 @@ export class GBVMService extends GBService {
public convertGBASICToVBS(code: string) {
// Start and End of VB2TS tags of processing.


code = `<%\n
from = this.getFrom(step)
today = this.getToday(step)
now = this.getNow(step)
id = sys().getRandomId()
username = this.getUserName(step);
mobile = this.getUserMobile(step);
Expand Down Expand Up @@ -323,11 +322,14 @@ export class GBVMService extends GBService {

parsedCode = this.handleThisAndAwait(parsedCode);

parsedCode = parsedCode.replace(/(now)(?=(?:[^"]|"[^"]*")*$)/, 'await this.getNow(step)');
parsedCode = parsedCode.replace(/(today)(?=(?:[^"]|"[^"]*")*$)/, 'await this.getToday(step)');

parsedCode = beautify(parsedCode, { indent_size: 2, space_in_empty_paren: true });
fs.writeFileSync(jsfile, parsedCode);

this.executeJS(min, deployer, parsedCode, mainName);
GBLog.info(`[GBVMService] Finished loading of ${filename}`);
GBLog.info(`[GBVMService] Finished loading of ${filename}, JavaScript from Word: ${parsedCode}`);
}
}

Expand Down Expand Up @@ -370,7 +372,7 @@ export class GBVMService extends GBService {
code = code.replace(/this\./gm, 'await this.');
code = code.replace(/function/gm, 'async function');
code = code.replace('ubound = async', 'ubound ='); // TODO: Improve this.

return code;
}

Expand All @@ -394,15 +396,13 @@ export class GBVMService extends GBService {
const opts = await promise(step, step.result);
return await step.replaceDialog('/hear', opts);
} catch (error) {
GBLog.error(`Error running BASIC code: ${error}`);
GBLog.error(`Error in BASIC code: ${error}`);
const locale = step.context.activity.locale;
min.conversationalService.sendText(min, step, Messages[locale].very_sorry_about_error);
return await step.replaceDialog('/ask', { isReturning: true });
}
} else {
await step.replaceDialog('/ask', { isReturning: true });
}
}
return await step.endDialog();
}
])
);
}
Expand Down

0 comments on commit a17f21e

Please sign in to comment.