mirror of
https://github.com/qaiu/netdisk-fast-download.git
synced 2026-06-10 23:47:29 +00:00
refactor: 统一版本号管理,消除硬编码
项目版本(pom.xml revision)和parser版本(parserVersion)统一为单一来源, 前端构建时自动同步,发版只需改根pom.xml的两个属性。
This commit is contained in:
23
web-front/scripts/sync-version.js
Normal file
23
web-front/scripts/sync-version.js
Normal file
@@ -0,0 +1,23 @@
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
|
||||
const pomPath = path.resolve(__dirname, '../../pom.xml');
|
||||
const pkgPath = path.resolve(__dirname, '../package.json');
|
||||
|
||||
const pomContent = fs.readFileSync(pomPath, 'utf-8');
|
||||
const match = pomContent.match(/<revision>([^<]+)<\/revision>/);
|
||||
if (!match) {
|
||||
console.error('sync-version: <revision> not found in root pom.xml');
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
const version = match[1];
|
||||
const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf-8'));
|
||||
if (pkg.version === version) {
|
||||
console.log(`sync-version: package.json already at ${version}`);
|
||||
process.exit(0);
|
||||
}
|
||||
|
||||
pkg.version = version;
|
||||
fs.writeFileSync(pkgPath, JSON.stringify(pkg, null, 2) + '\n');
|
||||
console.log(`sync-version: package.json ${pkg.version} -> ${version}`);
|
||||
Reference in New Issue
Block a user