feat(pnpm-policy): denyBuilds — declare install scripts that were reviewed and are not needed - #128
Conversation
…ewed and are not needed pnpm 11 fails the install (ERR_PNPM_IGNORED_BUILDS) for any build script that is neither allowed nor denied, so a policy that can only allow leaves fresh clones stuck on the interactive pnpm approve-builds prompt. denyBuilds emits false entries into the allowBuilds map (ignoredBuiltDependencies for the legacy key), with reasons, so the decision lives in pnpm-policy.yaml. Also close the three open questions in this workspace's own pnpm-workspace.yaml so pnpm 11 installs cleanly.
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
|
Review complete. 🟡 1 medium 💬 Inline comments (1)
🧹 Nitpicks (1) — 🟢 1 low
This PR introduces the
Two findings: a trivial import style issue in Reviewed commit: 45fd581 |
There was a problem hiding this comment.
Adds a pnpm-policy package that generates and validates pnpm-workspace.yaml build-policy settings from a normalized config.
Key findings
- 🟡
ignoredBuiltDependenciessilently deleted on generate — policy.ts:230
| 'minimumReleaseAge', | ||
| 'minimumReleaseAgeExclude', | ||
| buildsKey, | ||
| ...(buildsKey === 'onlyBuiltDependencies' ? [IGNORED_BUILDS_KEY] : []), |
There was a problem hiding this comment.
🟡 bug · medium
ignoredBuiltDependencies silently deleted on generate
managedKeys() now lists ignoredBuiltDependencies whenever buildsKey is onlyBuiltDependencies (policy.ts:230), and applyPolicy() deletes every managed key absent from the resolved settings (workspace.ts:53). A workspace that keeps ignoredBuiltDependencies set by hand — via pnpm approve-builds or a manual edit — without a matching denyBuilds in the config loses that key silently on the next pnpm-policy generate, dropping install-script denials it never asked to remove.
📋 Prompt for AI Agents
In packages/pnpm-policy/src/policy.ts around line 230, managedKeys() unconditionally adds IGNORED_BUILDS_KEY when buildsKey === 'onlyBuiltDependencies', and applyPolicy() (workspace.ts:53) deletes every managed key absent from policy.settings. This silently removes a hand-maintained ignoredBuiltDependencies from an existing pnpm-workspace.yaml on the next generate when the config defines no denyBuilds. Make managedKeys() claim ignoredBuiltDependencies only when the resolved policy will emit it (e.g. pass whether denyBuilds is non-empty), so existing persisted denials are preserved during the upgrade.
Summary
pnpm 11 turns every undecided install script into a hard failure:
pnpm installexits 1 withERR_PNPM_IGNORED_BUILDS, tells the developer to run the interactivepnpm approve-builds, and appends anallowBuilds: { pkg: "set this to true or false" }stub topnpm-workspace.yaml— outside the pnpm-policy managed block, so it also failspnpm-policy check. This is what a freshpgpm init workspacecurrently hits (constructive-io/constructive-planning#1970), and this repo hits it too (@launchql/protobufjs,nx,unrs-resolver).pnpm-policycould only allow; there was no way to say "we looked, this script is not needed" other than thesettings:passthrough, which replaces the wholeallowBuildsmap. This adds a first-classdenyBuilds:→ generated (
--builds-key allowBuilds, default):→ with
--builds-key onlyBuiltDependencies(pnpm < 10.16): allowed names go toonlyBuiltDependencies, denied names to a new managed keyignoredBuiltDependencies.PolicyConfig.denyBuilds?: Array<string | DeniedBuild> | Record<string, string | false>; same normalization/sorting asallowBuilds; a name in both lists is aPolicyError.managedKeys()includesignoredBuiltDependenciesonly for the legacy key, so it is owned/removed like the others.pnpm-policy initstarter gaindenyBuilds, and the README says explicitly not to runpnpm approve-buildsin a policy-managed workspace.Also: this repo's own
pnpm-workspace.yamlnow denies its three undecided scripts sopnpm installon pnpm 11 exits 0 (CI is on pnpm 10.12, which only warned).Follow-up (needs a release of
pnpm-policy): switch the pgpm boilerplates from thesettings.allowBuildspassthrough todenyBuilds.Link to Devin session: https://app.devin.ai/sessions/1ef0d1c209f041afa29e0e4cc4b2cb29
Open in Devin Desktop: https://app.devin.ai/desktop/session/1ef0d1c209f041afa29e0e4cc4b2cb29?variant=devin
Requested by: @pyramation