mirror of
https://gitee.com/nocobase/nocobase.git
synced 2025-07-02 11:12:20 +08:00
fix: version calculation error when creating migration (#4805)
This commit is contained in:
parent
d12763c6ee
commit
9a09f9e73d
@ -30,9 +30,14 @@ export default (app: Application) => {
|
|||||||
`${dayjs().format('YYYYMMDDHHmmss')}-${name}.ts`,
|
`${dayjs().format('YYYYMMDDHHmmss')}-${name}.ts`,
|
||||||
);
|
);
|
||||||
const version = app.getVersion();
|
const version = app.getVersion();
|
||||||
const keys: any[] = version.split('.');
|
// 匹配主版本号、次版本号、小版本号和后缀的正则表达式
|
||||||
keys.push(1 * keys.pop() + 1);
|
const regex = /(\d+)\.(\d+)\.(\d+)(-[\w.]+)?/;
|
||||||
const nextVersion = keys.join('.');
|
const nextVersion = version.replace(regex, (match, major, minor, patch, suffix) => {
|
||||||
|
// 将小版本号转换为整数并加1
|
||||||
|
const newPatch = parseInt(patch) + 1;
|
||||||
|
// 返回新的版本号
|
||||||
|
return `${major}.${minor}.${newPatch}${suffix || ''}`;
|
||||||
|
});
|
||||||
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}';
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user