Commit bdae5d4
authored
feat(pm): add
## 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):
```bash
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
- [x] `cargo test -p vite_install --lib approve_builds` → 23/23
- [x] `cargo test -p vite_pm_cli --lib approve_builds` → 8/8
- [x] `vp check --fix` → 0 warnings/errors
- [x] `pnpm -F vite-plus snap-test-local approve-builds` → 3/3 pass
- [x] `pnpm -F vite-plus snap-test-global approve-builds` → 2/2 pass
- [ ] CI matrix verification
<!-- CURSOR_SUMMARY -->
---
> [!NOTE]
> **Low Risk**
> New PM subcommand with pass-through to native tools; npm/yarn are
no-ops and pnpm gates limit misuse. Touches CLI error rendering only for
this path.
>
> **Overview**
> Introduces **`vp pm approve-builds`** so one CLI can approve
dependency install/postinstall scripts: **pnpm** gets `pnpm
approve-builds` (including `!pkg` on ≥11 and `--all` on ≥10.32.0),
**bun** gets `bun pm trust` with `!pkg` filtered and warned, and
**npm/yarn** print guidance and exit 0 without shelling out.
>
> The resolver uses **`node-semver`** for pnpm capability checks,
rejects **`--all` plus positional packages** (including via `--`), and
maps version-gate failures to **`UserMessage`** so local and global CLIs
show friendly errors. **`ApproveBuilds`** is wired through
**`vite_pm_cli`** (clap variant, handler, project-scoped PM build) and
the local CLI binding handles **`UserMessage`** like the global CLI.
>
> Adds an RFC, per-PM **snap tests**, updates **`vp pm -h`**, normalizes
bun banner hashes in snapshots, and drops the `error:` prefix on missing
**`package.json`** messages in one snap fixture.
>
> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit
7d975a4. Configure
[here](https://www.cursor.com/dashboard/bugbot).</sup>
<!-- /CURSOR_SUMMARY -->vp pm approve-builds subcommand (#1662)1 parent 8a76839 commit bdae5d4
39 files changed
Lines changed: 1848 additions & 44 deletions
File tree
- crates
- vite_install
- src/commands
- vite_pm_cli/src
- packages
- cli
- binding/src/cli
- snap-tests-global
- cli-helper-message
- command-add-bun
- command-list-bun
- command-outdated-bun
- command-pm-approve-builds-bun
- command-pm-approve-builds-pnpm10-old
- command-pm-approve-builds-pnpm11
- command-pm-approve-builds-yarn4
- command-remove-bun
- command-update-bun
- command-why-bun
- snap-tests
- command-pm-approve-builds-npm
- command-pm-approve-builds-pnpm10
- command-pm-approve-builds-yarn
- command-pm-no-package-json
- tools/src
- __tests__
- rfcs
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
| 17 | + | |
17 | 18 | | |
18 | 19 | | |
19 | 20 | | |
| |||
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
| 2 | + | |
2 | 3 | | |
3 | 4 | | |
4 | 5 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
554 | 554 | | |
555 | 555 | | |
556 | 556 | | |
| 557 | + | |
| 558 | + | |
| 559 | + | |
| 560 | + | |
| 561 | + | |
| 562 | + | |
| 563 | + | |
| 564 | + | |
| 565 | + | |
| 566 | + | |
| 567 | + | |
| 568 | + | |
| 569 | + | |
| 570 | + | |
| 571 | + | |
| 572 | + | |
| 573 | + | |
557 | 574 | | |
558 | 575 | | |
559 | 576 | | |
| |||
1182 | 1199 | | |
1183 | 1200 | | |
1184 | 1201 | | |
| 1202 | + | |
| 1203 | + | |
| 1204 | + | |
| 1205 | + | |
| 1206 | + | |
| 1207 | + | |
| 1208 | + | |
| 1209 | + | |
| 1210 | + | |
| 1211 | + | |
| 1212 | + | |
| 1213 | + | |
| 1214 | + | |
| 1215 | + | |
| 1216 | + | |
| 1217 | + | |
| 1218 | + | |
| 1219 | + | |
| 1220 | + | |
| 1221 | + | |
| 1222 | + | |
| 1223 | + | |
| 1224 | + | |
| 1225 | + | |
| 1226 | + | |
| 1227 | + | |
| 1228 | + | |
| 1229 | + | |
| 1230 | + | |
| 1231 | + | |
| 1232 | + | |
| 1233 | + | |
| 1234 | + | |
| 1235 | + | |
| 1236 | + | |
| 1237 | + | |
| 1238 | + | |
| 1239 | + | |
| 1240 | + | |
| 1241 | + | |
| 1242 | + | |
| 1243 | + | |
| 1244 | + | |
| 1245 | + | |
| 1246 | + | |
| 1247 | + | |
| 1248 | + | |
| 1249 | + | |
| 1250 | + | |
| 1251 | + | |
| 1252 | + | |
| 1253 | + | |
1185 | 1254 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| 11 | + | |
11 | 12 | | |
12 | 13 | | |
13 | 14 | | |
| |||
178 | 179 | | |
179 | 180 | | |
180 | 181 | | |
181 | | - | |
| 182 | + | |
| 183 | + | |
182 | 184 | | |
183 | 185 | | |
184 | 186 | | |
| |||
194 | 196 | | |
195 | 197 | | |
196 | 198 | | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
197 | 214 | | |
198 | 215 | | |
199 | 216 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
208 | 208 | | |
209 | 209 | | |
210 | 210 | | |
211 | | - | |
212 | | - | |
213 | | - | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
214 | 222 | | |
215 | 223 | | |
216 | 224 | | |
| |||
Lines changed: 20 additions & 19 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
313 | 313 | | |
314 | 314 | | |
315 | 315 | | |
316 | | - | |
317 | | - | |
318 | | - | |
319 | | - | |
320 | | - | |
321 | | - | |
322 | | - | |
323 | | - | |
324 | | - | |
325 | | - | |
326 | | - | |
327 | | - | |
328 | | - | |
329 | | - | |
330 | | - | |
331 | | - | |
332 | | - | |
333 | | - | |
334 | | - | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
335 | 336 | | |
336 | 337 | | |
337 | 338 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
36 | 36 | | |
37 | 37 | | |
38 | 38 | | |
39 | | - | |
| 39 | + | |
40 | 40 | | |
41 | 41 | | |
42 | 42 | | |
| |||
51 | 51 | | |
52 | 52 | | |
53 | 53 | | |
54 | | - | |
| 54 | + | |
55 | 55 | | |
56 | 56 | | |
57 | 57 | | |
| |||
70 | 70 | | |
71 | 71 | | |
72 | 72 | | |
73 | | - | |
| 73 | + | |
74 | 74 | | |
75 | 75 | | |
76 | 76 | | |
| |||
91 | 91 | | |
92 | 92 | | |
93 | 93 | | |
94 | | - | |
| 94 | + | |
95 | 95 | | |
96 | 96 | | |
97 | 97 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | | - | |
| 2 | + | |
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
| |||
0 commit comments