打包時自動遞增版號,避免同版號重包

摘要:
dist 與 dist:portable 掛上 pre 腳本自動執行 npm version patch,版本 2.0.0 → 2.0.1。

根本原因:
產物檔名帶版號(Claude Pet-<版本>-setup.exe),但版號要靠人記得改。
實際上 2.0.0 被重包了兩次而版號沒動:一次沒有 hover 跳躍、一次有,
使用者回報「滑鼠停上面沒有 jump」時,無法從檔名判斷手上是哪一份,
必須另外比對檔案時間才能確認。

影響:
同一個版號可能對應內容不同的散布檔,回報問題與確認修正都會失準。

修法:
- package.json 新增 predist 與 predist:portable,內容為
  `npm version patch --no-git-tag-version`;npm 會在對應的 dist 腳本前自動執行。
- pack 不掛(它只產 win-unpacked 供開發驗證,不是散布檔)。
- README 的「打包成 exe」補上說明:版號自動遞增、不要繞過、
  要升 minor/major 就先手動 npm version。

驗證:
執行 npm run dist,package.json 由 2.0.0 自動變成 2.0.1,
產物檔名同步為 Claude Pet-2.0.1-*;以 ELECTRON_RUN_AS_NODE 讀打包後的 app.asar
確認內含版本為 2.0.1,exe 的 FileVersion 亦為 2.0.1,
且 hover 跳躍、矩形判定、右鍵選單都還在。

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
2026-08-21 16:29:15 +08:00
co-authored by Claude Fable 5
parent 48b10c43de
commit 3f92e102cc
2 changed files with 9 additions and 1 deletions
+3 -1
View File
@@ -1,6 +1,6 @@
{
"name": "claude-pet",
"version": "2.0.0",
"version": "2.0.1",
"description": "Codex Pets 相容的 Claude Code 桌面寵物(spriteVersionNumber 29 個動作列 + 16 方向追視)",
"main": "main.js",
"private": true,
@@ -11,8 +11,10 @@
"autostart:install": "node scripts/autostart.js install",
"autostart:uninstall": "node scripts/autostart.js uninstall",
"autostart:status": "node scripts/autostart.js status",
"predist": "npm version patch --no-git-tag-version",
"dist": "electron-builder --win",
"pack": "electron-builder --win --dir",
"predist:portable": "npm version patch --no-git-tag-version",
"dist:portable": "electron-builder --win portable"
},
"devDependencies": {