Compare commits

...
Author SHA1 Message Date
wangheng 071507e53f Merge pull request 'fix(update): 更新检查改查本仓 Gitea,修复查不到新版 (v0.5.3-local.6)' (#7) from fix/v0.5.3-local.6-update-source into main
[v0.5.3-local.6] 更新检查改查本仓 Gitea
2026-12-02 17:01:11 +08:00
wangheng a25a23fcdb Merge pull request 'fix(release): verify-remote 支持自建 Gitea 并修 Windows tar 盘符' (#6) from fix/verify-remote-self-hosted into main
fix: verify-remote 支持自建 Gitea
2026-12-02 16:41:48 +08:00
wangheng 73f1ce439e fix(release): verify-remote 支持自建 Gitea 并修 Windows tar 盘符
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/安装/导入)
2026-12-02 16:41:34 +08:00
+7 -4
View File
@@ -26,7 +26,7 @@ function npmCliPath() {
return c[0] ?? 'npm' 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 一律拒绝 // 参数严格解析:--expect-sha <64位hex> [tag];缺值/非 hex/重复参数/多余 tag 一律拒绝
const args = process.argv.slice(2) const args = process.argv.slice(2)
let EXPECT_SHA = null let EXPECT_SHA = null
@@ -49,7 +49,9 @@ for (let i = 0; i < args.length; i++) {
sawTag = true sawTag = true
} }
// latest 用特殊路径 /releases/latest/download/<asset>;具体 tag 用 /releases/download/<tag>/<asset>(tag 保留 v 前缀) // latest 用特殊路径 /releases/latest/download/<asset>;具体 tag 用 /releases/download/<tag>/<asset>(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) { function httpGet(url, outFile) {
// PowerShell Invoke-WebRequest:走 WinINET 系统代理(本机网络环境需要);-L 行为由 IWR 自动跟随重定向 // 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) } if (!httpGet(fixedUrl, fixedFile)) { console.error('[verify-remote] FAIL: download fixed-name asset'); process.exit(1) }
// 2. 解包读版本,拼版本化 URL 并下载 // 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) } if (listTar.status !== 0) { console.error('[verify-remote] FAIL: tar -tzf'); process.exit(1) }
const entries = listTar.stdout.split(/\r?\n/).filter(Boolean) 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'] 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) } if (!okStruct) { console.error('[verify-remote] FAIL: structure mismatch: ' + entries.join(',')); process.exit(1) }
console.log('[verify-remote] structure ok (7 files)') console.log('[verify-remote] structure ok (7 files)')
const ext = join(work, 'ext'); mkdirSync(ext, { recursive: true }) 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) } 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 pkg = JSON.parse(readFileSync(join(ext, 'package', 'package.json'), 'utf8'))
const manifest = JSON.parse(readFileSync(join(ext, 'package', 'dsh.plugin.json'), 'utf8')) const manifest = JSON.parse(readFileSync(join(ext, 'package', 'dsh.plugin.json'), 'utf8'))