From 06c942103beb4115f13477de4f4058349c2af3ed Mon Sep 17 00:00:00 2001 From: sealday Date: Wed, 10 Apr 2024 01:00:04 +0800 Subject: [PATCH] fix: upgrade --- .changeset/itchy-houses-join.md | 5 +++++ packages/core/server/src/commands/start.ts | 10 +++++++++- .../core/server/src/plugin-manager/plugin-manager.ts | 11 ++++++++++- storage/.gitignore | 1 + 4 files changed, 25 insertions(+), 2 deletions(-) create mode 100644 .changeset/itchy-houses-join.md diff --git a/.changeset/itchy-houses-join.md b/.changeset/itchy-houses-join.md new file mode 100644 index 000000000..a45ac5a20 --- /dev/null +++ b/.changeset/itchy-houses-join.md @@ -0,0 +1,5 @@ +--- +"@nocobase/server": patch +--- + +fix upgrade diff --git a/packages/core/server/src/commands/start.ts b/packages/core/server/src/commands/start.ts index f73ab79cf..7ae3fb21d 100644 --- a/packages/core/server/src/commands/start.ts +++ b/packages/core/server/src/commands/start.ts @@ -1,3 +1,6 @@ +import { fsExists } from '@nocobase/utils'; +import fs from 'fs'; +import { resolve } from 'path'; import Application from '../application'; import { ApplicationNotInstall } from '../errors/application-not-install'; @@ -10,7 +13,12 @@ export default (app: Application) => { .action(async (...cliArgs) => { const [options] = cliArgs; console.log('start options', options); - if (options.quickstart) { + const file = resolve(process.cwd(), 'storage/app-upgrading'); + const upgrading = await fsExists(file); + if (upgrading) { + await app.upgrade(); + await fs.promises.rm(file); + } else if (options.quickstart) { if (await app.isInstalled()) { await app.upgrade(); } else { diff --git a/packages/core/server/src/plugin-manager/plugin-manager.ts b/packages/core/server/src/plugin-manager/plugin-manager.ts index 62e1bf4c6..4c5cc0c0a 100644 --- a/packages/core/server/src/plugin-manager/plugin-manager.ts +++ b/packages/core/server/src/plugin-manager/plugin-manager.ts @@ -815,7 +815,16 @@ export class PluginManager { } else { await this.upgradeByNpm(options as any); } - await this.app.upgrade(); + const file = resolve(process.cwd(), 'storage/app-upgrading'); + await fs.promises.writeFile(file, '', 'utf-8'); + // await this.app.upgrade(); + if (process.env.IS_DEV_CMD) { + await tsxRerunning(); + } else { + await execa('pnpm', ['nocobase', 'pm2-restart'], { + env: process.env, + }); + } } /** diff --git a/storage/.gitignore b/storage/.gitignore index 39489c602..40636a345 100644 --- a/storage/.gitignore +++ b/storage/.gitignore @@ -3,3 +3,4 @@ tmp app.watch.ts /e2e nocobase.conf +app-upgrading