fix: nocobase upgrade error

This commit is contained in:
chenos 2022-12-17 10:35:10 +08:00
parent cbf21a5942
commit 9285a8b6a2
2 changed files with 10 additions and 5 deletions

View File

@ -369,9 +369,11 @@ export class Application<StateT = DefaultState, ContextT = DefaultContext> exten
process.exit(1); process.exit(1);
} }
await this.dbVersionCheck({ exit: true }); await this.dbVersionCheck({ exit: true });
await this.load({ if (argv?.[2] !== 'upgrade') {
method: argv?.[2], await this.load({
}); method: argv?.[2],
});
}
return this.cli.parseAsync(argv, options); return this.cli.parseAsync(argv, options);
} }

View File

@ -66,8 +66,10 @@ export class PresetNocoBase extends Plugin {
await this.addBuiltInPlugins(); await this.addBuiltInPlugins();
} }
const builtInPlugins = this.getBuiltInPlugins(); const builtInPlugins = this.getBuiltInPlugins();
const plugins = await this.db.getRepository('applicationPlugins').find();
const pluginNames = plugins.map((p) => p.name);
await this.app.pm.add( await this.app.pm.add(
builtInPlugins.filter((plugin) => !this.app.pm.has(plugin)), builtInPlugins.filter((plugin) => !pluginNames.includes(plugin)),
{ {
enabled: true, enabled: true,
builtIn: true, builtIn: true,
@ -76,9 +78,10 @@ export class PresetNocoBase extends Plugin {
); );
const localPlugins = this.getLocalPlugins(); const localPlugins = this.getLocalPlugins();
await this.app.pm.add( await this.app.pm.add(
localPlugins.filter((plugin) => !this.app.pm.has(plugin)), localPlugins.filter((plugin) => !pluginNames.includes(plugin)),
{}, {},
); );
await this.app.reload();
}); });
this.app.on('beforeInstall', async () => { this.app.on('beforeInstall', async () => {
console.log(`Initialize all built-in plugins`); console.log(`Initialize all built-in plugins`);