From 9285a8b6a210c12de90cd41758f8bc92b0171002 Mon Sep 17 00:00:00 2001 From: chenos Date: Sat, 17 Dec 2022 10:35:10 +0800 Subject: [PATCH] fix: nocobase upgrade error --- packages/core/server/src/application.ts | 8 +++++--- packages/presets/nocobase/src/index.ts | 7 +++++-- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/packages/core/server/src/application.ts b/packages/core/server/src/application.ts index edf260634..e1d525da0 100644 --- a/packages/core/server/src/application.ts +++ b/packages/core/server/src/application.ts @@ -369,9 +369,11 @@ export class Application exten process.exit(1); } await this.dbVersionCheck({ exit: true }); - await this.load({ - method: argv?.[2], - }); + if (argv?.[2] !== 'upgrade') { + await this.load({ + method: argv?.[2], + }); + } return this.cli.parseAsync(argv, options); } diff --git a/packages/presets/nocobase/src/index.ts b/packages/presets/nocobase/src/index.ts index fa6913de0..3f52dec1e 100644 --- a/packages/presets/nocobase/src/index.ts +++ b/packages/presets/nocobase/src/index.ts @@ -66,8 +66,10 @@ export class PresetNocoBase extends Plugin { await this.addBuiltInPlugins(); } const builtInPlugins = this.getBuiltInPlugins(); + const plugins = await this.db.getRepository('applicationPlugins').find(); + const pluginNames = plugins.map((p) => p.name); await this.app.pm.add( - builtInPlugins.filter((plugin) => !this.app.pm.has(plugin)), + builtInPlugins.filter((plugin) => !pluginNames.includes(plugin)), { enabled: true, builtIn: true, @@ -76,9 +78,10 @@ export class PresetNocoBase extends Plugin { ); const localPlugins = this.getLocalPlugins(); 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 () => { console.log(`Initialize all built-in plugins`);