Skip to content

Commit

Permalink
Merge pull request microsoft#359 from Microsoft/southworks/tslint-fix…
Browse files Browse the repository at this point in the history
…/msbot/newline-before-return

Fixed TSLint 'newline-before-return' warning in MSBot
  • Loading branch information
cleemullins authored Aug 28, 2018
2 parents 00f0658 + a27c64b commit 64263d6
Show file tree
Hide file tree
Showing 19 changed files with 36 additions and 0 deletions.
8 changes: 8 additions & 0 deletions packages/MSBot/src/BotConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ export class BotConfig extends BotConfigModel {
if (service.id === nameOrId || service.name === nameOrId) {
svs.removeAt(i);
this.services = svs.toArray();

return service;
}
}
Expand All @@ -162,6 +163,7 @@ export class BotConfig extends BotConfigModel {
if (service.type === type && service.id === id) {
svs.removeAt(i);
this.services = svs.toArray();

return;
}
}
Expand All @@ -177,6 +179,7 @@ export class BotConfig extends BotConfigModel {

return this.internalEncrypt(value);
}

return value;
}

Expand All @@ -190,6 +193,7 @@ export class BotConfig extends BotConfigModel {

return this.internalDecrypt(encryptedValue);
}

return encryptedValue;
}

Expand Down Expand Up @@ -231,6 +235,7 @@ export class BotConfig extends BotConfigModel {
const val = <string>(<any>service)[prop];
(<any>service)[prop] = this.encryptValue(val);
}

return service;
}

Expand All @@ -242,20 +247,23 @@ export class BotConfig extends BotConfigModel {
const val = <string>(<any>service)[prop];
(<any>service)[prop] = this.decryptValue(val);
}

return service;
}

private internalEncrypt(value: string): string {
const cipher = crypto.createCipher('aes192', this.internal.secret);
let encryptedValue = cipher.update(value, 'utf8', 'hex');
encryptedValue += cipher.final('hex');

return encryptedValue;
}

private internalDecrypt(encryptedValue: string): string {
const decipher = crypto.createDecipher('aes192', this.internal.secret);
let value = decipher.update(encryptedValue, 'hex', 'utf8');
value += decipher.final('utf8');

return value;
}
}
1 change: 1 addition & 0 deletions packages/MSBot/src/models/azureBotService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export class AzureBotService extends ConnectedService implements IAzureBotServic

public toJSON(): IAzureBotService {
const { id, name, tenantId, subscriptionId, resourceGroup } = this;

return { type: ServiceType.AzureBotService, id, name, tenantId, subscriptionId, resourceGroup };
}
}
2 changes: 2 additions & 0 deletions packages/MSBot/src/models/botConfigModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,13 @@ export class BotConfigModel implements Partial<IBotConfig> {
services = services.slice().map(BotConfigModel.serviceFromJSON);
const botConfig = new BotConfigModel();
Object.assign(botConfig, { services, description, name, secretKey });

return botConfig;
}

public toJSON(): Partial<IBotConfig> {
const { name, description, services, secretKey } = this;

return { name, description, services, secretKey };
}
}
1 change: 1 addition & 0 deletions packages/MSBot/src/models/dispatchService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export class DispatchService extends ConnectedService implements IDispatchServic

public toJSON(): IDispatchService {
const { appId, authoringKey, name, serviceIds, subscriptionKey, version } = this;

return { type: ServiceType.Dispatch, id: appId, name, appId, authoringKey, serviceIds, subscriptionKey, version };
}
}
1 change: 1 addition & 0 deletions packages/MSBot/src/models/endpointService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export class EndpointService extends ConnectedService implements IEndpointServic

public toJSON(): IEndpointService {
const { appId = '', id = '', appPassword = '', endpoint = '', name = '' } = this;

return { type: ServiceType.Endpoint, name, id: endpoint, appId, appPassword, endpoint };
}
}
1 change: 1 addition & 0 deletions packages/MSBot/src/models/fileService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export class FileService extends ConnectedService implements IFileService {

public toJSON(): IFileService {
const { name = '', id = '', filePath = '' } = this;

return { type: ServiceType.File, id: filePath, name, filePath };
}
}
1 change: 1 addition & 0 deletions packages/MSBot/src/models/luisService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export class LuisService extends ConnectedService implements ILuisService {

public toJSON(): ILuisService {
const { appId, authoringKey, id, name, subscriptionKey, type, version } = this;

return { type: ServiceType.Luis, id: appId, name, version, appId, authoringKey, subscriptionKey };
}
}
1 change: 1 addition & 0 deletions packages/MSBot/src/models/qnaMakerService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export class QnaMakerService extends ConnectedService implements IQnAService {

public toJSON(): IQnAService {
const { id, name, kbId, subscriptionKey, endpointKey, hostname } = this;

return { type: ServiceType.QnA, id: kbId, name, kbId, subscriptionKey, endpointKey, hostname };
}
}
2 changes: 2 additions & 0 deletions packages/MSBot/src/msbot-connect-azure.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,12 +127,14 @@ async function processConnectAzureArgs(config: BotConfig): Promise<BotConfig> {
}
await config.save();
process.stdout.write(JSON.stringify(services, null, 2));

return config;
}

function showErrorHelp() {
program.outputHelp((str) => {
console.error(str);

return '';
});
process.exit(1);
Expand Down
2 changes: 2 additions & 0 deletions packages/MSBot/src/msbot-connect-dispatch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,12 +116,14 @@ async function processConnectDispatch(config: BotConfig): Promise<BotConfig> {
config.connectService(newService);
await config.save();
process.stdout.write(JSON.stringify(newService, null, 2));

return config;
}

function showErrorHelp() {
program.outputHelp((str) => {
console.error(str);

return '';
});
process.exit(1);
Expand Down
2 changes: 2 additions & 0 deletions packages/MSBot/src/msbot-connect-endpoint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,12 +118,14 @@ async function processConnectEndpointArgs(config: BotConfig): Promise<BotConfig>

await config.save();
process.stdout.write(JSON.stringify(newService, null, 2));

return config;
}

function showErrorHelp() {
program.outputHelp((str) => {
console.error(str);

return '';
});
process.exit(1);
Expand Down
2 changes: 2 additions & 0 deletions packages/MSBot/src/msbot-connect-file.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,14 @@ async function processConnectFile(config: BotConfig): Promise<BotConfig> {
config.connectService(newService);
await config.save();
process.stdout.write(JSON.stringify(newService, null, 2));

return config;
}

function showErrorHelp() {
program.outputHelp((str) => {
console.error(str);

return '';
});
process.exit(1);
Expand Down
2 changes: 2 additions & 0 deletions packages/MSBot/src/msbot-connect-luis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,12 +100,14 @@ async function processConnectLuisArgs(config: BotConfig): Promise<BotConfig> {
config.connectService(newService);
await config.save();
process.stdout.write(JSON.stringify(newService, null, 2));

return config;
}

function showErrorHelp() {
program.outputHelp((str) => {
console.error(str);

return '';
});
process.exit(1);
Expand Down
2 changes: 2 additions & 0 deletions packages/MSBot/src/msbot-connect-qna.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,12 +101,14 @@ async function processConnectQnaArgs(config: BotConfig): Promise<BotConfig> {

await config.save();
process.stdout.write(JSON.stringify(newService, null, 2));

return config;
}

function showErrorHelp() {
program.outputHelp((str) => {
console.error(str);

return '';
});
process.exit(1);
Expand Down
1 change: 1 addition & 0 deletions packages/MSBot/src/msbot-connect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ if (args) {
function showErrorHelp() {
program.outputHelp((str) => {
console.error(str);

return '';
});
process.exit(1);
Expand Down
1 change: 1 addition & 0 deletions packages/MSBot/src/msbot-disconnect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ async function processConnectAzureArgs(config: BotConfig): Promise<BotConfig> {
function showErrorHelp() {
program.outputHelp((str) => {
console.error(str);

return '';
});
process.exit(1);
Expand Down
2 changes: 2 additions & 0 deletions packages/MSBot/src/msbot-list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,14 @@ async function processListArgs(config: BotConfig): Promise<BotConfig> {
description: config.description,
services: config.services
}, null, 4));

return config;
}

function showErrorHelp() {
program.outputHelp((str) => {
console.error(str);

return '';
});
process.exit(1);
Expand Down
2 changes: 2 additions & 0 deletions packages/MSBot/src/msbot-secret.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,14 @@ async function processSecret(config: BotConfig): Promise<BotConfig> {
}

config.save(args.bot);

return config;
}

function showErrorHelp() {
program.outputHelp((str) => {
console.error(str);

return '';
});
process.exit(1);
Expand Down
2 changes: 2 additions & 0 deletions packages/MSBot/src/msbot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ program.Command.prototype.unknownOption = function (flag: any) {
console.error(chalk.default.redBright(`Unknown arguments: ${process.argv.slice(2).join(' ')}`));
program.outputHelp((str) => {
console.error(str);

return '';
});
process.exit(1);
Expand Down Expand Up @@ -57,6 +58,7 @@ if (args) {
console.error(chalk.default.redBright(`Unknown arguments: ${a.join(' ')}`));
program.outputHelp((str) => {
console.error(str);

return '';
});
process.exit(1);
Expand Down

0 comments on commit 64263d6

Please sign in to comment.