Skip to content

Commit

Permalink
feat: better bump #136
Browse files Browse the repository at this point in the history
  • Loading branch information
oeyoews committed Oct 19, 2024
1 parent 47a935c commit 788fc08
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions scripts/bump.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ const path = require('path');
const jsonInfo = require('../package.json');
const langtwInfo = require('../packages/lang-tiddlywiki/package.json');

// 版本类型,可以是 'major','minor' 或 'patch'
const versionType = process.argv[2] || 'patch'; // 从命令行参数中获取版本类型,默认为 'patch'

const infoFilePath = path.join(
__dirname,
'..',
Expand All @@ -15,9 +18,22 @@ const infoFileContent = fs.readFileSync(infoFilePath, 'utf8');
// 将 JSON 字符串转换成对象
const info = JSON.parse(infoFileContent);

// 递增版本号的末尾数字
// 递增版本号的相应部分
const currentVersion = info.version.split('.').map(Number); // 将版本号字符串转换为数字数组
currentVersion[2] += 1; // 递增末尾数字

if (versionType === 'major') {
currentVersion[0] += 1;
currentVersion[1] = 0;
currentVersion[2] = 0;
} else if (versionType === 'minor') {
currentVersion[1] += 1;
currentVersion[2] = 0;
} else if (versionType === 'patch') {
currentVersion[2] += 1;
} else {
console.error('无效的版本类型,必须是 "major"、"minor" 或 "patch"。');
process.exit(1); // 退出进程
}

// 更新对象中的版本号
info.version = currentVersion.join('.');
Expand Down

0 comments on commit 788fc08

Please sign in to comment.