Files
dc/client/scripts/check-archiver.cjs
T
dc aa5c3f887a
Build / Build-and-ng-test (pull_request) Failing after 2m33s
Build / Build-and-test-development (pull_request) Skipped
Lighthouse Checks / lighthouse (pull_request) Successful in 18m19s
ci: exercise the archiver path and install the client without scripts
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.
2026-10-31 02:42:14 +00:00

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()