Skip to content

Commit a07ed24

Browse files
committed
docs: record the install-script approval step
.npmrc sets strict-allow-scripts=true and the allowScripts map of package.json pins approved name@version entries, so a dependency version bump that leaves its pinned entry behind makes npm ci fail with ESTRICTALLOWSCRIPTS before any check runs. Renovate hits this on every lefthook, esbuild or fsevents bump and cannot fix it, because it only rewrites the dependency fields and the lockfile. Document the gate and `npm approve-scripts <package>` where a contributor meets it: CONTRIBUTING.md (initial setup and the Lefthook section), .github/copilot-instructions.md (bootstrap), and a comment beside the flag in .npmrc.
1 parent 48b839f commit a07ed24

3 files changed

Lines changed: 22 additions & 0 deletions

File tree

‎.github/copilot-instructions.md‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ Always reference these instructions first and fallback to search or bash command
2525
`npm ci`; NEVER CANCEL and set timeout to 30+ seconds.
2626
- Use when package-lock.json already exists
2727
- Faster than `npm install` for CI/existing setups
28+
- **Install-script policy**: `.npmrc` sets `strict-allow-scripts=true` and the `allowScripts`
29+
map of `package.json` pins approved `name@version` entries. When a dependency version
30+
changes, `npm ci` fails with `ESTRICTALLOWSCRIPTS` until the reviewed version is approved:
31+
`npm approve-scripts <package>`. Never bypass with `--dangerously-allow-all-scripts`.
2832

2933
### Building
3034

‎.npmrc‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
min-release-age=3
22
registry=https://registry.npmjs.org/
3+
# Install scripts run only for the entries of package.json#allowScripts, and those
4+
# entries pin an exact name@version. After bumping such a dependency, review the new
5+
# version on the branch and run: npm approve-scripts <package>
36
strict-allow-scripts=true

‎CONTRIBUTING.md‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,16 @@ accept pull requests.
9595
npm ci
9696
```
9797

98+
`.npmrc` sets `strict-allow-scripts=true`, so `npm ci` runs install scripts only for
99+
entries of the `allowScripts` map in `package.json`, and each entry pins an exact
100+
`name@version`. After a dependency version change, the stale entry makes `npm ci` fail
101+
with `ESTRICTALLOWSCRIPTS` before any other check runs; that gate is separate from the
102+
release-age gate above. Review the new version, then rewrite the entry:
103+
104+
```bash
105+
npm approve-scripts <package>
106+
```
107+
98108
4. **Set up environment variables** (optional, for testing)
99109

100110
```bash
@@ -230,6 +240,11 @@ afterward.
230240
This project uses [lefthook](https://github.com/evilmartians/lefthook) to enforce
231241
code quality automatically via git hooks. Hooks are installed automatically when you run `npm ci` or `npm install` (via the `prepare` lifecycle script).
232242

243+
Lefthook ships an install script, so its pinned `allowScripts` entry has to follow every
244+
lefthook bump, including the ones a dependency PR opens. Otherwise `npm ci` fails with
245+
`ESTRICTALLOWSCRIPTS`. Run `npm approve-scripts lefthook` on the branch to rewrite the
246+
entry to the installed version.
247+
233248
**Pre-commit hook** (runs on every `git commit`):
234249

235250
- **Prettier** — auto-formats staged files (`--write`)

0 commit comments

Comments
 (0)