2018-04-21 02:59:30 -03:00
|
|
|
/*****************************************************************************\
|
|
|
|
| ( )_ _ |
|
|
|
|
| _ _ _ __ _ _ __ ___ ___ _ _ | ,_)(_) ___ ___ _ |
|
|
|
|
| ( '_`\ ( '__)/'_` ) /'_ `\/' _ ` _ `\ /'_` )| | | |/',__)/' _ `\ /'_`\ |
|
|
|
|
| | (_) )| | ( (_| |( (_) || ( ) ( ) |( (_| || |_ | |\__, \| ( ) |( (_) ) |
|
|
|
|
| | ,__/'(_) `\__,_)`\__ |(_) (_) (_)`\__,_)`\__)(_)(____/(_) (_)`\___/' |
|
|
|
|
| | | ( )_) | |
|
|
|
|
| (_) \___/' |
|
|
|
|
| |
|
|
|
|
| General Bots Copyright (c) Pragmatismo.io. All rights reserved. |
|
|
|
|
| Licensed under the AGPL-3.0. |
|
2018-11-11 19:09:18 -02:00
|
|
|
| |
|
2018-04-21 02:59:30 -03:00
|
|
|
| According to our dual licensing model, this program can be used either |
|
|
|
|
| under the terms of the GNU Affero General Public License, version 3, |
|
|
|
|
| or under a proprietary license. |
|
|
|
|
| |
|
|
|
|
| The texts of the GNU Affero General Public License with an additional |
|
|
|
|
| permission and of our proprietary license can be found at and |
|
|
|
|
| in the LICENSE file you have received along with this program. |
|
|
|
|
| |
|
|
|
|
| This program is distributed in the hope that it will be useful, |
|
2018-09-11 19:40:53 -03:00
|
|
|
| but WITHOUT ANY WARRANTY, without even the implied warranty of |
|
2018-04-21 02:59:30 -03:00
|
|
|
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
|
|
|
| GNU Affero General Public License for more details. |
|
|
|
|
| |
|
|
|
|
| "General Bots" is a registered trademark of Pragmatismo.io. |
|
|
|
|
| The licensing of the program under the AGPLv3 does not imply a |
|
|
|
|
| trademark license. Therefore any rights, title and interest in |
|
|
|
|
| our trademarks remain entirely with us. |
|
|
|
|
| |
|
|
|
|
\*****************************************************************************/
|
|
|
|
|
2018-11-11 19:09:18 -02:00
|
|
|
/**
|
|
|
|
* @fileoverview General Bots server core.
|
|
|
|
*/
|
|
|
|
|
|
|
|
'use strict';
|
2018-09-24 11:04:36 -03:00
|
|
|
|
2018-11-12 12:20:44 -02:00
|
|
|
const logger = require('../../../src/logger');
|
|
|
|
const Path = require('path');
|
|
|
|
const UrlJoin = require('url-join');
|
|
|
|
const Fs = require('fs');
|
|
|
|
const WaitUntil = require('wait-until');
|
|
|
|
const express = require('express');
|
|
|
|
|
|
|
|
import { IGBCoreService, IGBInstance } from 'botlib';
|
|
|
|
import { GBError } from 'botlib';
|
|
|
|
import { IGBPackage } from 'botlib';
|
|
|
|
import { AzureSearch } from 'pragmatismo-io-framework';
|
|
|
|
import { AzureDeployerService } from '../../azuredeployer.gbapp/services/AzureDeployerService';
|
|
|
|
import { GuaribasInstance, GuaribasPackage } from '../models/GBModel';
|
|
|
|
import { KBService } from './../../kb.gbapp/services/KBService';
|
|
|
|
import { GBConfigService } from './GBConfigService';
|
|
|
|
import { GBImporter } from './GBImporter';
|
2018-04-21 02:59:30 -03:00
|
|
|
|
|
|
|
/** Deployer service for bots, themes, ai and more. */
|
|
|
|
export class GBDeployer {
|
2018-11-12 12:20:44 -02:00
|
|
|
public static deployFolder = 'packages';
|
|
|
|
public core: IGBCoreService;
|
|
|
|
public importer: GBImporter;
|
|
|
|
public workDir: string = './work';
|
2018-09-10 12:09:48 -03:00
|
|
|
|
2018-04-21 02:59:30 -03:00
|
|
|
constructor(core: IGBCoreService, importer: GBImporter) {
|
2018-09-24 11:04:36 -03:00
|
|
|
this.core = core;
|
|
|
|
this.importer = importer;
|
2018-04-21 02:59:30 -03:00
|
|
|
}
|
|
|
|
|
2018-11-12 12:20:44 -02:00
|
|
|
public static getConnectionStringFromInstance(instance: GuaribasInstance) {
|
|
|
|
return `Server=tcp:${
|
|
|
|
instance.storageServer
|
|
|
|
}.database.windows.net,1433;Database=${instance.storageName};User ID=${
|
|
|
|
instance.storageUsername
|
|
|
|
};Password=${
|
|
|
|
instance.storagePassword
|
|
|
|
};Trusted_Connection=False;Encrypt=True;Connection Timeout=30;`;
|
|
|
|
}
|
|
|
|
|
2018-09-11 19:33:58 -03:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
* Performs package deployment in all .gbai or default.
|
|
|
|
*
|
2018-09-10 12:09:48 -03:00
|
|
|
* */
|
2018-09-11 19:33:58 -03:00
|
|
|
public deployPackages(
|
|
|
|
core: IGBCoreService,
|
|
|
|
server: any,
|
2018-11-12 12:20:44 -02:00
|
|
|
appPackages: IGBPackage[]
|
2018-09-11 19:33:58 -03:00
|
|
|
) {
|
2018-11-12 12:20:44 -02:00
|
|
|
const _this = this;
|
2018-11-11 19:09:18 -02:00
|
|
|
return new Promise((resolve: any, reject: any): any => {
|
2018-09-24 19:56:11 -03:00
|
|
|
let totalPackages = 0;
|
2018-11-12 12:20:44 -02:00
|
|
|
const additionalPath = GBConfigService.get('ADDITIONAL_DEPLOY_PATH');
|
2018-09-24 19:56:11 -03:00
|
|
|
let paths = [GBDeployer.deployFolder];
|
|
|
|
if (additionalPath) {
|
2018-11-12 12:20:44 -02:00
|
|
|
paths = paths.concat(additionalPath.toLowerCase().split(';'));
|
2018-09-24 19:56:11 -03:00
|
|
|
}
|
2018-11-12 12:20:44 -02:00
|
|
|
const botPackages = new Array<string>();
|
|
|
|
const gbappPackages = new Array<string>();
|
2018-09-24 19:56:11 -03:00
|
|
|
let generalPackages = new Array<string>();
|
|
|
|
|
|
|
|
function doIt(path) {
|
|
|
|
const isDirectory = source => Fs.lstatSync(source).isDirectory();
|
|
|
|
const getDirectories = source =>
|
|
|
|
Fs.readdirSync(source)
|
|
|
|
.map(name => Path.join(source, name))
|
|
|
|
.filter(isDirectory);
|
|
|
|
|
2018-11-12 12:20:44 -02:00
|
|
|
const dirs = getDirectories(path);
|
2018-09-24 19:56:11 -03:00
|
|
|
dirs.forEach(element => {
|
2018-11-12 12:20:44 -02:00
|
|
|
if (element.startsWith('.')) {
|
2018-09-24 19:56:11 -03:00
|
|
|
logger.info(`Ignoring ${element}...`);
|
|
|
|
} else {
|
2018-11-12 12:20:44 -02:00
|
|
|
if (element.endsWith('.gbot')) {
|
2018-09-24 19:56:11 -03:00
|
|
|
botPackages.push(element);
|
2018-11-12 12:20:44 -02:00
|
|
|
} else if (element.endsWith('.gbapp')) {
|
2018-09-24 19:56:11 -03:00
|
|
|
gbappPackages.push(element);
|
2018-09-11 19:33:58 -03:00
|
|
|
} else {
|
2018-09-24 19:56:11 -03:00
|
|
|
generalPackages.push(element);
|
2018-09-10 12:09:48 -03:00
|
|
|
}
|
|
|
|
}
|
2018-09-24 11:04:36 -03:00
|
|
|
});
|
2018-09-24 19:56:11 -03:00
|
|
|
}
|
2018-09-10 12:09:48 -03:00
|
|
|
|
2018-09-24 19:56:11 -03:00
|
|
|
logger.info(
|
|
|
|
`Starting looking for packages (.gbot, .gbtheme, .gbkb, .gbapp)...`
|
|
|
|
);
|
|
|
|
paths.forEach(e => {
|
|
|
|
logger.info(`Looking in: ${e}...`);
|
|
|
|
doIt(e);
|
|
|
|
});
|
|
|
|
|
|
|
|
/** Deploys all .gbapp files first. */
|
|
|
|
|
|
|
|
let appPackagesProcessed = 0;
|
|
|
|
|
|
|
|
gbappPackages.forEach(e => {
|
|
|
|
// Skips .gbapp inside deploy folder.
|
2018-11-12 12:20:44 -02:00
|
|
|
if (!e.startsWith('packages')) {
|
2018-09-24 19:56:11 -03:00
|
|
|
logger.info(`Deploying app: ${e}...`);
|
|
|
|
import(e)
|
|
|
|
.then(m => {
|
2018-11-12 12:20:44 -02:00
|
|
|
const p = new m.Package();
|
2018-09-24 19:56:11 -03:00
|
|
|
p.loadPackage(core, core.sequelize);
|
|
|
|
appPackages.push(p);
|
|
|
|
logger.info(`App (.gbapp) deployed: ${e}.`);
|
|
|
|
appPackagesProcessed++;
|
|
|
|
})
|
|
|
|
.catch(err => {
|
|
|
|
logger.error(`Error deploying App (.gbapp): ${e}: ${err}`);
|
|
|
|
appPackagesProcessed++;
|
2018-09-24 11:04:36 -03:00
|
|
|
});
|
2018-09-24 19:56:11 -03:00
|
|
|
} else {
|
|
|
|
appPackagesProcessed++;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
WaitUntil()
|
|
|
|
.interval(1000)
|
|
|
|
.times(10)
|
|
|
|
.condition(function(cb) {
|
|
|
|
logger.info(`Waiting for app package deployment...`);
|
|
|
|
cb(appPackagesProcessed == gbappPackages.length);
|
|
|
|
})
|
|
|
|
.done(async result => {
|
|
|
|
logger.info(`App Package deployment done.`);
|
|
|
|
|
|
|
|
try {
|
|
|
|
await core.syncDatabaseStructure();
|
|
|
|
} catch (e) {
|
|
|
|
throw e;
|
|
|
|
}
|
2018-09-10 12:09:48 -03:00
|
|
|
|
2018-09-24 19:56:11 -03:00
|
|
|
/** Deploys all .gbot files first. */
|
2018-09-10 12:09:48 -03:00
|
|
|
|
2018-09-24 19:56:11 -03:00
|
|
|
botPackages.forEach(e => {
|
|
|
|
logger.info(`Deploying bot: ${e}...`);
|
|
|
|
_this.deployBot(e);
|
|
|
|
logger.info(`Bot: ${e} deployed...`);
|
|
|
|
});
|
2018-09-10 12:09:48 -03:00
|
|
|
|
2018-09-24 19:56:11 -03:00
|
|
|
/** Then all remaining generalPackages are loaded. */
|
|
|
|
|
2018-11-12 12:20:44 -02:00
|
|
|
generalPackages = generalPackages.filter(p => !p.endsWith('.git'));
|
2018-09-24 19:56:11 -03:00
|
|
|
|
|
|
|
generalPackages.forEach(filename => {
|
2018-11-12 12:20:44 -02:00
|
|
|
const filenameOnly = Path.basename(filename);
|
2018-09-24 19:56:11 -03:00
|
|
|
logger.info(`Deploying package: ${filename}...`);
|
|
|
|
|
|
|
|
/** Handles apps for general bots - .gbapp must stay out of deploy folder. */
|
|
|
|
|
|
|
|
if (
|
2018-11-12 12:20:44 -02:00
|
|
|
Path.extname(filename) === '.gbapp' ||
|
|
|
|
Path.extname(filename) === '.gblib'
|
2018-09-24 19:56:11 -03:00
|
|
|
) {
|
|
|
|
/** Themes for bots. */
|
2018-11-12 12:20:44 -02:00
|
|
|
} else if (Path.extname(filename) === '.gbtheme') {
|
|
|
|
server.use('/themes/' + filenameOnly, express.static(filename));
|
2018-09-24 19:56:11 -03:00
|
|
|
logger.info(
|
2018-11-12 12:20:44 -02:00
|
|
|
`Theme (.gbtheme) assets accessible at: ${'/themes/' +
|
2018-09-24 19:56:11 -03:00
|
|
|
filenameOnly}.`
|
|
|
|
);
|
|
|
|
|
|
|
|
/** Knowledge base for bots. */
|
2018-11-12 12:20:44 -02:00
|
|
|
} else if (Path.extname(filename) === '.gbkb') {
|
2018-09-24 19:56:11 -03:00
|
|
|
server.use(
|
2018-11-12 12:20:44 -02:00
|
|
|
'/kb/' + filenameOnly + '/subjects',
|
|
|
|
express.static(UrlJoin(filename, 'subjects'))
|
2018-09-24 19:56:11 -03:00
|
|
|
);
|
|
|
|
logger.info(
|
2018-11-12 12:20:44 -02:00
|
|
|
`KB (.gbkb) assets accessible at: ${'/kb/' + filenameOnly}.`
|
2018-09-24 19:56:11 -03:00
|
|
|
);
|
2018-11-12 12:20:44 -02:00
|
|
|
} else if (Path.extname(filename) === '.gbui') {
|
2018-09-24 19:56:11 -03:00
|
|
|
// Already Handled
|
|
|
|
} else {
|
|
|
|
/** Unknown package format. */
|
2018-11-12 12:20:44 -02:00
|
|
|
const err = new Error(`Package type not handled: ${filename}.`);
|
2018-09-24 19:56:11 -03:00
|
|
|
reject(err);
|
|
|
|
}
|
|
|
|
totalPackages++;
|
|
|
|
});
|
2018-09-10 12:09:48 -03:00
|
|
|
|
2018-09-24 19:56:11 -03:00
|
|
|
WaitUntil()
|
|
|
|
.interval(100)
|
|
|
|
.times(5)
|
|
|
|
.condition(function(cb) {
|
|
|
|
logger.info(`Waiting for package deployment...`);
|
|
|
|
cb(totalPackages == generalPackages.length);
|
|
|
|
})
|
|
|
|
.done(function(result) {
|
|
|
|
if (botPackages.length === 0) {
|
2018-11-17 08:52:16 -02:00
|
|
|
logger.info(
|
2018-11-12 12:20:44 -02:00
|
|
|
'No external packages to load, please use ADDITIONAL_DEPLOY_PATH to point to a .gbai package folder.'
|
2018-09-24 11:04:36 -03:00
|
|
|
);
|
2018-09-11 19:33:58 -03:00
|
|
|
} else {
|
2018-09-24 19:56:11 -03:00
|
|
|
logger.info(`Package deployment done.`);
|
2018-09-10 12:09:48 -03:00
|
|
|
}
|
2018-09-24 19:56:11 -03:00
|
|
|
resolve();
|
2018-09-24 11:04:36 -03:00
|
|
|
});
|
2018-09-24 19:56:11 -03:00
|
|
|
});
|
2018-09-24 11:04:36 -03:00
|
|
|
});
|
2018-09-10 12:09:48 -03:00
|
|
|
}
|
|
|
|
|
2018-09-11 19:33:58 -03:00
|
|
|
/**
|
|
|
|
* Deploys a bot to the storage.
|
2018-09-09 14:39:37 -03:00
|
|
|
*/
|
|
|
|
|
2018-11-12 12:20:44 -02:00
|
|
|
public async deployBot(localPath: string): Promise<IGBInstance> {
|
|
|
|
const packageType = Path.extname(localPath);
|
|
|
|
const packageName = Path.basename(localPath);
|
|
|
|
const instance = await this.importer.importIfNotExistsBotPackage(
|
2018-04-21 02:59:30 -03:00
|
|
|
packageName,
|
2018-09-09 14:39:37 -03:00
|
|
|
localPath
|
2018-09-24 11:04:36 -03:00
|
|
|
);
|
|
|
|
return instance;
|
2018-04-21 02:59:30 -03:00
|
|
|
}
|
|
|
|
|
2018-11-12 12:20:44 -02:00
|
|
|
public async deployPackageToStorage(
|
2018-04-21 02:59:30 -03:00
|
|
|
instanceId: number,
|
2018-09-11 19:33:58 -03:00
|
|
|
packageName: string
|
|
|
|
): Promise<GuaribasPackage> {
|
2018-09-09 14:39:37 -03:00
|
|
|
return GuaribasPackage.create({
|
2018-04-21 02:59:30 -03:00
|
|
|
packageName: packageName,
|
|
|
|
instanceId: instanceId
|
2018-09-24 11:04:36 -03:00
|
|
|
});
|
2018-04-21 02:59:30 -03:00
|
|
|
}
|
|
|
|
|
2018-11-12 12:20:44 -02:00
|
|
|
public deployTheme(localPath: string) {
|
2018-04-21 02:59:30 -03:00
|
|
|
// DISABLED: Until completed, "/ui/public".
|
|
|
|
// FsExtra.copy(localPath, this.workDir + packageName)
|
|
|
|
// .then(() => {
|
|
|
|
// })
|
|
|
|
// .catch(err => {
|
|
|
|
// var gberr = GBError.create(
|
|
|
|
// `GuaribasBusinessError: Error copying package: ${localPath}.`
|
2018-09-11 19:40:53 -03:00
|
|
|
// )
|
|
|
|
// })
|
2018-04-21 02:59:30 -03:00
|
|
|
}
|
|
|
|
|
2018-11-12 12:20:44 -02:00
|
|
|
public async deployPackageFromLocalPath(localPath: string) {
|
|
|
|
const packageType = Path.extname(localPath);
|
2018-04-21 02:59:30 -03:00
|
|
|
|
|
|
|
switch (packageType) {
|
2018-11-12 12:20:44 -02:00
|
|
|
case '.gbot':
|
2018-09-24 11:04:36 -03:00
|
|
|
return this.deployBot(localPath);
|
2018-04-21 02:59:30 -03:00
|
|
|
|
2018-11-12 12:20:44 -02:00
|
|
|
case '.gbtheme':
|
2018-09-24 11:04:36 -03:00
|
|
|
return this.deployTheme(localPath);
|
2018-04-21 02:59:30 -03:00
|
|
|
|
|
|
|
// PACKAGE: Put in package logic.
|
2018-11-12 12:20:44 -02:00
|
|
|
case '.gbkb':
|
|
|
|
const service = new KBService(this.core.sequelize);
|
2018-09-24 11:04:36 -03:00
|
|
|
return service.deployKb(this.core, this, localPath);
|
2018-04-21 02:59:30 -03:00
|
|
|
|
2018-11-12 12:20:44 -02:00
|
|
|
case '.gbui':
|
2018-09-24 11:04:36 -03:00
|
|
|
break;
|
2018-04-21 02:59:30 -03:00
|
|
|
|
|
|
|
default:
|
2018-11-12 12:20:44 -02:00
|
|
|
const err = GBError.create(
|
2018-04-21 02:59:30 -03:00
|
|
|
`GuaribasBusinessError: Unknow package type: ${packageType}.`
|
2018-09-24 11:04:36 -03:00
|
|
|
);
|
|
|
|
Promise.reject(err);
|
|
|
|
break;
|
2018-04-21 02:59:30 -03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-11-12 12:20:44 -02:00
|
|
|
public async undeployPackageFromLocalPath(instance: IGBInstance, localPath: string) {
|
|
|
|
const packageType = Path.extname(localPath);
|
|
|
|
const packageName = Path.basename(localPath);
|
2018-04-21 02:59:30 -03:00
|
|
|
|
2018-11-12 12:20:44 -02:00
|
|
|
const p = await this.getPackageByName(instance.instanceId, packageName);
|
2018-04-21 02:59:30 -03:00
|
|
|
|
2018-09-09 14:39:37 -03:00
|
|
|
switch (packageType) {
|
2018-11-12 12:20:44 -02:00
|
|
|
case '.gbot':
|
2018-09-11 19:40:53 -03:00
|
|
|
// TODO: this.undeployBot(packageName, localPath)
|
2018-09-24 11:04:36 -03:00
|
|
|
break;
|
2018-04-21 02:59:30 -03:00
|
|
|
|
2018-11-12 12:20:44 -02:00
|
|
|
case '.gbtheme':
|
2018-09-11 19:40:53 -03:00
|
|
|
// TODO: this.undeployTheme(packageName, localPath)
|
2018-09-24 11:04:36 -03:00
|
|
|
break;
|
2018-04-21 02:59:30 -03:00
|
|
|
|
2018-11-12 12:20:44 -02:00
|
|
|
case '.gbkb':
|
|
|
|
const service = new KBService(this.core.sequelize);
|
2018-09-24 11:04:36 -03:00
|
|
|
return service.undeployKbFromStorage(instance, this, p.packageId);
|
2018-09-09 14:39:37 -03:00
|
|
|
|
2018-11-12 12:20:44 -02:00
|
|
|
case '.gbui':
|
2018-09-24 11:04:36 -03:00
|
|
|
break;
|
2018-09-09 14:39:37 -03:00
|
|
|
|
|
|
|
default:
|
2018-11-12 12:20:44 -02:00
|
|
|
const err = GBError.create(
|
2018-09-09 14:39:37 -03:00
|
|
|
`GuaribasBusinessError: Unknown package type: ${packageType}.`
|
2018-09-24 11:04:36 -03:00
|
|
|
);
|
|
|
|
Promise.reject(err);
|
|
|
|
break;
|
2018-09-09 14:39:37 -03:00
|
|
|
}
|
2018-04-21 02:59:30 -03:00
|
|
|
}
|
|
|
|
|
2018-09-24 11:04:36 -03:00
|
|
|
public async rebuildIndex(instance: GuaribasInstance) {
|
2018-11-12 12:20:44 -02:00
|
|
|
const search = new AzureSearch(
|
2018-09-24 11:04:36 -03:00
|
|
|
instance.searchKey,
|
|
|
|
instance.searchHost,
|
|
|
|
instance.searchIndex,
|
|
|
|
instance.searchIndexer
|
|
|
|
);
|
2018-10-22 15:33:23 -03:00
|
|
|
|
2018-11-12 12:20:44 -02:00
|
|
|
const connectionString = GBDeployer.getConnectionStringFromInstance(instance);
|
2018-10-22 15:33:23 -03:00
|
|
|
|
2018-11-12 12:20:44 -02:00
|
|
|
const dsName = 'gb';
|
2018-11-04 09:19:03 -02:00
|
|
|
try {
|
|
|
|
await search.deleteDataSource(dsName);
|
|
|
|
} catch (err) {
|
|
|
|
if (err.code != 404) {
|
|
|
|
// First time, nothing to delete.
|
|
|
|
throw err;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
await search.createDataSource(
|
2018-10-22 15:33:23 -03:00
|
|
|
dsName,
|
|
|
|
dsName,
|
2018-11-12 12:20:44 -02:00
|
|
|
'GuaribasQuestion',
|
|
|
|
'azuresql',
|
2018-10-22 15:33:23 -03:00
|
|
|
connectionString
|
|
|
|
);
|
2018-11-04 09:19:03 -02:00
|
|
|
|
|
|
|
try {
|
|
|
|
await search.deleteIndex();
|
|
|
|
} catch (err) {
|
|
|
|
if (err.code != 404) {
|
|
|
|
// First time, nothing to delete.
|
|
|
|
throw err;
|
|
|
|
}
|
|
|
|
}
|
2018-09-24 11:04:36 -03:00
|
|
|
await search.createIndex(
|
2018-10-22 15:33:23 -03:00
|
|
|
AzureDeployerService.getKBSearchSchema(instance.searchIndex),
|
|
|
|
dsName
|
2018-09-24 11:04:36 -03:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2018-11-12 12:20:44 -02:00
|
|
|
public async getPackageByName(
|
2018-09-11 19:33:58 -03:00
|
|
|
instanceId: number,
|
|
|
|
packageName: string
|
|
|
|
): Promise<GuaribasPackage> {
|
2018-11-12 12:20:44 -02:00
|
|
|
const where = { packageName: packageName, instanceId: instanceId };
|
2018-09-09 14:39:37 -03:00
|
|
|
return GuaribasPackage.findOne({
|
|
|
|
where: where
|
2018-09-24 11:04:36 -03:00
|
|
|
});
|
2018-09-09 14:39:37 -03:00
|
|
|
}
|
2018-04-21 02:59:30 -03:00
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* Hot deploy processing.
|
|
|
|
*
|
|
|
|
*/
|
2018-11-12 12:20:44 -02:00
|
|
|
public async scanBootPackage() {
|
|
|
|
const deployFolder = 'packages';
|
|
|
|
const bootPackage = GBConfigService.get('BOOT_PACKAGE');
|
2018-04-21 02:59:30 -03:00
|
|
|
|
2018-11-12 12:20:44 -02:00
|
|
|
if (bootPackage === 'none') {
|
2018-09-24 11:04:36 -03:00
|
|
|
return Promise.resolve(true);
|
2018-04-21 02:59:30 -03:00
|
|
|
} else {
|
2018-09-09 14:39:37 -03:00
|
|
|
return this.deployPackageFromLocalPath(
|
|
|
|
UrlJoin(deployFolder, bootPackage)
|
2018-09-24 11:04:36 -03:00
|
|
|
);
|
2018-04-21 02:59:30 -03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|