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/安装/导入)
This commit is contained in:
@@ -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/<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) {
|
||||
// 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'))
|
||||
|
||||
Reference in New Issue
Block a user