fix(core.gbapp): .gbapp now can be debugged within .ts files.
This commit is contained in:
parent
4ba3db79de
commit
10990e601c
6 changed files with 25 additions and 53 deletions
1
.vscode/launch.json
vendored
1
.vscode/launch.json
vendored
|
@ -4,6 +4,7 @@
|
||||||
{
|
{
|
||||||
"type": "node",
|
"type": "node",
|
||||||
"request": "launch",
|
"request": "launch",
|
||||||
|
"sourceMaps": true,
|
||||||
"name": "Debug Program",
|
"name": "Debug Program",
|
||||||
"program": "${workspaceRoot}/boot.js",
|
"program": "${workspaceRoot}/boot.js",
|
||||||
"cwd": "${workspaceRoot}",
|
"cwd": "${workspaceRoot}",
|
||||||
|
|
|
@ -233,7 +233,7 @@ export class GBAdminService implements IGBAdminService {
|
||||||
if (packageType !== '.gbot') {
|
if (packageType !== '.gbot') {
|
||||||
let s = new GBSharePointService();
|
let s = new GBSharePointService();
|
||||||
|
|
||||||
let localFolder = Path.join('work', Path.basename(folderName));
|
let localFolder = Path.join('work', `${min.instance.botId}.gbai`, Path.basename(folderName));
|
||||||
GBLog.warn(`${GBConfigService.get('CLOUD_USERNAME')} must be authorized on SharePoint related site`);
|
GBLog.warn(`${GBConfigService.get('CLOUD_USERNAME')} must be authorized on SharePoint related site`);
|
||||||
await s.downloadFolder(localFolder, siteName, folderName,
|
await s.downloadFolder(localFolder, siteName, folderName,
|
||||||
GBConfigService.get('CLOUD_USERNAME'), GBConfigService.get('CLOUD_PASSWORD'))
|
GBConfigService.get('CLOUD_USERNAME'), GBConfigService.get('CLOUD_PASSWORD'))
|
||||||
|
|
|
@ -91,9 +91,6 @@ export class GBDeployer implements IGBDeployer {
|
||||||
public async deployPackages(core: IGBCoreService, server: any, appPackages: IGBPackage[]) {
|
public async deployPackages(core: IGBCoreService, server: any, appPackages: IGBPackage[]) {
|
||||||
const _this = this;
|
const _this = this;
|
||||||
|
|
||||||
|
|
||||||
GBLog.info(`PWD ${process.env.PWD}...`);
|
|
||||||
let totalPackages = 0;
|
|
||||||
let paths = [urlJoin(process.env.PWD, GBDeployer.deployFolder), urlJoin(process.env.PWD, GBDeployer.workFolder)];
|
let paths = [urlJoin(process.env.PWD, GBDeployer.deployFolder), urlJoin(process.env.PWD, GBDeployer.workFolder)];
|
||||||
const additionalPath = GBConfigService.get('ADDITIONAL_DEPLOY_PATH');
|
const additionalPath = GBConfigService.get('ADDITIONAL_DEPLOY_PATH');
|
||||||
if (additionalPath !== undefined && additionalPath !== '') {
|
if (additionalPath !== undefined && additionalPath !== '') {
|
||||||
|
@ -151,14 +148,12 @@ export class GBDeployer implements IGBDeployer {
|
||||||
|
|
||||||
GBLog.info(`App Package deployment done.`);
|
GBLog.info(`App Package deployment done.`);
|
||||||
|
|
||||||
({ generalPackages, totalPackages } = await this.deployDataPackages(
|
({ generalPackages } = await this.deployDataPackages(
|
||||||
|
|
||||||
core,
|
core,
|
||||||
botPackages,
|
botPackages,
|
||||||
_this,
|
_this,
|
||||||
generalPackages,
|
generalPackages
|
||||||
server,
|
|
||||||
totalPackages
|
|
||||||
));
|
));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -337,7 +332,7 @@ export class GBDeployer implements IGBDeployer {
|
||||||
}
|
}
|
||||||
GBServer.globals.minService.unmountBot(botId);
|
GBServer.globals.minService.unmountBot(botId);
|
||||||
await this.core.deleteInstance(botId);
|
await this.core.deleteInstance(botId);
|
||||||
const packageFolder = Path.join(process.env.PWD, 'work', packageName);
|
const packageFolder = Path.join(process.env.PWD, 'work', `${botId}.gbai`, packageName);
|
||||||
}
|
}
|
||||||
public async deployPackageToStorage(instanceId: number, packageName: string): Promise<GuaribasPackage> {
|
public async deployPackageToStorage(instanceId: number, packageName: string): Promise<GuaribasPackage> {
|
||||||
return GuaribasPackage.create({
|
return GuaribasPackage.create({
|
||||||
|
@ -373,8 +368,8 @@ export class GBDeployer implements IGBDeployer {
|
||||||
await CollectionUtil.asyncForEach(min.appPackages, async (e: IGBPackage) => {
|
await CollectionUtil.asyncForEach(min.appPackages, async (e: IGBPackage) => {
|
||||||
if (pck = await e.onExchangeData(min, "handlePackage", {
|
if (pck = await e.onExchangeData(min, "handlePackage", {
|
||||||
name: localPath,
|
name: localPath,
|
||||||
createPackage: async () => {
|
createPackage: async (packageName) => {
|
||||||
return await _this.deployPackageToStorage(min.instance.instanceId, localPath);
|
return await _this.deployPackageToStorage(min.instance.instanceId, packageName);
|
||||||
}, updatePackage: async (p: GuaribasPackage) => {
|
}, updatePackage: async (p: GuaribasPackage) => {
|
||||||
p.save();
|
p.save();
|
||||||
}
|
}
|
||||||
|
@ -540,10 +535,7 @@ export class GBDeployer implements IGBDeployer {
|
||||||
core: IGBCoreService,
|
core: IGBCoreService,
|
||||||
botPackages: string[],
|
botPackages: string[],
|
||||||
_this: this,
|
_this: this,
|
||||||
generalPackages: string[],
|
generalPackages: string[]
|
||||||
server: any,
|
|
||||||
totalPackages: number
|
|
||||||
|
|
||||||
) {
|
) {
|
||||||
try {
|
try {
|
||||||
await core.syncDatabaseStructure();
|
await core.syncDatabaseStructure();
|
||||||
|
@ -563,44 +555,23 @@ export class GBDeployer implements IGBDeployer {
|
||||||
|
|
||||||
// Then all remaining generalPackages are loaded.
|
// Then all remaining generalPackages are loaded.
|
||||||
|
|
||||||
generalPackages = generalPackages.filter(p => !p.endsWith('.git'));
|
const instances = core.loadInstances();
|
||||||
await CollectionUtil.asyncForEach(generalPackages, async filename => {
|
await CollectionUtil.asyncForEach(instances, async instance => {
|
||||||
const filenameOnly = Path.basename(filename);
|
|
||||||
GBLog.info(`Deploying package: ${filename}...`);
|
|
||||||
|
|
||||||
// Handles apps for general bots - .gbapp must stay out of deploy folder.
|
this.mountGBKBAssets(`{instance.botId}.gbkb`, instance.botId, `{instance.botId}.gbkb`);
|
||||||
|
|
||||||
if (Path.extname(filename) === '.gbapp' || Path.extname(filename) === '.gblib') {
|
|
||||||
// Themes for bots.
|
|
||||||
} else if (Path.extname(filename) === '.gbtheme') {
|
|
||||||
} else if (Path.extname(filename) === '.gbkb') {
|
|
||||||
this.mountGBKBAssets(filenameOnly, filename);
|
|
||||||
} else if (Path.extname(filename) === '.gbui') {
|
|
||||||
// Already Handled
|
|
||||||
} else if (Path.extname(filename) === '.gbdialog') {
|
|
||||||
// Already Handled
|
|
||||||
} else if (Path.extname(filename) === '.gbignore') {
|
|
||||||
// Ignored
|
|
||||||
} else {
|
|
||||||
// Unknown package format.
|
|
||||||
const err = new Error(`Package type not handled: ${filename}.`);
|
|
||||||
throw err;
|
|
||||||
|
|
||||||
}
|
|
||||||
totalPackages++;
|
|
||||||
});
|
});
|
||||||
|
|
||||||
GBLog.info(`Package deployment done.`);
|
GBLog.info(`Package deployment done.`);
|
||||||
return { generalPackages, totalPackages };
|
return { generalPackages};
|
||||||
}
|
}
|
||||||
|
|
||||||
public mountGBKBAssets(packageName: any, filename: string) {
|
public mountGBKBAssets(packageName: any, botId: string, filename: string) {
|
||||||
GBServer.globals.server.use(`/kb/${packageName}/subjects`, express.static(urlJoin(filename, 'subjects')));
|
GBServer.globals.server.use(`/kb/${botId}.gbai/${packageName}/subjects`, express.static(urlJoin(filename, 'subjects')));
|
||||||
GBServer.globals.server.use(`/kb/${packageName}/assets`, express.static(urlJoin(filename, 'assets')));
|
GBServer.globals.server.use(`/kb/${botId}.gbai/${packageName}/assets`, express.static(urlJoin(filename, 'assets')));
|
||||||
GBServer.globals.server.use(`/kb/${packageName}/images`, express.static(urlJoin(filename, 'images')));
|
GBServer.globals.server.use(`/kb/${botId}.gbai/${packageName}/images`, express.static(urlJoin(filename, 'images')));
|
||||||
GBServer.globals.server.use(`/kb/${packageName}/audios`, express.static(urlJoin(filename, 'audios')));
|
GBServer.globals.server.use(`/kb/${botId}.gbai/${packageName}/audios`, express.static(urlJoin(filename, 'audios')));
|
||||||
GBServer.globals.server.use(`/kb/${packageName}/videos`, express.static(urlJoin(filename, 'videos')));
|
GBServer.globals.server.use(`/kb/${botId}.gbai/${packageName}/videos`, express.static(urlJoin(filename, 'videos')));
|
||||||
GBLog.info(`KB (.gbkb) assets accessible at: /kb/${packageName}.`);
|
GBLog.info(`KB (.gbkb) assets accessible at: /kb/${botId}.gbai/${packageName}.`);
|
||||||
}
|
}
|
||||||
|
|
||||||
private isSystemPackage(name: string): Boolean {
|
private isSystemPackage(name: string): Boolean {
|
||||||
|
|
|
@ -219,19 +219,19 @@ export class GBMinService {
|
||||||
|
|
||||||
// Install per bot deployed packages.
|
// Install per bot deployed packages.
|
||||||
|
|
||||||
let packagePath = `work/${min.botId}.gbdialog`;
|
let packagePath = `work/${min.botId}.gbai/${min.botId}.gbdialog`;
|
||||||
if (fs.existsSync(packagePath)) {
|
if (fs.existsSync(packagePath)) {
|
||||||
await this.deployer.deployPackage(min, packagePath);
|
await this.deployer.deployPackage(min, packagePath);
|
||||||
}
|
}
|
||||||
packagePath = `work/${min.botId}.gbapp`;
|
packagePath = `work/${min.botId}.gbai/${min.botId}.gbapp`;
|
||||||
if (fs.existsSync(packagePath)) {
|
if (fs.existsSync(packagePath)) {
|
||||||
await this.deployer.deployPackage(min, packagePath);
|
await this.deployer.deployPackage(min, packagePath);
|
||||||
}
|
}
|
||||||
packagePath = `work/${min.botId}.gbtheme`;
|
packagePath = `work/${min.botId}.gbai/${min.botId}.gbtheme`;
|
||||||
if (fs.existsSync(packagePath)) {
|
if (fs.existsSync(packagePath)) {
|
||||||
await this.deployer.deployPackage(min, packagePath);
|
await this.deployer.deployPackage(min, packagePath);
|
||||||
}
|
}
|
||||||
packagePath = `work/${min.botId}.gblib`;
|
packagePath = `work/${min.botId}.gbai/${min.botId}.gblib`;
|
||||||
if (fs.existsSync(packagePath)) {
|
if (fs.existsSync(packagePath)) {
|
||||||
await this.deployer.deployPackage(min, packagePath);
|
await this.deployer.deployPackage(min, packagePath);
|
||||||
}
|
}
|
||||||
|
|
|
@ -619,7 +619,7 @@ export class KBService implements IGBKBService {
|
||||||
GBLog.info(`[GBDeployer] Importing: ${localPath}`);
|
GBLog.info(`[GBDeployer] Importing: ${localPath}`);
|
||||||
const p = await deployer.deployPackageToStorage(instance.instanceId, packageName);
|
const p = await deployer.deployPackageToStorage(instance.instanceId, packageName);
|
||||||
await this.importKbPackage(localPath, p, instance);
|
await this.importKbPackage(localPath, p, instance);
|
||||||
deployer.mountGBKBAssets(packageName, localPath);
|
deployer.mountGBKBAssets(packageName,min.botId, localPath);
|
||||||
|
|
||||||
await deployer.rebuildIndex(instance, new AzureDeployerService(deployer).getKBSearchSchema(instance.searchIndex));
|
await deployer.rebuildIndex(instance, new AzureDeployerService(deployer).getKBSearchSchema(instance.searchIndex));
|
||||||
GBLog.info(`[GBDeployer] Finished import of ${localPath}`);
|
GBLog.info(`[GBDeployer] Finished import of ${localPath}`);
|
||||||
|
|
Loading…
Add table
Reference in a new issue