fix: appVersion incorrectly generated by create-migration (#6740)

This commit is contained in:
chenos 2025-04-22 13:10:59 +08:00 committed by GitHub
parent e5055ef4f6
commit 62aff88e5e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -29,14 +29,13 @@ export default (app: Application) => {
'migrations', 'migrations',
`${dayjs().format('YYYYMMDDHHmmss')}-${name}.ts`, `${dayjs().format('YYYYMMDDHHmmss')}-${name}.ts`,
); );
const version = app.getVersion(); const version = app.getPackageVersion();
// 匹配主版本号、次版本号、小版本号和后缀的正则表达式
const regex = /(\d+)\.(\d+)\.(\d+)(-[\w.]+)?/; const regex = /(\d+)\.(\d+)\.(\d+)(-[\w.]+)?/;
const nextVersion = version.replace(regex, (match, major, minor, patch, suffix) => { const nextVersion = version.replace(regex, (match, major, minor, patch, suffix) => {
// 将小版本号转换为整数并加1 if (version.includes('beta') || version.includes('alpha')) {
const newPatch = parseInt(patch) + 1; return `${major}.${minor}.${patch}`;
// 返回新的版本号 }
return `${major}.${minor}.${newPatch}${suffix || ''}`; return `${major}.${1 + 1 * minor}.0`;
}); });
const from = pkg === '@nocobase/server' ? `../migration` : '@nocobase/server'; const from = pkg === '@nocobase/server' ? `../migration` : '@nocobase/server';
const data = `import { Migration } from '${from}'; const data = `import { Migration } from '${from}';