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",
|
||||
"request": "launch",
|
||||
"sourceMaps": true,
|
||||
"name": "Debug Program",
|
||||
"program": "${workspaceRoot}/boot.js",
|
||||
"cwd": "${workspaceRoot}",
|
||||
|
|
|
@ -233,7 +233,7 @@ export class GBAdminService implements IGBAdminService {
|
|||
if (packageType !== '.gbot') {
|
||||
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`);
|
||||
await s.downloadFolder(localFolder, siteName, folderName,
|
||||
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[]) {
|
||||
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)];
|
||||
const additionalPath = GBConfigService.get('ADDITIONAL_DEPLOY_PATH');
|
||||
if (additionalPath !== undefined && additionalPath !== '') {
|
||||
|
@ -151,14 +148,12 @@ export class GBDeployer implements IGBDeployer {
|
|||
|
||||
GBLog.info(`App Package deployment done.`);
|
||||
|
||||
({ generalPackages, totalPackages } = await this.deployDataPackages(
|
||||
({ generalPackages } = await this.deployDataPackages(
|
||||
|
||||
core,
|
||||
botPackages,
|
||||
_this,
|
||||
generalPackages,
|
||||
server,
|
||||
totalPackages
|
||||
generalPackages
|
||||
));
|
||||
|
||||
}
|
||||
|
@ -337,7 +332,7 @@ export class GBDeployer implements IGBDeployer {
|
|||
}
|
||||
GBServer.globals.minService.unmountBot(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> {
|
||||
return GuaribasPackage.create({
|
||||
|
@ -373,8 +368,8 @@ export class GBDeployer implements IGBDeployer {
|
|||
await CollectionUtil.asyncForEach(min.appPackages, async (e: IGBPackage) => {
|
||||
if (pck = await e.onExchangeData(min, "handlePackage", {
|
||||
name: localPath,
|
||||
createPackage: async () => {
|
||||
return await _this.deployPackageToStorage(min.instance.instanceId, localPath);
|
||||
createPackage: async (packageName) => {
|
||||
return await _this.deployPackageToStorage(min.instance.instanceId, packageName);
|
||||
}, updatePackage: async (p: GuaribasPackage) => {
|
||||
p.save();
|
||||
}
|
||||
|
@ -540,10 +535,7 @@ export class GBDeployer implements IGBDeployer {
|
|||
core: IGBCoreService,
|
||||
botPackages: string[],
|
||||
_this: this,
|
||||
generalPackages: string[],
|
||||
server: any,
|
||||
totalPackages: number
|
||||
|
||||
generalPackages: string[]
|
||||
) {
|
||||
try {
|
||||
await core.syncDatabaseStructure();
|
||||
|
@ -563,44 +555,23 @@ export class GBDeployer implements IGBDeployer {
|
|||
|
||||
// Then all remaining generalPackages are loaded.
|
||||
|
||||
generalPackages = generalPackages.filter(p => !p.endsWith('.git'));
|
||||
await CollectionUtil.asyncForEach(generalPackages, async filename => {
|
||||
const filenameOnly = Path.basename(filename);
|
||||
GBLog.info(`Deploying package: ${filename}...`);
|
||||
const instances = core.loadInstances();
|
||||
await CollectionUtil.asyncForEach(instances, async instance => {
|
||||
|
||||
// Handles apps for general bots - .gbapp must stay out of deploy folder.
|
||||
|
||||
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++;
|
||||
this.mountGBKBAssets(`{instance.botId}.gbkb`, instance.botId, `{instance.botId}.gbkb`);
|
||||
});
|
||||
|
||||
GBLog.info(`Package deployment done.`);
|
||||
return { generalPackages, totalPackages };
|
||||
return { generalPackages};
|
||||
}
|
||||
|
||||
public mountGBKBAssets(packageName: any, filename: string) {
|
||||
GBServer.globals.server.use(`/kb/${packageName}/subjects`, express.static(urlJoin(filename, 'subjects')));
|
||||
GBServer.globals.server.use(`/kb/${packageName}/assets`, express.static(urlJoin(filename, 'assets')));
|
||||
GBServer.globals.server.use(`/kb/${packageName}/images`, express.static(urlJoin(filename, 'images')));
|
||||
GBServer.globals.server.use(`/kb/${packageName}/audios`, express.static(urlJoin(filename, 'audios')));
|
||||
GBServer.globals.server.use(`/kb/${packageName}/videos`, express.static(urlJoin(filename, 'videos')));
|
||||
GBLog.info(`KB (.gbkb) assets accessible at: /kb/${packageName}.`);
|
||||
public mountGBKBAssets(packageName: any, botId: string, filename: string) {
|
||||
GBServer.globals.server.use(`/kb/${botId}.gbai/${packageName}/subjects`, express.static(urlJoin(filename, 'subjects')));
|
||||
GBServer.globals.server.use(`/kb/${botId}.gbai/${packageName}/assets`, express.static(urlJoin(filename, 'assets')));
|
||||
GBServer.globals.server.use(`/kb/${botId}.gbai/${packageName}/images`, express.static(urlJoin(filename, 'images')));
|
||||
GBServer.globals.server.use(`/kb/${botId}.gbai/${packageName}/audios`, express.static(urlJoin(filename, 'audios')));
|
||||
GBServer.globals.server.use(`/kb/${botId}.gbai/${packageName}/videos`, express.static(urlJoin(filename, 'videos')));
|
||||
GBLog.info(`KB (.gbkb) assets accessible at: /kb/${botId}.gbai/${packageName}.`);
|
||||
}
|
||||
|
||||
private isSystemPackage(name: string): Boolean {
|
||||
|
|
|
@ -219,19 +219,19 @@ export class GBMinService {
|
|||
|
||||
// Install per bot deployed packages.
|
||||
|
||||
let packagePath = `work/${min.botId}.gbdialog`;
|
||||
let packagePath = `work/${min.botId}.gbai/${min.botId}.gbdialog`;
|
||||
if (fs.existsSync(packagePath)) {
|
||||
await this.deployer.deployPackage(min, packagePath);
|
||||
}
|
||||
packagePath = `work/${min.botId}.gbapp`;
|
||||
packagePath = `work/${min.botId}.gbai/${min.botId}.gbapp`;
|
||||
if (fs.existsSync(packagePath)) {
|
||||
await this.deployer.deployPackage(min, packagePath);
|
||||
}
|
||||
packagePath = `work/${min.botId}.gbtheme`;
|
||||
packagePath = `work/${min.botId}.gbai/${min.botId}.gbtheme`;
|
||||
if (fs.existsSync(packagePath)) {
|
||||
await this.deployer.deployPackage(min, packagePath);
|
||||
}
|
||||
packagePath = `work/${min.botId}.gblib`;
|
||||
packagePath = `work/${min.botId}.gbai/${min.botId}.gblib`;
|
||||
if (fs.existsSync(packagePath)) {
|
||||
await this.deployer.deployPackage(min, packagePath);
|
||||
}
|
||||
|
|
|
@ -619,7 +619,7 @@ export class KBService implements IGBKBService {
|
|||
GBLog.info(`[GBDeployer] Importing: ${localPath}`);
|
||||
const p = await deployer.deployPackageToStorage(instance.instanceId, packageName);
|
||||
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));
|
||||
GBLog.info(`[GBDeployer] Finished import of ${localPath}`);
|
||||
|
|
|
@ -134,7 +134,7 @@ export class GBServer {
|
|||
GBLog.info(`Defining server address at ${serverAddress}...`);
|
||||
GBServer.globals.publicAddress = serverAddress;
|
||||
}
|
||||
|
||||
|
||||
// Creates a boot instance or load it from storage.
|
||||
|
||||
try {
|
||||
|
|
Loading…
Add table
Reference in a new issue