From 075bdcdd549431ac84b4f2473b0718b4beb0413f Mon Sep 17 00:00:00 2001 From: lanyuanxiaoyao Date: Tue, 9 Jun 2026 18:32:47 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E6=B5=8B=E8=AF=95=E9=80=9A=E8=BF=87?= =?UTF-8?q?=E5=90=8E=E5=86=8D=E5=86=99=E5=9B=9E=E7=89=88=E6=9C=AC=E5=8F=B7?= =?UTF-8?q?=EF=BC=8C=E9=81=BF=E5=85=8D=E6=B5=8B=E8=AF=95=E5=A4=B1=E8=B4=A5?= =?UTF-8?q?=E6=97=B6=E6=B1=A1=E6=9F=93=20package.json?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/release.ts | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/scripts/release.ts b/scripts/release.ts index 38b5a80..2625546 100644 --- a/scripts/release.ts +++ b/scripts/release.ts @@ -80,9 +80,6 @@ async function stepBumpVersion(): Promise { process.exit(0); } - pkg.version = newVersion; - writeFileSync(pkgPath, JSON.stringify(pkg, null, 2) + "\n"); - console.log(`版本号已更新: ${currentVersion} → ${newVersion}`); return newVersion; } @@ -180,18 +177,28 @@ async function stepNpmPublish(): Promise { console.log("npm 发布成功"); } +function writeVersion(version: string): void { + const pkgPath = join(import.meta.dir, "..", "package.json"); + const pkg = JSON.parse(readFileSync(pkgPath, "utf-8")) as { version: string }; + pkg.version = version; + writeFileSync(pkgPath, JSON.stringify(pkg, null, 2) + "\n"); +} + async function main(): Promise { const newVersion = await stepBumpVersion(); - console.log(`[1/4] 版本号递增完成: ${newVersion}`); + console.log(`目标版本: ${newVersion}`); await runTests(); - console.log("[2/4] 测试通过"); + console.log("[1/3] 测试通过"); + + writeVersion(newVersion); + console.log(`[2/3] 版本号已更新: ${newVersion}`); await stepGitCommitTag(newVersion); - console.log(`[3/4] git commit 和 tag v${newVersion} 完成`); + console.log(`[3/3] git commit 和 tag v${newVersion} 完成`); await stepNpmPublish(); - console.log("[4/4] npm 发布完成"); + console.log("npm 发布完成"); } if (import.meta.main) {