mirror of
https://github.com/qaiu/netdisk-fast-download.git
synced 2026-06-10 23:47:29 +00:00
refactor: GitHub URL 改为构建时自动从 git remote origin 识别
前端:vue.config.js 通过 DefinePlugin 注入 VUE_APP_GITHUB_REPO_URL, Home.vue/Playground.vue 中硬编码的 GitHub URL 全部改为动态变量。 后端:parser/pom.xml 添加 gmavenplus-plugin 在 initialize 阶段从 git remote origin 解析 github.owner/github.repo,SCM 字段引用 property。
This commit is contained in:
@@ -1,10 +1,23 @@
|
||||
|
||||
const path = require("path");
|
||||
const { execSync } = require("child_process");
|
||||
const webpack = require("webpack");
|
||||
|
||||
function resolve(dir) {
|
||||
return path.join(__dirname, dir)
|
||||
}
|
||||
|
||||
// 从 git remote origin 自动识别 GitHub 仓库地址
|
||||
function getGitHubRepoUrl() {
|
||||
try {
|
||||
const remoteUrl = execSync('git remote get-url origin', { encoding: 'utf-8', cwd: path.resolve(__dirname, '..') }).trim();
|
||||
const match = remoteUrl.match(/github\.com[:/]([^/]+\/[^/.]+?)(?:\.git)?$/);
|
||||
if (match) return `https://github.com/${match[1]}`;
|
||||
} catch (e) {}
|
||||
return 'https://github.com/qaiu/netdisk-fast-download';
|
||||
}
|
||||
const GITHUB_REPO_URL = getGitHubRepoUrl();
|
||||
|
||||
const CompressionPlugin = require('compression-webpack-plugin');
|
||||
const FileManagerPlugin = require('filemanager-webpack-plugin');
|
||||
const MonacoEditorPlugin = require('monaco-editor-webpack-plugin');
|
||||
@@ -55,6 +68,9 @@ module.exports = {
|
||||
]
|
||||
},
|
||||
plugins: [
|
||||
new webpack.DefinePlugin({
|
||||
'process.env.VUE_APP_GITHUB_REPO_URL': JSON.stringify(GITHUB_REPO_URL)
|
||||
}),
|
||||
new MonacoEditorPlugin({
|
||||
languages: ['javascript', 'typescript', 'json'],
|
||||
features: ['coreCommands', 'find', 'format', 'suggest', 'quickCommand'],
|
||||
|
||||
Reference in New Issue
Block a user