摘要: scripts/release.js 建立 tag v<版本> 的 release 並上傳 dist 的 .exe / .zip, 附帶 --dry-run 與伺服器設定預檢。 根本原因: 產物有 345 MB 且不進版控,需要一個散布管道。Gitea 有 Releases 與附件 API, 但目前伺服器設定會擋下全部三個檔: - [attachment] max_size 為 100 MB,portable 101.7 / setup 102.0 / zip 141.3 都超過 - allowed_types 白名單只有文件與圖片類,沒有 .exe 另外 .npmrc 裡現有的 token 只有套件庫權限,呼叫 repo API 會回 403。 影響: 沒有腳本就得手動上傳三個上百 MB 的檔;直接上傳也會因上述設定而失敗。 修法: - 新增 scripts/release.js 與 npm script release: owner/repo 由 git remote 推導,網址可用 GITEA_URL 覆寫(SSH 埠與網頁埠不同時)。 release 說明取自上一個 tag 之後的 commit 標題;沒有舊 tag 就取最近 30 筆。 release 已存在則重用,同名附件先刪再傳,可重複執行。 - 上傳採用手動組裝的 multipart 並以串流送出,不把上百 MB 的檔案讀進記憶體。 - 發佈前先讀 /api/v1/settings/attachment 做預檢,超過上限或副檔名不允許時 直接列出是哪個檔案卡在哪一條並中止,不會傳到一半才失敗。 - --dry-run 只做讀取,印出將建立或重用的 release 與變更說明。 - git() 關閉 stderr:releaseNotes 會刻意 describe 一個可能不存在的舊 tag, 否則 git 的 fatal 訊息會被誤認成發佈失敗。 - README 新增「發佈到 Gitea Releases」一節,寫明所需的 app.ini 設定與 token 權限。 驗證: - 對真實伺服器執行 --dry-run:正確推導出 AI/claude-pet 與 tag v2.0.3, 並列出三個檔各自違反的限制後中止,全程只有 GET。 - 另寫一個假的 Gitea(本機 http)跑完整流程:建立 release 的 tag、名稱、 target_commitish 與說明皆正確;三個附件的 Content-Length 與實收位元組相符、 multipart 邊界與 Content-Disposition 正確、結尾正確, 且收到的檔案內容 SHA256 與磁碟上的完全一致(共 345 MB)。 未執行: 實際發佈需要伺服器調整設定與一個有 write:repository 權限的 token,兩者都在使用者手上。 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
91 lines
2.3 KiB
JSON
91 lines
2.3 KiB
JSON
{
|
||
"name": "claude-pet",
|
||
"version": "2.0.3",
|
||
"description": "Codex Pets 相容的 Claude Code 桌面寵物(spriteVersionNumber 2:9 個動作列 + 16 方向追視)",
|
||
"main": "main.js",
|
||
"private": true,
|
||
"scripts": {
|
||
"start": "electron .",
|
||
"hooks:install": "node scripts/install-hooks.js",
|
||
"hooks:uninstall": "node scripts/uninstall-hooks.js",
|
||
"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",
|
||
"release": "node scripts/release.js",
|
||
"predist:portable": "npm version patch --no-git-tag-version",
|
||
"dist:portable": "electron-builder --win portable"
|
||
},
|
||
"devDependencies": {
|
||
"electron": "^43.4.1",
|
||
"electron-builder": "^26.0.12"
|
||
},
|
||
"author": "JianMiau",
|
||
"build": {
|
||
"appId": "com.jianmiau.claude-pet",
|
||
"productName": "Claude Pet",
|
||
"copyright": "JianMiau",
|
||
"directories": {
|
||
"output": "dist",
|
||
"buildResources": "build"
|
||
},
|
||
"files": [
|
||
"main.js",
|
||
"preload.js",
|
||
"renderer/**/*",
|
||
"lib/**/*",
|
||
"hook/**/*",
|
||
"package.json"
|
||
],
|
||
"asarUnpack": [
|
||
"hook/**/*"
|
||
],
|
||
"win": {
|
||
"target": [
|
||
{
|
||
"target": "nsis",
|
||
"arch": [
|
||
"x64"
|
||
]
|
||
},
|
||
{
|
||
"target": "portable",
|
||
"arch": [
|
||
"x64"
|
||
]
|
||
},
|
||
{
|
||
"target": "zip",
|
||
"arch": [
|
||
"x64"
|
||
]
|
||
}
|
||
],
|
||
"icon": "build/icon.ico"
|
||
},
|
||
"nsis": {
|
||
"oneClick": false,
|
||
"perMachine": false,
|
||
"allowToChangeInstallationDirectory": true,
|
||
"createDesktopShortcut": true,
|
||
"createStartMenuShortcut": true,
|
||
"shortcutName": "Claude Pet",
|
||
"deleteAppDataOnUninstall": false,
|
||
"artifactName": "${productName}-${version}-setup.${ext}"
|
||
},
|
||
"portable": {
|
||
"artifactName": "${productName}-${version}-portable.${ext}",
|
||
"unpackDirName": "ClaudePet",
|
||
"requestExecutionLevel": "user"
|
||
},
|
||
"extraFiles": [
|
||
{
|
||
"from": "pets",
|
||
"to": "pets"
|
||
}
|
||
]
|
||
}
|
||
}
|