Skip to content

Commit

Permalink
fix(core.gbapp): Fix in deploy.
Browse files Browse the repository at this point in the history
  • Loading branch information
rodrigorodriguez committed Apr 3, 2020
1 parent b477c46 commit c6d3086
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 18 deletions.
5 changes: 3 additions & 2 deletions packages/core.gbapp/services/GBDeployer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -529,10 +529,11 @@ export class GBDeployer implements IGBDeployer {
}
folder = Path.join(e, 'dist');
if (!Fs.existsSync()) {
GBLog.info(`Compiling ${e}...`);


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 });
}
const m = await import(e);
Expand Down
25 changes: 18 additions & 7 deletions packages/core.gbapp/services/GBMinService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ const removeRoute = require('express-remove-route');
const AuthenticationContext = require('adal-node').AuthenticationContext;
const wash = require('washyourmouthoutwithsoap');
import { AutoSaveStateMiddleware, BotFrameworkAdapter, ConversationState, MemoryStorage, UserState } from 'botbuilder';
import { CollectionUtil } from 'pragmatismo-io-framework';
import { ConfirmPrompt, WaterfallDialog } from 'botbuilder-dialogs';
import {
GBDialogStep,
Expand All @@ -65,6 +66,7 @@ import { GBConfigService } from './GBConfigService';
import { GBDeployer } from './GBDeployer';
import { SecService } from '../../security.gblib/services/SecService';
import { AnalyticsService } from '../../analytics.gblib/services/AnalyticsService';
import { WhatsappDirectLine } from '../../whatsapp.gblib/services/WhatsappDirectLine';

/**
* Minimal service layer for a bot.
Expand Down Expand Up @@ -207,7 +209,7 @@ export class GBMinService {
// this.deployer.deployPackage(min, 'packages/default.gbdialog');

// 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...
const url = `/api/messages/${instance.botId}`;
Expand Down Expand Up @@ -402,6 +404,16 @@ export class GBMinService {
min.scriptMap = {};
min.sandBoxMap = {};
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');
const dialogState = conversationState.createProperty('dialogState');

Expand All @@ -412,12 +424,11 @@ export class GBMinService {
return { min, adapter, conversationState };
}

private invokeLoadBot(appPackages: IGBPackage[], sysPackages: IGBPackage[], min: GBMinInstance) {
sysPackages.forEach(e => {
private async invokeLoadBot(appPackages: IGBPackage[], sysPackages: IGBPackage[], min: GBMinInstance) {
await CollectionUtil.asyncForEach(sysPackages, async e => {
e.loadBot(min);
}, this);

appPackages.forEach(p => {
});
await CollectionUtil.asyncForEach(appPackages, async p => {
p.sysPackages = sysPackages;
p.loadBot(min);
if (p.getDialogs !== undefined) {
Expand All @@ -426,7 +437,7 @@ export class GBMinService {
min.dialogs.add(new WaterfallDialog(dialog.id, dialog.waterfall));
});
}
}, this);
});
}

/**
Expand Down
9 changes: 0 additions & 9 deletions packages/whatsapp.gblib/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,6 @@ export class GBWhatsappPackage implements IGBPackage {
public loadBot(min: GBMinInstance): void {
// 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) {
Expand Down

0 comments on commit c6d3086

Please sign in to comment.