Skip to content

feat(pm): add vp pm approve-builds subcommand#1662

Draft
fengmk2 wants to merge 1 commit into
mainfrom
feat/pm-approve-builds
Draft

feat(pm): add vp pm approve-builds subcommand#1662
fengmk2 wants to merge 1 commit into
mainfrom
feat/pm-approve-builds

Conversation

@fengmk2
Copy link
Copy Markdown
Member

@fengmk2 fengmk2 commented May 22, 2026

Summary

Adds vp pm approve-builds — a unified subcommand for approving dependency lifecycle scripts (install/postinstall). Mirrors pnpm approve-builds one-to-one, adapts to bun pm trust, and falls back to informative warn-and-noop on npm/yarn.

Surface (intentionally tight, matches pnpm's documented flags):

vp pm approve-builds                       # interactive (pnpm)
vp pm approve-builds esbuild fsevents      # approve named packages
vp pm approve-builds esbuild !core-js      # pnpm >= 11.0.0 (deny syntax)
vp pm approve-builds --all                 # pnpm >= 10.32.0 / bun
vp pm approve-builds -- <raw args>         # forward to underlying PM

Cross-PM behavior

PM Behavior
pnpm Pass-through. --all gated on >= 10.32.0, !pkg deny syntax gated on >= 11.0.0 (per pnpm PR #11030). Prereleases (10.32.0-rc.0, 11.0.0-beta.1) satisfy via Version::parse("<floor>-0") comparison.
bun bun pm trust [--all] [pkgs...]. !pkg tokens emit a warn and are filtered (bun has no denylist model). When only deny tokens are given, the warn alone is enough — no redundant note.
npm Warn + exit 0, pointing at ignore-scripts=true in .npmrc.
yarn Warn + exit 0. Yarn 1 (Classic) gets an npm-style hint (lifecycle scripts run by default); Yarn Berry gets dependenciesMeta.<pkg>.built: true advice. Per yarn docs, enableScripts defaults to false in Berry.

Safety

  • --all and positional packages are mutually exclusive at the clap layer (conflicts_with = "packages"). This prevents a silent override where --all !core-js on bun would warn "Skipping: core-js" then bun pm trust --all everything anyway.
  • Version-gate failures render via Error::UserMessage (no harsh error: prefix).
  • ApproveBuilds is not in the needs_project allowlist, so the npm/yarn/bun educational messages can fire outside a project directory.

Files

  • Code: crates/vite_install/src/commands/approve_builds.rs (new), crates/vite_install/src/commands/mod.rs (export), crates/vite_pm_cli/src/cli.rs (variant + parse tests), crates/vite_pm_cli/src/handlers.rs (dispatch + error mapping)
  • RFC: rfcs/approve-builds-command.md
  • Snap tests:
    • Local: command-pm-approve-builds-{pnpm10,npm,yarn}/
    • Global: command-pm-approve-builds-{bun,pnpm10-old}/ (new)
    • Updated: snap-tests-global/cli-helper-message/snap.txt (for the new subcommand entry)

Test plan

  • cargo test -p vite_install --lib approve_builds → 23/23
  • cargo test -p vite_pm_cli --lib approve_builds → 8/8
  • vp check --fix → 0 warnings/errors
  • pnpm -F vite-plus snap-test-local approve-builds → 3/3 pass
  • pnpm -F vite-plus snap-test-global approve-builds → 2/2 pass
  • CI matrix verification

Adds a unified `vp pm approve-builds` command that mirrors
`pnpm approve-builds` and adapts to `bun pm trust`, with informative
warn-and-noop fallbacks for npm and yarn.

Surface (intentionally tight, matches pnpm's documented flags):
  vp pm approve-builds                # interactive (pnpm)
  vp pm approve-builds esbuild        # approve named packages
  vp pm approve-builds esbuild !core-js   # pnpm >= 11.0.0 (deny syntax)
  vp pm approve-builds --all          # pnpm >= 10.32.0 / bun
  vp pm approve-builds -- <raw args>  # forward to underlying PM

Cross-PM behavior:
- pnpm: pass-through. Version-gates `--all` on >= 10.32.0 and `!pkg`
  deny syntax on >= 11.0.0 (per pnpm PR #11030); prerelease versions
  compared against the lowest prerelease floor (`10.32.0-0` / `11.0.0-0`)
  so RCs are accepted.
- bun: `bun pm trust [--all] [pkgs...]`. `!pkg` tokens emit a warn and
  are filtered (bun has no denylist model). When only deny tokens are
  given, the warn alone is enough context — no redundant note.
- npm: warn and exit 0, pointing at `ignore-scripts=true` in `.npmrc`.
- yarn: warn and exit 0. Yarn 1 (Classic) gets an npm-style hint
  (lifecycle scripts run by default); yarn Berry gets
  `dependenciesMeta.<pkg>.built: true` advice.

Safety:
- `--all` and positional packages are mutually exclusive at the clap
  layer, preventing a silent override where `--all` would otherwise
  drop denylisted packages on bun.
- Version-gate failures render via `Error::UserMessage` (no harsh
  `error:` prefix).

Coverage:
- 23 Rust unit tests (resolver, version gates, prereleases, deny gate,
  yarn 1 vs Berry, pass-through args, strict unparseable-version)
- 8 clap parse tests (conflicts, lone-flag, lone-packages, pass-through
  capture, deny conflict)
- 5 snap fixtures: local pnpm10/npm/yarn + global bun/pnpm10-old
- RFC at `rfcs/approve-builds-command.md`
@fengmk2 fengmk2 self-assigned this May 22, 2026
@netlify
Copy link
Copy Markdown

netlify Bot commented May 22, 2026

Deploy Preview for viteplus-preview canceled.

Name Link
🔨 Latest commit 06be8c5
🔍 Latest deploy log https://app.netlify.com/projects/viteplus-preview/deploys/6a101f995482de00081a723d

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant