Repository navigation
ci: reject new install-time lifecycle scripts by default - #495
larryjay007 wants to merge 1 commit into
Conversation
|
@larryjay007 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
|
The dependency-free scanner and its tests are sound, but the PR now conflicts with |
…sue#492) No workspace package defines an install-time lifecycle script today. Adding preinstall, install, postinstall or prepare later would create a new automatic execution path on every contributor machine and CI runner. scripts/check-lifecycle-scripts.mjs reads the root package.json and every package matched by pnpm-workspace.yaml and fails on preinstall, install, postinstall, prepare, prepublish or prepublishOnly unless the manifest path and script are listed in scripts/lifecycle-scripts-allowlist.json. The allowlist starts empty and each entry needs a reason. The checker parses JSON only. It never runs a script and never prints a command body: a finding names the manifest path and the script name. It also fails on a manifest that is not valid JSON, on a workspace glob it cannot expand, and on an allowlist entry that matches nothing, so none of those can turn into a silent pass. The check runs in the two workflows that install dependencies, before pnpm install. docs/CI.md describes it and how maintainers review an exception.
2940753 to
833381b
Compare
|
Rebased onto current
Note: the red jobs on this PR ( |
What this does
Adds a dependency-free CI check that rejects install-time lifecycle scripts in workspace manifests, and runs it before
pnpm install.scripts/check-lifecycle-scripts.mjsscans the rootpackage.jsonand every package matched bypnpm-workspace.yaml. It fails onpreinstall,install,postinstall,prepare,prepublishandprepublishOnly.scripts/lifecycle-scripts-allowlist.jsonis empty. An entry is scoped to one manifest path and one script, and needs areason.**, negation), and when an allowlist entry matches nothing (so a stale exception cannot linger).pnpm installinbindings-check.ymlandcoverage.yml, the two workflows that install dependencies.contract.ymlanddocs-links.ymldo not runpnpm install.docs/CI.mddocuments the check and how maintainers review an exception. Root scripts:pnpm lifecycle-scripts:checkandpnpm lifecycle-scripts:test.Verification
node --test scripts/check-lifecycle-scripts.test.mjs: 19 tests pass. They cover each of the six script names, the root manifest, every workspace glob, near-miss names (install:docs), allowlist match/stale/malformed entries, invalid JSON, an unsupported glob, a missingexamples/directory, and that the command body never reaches the output.preparefrom the forbidden list fails a test, and leaking a command body into the output fails 10. The file was restored byte for byte afterwards.scripts/check-logging.mjsstill passes (the checker uses the repo logger, noconsole).Not verified: the two workflow edits have not run on a GitHub runner yet; they only call
nodeon files already in the checkout, so they need no install.Closes #492