new(core.gbapp): /publish now can be used with .gbapp custom procedures.
This commit is contained in:
parent
1ed4a9bcc1
commit
d14b33c5ad
2 changed files with 53 additions and 10 deletions
|
@ -273,7 +273,9 @@ export class GuaribasPackage extends Model<GuaribasPackage> {
|
||||||
@Column
|
@Column
|
||||||
@UpdatedAt
|
@UpdatedAt
|
||||||
public updatedAt: Date;
|
public updatedAt: Date;
|
||||||
|
|
||||||
|
@Column({ type: DataType.STRING(512) })
|
||||||
|
public custom: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -112,12 +112,13 @@ export class GBDeployer implements IGBDeployer {
|
||||||
|
|
||||||
const dirs = getDirectories(path);
|
const dirs = getDirectories(path);
|
||||||
await CollectionUtil.asyncForEach(dirs, async element => {
|
await CollectionUtil.asyncForEach(dirs, async element => {
|
||||||
|
element = element.toLowerCase();
|
||||||
if (element === '.') {
|
if (element === '.') {
|
||||||
GBLog.info(`Ignoring ${element}...`);
|
GBLog.info(`Ignoring ${element}...`);
|
||||||
} else {
|
} else {
|
||||||
if (element.endsWith('.gbot')) {
|
if (element.endsWith('.gbot')) {
|
||||||
botPackages.push(element);
|
botPackages.push(element);
|
||||||
} else if (element.endsWith('.gbapp')) {
|
} else if (element.endsWith('.gbapp') || element.endsWith('.gblib')) {
|
||||||
gbappPackages.push(element);
|
gbappPackages.push(element);
|
||||||
} else {
|
} else {
|
||||||
generalPackages.push(element);
|
generalPackages.push(element);
|
||||||
|
@ -132,9 +133,21 @@ export class GBDeployer implements IGBDeployer {
|
||||||
await scanPackageDirectory(e);
|
await scanPackageDirectory(e);
|
||||||
});
|
});
|
||||||
|
|
||||||
// Deploys all .gbapp files first.
|
// Deploys all .gblib files first.
|
||||||
|
|
||||||
await this.deployAppPackages(gbappPackages, core, appPackages);
|
let list = [];
|
||||||
|
for (let index = 0; index < gbappPackages.length; index++) {
|
||||||
|
const element = gbappPackages[index];
|
||||||
|
if (element.endsWith('.gblib')) {
|
||||||
|
list.push(element);
|
||||||
|
gbappPackages.splice(index, 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (let index = 0; index < gbappPackages.length; index++) {
|
||||||
|
const element = gbappPackages[index];
|
||||||
|
list.push(element);
|
||||||
|
}
|
||||||
|
await this.deployAppPackages(list, core, appPackages);
|
||||||
|
|
||||||
GBLog.info(`App Package deployment done.`);
|
GBLog.info(`App Package deployment done.`);
|
||||||
|
|
||||||
|
@ -351,6 +364,32 @@ export class GBDeployer implements IGBDeployer {
|
||||||
public async deployPackage(min: GBMinInstance, localPath: string) {
|
public async deployPackage(min: GBMinInstance, localPath: string) {
|
||||||
const packageType = Path.extname(localPath);
|
const packageType = Path.extname(localPath);
|
||||||
|
|
||||||
|
const _this = this;
|
||||||
|
let handled = false;
|
||||||
|
let pck = null;
|
||||||
|
|
||||||
|
// .gbapp package or platform package checking.
|
||||||
|
|
||||||
|
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);
|
||||||
|
}, updatePackage: async (p: GuaribasPackage) => {
|
||||||
|
p.save();
|
||||||
|
}
|
||||||
|
})) {
|
||||||
|
handled = true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
if (handled) {
|
||||||
|
|
||||||
|
return pck;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Deploy platform packages here.
|
||||||
|
|
||||||
switch (packageType) {
|
switch (packageType) {
|
||||||
case '.gbot':
|
case '.gbot':
|
||||||
if (Fs.existsSync(localPath)) {
|
if (Fs.existsSync(localPath)) {
|
||||||
|
@ -457,7 +496,7 @@ export class GBDeployer implements IGBDeployer {
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Use temporary names for index for exchanging them after the new one is created.
|
// TODO: Use temporary names for index for exchanging them after the new one is created.
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await search.deleteIndex();
|
await search.deleteIndex();
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
@ -565,7 +604,7 @@ export class GBDeployer implements IGBDeployer {
|
||||||
}
|
}
|
||||||
|
|
||||||
private isSystemPackage(name: string): Boolean {
|
private isSystemPackage(name: string): Boolean {
|
||||||
const names = ['core.gbapp', 'admin.gbapp', 'azuredeployer.gbapp', 'customer-satisfaction.gbapp', 'kb.gbapp'];
|
const names = ['analytics.gblib', 'console.gblib', 'security.gblib', 'whatsapp.gblib', 'sharepoint.gblib', 'core.gbapp', 'admin.gbapp', 'azuredeployer.gbapp', 'customer-satisfaction.gbapp', 'kb.gbapp'];
|
||||||
|
|
||||||
return names.indexOf(name) > -1;
|
return names.indexOf(name) > -1;
|
||||||
}
|
}
|
||||||
|
@ -602,7 +641,7 @@ export class GBDeployer implements IGBDeployer {
|
||||||
child_process.execSync(Path.join(process.env.PWD, 'node_modules/.bin/tsc'), { cwd: gbappPath });
|
child_process.execSync(Path.join(process.env.PWD, 'node_modules/.bin/tsc'), { cwd: gbappPath });
|
||||||
}
|
}
|
||||||
|
|
||||||
if(gbappPath.endsWith('.gbapp')){
|
if (gbappPath.endsWith('.gbapp')) {
|
||||||
const m = await import(gbappPath);
|
const m = await import(gbappPath);
|
||||||
const p = new m.Package();
|
const p = new m.Package();
|
||||||
await p.loadPackage(core, core.sequelize);
|
await p.loadPackage(core, core.sequelize);
|
||||||
|
@ -610,13 +649,15 @@ export class GBDeployer implements IGBDeployer {
|
||||||
appPackages.push(p);
|
appPackages.push(p);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
GBLog.info(`.gbapp or .gblib deployed: ${gbappPath}.`);
|
GBLog.info(`.gbapp or .gblib deployed: ${gbappPath}.`);
|
||||||
appPackagesProcessed++;
|
appPackagesProcessed++;
|
||||||
}
|
}
|
||||||
catch (error) {
|
catch (error) {
|
||||||
GBLog.error(`Error message: ${error.stack}`);
|
GBLog.error(`Error compiling package, message: ${error.message}\n${error.stack}`);
|
||||||
GBLog.error(`Error compiling package ${gbappPath}:\n${error.stdout.toString()}`);
|
if (error.stdout) {
|
||||||
|
GBLog.error(`Error compiling package, stdout: ${gbappPath}:\n${error.stdout.toString()}`);
|
||||||
|
}
|
||||||
appPackagesProcessed++;
|
appPackagesProcessed++;
|
||||||
}
|
}
|
||||||
return appPackagesProcessed;
|
return appPackagesProcessed;
|
||||||
|
|
Loading…
Add table
Reference in a new issue