Skip to content

Commit

Permalink
fix(general): tslint being applied in all sources.
Browse files Browse the repository at this point in the history
  • Loading branch information
rodrigorodriguez committed Mar 8, 2019
1 parent a5a5f23 commit 5d08457
Show file tree
Hide file tree
Showing 28 changed files with 446 additions and 579 deletions.
6 changes: 3 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
"botbuilder-choices": "4.0.0-preview1.2",
"botbuilder-dialogs": "4.2.0",
"botbuilder-prompts": "4.0.0-preview1.2",
"botlib": "0.1.19",
"botlib": "^0.1.21",
"chai": "4.2.0",
"child_process": "^1.0.2",
"chokidar": "2.1.2",
Expand Down
22 changes: 12 additions & 10 deletions packages/admin.gbapp/dialogs/AdminDialog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,14 @@

const UrlJoin = require('url-join');
import { BotAdapter } from 'botbuilder';
import { WaterfallDialog, WaterfallStep, WaterfallStepContext } from 'botbuilder-dialogs';
import { GBMinInstance } from 'botlib';
import { IGBDialog } from 'botlib';
import { WaterfallDialog } from 'botbuilder-dialogs';
import { GBMinInstance, IGBDialog } from 'botlib';
import { GBConfigService } from '../../core.gbapp/services/GBConfigService';
import { GBDeployer } from '../../core.gbapp/services/GBDeployer';
import { GBImporter } from '../../core.gbapp/services/GBImporterService';
import { GBAdminService } from '../services/GBAdminService';
import { Messages } from '../strings';
import { AzureDeployerService } from '../../azuredeployer.gbapp/services/AzureDeployerService';

/**
* Dialogs for administration tasks.
Expand Down Expand Up @@ -79,7 +79,10 @@ export class AdminDialog extends IGBDialog {
}

public static async rebuildIndexPackageCommand(min: GBMinInstance, text: string, deployer: GBDeployer) {
await deployer.rebuildIndex(min.instance);
await deployer.rebuildIndex(
min.instance,
new AzureDeployerService(deployer).getKBSearchSchema(min.instance.searchIndex)
);
}

public static async addConnectionCommand(min: GBMinInstance, text: any) {
Expand Down Expand Up @@ -136,7 +139,7 @@ export class AdminDialog extends IGBDialog {
if (text === 'quit') {
return await step.replaceDialog('/');
} else if (cmdName === 'createFarm') {
await AdminDialog.createFarmCommand(text, deployer);
await AdminDialog.createFarmCommand(text, min);

return await step.replaceDialog('/admin', { firstRun: false });
} else if (cmdName === 'deployPackage') {
Expand Down Expand Up @@ -224,20 +227,19 @@ export class AdminDialog extends IGBDialog {

await min.adminService.setValue(min.instance.instanceId, 'AntiCSRFAttackState', state);

const url = `https://login.microsoftonline.com/${min.instance.authenticatorTenant}/oauth2/authorize?client_id=${
min.instance.authenticatorClientId
}&response_type=code&redirect_uri=${UrlJoin(
const url = `https://login.microsoftonline.com/${
min.instance.authenticatorTenant
}/oauth2/authorize?client_id=${min.instance.authenticatorClientId}&response_type=code&redirect_uri=${UrlJoin(
min.instance.botEndpoint,
min.instance.botId,
'/token'
)}&state=${state}&response_mode=query`;

await step.context.sendActivity(Messages[locale].consent(url));

return await step.replaceDialog('/ask', {isReturning: true});
return await step.replaceDialog('/ask', { isReturning: true });
}
])
);
}

}
9 changes: 6 additions & 3 deletions packages/admin.gbapp/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,18 @@

'use strict';

import urlJoin = require('url-join');

import { GBMinInstance, IGBCoreService, IGBPackage } from 'botlib';
import { Sequelize } from 'sequelize-typescript';
import { AdminDialog } from './dialogs/AdminDialog';
import { GuaribasAdmin } from './models/AdminModel';

export class GBAdminPackage implements IGBPackage {
public sysPackages: IGBPackage[] = null;
public sysPackages: IGBPackage[] = undefined;

public unloadPackage(core: IGBCoreService): void {}
public getDialogs(min: GBMinInstance) {}
public unloadBot(min: GBMinInstance): void {}
public onNewSession(min: GBMinInstance, step: any): void {}

public loadPackage(core: IGBCoreService, sequelize: Sequelize): void {
core.sequelize.addModels([GuaribasAdmin]);
Expand Down
11 changes: 5 additions & 6 deletions packages/admin.gbapp/services/GBAdminService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
'use strict';

import { AuthenticationContext, TokenResponse } from 'adal-node';
import { IGBCoreService } from 'botlib';
import { IGBCoreService, IGBAdminService } from 'botlib';
import { GuaribasInstance } from '../../core.gbapp/models/GBModel';
import { GuaribasAdmin } from '../models/AdminModel';
const UrlJoin = require('url-join');
Expand All @@ -47,7 +47,7 @@ const PasswordGenerator = require('strict-password-generator').default;
/**
* Services for server administration.
*/
export class GBAdminService {
export class GBAdminService implements IGBAdminService {
public static GB_PROMPT: string = 'GeneralBots: ';
public static masterBotInstanceId = 0;

Expand Down Expand Up @@ -76,7 +76,7 @@ export class GBAdminService {
return credentials;
}

public static getRndPassword() {
public static getRndPassword(): string {
const passwordGenerator = new PasswordGenerator();
const options = {
upperCaseAlpha: true,
Expand Down Expand Up @@ -105,7 +105,7 @@ export class GBAdminService {
return name;
}

public async setValue(instanceId: number, key: string, value: string): Promise<GuaribasAdmin> {
public async setValue(instanceId: number, key: string, value: string) {
const options = { where: {} };
options.where = { key: key };
let admin = await GuaribasAdmin.findOne(options);
Expand All @@ -115,8 +115,7 @@ export class GBAdminService {
}
admin.value = value;
admin.instanceId = instanceId;

return admin.save();
await admin.save();
}

public async updateSecurityInfo(
Expand Down
4 changes: 2 additions & 2 deletions packages/analytics.gblib/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ import { GBMinInstance, IGBCoreService, IGBPackage } from 'botlib';
import { Sequelize } from 'sequelize-typescript';

export class GBAnalyticsPackage implements IGBPackage {
public sysPackages: IGBPackage[] = null;

public sysPackages: IGBPackage[] = undefined;
public getDialogs(min: GBMinInstance) {}
public loadPackage(core: IGBCoreService, sequelize: Sequelize): void {}
public unloadPackage(core: IGBCoreService): void {}
public loadBot(min: GBMinInstance): void {}
Expand Down
18 changes: 9 additions & 9 deletions packages/azuredeployer.gbapp/dialogs/BotFarmDialog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ import { BotAdapter } from 'botbuilder';
import { GBMinInstance } from 'botlib';
import { IGBDialog } from 'botlib';
import { Messages } from '../strings';
import { WaterfallDialog } from 'botlib/node_modules/botbuilder-dialogs';

export class BotFarmDialog extends IGBDialog {
/**
Expand All @@ -49,21 +50,20 @@ export class BotFarmDialog extends IGBDialog {
* @param min The minimal bot instance data.
*/
public static setup(bot: BotAdapter, min: GBMinInstance) {
min.dialogs.add('/createBotFarm', [
min.dialogs.add(new WaterfallDialog ('/createBotFarm', [
async step => {
const locale = step.context.activity.locale;
await step.prompt('choicePrompt', Messages[locale].what_about_me, [
'1',
'2',
'3',
'4',
'5'
]);
await step.prompt('choicePrompt', Messages[locale].what_about_me);

return step.next();
},
async step => {

const locale = step.context.activity.locale;
await step.context.sendActivity(Messages[locale].thanks);

return step.next();
}
]);
]));
}
}
13 changes: 6 additions & 7 deletions packages/azuredeployer.gbapp/dialogs/StartDialog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,18 +37,18 @@
'use strict';

import { IGBInstance } from 'botlib';
import { IGBInstallationDeployer } from 'botlib';
import * as fs from 'fs';
import { GBAdminService } from '../../../packages/admin.gbapp/services/GBAdminService';
import { GBConfigService } from '../../../packages/core.gbapp/services/GBConfigService';
import { AzureDeployerService } from '../services/AzureDeployerService';
import { GuaribasInstance } from '../../../packages/core.gbapp/models/GBModel';
const scanf = require('scanf');

/**
* Handles command-line dialog for getting info for Boot Bot.
*/
export class StartDialog {
public static async createBaseInstance() {

public static async createBaseInstance(installationDeployer: IGBInstallationDeployer) {
// No .env so asks for cloud credentials to start a new farm.

if (!fs.existsSync(`.env`)) {
Expand All @@ -75,7 +75,7 @@ export class StartDialog {
// Connects to the cloud and retrieves subscriptions.

const credentials = await GBAdminService.getADALCredentialsFromUsername(username, password);
const list = await AzureDeployerService.getSubscriptions(credentials);
const list = await installationDeployer.getSubscriptions(credentials);

let subscriptionId: string;
while (subscriptionId === undefined) {
Expand Down Expand Up @@ -104,9 +104,8 @@ export class StartDialog {

process.stdout.write(`${GBAdminService.GB_PROMPT}Thank you. That is enough information.\nNow building farm...`);


// Prepares the first instance on bot farm.
const instance: IGBInstance = {};
const instance = <IGBInstance>{};

instance.botId = botId;
instance.cloudUsername = username;
Expand Down Expand Up @@ -223,7 +222,7 @@ generate manually an App ID and App Secret.\n`
private static retrieveLocation() {
let location = GBConfigService.get('CLOUD_LOCATION');
if (!location) {
process.stdout.write("CLOUD_LOCATION (eg. 'westus'):");
process.stdout.write('CLOUD_LOCATION (eg. \'westus\'):');
location = scanf('%s');
}

Expand Down
4 changes: 2 additions & 2 deletions packages/azuredeployer.gbapp/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ import { GBMinInstance, IGBCoreService, IGBPackage } from 'botlib';
import { Sequelize } from 'sequelize-typescript';

export class GBAzureDeployerPackage implements IGBPackage {

public sysPackages: IGBPackage[] = null;
public sysPackages: IGBPackage[] = undefined;
public getDialogs(min: GBMinInstance) {}

public loadPackage(core: IGBCoreService, sequelize: Sequelize): void {}

Expand Down
Loading

0 comments on commit 5d08457

Please sign in to comment.