mirror of
https://github.com/nocobase/nocobase
synced 2024-11-15 08:47:20 +00:00
fix: upgrade sub app (#4246)
This commit is contained in:
parent
e5152af4c2
commit
d15eab2294
@ -13,7 +13,7 @@ describe('multiple apps', () => {
|
|||||||
|
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
app = await createMockServer({
|
app = await createMockServer({
|
||||||
plugins: ['multi-app-manager'],
|
plugins: ['nocobase', 'multi-app-manager'],
|
||||||
});
|
});
|
||||||
db = app.db;
|
db = app.db;
|
||||||
});
|
});
|
||||||
@ -94,6 +94,43 @@ describe('multiple apps', () => {
|
|||||||
expect(subAppStatus).toEqual('running');
|
expect(subAppStatus).toEqual('running');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should upgrade sub app', async () => {
|
||||||
|
await db.getRepository('applications').create({
|
||||||
|
values: {
|
||||||
|
name: 'test1',
|
||||||
|
options: {
|
||||||
|
plugins: ['nocobase'],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
context: {
|
||||||
|
waitSubAppInstall: true,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
await db.getRepository('applications').create({
|
||||||
|
values: {
|
||||||
|
name: 'test2',
|
||||||
|
options: {
|
||||||
|
plugins: ['nocobase'],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
context: {
|
||||||
|
waitSubAppInstall: true,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
await app.runCommand('restart');
|
||||||
|
await app.runCommand('upgrade');
|
||||||
|
// const subAppStatus = AppSupervisor.getInstance().getAppStatus(name);
|
||||||
|
// expect(subAppStatus).toEqual('running');
|
||||||
|
//
|
||||||
|
// const subApp = await AppSupervisor.getInstance().getApp(name);
|
||||||
|
// await subApp.runCommand('upgrade');
|
||||||
|
//
|
||||||
|
// await AppSupervisor.getInstance().removeApp(name);
|
||||||
|
// expect(await db.getRepository('applications').count()).toBe(1);
|
||||||
|
});
|
||||||
|
|
||||||
it('should list application with status', async () => {
|
it('should list application with status', async () => {
|
||||||
const sub1 = `td_${uid()}`;
|
const sub1 = `td_${uid()}`;
|
||||||
await db.getRepository('applications').create({
|
await db.getRepository('applications').create({
|
||||||
|
@ -36,11 +36,8 @@ const defaultSubAppUpgradeHandle: SubAppUpgradeHandler = async (mainApp: Applica
|
|||||||
upgrading: true,
|
upgrading: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
console.log({ beforeSubAppStatus });
|
|
||||||
try {
|
try {
|
||||||
mainApp.setMaintainingMessage(`upgrading sub app ${instance.name}...`);
|
mainApp.setMaintainingMessage(`upgrading sub app ${instance.name}...`);
|
||||||
console.log(`${instance.name}: upgrading...`);
|
|
||||||
|
|
||||||
await subApp.runAsCLI(['upgrade'], { from: 'user' });
|
await subApp.runAsCLI(['upgrade'], { from: 'user' });
|
||||||
if (!beforeSubAppStatus && AppSupervisor.getInstance().getAppStatus(instance.name) === 'initialized') {
|
if (!beforeSubAppStatus && AppSupervisor.getInstance().getAppStatus(instance.name) === 'initialized') {
|
||||||
await AppSupervisor.getInstance().removeApp(instance.name);
|
await AppSupervisor.getInstance().removeApp(instance.name);
|
||||||
@ -204,7 +201,8 @@ export class PluginMultiAppManagerServer extends Plugin {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const applicationRecord = (await self.app.db.getRepository('applications').findOne({
|
const mainApp = await appSupervisor.getApp('main');
|
||||||
|
const applicationRecord = (await mainApp.db.getRepository('applications').findOne({
|
||||||
filter: {
|
filter: {
|
||||||
name,
|
name,
|
||||||
},
|
},
|
||||||
@ -224,7 +222,7 @@ export class PluginMultiAppManagerServer extends Plugin {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const subApp = applicationRecord.registerToSupervisor(self.app, {
|
const subApp = applicationRecord.registerToSupervisor(mainApp, {
|
||||||
appOptionsFactory: self.appOptionsFactory,
|
appOptionsFactory: self.appOptionsFactory,
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -234,7 +232,7 @@ export class PluginMultiAppManagerServer extends Plugin {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
AppSupervisor.getInstance().setAppBootstrapper(LazyLoadApplication);
|
AppSupervisor.getInstance().setAppBootstrapper(LazyLoadApplication.bind(this));
|
||||||
|
|
||||||
Gateway.getInstance().addAppSelectorMiddleware(async (ctx, next) => {
|
Gateway.getInstance().addAppSelectorMiddleware(async (ctx, next) => {
|
||||||
const { req } = ctx;
|
const { req } = ctx;
|
||||||
|
Loading…
Reference in New Issue
Block a user