From 73f1ce439e910071c0247bc28f03a1f95ea5a22c Mon Sep 17 00:00:00 2001 From: wangheng Date: Wed, 2 Dec 2026 16:41:34 +0800 Subject: [PATCH] =?UTF-8?q?fix(release):=20verify-remote=20=E6=94=AF?= =?UTF-8?q?=E6=8C=81=E8=87=AA=E5=BB=BA=20Gitea=20=E5=B9=B6=E4=BF=AE=20Wind?= =?UTF-8?q?ows=20tar=20=E7=9B=98=E7=AC=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit verify-remote.mjs 原本硬编码上游 Aisland-SJL/dsh-worktable 与 github.com, 在本仓(xiaoqu/dsh-worktable)发布时无法核对远端。 - 新增 SLARK_WT_HOST / SLARK_WT_REPO 环境变量覆盖,默认保持上游行为 - tar 调用加 --force-local:Windows 上 GNU tar 会把 "C:\..." 的盘符 当成 rsh 远端主机,报 Cannot connect to C: resolve failed 验证:SLARK_WT_HOST=https://gitea.ququclean.com SLARK_WT_REPO=xiaoqu/dsh-worktable npm run verify:remote -- --expect-sha cf633ad7… v0.5.3-local.5 → PASS (文件名/结构/版本/SHA 同源 + 远端=验收 SHA/安装/导入) --- 01_content/verify-remote.mjs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/01_content/verify-remote.mjs b/01_content/verify-remote.mjs index 67b8d38..002d6e8 100644 --- a/01_content/verify-remote.mjs +++ b/01_content/verify-remote.mjs @@ -26,7 +26,7 @@ function npmCliPath() { return c[0] ?? 'npm' } -const REPO = 'Aisland-SJL/dsh-worktable' +const REPO = process.env.SLARK_WT_REPO || 'Aisland-SJL/dsh-worktable' // 参数严格解析:--expect-sha <64位hex> [tag];缺值/非 hex/重复参数/多余 tag 一律拒绝 const args = process.argv.slice(2) let EXPECT_SHA = null @@ -49,7 +49,9 @@ for (let i = 0; i < args.length; i++) { sawTag = true } // latest 用特殊路径 /releases/latest/download/;具体 tag 用 /releases/download//(tag 保留 v 前缀) -const assetBase = TAG === '' ? 'https://github.com/' + REPO + '/releases/latest/download/' : 'https://github.com/' + REPO + '/releases/download/' + TAG + '/' +// SLARK_WT_HOST 可指向自建 Gitea(默认 GitHub 上游) +const HOST = process.env.SLARK_WT_HOST || 'https://github.com' +const assetBase = TAG === '' ? HOST + '/' + REPO + '/releases/latest/download/' : HOST + '/' + REPO + '/releases/download/' + TAG + '/' function httpGet(url, outFile) { // PowerShell Invoke-WebRequest:走 WinINET 系统代理(本机网络环境需要);-L 行为由 IWR 自动跟随重定向 @@ -69,7 +71,8 @@ console.log('[verify-remote] GET ' + fixedUrl) if (!httpGet(fixedUrl, fixedFile)) { console.error('[verify-remote] FAIL: download fixed-name asset'); process.exit(1) } // 2. 解包读版本,拼版本化 URL 并下载 -const listTar = spawnSync('tar', ['-tzf', fixedFile], { encoding: 'utf8' }) +// Windows: GNU tar 会把 "C:\..." 的盘符当成 rsh 主机,必须 --force-local +const listTar = spawnSync('tar', ['--force-local', '-tzf', fixedFile], { encoding: 'utf8' }) if (listTar.status !== 0) { console.error('[verify-remote] FAIL: tar -tzf'); process.exit(1) } const entries = listTar.stdout.split(/\r?\n/).filter(Boolean) const EXPECTED = ['package/LICENSE','package/README.md','package/cordis.patch.yml','package/dsh.plugin.json','package/lib/client.js','package/lib/index.js','package/package.json'] @@ -77,7 +80,7 @@ const okStruct = entries.length === EXPECTED.length && EXPECTED.every((e) => ent if (!okStruct) { console.error('[verify-remote] FAIL: structure mismatch: ' + entries.join(',')); process.exit(1) } console.log('[verify-remote] structure ok (7 files)') const ext = join(work, 'ext'); mkdirSync(ext, { recursive: true }) -const x = spawnSync('tar', ['-xzf', fixedFile, '-C', ext]) +const x = spawnSync('tar', ['--force-local', '-xzf', fixedFile, '-C', ext]) if (x.status !== 0) { console.error('[verify-remote] FAIL: tar extract'); process.exit(1) } const pkg = JSON.parse(readFileSync(join(ext, 'package', 'package.json'), 'utf8')) const manifest = JSON.parse(readFileSync(join(ext, 'package', 'dsh.plugin.json'), 'utf8'))