fix(release): [REL-02] accept Yarn directory entries in candidate archives

This commit is contained in:
Harvey Zhao committed 2026-09-16 01:52:36 +08:00
1 parent e54fc998ea
commit 1b81888347
11 files changed
+425 -19

No files matched your search

+17
View File
@@ -0,0 +1,17 @@
import assert from 'node:assert/strict'
import { execFileSync } from 'node:child_process'
export function packedFiles(archive) {
const args = { encoding: 'utf8', windowsHide: true }
const names = execFileSync('tar', ['-tzf', archive], args).trim().split(/\r?\n/)
const entries = execFileSync('tar', ['-tvzf', archive], args).trim().split(/\r?\n/)
assert.equal(names.length, entries.length, 'Archive listing mismatch')
assert.equal(new Set(names).size, names.length, 'Duplicate archive members')
return names.filter((name, index) => {
const type = entries[index][0]
assert(['d', '-'].includes(type), 'Package links and special files are unsupported')
assert((type === 'd' && name === 'package') || name.startsWith('package/'), 'Invalid package root')
assert(!name.includes('\\') && !name.split('/').includes('..'), 'Unsafe package member')
return type === '-'
}).sort()
}