mirror of
https://gh.catmak.name/https://github.com/mihomo-party-org/mihomo-party
synced 2025-12-27 05:00:30 +08:00
Revert "feat: add commit hash in dev version"
This reverts commit c01c985c91f8446065e9eb89f600b133db60151b.
This commit is contained in:
parent
d86106ac00
commit
80c611aec8
@ -19,12 +19,6 @@
|
|||||||
"artifact": "node scripts/artifact.mjs",
|
"artifact": "node scripts/artifact.mjs",
|
||||||
"dev": "electron-vite dev",
|
"dev": "electron-vite dev",
|
||||||
"postinstall": "electron-builder install-app-deps",
|
"postinstall": "electron-builder install-app-deps",
|
||||||
"prebuild:win": "node scripts/version.js",
|
|
||||||
"prebuild:mac": "node scripts/version.js",
|
|
||||||
"prebuild:linux": "node scripts/version.js",
|
|
||||||
"postbuild:win": "node scripts/restore-version.js",
|
|
||||||
"postbuild:mac": "node scripts/restore-version.js",
|
|
||||||
"postbuild:linux": "node scripts/restore-version.js",
|
|
||||||
"build:win": "electron-vite build && electron-builder --publish never --win",
|
"build:win": "electron-vite build && electron-builder --publish never --win",
|
||||||
"build:mac": "electron-vite build && electron-builder --publish never --mac",
|
"build:mac": "electron-vite build && electron-builder --publish never --mac",
|
||||||
"build:linux": "electron-vite build && electron-builder --publish never --linux"
|
"build:linux": "electron-vite build && electron-builder --publish never --linux"
|
||||||
|
|||||||
@ -1,32 +0,0 @@
|
|||||||
const fs = require('fs')
|
|
||||||
const path = require('path')
|
|
||||||
|
|
||||||
function restoreVersion() {
|
|
||||||
const backupPath = path.join(__dirname, '..', 'package.json.bak')
|
|
||||||
const packagePath = path.join(__dirname, '..', 'package.json')
|
|
||||||
|
|
||||||
if (fs.existsSync(backupPath)) {
|
|
||||||
try {
|
|
||||||
const backup = JSON.parse(fs.readFileSync(backupPath, 'utf8'))
|
|
||||||
const packageJson = JSON.parse(fs.readFileSync(packagePath, 'utf8'))
|
|
||||||
|
|
||||||
// 恢复版本号
|
|
||||||
packageJson.version = backup.version
|
|
||||||
fs.writeFileSync(packagePath, JSON.stringify(packageJson, null, 2))
|
|
||||||
|
|
||||||
// 删除备份文件
|
|
||||||
fs.unlinkSync(backupPath)
|
|
||||||
|
|
||||||
console.log(`版本号已恢复: ${backup.version}`)
|
|
||||||
} catch (error) {
|
|
||||||
console.error('恢复版本号时出错:', error)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 如果是直接运行此脚本,则执行版本恢复
|
|
||||||
if (require.main === module) {
|
|
||||||
restoreVersion()
|
|
||||||
}
|
|
||||||
|
|
||||||
module.exports = { restoreVersion }
|
|
||||||
@ -1,47 +0,0 @@
|
|||||||
const { execSync } = require('child_process')
|
|
||||||
const fs = require('fs')
|
|
||||||
const path = require('path')
|
|
||||||
|
|
||||||
function getGitCommitHash() {
|
|
||||||
try {
|
|
||||||
return execSync('git rev-parse --short=7 HEAD').toString().trim()
|
|
||||||
} catch (error) {
|
|
||||||
console.warn('无法获取 Git commit hash,使用默认值')
|
|
||||||
return 'unknown'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function processVersion() {
|
|
||||||
const packagePath = path.join(__dirname, '..', 'package.json')
|
|
||||||
const packageJson = JSON.parse(fs.readFileSync(packagePath, 'utf8'))
|
|
||||||
|
|
||||||
// 备份原始版本号
|
|
||||||
const originalVersion = packageJson.version
|
|
||||||
fs.writeFileSync(
|
|
||||||
path.join(__dirname, '..', 'package.json.bak'),
|
|
||||||
JSON.stringify({ version: originalVersion }, null, 2)
|
|
||||||
)
|
|
||||||
|
|
||||||
// 检查版本号是否以 -dev 结尾
|
|
||||||
if (originalVersion.endsWith('-dev')) {
|
|
||||||
const commitHash = getGitCommitHash()
|
|
||||||
const newVersion = originalVersion.replace('-dev', `-${commitHash}-dev`)
|
|
||||||
|
|
||||||
// 更新 package.json
|
|
||||||
packageJson.version = newVersion
|
|
||||||
fs.writeFileSync(packagePath, JSON.stringify(packageJson, null, 2))
|
|
||||||
|
|
||||||
console.log(`版本号已更新: ${originalVersion} -> ${newVersion}`)
|
|
||||||
return newVersion
|
|
||||||
}
|
|
||||||
|
|
||||||
console.log(`版本号未修改: ${originalVersion}`)
|
|
||||||
return originalVersion
|
|
||||||
}
|
|
||||||
|
|
||||||
// 如果是直接运行此脚本,则执行版本处理
|
|
||||||
if (require.main === module) {
|
|
||||||
processVersion()
|
|
||||||
}
|
|
||||||
|
|
||||||
module.exports = { processVersion, getGitCommitHash }
|
|
||||||
Loading…
x
Reference in New Issue
Block a user