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',
`${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}';