From 0446d09b3b69752506610c070e1a1a89251e4aa1 Mon Sep 17 00:00:00 2001 From: mac Date: Sun, 16 Aug 2026 14:20:19 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E8=A1=A5=E5=8F=91=E7=83=AD=E6=9B=B4=201?= =?UTF-8?q?.5.84=EF=BC=881.5.83=20=E6=98=A8=E6=97=A5=E5=B7=B2=E8=A2=AB?= =?UTF-8?q?=E5=8D=A0=E7=94=A8=E5=AF=BC=E8=87=B4=E6=92=9E=E5=8F=B7=E6=9C=AA?= =?UTF-8?q?=E7=94=9F=E6=95=88=EF=BC=89=EF=BC=9Bpublish-hot=20=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E7=89=88=E6=9C=AC=E5=A4=8D=E7=94=A8=E5=AE=88=E5=8D=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 2 +- scripts/publish-hot.js | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 27d4034..4f60e63 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,7 @@ "author": "Codex Market", "license": "MIT", "main": "electron/bootstrap.js", - "hotContentVersion": "1.5.83", + "hotContentVersion": "1.5.84", "hotMinAppVersion": "1.5.0", "scripts": { "start": "electron .", diff --git a/scripts/publish-hot.js b/scripts/publish-hot.js index c0bb5c4..1855c68 100644 --- a/scripts/publish-hot.js +++ b/scripts/publish-hot.js @@ -50,6 +50,23 @@ fs.mkdirSync(OUT, { recursive: true }); const bundleName = `bundle-${version}.zip`; const bundlePath = path.join(OUT, bundleName); +// —— 0) 版本复用守卫:远端 manifest 已是该版本时拒绝发布(除非 --force)。 +// 客户端按 contentVersion 判断是否更新,同名覆盖会让已装用户永远收不到新内容。 +try { + const rel = JSON.parse(execFileSync("curl", ["-s", `-H`, `Authorization: token ${token}`, + `${API}/releases/tags/${TAG}`], { encoding: "utf8", maxBuffer: 64 * 1024 * 1024 })); + const mAsset = (rel.assets || []).find((a) => a.name === "hotupdate.json"); + if (mAsset) { + const remote = JSON.parse(execFileSync("curl", ["-s", "-H", `Authorization: token ${token}`, + mAsset.browser_download_url], { encoding: "utf8" })); + if (remote && remote.contentVersion === version && !has("--force")) { + console.error(`✖ 版本 ${version} 已发布过(远端 manifest contentVersion 相同)。`); + console.error(" 客户端会认为已是最新而忽略同名覆盖。请递增 --version 后重试,或确需覆盖时加 --force。"); + process.exit(1); + } + } +} catch (e) { /* 拉不到远端 manifest 时不阻塞发布 */ } + // —— 1) 打包(zip,deflate,可被 lib/zip.js 解压)—— fs.rmSync(bundlePath, { force: true }); console.log(`打包 electron/ + renderer/ → ${bundleName} …`);