The minimatch override forces a major above readdir-glob's own range, and archiver's directory() is the only runtime caller of that path. scripts/ check-archiver.cjs archives a small tree and fails if the result is too small to hold it, so the override is guarded by a run rather than by the install succeeding. client/.npmrc is gitignored - it is where a developer's registry credentials live - so the repo-wide ignore-scripts policy is passed on the client install steps instead. Verified locally: npm ci --ignore-scripts, the archiver check and ng build all succeed.
40 lines
1.5 KiB
JavaScript
40 lines
1.5 KiB
JavaScript
/* Guards the readdir-glob -> minimatch override in client/package.json.
|
|
*
|
|
* The override forces minimatch 11 where readdir-glob asks for ^10. An
|
|
* incompatible API would only show up at runtime, in the one place that walks a
|
|
* directory through readdir-glob: archiver's directory(), which exceljs uses to
|
|
* build an xlsx. This archives a small tree and checks the archive holds both
|
|
* files, so a broken override fails here rather than in a user's download.
|
|
*/
|
|
const fs = require('fs')
|
|
const os = require('os')
|
|
const path = require('path')
|
|
const { ZipArchive } = require('archiver')
|
|
|
|
const dir = fs.mkdtempSync(path.join(os.tmpdir(), 'dc-arch-'))
|
|
fs.writeFileSync(path.join(dir, 'a.txt'), 'hello')
|
|
fs.mkdirSync(path.join(dir, 'sub'))
|
|
fs.writeFileSync(path.join(dir, 'sub', 'b.txt'), 'world')
|
|
|
|
const out = path.join(os.tmpdir(), 'dc-arch-test.zip')
|
|
const sink = fs.createWriteStream(out)
|
|
const archive = new ZipArchive({ zlib: { level: 9 } })
|
|
|
|
archive.on('error', (err) => {
|
|
console.error('archiver error: ' + err.message)
|
|
process.exit(1)
|
|
})
|
|
sink.on('close', () => {
|
|
const bytes = fs.statSync(out).size
|
|
/* two tiny files plus central directory; an empty or truncated archive is far
|
|
smaller, which is what a broken glob matcher would produce */
|
|
if (bytes < 200) {
|
|
console.error('archive is too small: ' + bytes + ' bytes')
|
|
process.exit(1)
|
|
}
|
|
console.log('archiver directory walk ok: ' + bytes + ' bytes')
|
|
})
|
|
archive.pipe(sink)
|
|
archive.directory(dir, false)
|
|
archive.finalize()
|