From 62aff88e5e3cd87608f957c6af2865b0c12c0d26 Mon Sep 17 00:00:00 2001 From: chenos Date: Tue, 22 Apr 2025 13:10:59 +0800 Subject: [PATCH] fix: appVersion incorrectly generated by create-migration (#6740) --- packages/core/server/src/commands/create-migration.ts | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/packages/core/server/src/commands/create-migration.ts b/packages/core/server/src/commands/create-migration.ts index 4b76620f63..e09a488e6f 100644 --- a/packages/core/server/src/commands/create-migration.ts +++ b/packages/core/server/src/commands/create-migration.ts @@ -29,14 +29,13 @@ export default (app: Application) => { 'migrations', `${dayjs().format('YYYYMMDDHHmmss')}-${name}.ts`, ); - const version = app.getVersion(); - // 匹配主版本号、次版本号、小版本号和后缀的正则表达式 + const version = app.getPackageVersion(); const regex = /(\d+)\.(\d+)\.(\d+)(-[\w.]+)?/; const nextVersion = version.replace(regex, (match, major, minor, patch, suffix) => { - // 将小版本号转换为整数并加1 - const newPatch = parseInt(patch) + 1; - // 返回新的版本号 - return `${major}.${minor}.${newPatch}${suffix || ''}`; + if (version.includes('beta') || version.includes('alpha')) { + return `${major}.${minor}.${patch}`; + } + return `${major}.${1 + 1 * minor}.0`; }); const from = pkg === '@nocobase/server' ? `../migration` : '@nocobase/server'; const data = `import { Migration } from '${from}';