mirror of
https://github.com/qaiu/netdisk-fast-download.git
synced 2026-06-11 07:57:28 +00:00
refactor: 统一版本号管理,消除硬编码
项目版本(pom.xml revision)和parser版本(parserVersion)统一为单一来源, 前端构建时自动同步,发版只需改根pom.xml的两个属性。
This commit is contained in:
@@ -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'],
|
||||
|
||||
Reference in New Issue
Block a user