fix(core.gbapp): Fix in deploy.

This commit is contained in:
Rodrigo Rodriguez 2020-04-03 09:46:13 -03:00
parent b477c46d9c
commit c6d3086fa0
3 changed files with 21 additions and 18 deletions

View file

@ -529,10 +529,11 @@ export class GBDeployer implements IGBDeployer {
} }
folder = Path.join(e, 'dist'); folder = Path.join(e, 'dist');
if (!Fs.existsSync()) { if (!Fs.existsSync()) {
GBLog.info(`Compiling ${e}...`);
try { try {
if (process.env.GBAPP_DISABLE_COMPILE !== "true") { GBLog.info(`process.env.GBAPP_DISABLE_COMPILE: ${process.env.GBAPP_DISABLE_COMPILE}`);
if (process.env.GBAPP_DISABLE_COMPILE !== "true" && false) {
child_process.execSync(Path.join(process.env.PWD, 'node_modules/.bin/tsc'), { cwd: e }); child_process.execSync(Path.join(process.env.PWD, 'node_modules/.bin/tsc'), { cwd: e });
} }
const m = await import(e); const m = await import(e);

View file

@ -44,6 +44,7 @@ const removeRoute = require('express-remove-route');
const AuthenticationContext = require('adal-node').AuthenticationContext; const AuthenticationContext = require('adal-node').AuthenticationContext;
const wash = require('washyourmouthoutwithsoap'); const wash = require('washyourmouthoutwithsoap');
import { AutoSaveStateMiddleware, BotFrameworkAdapter, ConversationState, MemoryStorage, UserState } from 'botbuilder'; import { AutoSaveStateMiddleware, BotFrameworkAdapter, ConversationState, MemoryStorage, UserState } from 'botbuilder';
import { CollectionUtil } from 'pragmatismo-io-framework';
import { ConfirmPrompt, WaterfallDialog } from 'botbuilder-dialogs'; import { ConfirmPrompt, WaterfallDialog } from 'botbuilder-dialogs';
import { import {
GBDialogStep, GBDialogStep,
@ -65,6 +66,7 @@ import { GBConfigService } from './GBConfigService';
import { GBDeployer } from './GBDeployer'; import { GBDeployer } from './GBDeployer';
import { SecService } from '../../security.gblib/services/SecService'; import { SecService } from '../../security.gblib/services/SecService';
import { AnalyticsService } from '../../analytics.gblib/services/AnalyticsService'; import { AnalyticsService } from '../../analytics.gblib/services/AnalyticsService';
import { WhatsappDirectLine } from '../../whatsapp.gblib/services/WhatsappDirectLine';
/** /**
* Minimal service layer for a bot. * Minimal service layer for a bot.
@ -207,7 +209,7 @@ export class GBMinService {
// this.deployer.deployPackage(min, 'packages/default.gbdialog'); // this.deployer.deployPackage(min, 'packages/default.gbdialog');
// Call the loadBot context.activity for all packages. // Call the loadBot context.activity for all packages.
this.invokeLoadBot(GBServer.globals.appPackages, GBServer.globals.sysPackages, min); await this.invokeLoadBot(GBServer.globals.appPackages, GBServer.globals.sysPackages, min);
// Serves individual URL for each bot conversational interface... // Serves individual URL for each bot conversational interface...
const url = `/api/messages/${instance.botId}`; const url = `/api/messages/${instance.botId}`;
@ -402,6 +404,16 @@ export class GBMinService {
min.scriptMap = {}; min.scriptMap = {};
min.sandBoxMap = {}; min.sandBoxMap = {};
min.packages = sysPackages; min.packages = sysPackages;
if (min.instance.whatsappServiceKey !== null ) {
min.whatsAppDirectLine = new WhatsappDirectLine(
min.botId,
min.instance.whatsappBotKey,
min.instance.whatsappServiceKey,
min.instance.whatsappServiceNumber,
min.instance.whatsappServiceUrl
);
}
min.userProfile = conversationState.createProperty('userProfile'); min.userProfile = conversationState.createProperty('userProfile');
const dialogState = conversationState.createProperty('dialogState'); const dialogState = conversationState.createProperty('dialogState');
@ -412,12 +424,11 @@ export class GBMinService {
return { min, adapter, conversationState }; return { min, adapter, conversationState };
} }
private invokeLoadBot(appPackages: IGBPackage[], sysPackages: IGBPackage[], min: GBMinInstance) { private async invokeLoadBot(appPackages: IGBPackage[], sysPackages: IGBPackage[], min: GBMinInstance) {
sysPackages.forEach(e => { await CollectionUtil.asyncForEach(sysPackages, async e => {
e.loadBot(min); e.loadBot(min);
}, this); });
await CollectionUtil.asyncForEach(appPackages, async p => {
appPackages.forEach(p => {
p.sysPackages = sysPackages; p.sysPackages = sysPackages;
p.loadBot(min); p.loadBot(min);
if (p.getDialogs !== undefined) { if (p.getDialogs !== undefined) {
@ -426,7 +437,7 @@ export class GBMinService {
min.dialogs.add(new WaterfallDialog(dialog.id, dialog.waterfall)); min.dialogs.add(new WaterfallDialog(dialog.id, dialog.waterfall));
}); });
} }
}, this); });
} }
/** /**

View file

@ -49,15 +49,6 @@ export class GBWhatsappPackage implements IGBPackage {
public loadBot(min: GBMinInstance): void { public loadBot(min: GBMinInstance): void {
// Only loads engine if it is defined on services.json. // Only loads engine if it is defined on services.json.
if (min.instance.whatsappServiceKey !== null ) {
min.whatsAppDirectLine = new WhatsappDirectLine(
min.botId,
min.instance.whatsappBotKey,
min.instance.whatsappServiceKey,
min.instance.whatsappServiceNumber,
min.instance.whatsappServiceUrl
);
}
} }
public getDialogs(min: GBMinInstance) { public getDialogs(min: GBMinInstance) {