fix(general): tslint being applied in all sources.
This commit is contained in:
parent
8fec26ce03
commit
c74b3ee97c
8 changed files with 51 additions and 49 deletions
|
@ -95,7 +95,7 @@
|
||||||
"request-promise": "4.2.4",
|
"request-promise": "4.2.4",
|
||||||
"request-promise-native": "1.0.7",
|
"request-promise-native": "1.0.7",
|
||||||
"scanf": "^1.0.2",
|
"scanf": "^1.0.2",
|
||||||
"sequelize": "4.43.0",
|
"sequelize": "^4.43.0",
|
||||||
"sequelize-typescript": "0.6.7",
|
"sequelize-typescript": "0.6.7",
|
||||||
"shx": "0.3.2",
|
"shx": "0.3.2",
|
||||||
"simple-git": "1.107.0",
|
"simple-git": "1.107.0",
|
||||||
|
|
|
@ -86,10 +86,9 @@ export class AzureDeployerService implements IGBInstallationDeployer {
|
||||||
const req = new WebResource();
|
const req = new WebResource();
|
||||||
req.method = verb;
|
req.method = verb;
|
||||||
req.url = url;
|
req.url = url;
|
||||||
req.headers = <HttpHeaders>{};
|
req.headers.set('Content-Type', 'application/json');
|
||||||
req.headers['Content-Type'] = 'application/json';
|
req.headers.set('accept-language', '*');
|
||||||
req.headers['accept-language'] = '*';
|
req.headers.set('Authorization', `Bearer ${accessToken}`);
|
||||||
req.headers.set(' Authorization', `Bearer ${accessToken}`);
|
|
||||||
req.body = body;
|
req.body = body;
|
||||||
|
|
||||||
return req;
|
return req;
|
||||||
|
@ -405,10 +404,10 @@ export class AzureDeployerService implements IGBInstallationDeployer {
|
||||||
const req = new WebResource();
|
const req = new WebResource();
|
||||||
req.method = 'POST';
|
req.method = 'POST';
|
||||||
req.url = requestUrl;
|
req.url = requestUrl;
|
||||||
req.headers = <HttpHeaders>{};
|
req.headers = <any>{};
|
||||||
req.headers['Content-Type'] = 'application/json; charset=utf-8';
|
req.headers['Content-Type'] = 'application/json; charset=utf-8';
|
||||||
req.headers['accept-language'] = '*';
|
req.headers['accept-language'] = '*';
|
||||||
req.headers.set('Authorization', `Bearer ${accessToken}`);
|
(req.headers as any).Authorization = `Bearer ${accessToken}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -486,7 +485,7 @@ export class AzureDeployerService implements IGBInstallationDeployer {
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
reject(error);
|
reject(error);
|
||||||
}
|
}
|
||||||
}, 20000);
|
}, 20000);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -527,10 +526,9 @@ export class AzureDeployerService implements IGBInstallationDeployer {
|
||||||
const req = new WebResource();
|
const req = new WebResource();
|
||||||
req.method = method;
|
req.method = method;
|
||||||
req.url = `https://${location}.api.cognitive.microsoft.com/luis/api/v2.0/${resource}`;
|
req.url = `https://${location}.api.cognitive.microsoft.com/luis/api/v2.0/${resource}`;
|
||||||
req.headers = <HttpHeaders>{};
|
req.headers.set('Content-Type', 'application/json');
|
||||||
req.headers['Content-Type'] = 'application/json';
|
req.headers.set('accept-language', '*');
|
||||||
req.headers['accept-language'] = '*';
|
req.headers.set('Ocp-Apim-Subscription-Key', authoringKey);
|
||||||
req.headers['Ocp-Apim-Subscription-Key'] = authoringKey;
|
|
||||||
req.body = body;
|
req.body = body;
|
||||||
const httpClient = new ServiceClient();
|
const httpClient = new ServiceClient();
|
||||||
|
|
||||||
|
|
|
@ -42,7 +42,6 @@ import { GBLog } from 'botlib';
|
||||||
* Base configuration for the server like storage.
|
* Base configuration for the server like storage.
|
||||||
*/
|
*/
|
||||||
export class GBConfigService {
|
export class GBConfigService {
|
||||||
|
|
||||||
public static getServerPort(): number {
|
public static getServerPort(): number {
|
||||||
if (process.env.port !== undefined) {
|
if (process.env.port !== undefined) {
|
||||||
return Number(process.env.port);
|
return Number(process.env.port);
|
||||||
|
@ -71,7 +70,7 @@ export class GBConfigService {
|
||||||
public static get(key: string): string | undefined {
|
public static get(key: string): string | undefined {
|
||||||
let value = GBConfigService.tryGet(key);
|
let value = GBConfigService.tryGet(key);
|
||||||
|
|
||||||
if (value !== undefined) {
|
if (value === undefined) {
|
||||||
switch (key) {
|
switch (key) {
|
||||||
case 'CLOUD_USERNAME':
|
case 'CLOUD_USERNAME':
|
||||||
value = undefined;
|
value = undefined;
|
||||||
|
@ -130,9 +129,9 @@ export class GBConfigService {
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static tryGet(key: string) {
|
public static tryGet(key: string): any {
|
||||||
let value = process.env[`container:${key}`];
|
let value = process.env[`container:${key}`];
|
||||||
if (value !== undefined) {
|
if (value === undefined) {
|
||||||
value = process.env[key];
|
value = process.env[key];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -246,7 +246,7 @@ STORAGE_SYNC=true
|
||||||
|
|
||||||
return await ngrok.connect({ port: port });
|
return await ngrok.connect({ port: port });
|
||||||
} else {
|
} else {
|
||||||
GBLog.warn('ngrok executable not found. Check installation or node_modules folder.');
|
GBLog.warn('ngrok executable not found (only tested on Windows). Check installation or node_modules folder.');
|
||||||
|
|
||||||
return 'localhost';
|
return 'localhost';
|
||||||
}
|
}
|
||||||
|
@ -294,19 +294,23 @@ STORAGE_SYNC=true
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
// Check if storage is empty and needs formatting.
|
if (error.parent === undefined) {
|
||||||
const isInvalidObject = error.parent.number === 208 || error.parent.errno === 1; // MSSQL or SQLITE.
|
|
||||||
if (isInvalidObject) {
|
|
||||||
if (GBConfigService.get('STORAGE_SYNC') !== 'true') {
|
|
||||||
throw new Error(
|
|
||||||
`Operating storage is out of sync or there is a storage connection error.
|
|
||||||
Try setting STORAGE_SYNC to true in .env file. Error: ${error.message}.`
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
GBLog.info(`Storage is empty. After collecting storage structure from all .gbapps it will get synced.`);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
throw new Error(`Cannot connect to operating storage: ${error.message}.`);
|
throw new Error(`Cannot connect to operating storage: ${error.message}.`);
|
||||||
|
} else {
|
||||||
|
// Check if storage is empty and needs formatting.
|
||||||
|
const isInvalidObject = error.parent.number === 208 || error.parent.errno === 1; // MSSQL or SQLITE.
|
||||||
|
if (isInvalidObject) {
|
||||||
|
if (GBConfigService.get('STORAGE_SYNC') !== 'true') {
|
||||||
|
throw new Error(
|
||||||
|
`Operating storage is out of sync or there is a storage connection error.
|
||||||
|
Try setting STORAGE_SYNC to true in .env file. Error: ${error.message}.`
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
GBLog.info(`Storage is empty. After collecting storage structure from all .gbapps it will get synced.`);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
throw new Error(`Cannot connect to operating storage: ${error.message}.`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -429,7 +433,7 @@ STORAGE_SYNC=true
|
||||||
const fkcols = args[0];
|
const fkcols = args[0];
|
||||||
let fkname = table;
|
let fkname = table;
|
||||||
let matches2 = re4.exec(fkcols);
|
let matches2 = re4.exec(fkcols);
|
||||||
while (matches2 !== undefined) {
|
while (matches2 !== null) {
|
||||||
fkname += `_${matches2[1]}`;
|
fkname += `_${matches2[1]}`;
|
||||||
matches2 = re4.exec(fkcols);
|
matches2 = re4.exec(fkcols);
|
||||||
}
|
}
|
||||||
|
@ -464,7 +468,7 @@ STORAGE_SYNC=true
|
||||||
const fkcols = args[2];
|
const fkcols = args[2];
|
||||||
let fkname = table;
|
let fkname = table;
|
||||||
let matches2 = re3.exec(fkcols);
|
let matches2 = re3.exec(fkcols);
|
||||||
while (matches2 !== undefined) {
|
while (matches2 !== null) {
|
||||||
fkname += `_${matches2[1]}`;
|
fkname += `_${matches2[1]}`;
|
||||||
matches2 = re3.exec(fkcols);
|
matches2 = re3.exec(fkcols);
|
||||||
}
|
}
|
||||||
|
@ -484,8 +488,7 @@ STORAGE_SYNC=true
|
||||||
*/
|
*/
|
||||||
private async openStorageFrontier(installationDeployer: IGBInstallationDeployer) {
|
private async openStorageFrontier(installationDeployer: IGBInstallationDeployer) {
|
||||||
const group = GBConfigService.get('CLOUD_GROUP');
|
const group = GBConfigService.get('CLOUD_GROUP');
|
||||||
const serverName = GBConfigService.get('STORAGE_SERVER')
|
const serverName = GBConfigService.get('STORAGE_SERVER').split('.database.windows.net')[0];
|
||||||
.split('.database.windows.net')[0];
|
|
||||||
await installationDeployer.openStorageFirewall(group, serverName);
|
await installationDeployer.openStorageFirewall(group, serverName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -91,9 +91,9 @@ export class GBDeployer {
|
||||||
if (additionalPath !== undefined) {
|
if (additionalPath !== undefined) {
|
||||||
paths = paths.concat(additionalPath.toLowerCase().split(';'));
|
paths = paths.concat(additionalPath.toLowerCase().split(';'));
|
||||||
}
|
}
|
||||||
const botPackages: string[] = undefined;
|
const botPackages: string[] = [];
|
||||||
const gbappPackages: string[] = undefined;
|
const gbappPackages: string[] = [];
|
||||||
let generalPackages: string[];
|
let generalPackages: string[] = [];
|
||||||
|
|
||||||
function doIt(path) {
|
function doIt(path) {
|
||||||
const isDirectory = source => Fs.lstatSync(source).isDirectory();
|
const isDirectory = source => Fs.lstatSync(source).isDirectory();
|
||||||
|
|
|
@ -53,7 +53,7 @@ export class GBImporter {
|
||||||
|
|
||||||
public async importIfNotExistsBotPackage(botId: string, packageName: string, localPath: string) {
|
public async importIfNotExistsBotPackage(botId: string, packageName: string, localPath: string) {
|
||||||
const packageJson = JSON.parse(fs.readFileSync(urlJoin(localPath, 'package.json'), 'utf8'));
|
const packageJson = JSON.parse(fs.readFileSync(urlJoin(localPath, 'package.json'), 'utf8'));
|
||||||
if (botId !== undefined) {
|
if (botId === undefined) {
|
||||||
botId = packageJson.botId;
|
botId = packageJson.botId;
|
||||||
}
|
}
|
||||||
const instance = await this.core.loadInstance(botId);
|
const instance = await this.core.loadInstance(botId);
|
||||||
|
|
|
@ -200,10 +200,10 @@ export class GBMinService {
|
||||||
GBLog.error(msg);
|
GBLog.error(msg);
|
||||||
res.send(msg);
|
res.send(msg);
|
||||||
} else {
|
} else {
|
||||||
await this.adminService.setValue(instance.instanceId, 'refreshToken', token.refreshToken);
|
this.adminService.setValue(instance.instanceId, 'refreshToken', token.refreshToken);
|
||||||
await this.adminService.setValue(instance.instanceId, 'accessToken', token.accessToken);
|
this.adminService.setValue(instance.instanceId, 'accessToken', token.accessToken);
|
||||||
await this.adminService.setValue(instance.instanceId, 'expiresOn', token.expiresOn.toString());
|
this.adminService.setValue(instance.instanceId, 'expiresOn', token.expiresOn.toString());
|
||||||
await this.adminService.setValue(instance.instanceId, 'AntiCSRFAttackState', undefined);
|
this.adminService.setValue(instance.instanceId, 'AntiCSRFAttackState', undefined);
|
||||||
res.redirect(min.instance.botEndpoint);
|
res.redirect(min.instance.botEndpoint);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -346,7 +346,7 @@ export class GBMinService {
|
||||||
}
|
}
|
||||||
|
|
||||||
private invokeLoadBot(appPackages: any[], min: GBMinInstance, server: any) {
|
private invokeLoadBot(appPackages: any[], min: GBMinInstance, server: any) {
|
||||||
const sysPackages : IGBPackage[] = undefined;
|
const sysPackages : IGBPackage[] = [];
|
||||||
// NOTE: A semicolon is necessary before this line.
|
// NOTE: A semicolon is necessary before this line.
|
||||||
[
|
[
|
||||||
GBCorePackage,
|
GBCorePackage,
|
||||||
|
|
16
src/app.ts
16
src/app.ts
|
@ -50,7 +50,7 @@ import { GBDeployer } from '../packages/core.gbapp/services/GBDeployer';
|
||||||
import { GBImporter } from '../packages/core.gbapp/services/GBImporterService';
|
import { GBImporter } from '../packages/core.gbapp/services/GBImporterService';
|
||||||
import { GBMinService } from '../packages/core.gbapp/services/GBMinService';
|
import { GBMinService } from '../packages/core.gbapp/services/GBMinService';
|
||||||
|
|
||||||
const appPackages: IGBPackage[] = undefined;
|
const appPackages: IGBPackage[] = [];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* General Bots open-core entry point.
|
* General Bots open-core entry point.
|
||||||
|
@ -64,16 +64,13 @@ export class GBServer {
|
||||||
GBLog.info(`The Bot Server is in STARTING mode...`);
|
GBLog.info(`The Bot Server is in STARTING mode...`);
|
||||||
|
|
||||||
// Creates a basic HTTP server that will serve several URL, one for each
|
// Creates a basic HTTP server that will serve several URL, one for each
|
||||||
// bot instance. This allows the same server to attend multiple Bot on
|
// bot instance.
|
||||||
// the Marketplace until GB get serverless.
|
|
||||||
|
|
||||||
const port = GBConfigService.getServerPort();
|
const port = GBConfigService.getServerPort();
|
||||||
const server = express();
|
const server = express();
|
||||||
|
server.use(bodyParser.json());
|
||||||
server.use(bodyParser.json()); // to support JSON-encoded bodies
|
|
||||||
server.use(
|
server.use(
|
||||||
bodyParser.urlencoded({
|
bodyParser.urlencoded({
|
||||||
// to support URL-encoded bodies
|
|
||||||
extended: true
|
extended: true
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
@ -105,6 +102,7 @@ export class GBServer {
|
||||||
try {
|
try {
|
||||||
await core.initStorage();
|
await core.initStorage();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
GBLog.verbose(`Error initializing storage: ${error}`);
|
||||||
bootInstance = await core.createBootInstance(core, azureDeployer, proxyAddress);
|
bootInstance = await core.createBootInstance(core, azureDeployer, proxyAddress);
|
||||||
await core.initStorage();
|
await core.initStorage();
|
||||||
}
|
}
|
||||||
|
@ -126,7 +124,11 @@ export class GBServer {
|
||||||
'boot.gbot',
|
'boot.gbot',
|
||||||
'packages/boot.gbot'
|
'packages/boot.gbot'
|
||||||
);
|
);
|
||||||
const fullInstance = { ...packageInstance, ...bootInstance };
|
if (bootInstance === undefined) {
|
||||||
|
bootInstance = packageInstance;
|
||||||
|
}
|
||||||
|
// tslint:disable-next-line:prefer-object-spread
|
||||||
|
const fullInstance = Object.assign(packageInstance, bootInstance);
|
||||||
await core.saveInstance(fullInstance);
|
await core.saveInstance(fullInstance);
|
||||||
let instances: IGBInstance[] = await core.loadAllInstances(core, azureDeployer, proxyAddress);
|
let instances: IGBInstance[] = await core.loadAllInstances(core, azureDeployer, proxyAddress);
|
||||||
instances = await core.ensureInstances(instances, bootInstance, core);
|
instances = await core.ensureInstances(instances, bootInstance, core);
|
||||||
|
|
Loading…
Add table
Reference in a new issue