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-native": "1.0.7",
|
||||
"scanf": "^1.0.2",
|
||||
"sequelize": "4.43.0",
|
||||
"sequelize": "^4.43.0",
|
||||
"sequelize-typescript": "0.6.7",
|
||||
"shx": "0.3.2",
|
||||
"simple-git": "1.107.0",
|
||||
|
|
|
@ -86,10 +86,9 @@ export class AzureDeployerService implements IGBInstallationDeployer {
|
|||
const req = new WebResource();
|
||||
req.method = verb;
|
||||
req.url = url;
|
||||
req.headers = <HttpHeaders>{};
|
||||
req.headers['Content-Type'] = 'application/json';
|
||||
req.headers['accept-language'] = '*';
|
||||
req.headers.set(' Authorization', `Bearer ${accessToken}`);
|
||||
req.headers.set('Content-Type', 'application/json');
|
||||
req.headers.set('accept-language', '*');
|
||||
req.headers.set('Authorization', `Bearer ${accessToken}`);
|
||||
req.body = body;
|
||||
|
||||
return req;
|
||||
|
@ -405,10 +404,10 @@ export class AzureDeployerService implements IGBInstallationDeployer {
|
|||
const req = new WebResource();
|
||||
req.method = 'POST';
|
||||
req.url = requestUrl;
|
||||
req.headers = <HttpHeaders>{};
|
||||
req.headers = <any>{};
|
||||
req.headers['Content-Type'] = 'application/json; charset=utf-8';
|
||||
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) {
|
||||
reject(error);
|
||||
}
|
||||
}, 20000);
|
||||
}, 20000);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -527,10 +526,9 @@ export class AzureDeployerService implements IGBInstallationDeployer {
|
|||
const req = new WebResource();
|
||||
req.method = method;
|
||||
req.url = `https://${location}.api.cognitive.microsoft.com/luis/api/v2.0/${resource}`;
|
||||
req.headers = <HttpHeaders>{};
|
||||
req.headers['Content-Type'] = 'application/json';
|
||||
req.headers['accept-language'] = '*';
|
||||
req.headers['Ocp-Apim-Subscription-Key'] = authoringKey;
|
||||
req.headers.set('Content-Type', 'application/json');
|
||||
req.headers.set('accept-language', '*');
|
||||
req.headers.set('Ocp-Apim-Subscription-Key', authoringKey);
|
||||
req.body = body;
|
||||
const httpClient = new ServiceClient();
|
||||
|
||||
|
|
|
@ -42,7 +42,6 @@ import { GBLog } from 'botlib';
|
|||
* Base configuration for the server like storage.
|
||||
*/
|
||||
export class GBConfigService {
|
||||
|
||||
public static getServerPort(): number {
|
||||
if (process.env.port !== undefined) {
|
||||
return Number(process.env.port);
|
||||
|
@ -71,7 +70,7 @@ export class GBConfigService {
|
|||
public static get(key: string): string | undefined {
|
||||
let value = GBConfigService.tryGet(key);
|
||||
|
||||
if (value !== undefined) {
|
||||
if (value === undefined) {
|
||||
switch (key) {
|
||||
case 'CLOUD_USERNAME':
|
||||
value = undefined;
|
||||
|
@ -130,9 +129,9 @@ export class GBConfigService {
|
|||
return value;
|
||||
}
|
||||
|
||||
public static tryGet(key: string) {
|
||||
public static tryGet(key: string): any {
|
||||
let value = process.env[`container:${key}`];
|
||||
if (value !== undefined) {
|
||||
if (value === undefined) {
|
||||
value = process.env[key];
|
||||
}
|
||||
|
||||
|
|
|
@ -246,7 +246,7 @@ STORAGE_SYNC=true
|
|||
|
||||
return await ngrok.connect({ port: port });
|
||||
} 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';
|
||||
}
|
||||
|
@ -294,19 +294,23 @@ STORAGE_SYNC=true
|
|||
);
|
||||
}
|
||||
} catch (error) {
|
||||
// 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 {
|
||||
if (error.parent === undefined) {
|
||||
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];
|
||||
let fkname = table;
|
||||
let matches2 = re4.exec(fkcols);
|
||||
while (matches2 !== undefined) {
|
||||
while (matches2 !== null) {
|
||||
fkname += `_${matches2[1]}`;
|
||||
matches2 = re4.exec(fkcols);
|
||||
}
|
||||
|
@ -464,7 +468,7 @@ STORAGE_SYNC=true
|
|||
const fkcols = args[2];
|
||||
let fkname = table;
|
||||
let matches2 = re3.exec(fkcols);
|
||||
while (matches2 !== undefined) {
|
||||
while (matches2 !== null) {
|
||||
fkname += `_${matches2[1]}`;
|
||||
matches2 = re3.exec(fkcols);
|
||||
}
|
||||
|
@ -484,8 +488,7 @@ STORAGE_SYNC=true
|
|||
*/
|
||||
private async openStorageFrontier(installationDeployer: IGBInstallationDeployer) {
|
||||
const group = GBConfigService.get('CLOUD_GROUP');
|
||||
const serverName = GBConfigService.get('STORAGE_SERVER')
|
||||
.split('.database.windows.net')[0];
|
||||
const serverName = GBConfigService.get('STORAGE_SERVER').split('.database.windows.net')[0];
|
||||
await installationDeployer.openStorageFirewall(group, serverName);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -91,9 +91,9 @@ export class GBDeployer {
|
|||
if (additionalPath !== undefined) {
|
||||
paths = paths.concat(additionalPath.toLowerCase().split(';'));
|
||||
}
|
||||
const botPackages: string[] = undefined;
|
||||
const gbappPackages: string[] = undefined;
|
||||
let generalPackages: string[];
|
||||
const botPackages: string[] = [];
|
||||
const gbappPackages: string[] = [];
|
||||
let generalPackages: string[] = [];
|
||||
|
||||
function doIt(path) {
|
||||
const isDirectory = source => Fs.lstatSync(source).isDirectory();
|
||||
|
|
|
@ -53,7 +53,7 @@ export class GBImporter {
|
|||
|
||||
public async importIfNotExistsBotPackage(botId: string, packageName: string, localPath: string) {
|
||||
const packageJson = JSON.parse(fs.readFileSync(urlJoin(localPath, 'package.json'), 'utf8'));
|
||||
if (botId !== undefined) {
|
||||
if (botId === undefined) {
|
||||
botId = packageJson.botId;
|
||||
}
|
||||
const instance = await this.core.loadInstance(botId);
|
||||
|
|
|
@ -200,10 +200,10 @@ export class GBMinService {
|
|||
GBLog.error(msg);
|
||||
res.send(msg);
|
||||
} else {
|
||||
await this.adminService.setValue(instance.instanceId, 'refreshToken', token.refreshToken);
|
||||
await this.adminService.setValue(instance.instanceId, 'accessToken', token.accessToken);
|
||||
await this.adminService.setValue(instance.instanceId, 'expiresOn', token.expiresOn.toString());
|
||||
await this.adminService.setValue(instance.instanceId, 'AntiCSRFAttackState', undefined);
|
||||
this.adminService.setValue(instance.instanceId, 'refreshToken', token.refreshToken);
|
||||
this.adminService.setValue(instance.instanceId, 'accessToken', token.accessToken);
|
||||
this.adminService.setValue(instance.instanceId, 'expiresOn', token.expiresOn.toString());
|
||||
this.adminService.setValue(instance.instanceId, 'AntiCSRFAttackState', undefined);
|
||||
res.redirect(min.instance.botEndpoint);
|
||||
}
|
||||
}
|
||||
|
@ -346,7 +346,7 @@ export class GBMinService {
|
|||
}
|
||||
|
||||
private invokeLoadBot(appPackages: any[], min: GBMinInstance, server: any) {
|
||||
const sysPackages : IGBPackage[] = undefined;
|
||||
const sysPackages : IGBPackage[] = [];
|
||||
// NOTE: A semicolon is necessary before this line.
|
||||
[
|
||||
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 { GBMinService } from '../packages/core.gbapp/services/GBMinService';
|
||||
|
||||
const appPackages: IGBPackage[] = undefined;
|
||||
const appPackages: IGBPackage[] = [];
|
||||
|
||||
/**
|
||||
* General Bots open-core entry point.
|
||||
|
@ -64,16 +64,13 @@ export class GBServer {
|
|||
GBLog.info(`The Bot Server is in STARTING mode...`);
|
||||
|
||||
// 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
|
||||
// the Marketplace until GB get serverless.
|
||||
// bot instance.
|
||||
|
||||
const port = GBConfigService.getServerPort();
|
||||
const server = express();
|
||||
|
||||
server.use(bodyParser.json()); // to support JSON-encoded bodies
|
||||
server.use(bodyParser.json());
|
||||
server.use(
|
||||
bodyParser.urlencoded({
|
||||
// to support URL-encoded bodies
|
||||
extended: true
|
||||
})
|
||||
);
|
||||
|
@ -105,6 +102,7 @@ export class GBServer {
|
|||
try {
|
||||
await core.initStorage();
|
||||
} catch (error) {
|
||||
GBLog.verbose(`Error initializing storage: ${error}`);
|
||||
bootInstance = await core.createBootInstance(core, azureDeployer, proxyAddress);
|
||||
await core.initStorage();
|
||||
}
|
||||
|
@ -126,7 +124,11 @@ export class GBServer {
|
|||
'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);
|
||||
let instances: IGBInstance[] = await core.loadAllInstances(core, azureDeployer, proxyAddress);
|
||||
instances = await core.ensureInstances(instances, bootInstance, core);
|
||||
|
|
Loading…
Add table
Reference in a new issue