refactor: 统一版本号管理,消除硬编码

项目版本(pom.xml revision)和parser版本(parserVersion)统一为单一来源,
前端构建时自动同步,发版只需改根pom.xml的两个属性。
This commit is contained in:
yukaidi
2026-05-29 10:57:49 +08:00
parent a4e8585e2c
commit 0e14c9a925
10 changed files with 54 additions and 16 deletions

View File

@@ -16,6 +16,17 @@ function getGitHubRepoUrl() {
} catch (e) {}
return 'https://github.com/qaiu/netdisk-fast-download';
}
// 从根 pom.xml 读取项目版本号(单一版本来源)
function getProjectVersion() {
try {
const pomContent = require('fs').readFileSync(path.resolve(__dirname, '../pom.xml'), 'utf-8');
const match = pomContent.match(/<revision>([^<]+)<\/revision>/);
if (match) return match[1];
} catch (e) {}
return require('./package.json').version;
}
const PROJECT_VERSION = getProjectVersion();
const GITHUB_REPO_URL = getGitHubRepoUrl();
const CompressionPlugin = require('compression-webpack-plugin');
@@ -69,7 +80,8 @@ module.exports = {
},
plugins: [
new webpack.DefinePlugin({
'process.env.VUE_APP_GITHUB_REPO_URL': JSON.stringify(GITHUB_REPO_URL)
'process.env.VUE_APP_GITHUB_REPO_URL': JSON.stringify(GITHUB_REPO_URL),
'process.env.VUE_APP_VERSION': JSON.stringify(PROJECT_VERSION)
}),
new MonacoEditorPlugin({
languages: ['javascript', 'typescript', 'json'],