From 489dc8ac6718c5adc6114b03164e349ed10c0b60 Mon Sep 17 00:00:00 2001 From: ezequielnick <107352853+ezequielnick@users.noreply.github.com> Date: Sun, 31 Aug 2025 17:19:30 +0800 Subject: [PATCH] chore: update&fix workflow dev version --- scripts/update-version.mjs | 12 +++++------- scripts/version-utils.mjs | 6 +++--- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/scripts/update-version.mjs b/scripts/update-version.mjs index 8f758e1..9f99e0b 100644 --- a/scripts/update-version.mjs +++ b/scripts/update-version.mjs @@ -7,7 +7,7 @@ function updatePackageVersion() { const packagePath = 'package.json' const packageContent = readFileSync(packagePath, 'utf-8') const packageData = JSON.parse(packageContent) - + // 获取处理后的版本号 const newVersion = getProcessedVersion() @@ -15,20 +15,18 @@ function updatePackageVersion() { console.log(`${isDevBuild() ? 'Dev构建' : '正式构建'} - 新版本: ${newVersion}`) packageData.version = newVersion - + // 写回package.json writeFileSync(packagePath, JSON.stringify(packageData, null, 2) + '\n') - + console.log(`✅ package.json版本号已更新为: ${newVersion}`) - + } catch (error) { console.error('❌ 更新package.json版本号失败:', error.message) process.exit(1) } } -if (import.meta.url === `file://${process.argv[1]}`) { - updatePackageVersion() -} +updatePackageVersion() export { updatePackageVersion } \ No newline at end of file diff --git a/scripts/version-utils.mjs b/scripts/version-utils.mjs index 4592e54..8080a04 100644 --- a/scripts/version-utils.mjs +++ b/scripts/version-utils.mjs @@ -26,7 +26,7 @@ export function getBaseVersion() { const pkg = readFileSync('package.json', 'utf-8') const { version } = JSON.parse(pkg) // 移除dev版本格式后缀 - return version.replace('-dev', '').replace(/-\d{4}-[a-f0-9]{7}$/, '') + return version.replace(/-d\d{2,4}\.[a-f0-9]{7}$/, '') } catch (error) { console.error('Failed to read package.json:', error.message) return '1.0.0' @@ -38,8 +38,8 @@ export function getDevVersion() { const baseVersion = getBaseVersion() const monthDate = getCurrentMonthDate() const commitHash = getGitCommitHash(true) - - return `${baseVersion}-${monthDate}-${commitHash}` + + return `${baseVersion}-d${monthDate}.${commitHash}` } // 检查当前环境是否为dev构建