feat(pnpmfile): wire hooks into update; add preResolution hook#423
Conversation
Greptile SummaryThis PR closes three pnpmfile gaps: Confidence Score: 5/5Safe to merge; all findings are P2 quality/efficiency suggestions with no runtime impact. No P0 or P1 findings. The three comments are P2: redundant load_npm_config call, missing has_hook guard on afterAllResolved, and unwrap_or_default() on workspace config in update. The core hook-wiring logic, chained install propagation, and bats test coverage are all correct. crates/aube/src/commands/update.rs — workspace config loaded fresh with unwrap_or_default() rather than reusing pre-loaded config Important Files Changed
Reviews (7): Last reviewed commit: "feat(pnpmfile): wire hooks into update; ..." | Re-trigger Greptile |
Benchmark changesVersions:
Public ratios: warm installs vs Bun 4x -> 10x; warm installs vs pnpm 5x -> 12x.
1ad36a5 vs 164efb0 | aube/bun/pnpm | 3 scenarios | 3 runs | 500mbit/50ms | generated by Codex. |
f2560f8 to
a4e390e
Compare
ef236ae to
c0c06ed
Compare
| crate::pnpmfile::run_after_all_resolved(p, &mut graph) | ||
| .await | ||
| .wrap_err("pnpmfile afterAllResolved hook failed")?; | ||
| } |
There was a problem hiding this comment.
Update's chained install doesn't propagate ignore_pnpmfile flag
Low Severity
When aube update --ignore-pnpmfile is used, the update step correctly skips pnpmfile hooks during resolution. However, the subsequent install::run call uses InstallOptions::with_mode(...), which hardcodes ignore_pnpmfile: false. If the chained install's frozen-prefer mode encounters drift and falls through to re-resolve, pnpmfile hooks would fire despite the user's explicit --ignore-pnpmfile flag, contradicting the intended behavior.
Additional Locations (1)
Reviewed by Cursor Bugbot for commit c0c06ed. Configure here.
There was a problem hiding this comment.
Good catch — propagated args.ignore_pnpmfile through to the chained install::run call in 6eefd32. Frozen-prefer should normally short-circuit so this isn't observable today, but the flag now flows correctly if drift forces a re-resolve.
This comment was generated by Claude.
c0c06ed to
6eefd32
Compare
23a4415 to
4b64ada
Compare
35cb53c to
659ac9f
Compare
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
There are 2 total unresolved issues (including 1 from previous review).
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 659ac9f. Configure here.
Closes three pnpmfile gaps surfaced while porting more cases from pnpm/test/install/hooks.ts (follow-up to #419): - `aube update` now runs the full pnpmfile cycle (preResolution + readPackage + afterAllResolved). Previously it built its resolver via `commands::build_resolver` without attaching the readPackage host, then handed off to `install::run` in frozen-prefer mode — which consumes the lockfile as-is, so the hook never fired on update. - `aube update --ignore-pnpmfile` is now accepted and honored, matching the install-side flag (and pnpm). - The `preResolution` hook is now supported. The hook receives a context object with `lockfileDir`, `storeDir`, `currentLockfile`, `wantedLockfile`, `existsCurrentLockfile`, `existsNonEmptyWantedLockfile`, and a `registries` map (default + scoped), matching pnpm's shape on the wire (camelCase). It fires before resolve in install (lockfile-only and streaming paths) and update; the spawn is skipped when the pnpmfile doesn't reference `preResolution`, so hook-less files don't pay the per-install node-startup cost. Implementation factors out a `run_one_shot_hook` helper in pnpmfile.rs so afterAllResolved and preResolution share the same node-spawn / pipe / wait scaffolding, and a `commands::run_pnpmfile_pre_resolution` helper so install and update build the context from the same sources. Also un-skips the three previously-skipped tests in test/pnpm_install_hooks.bats now that the underlying gaps are closed; they were the originals that surfaced these divergences during the port. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
659ac9f to
1ad36a5
Compare


Summary
Closes three pnpmfile gaps surfaced while porting more cases from
pnpm/test/install/hooks.ts(follow-up to #419):aube updatenow runs the full pnpmfile cycle. Previously update built its resolver viacommands::build_resolverwithout attaching the readPackage host, then handed off toinstall::runin frozen-prefer mode — which consumes the lockfile as-is, so the hook never fired on update. Now update wirespreResolution+readPackage+afterAllResolvedthe same way install does.aube update --ignore-pnpmfileis now accepted and honored, matching the install-side flag and pnpm.preResolutionhook is now supported. The hook receives a context object withlockfileDir,storeDir,currentLockfile,wantedLockfile,existsCurrentLockfile,existsNonEmptyWantedLockfile, and aregistriesmap (default + scoped), matching pnpm's wire shape (camelCase). It fires before resolve in install (lockfile-only and streaming paths) and update; the spawn is skipped when the pnpmfile doesn't referencepreResolution, so hook-less files don't pay the per-install node-startup cost.Implementation factors out a
run_one_shot_hookhelper incrates/aube/src/pnpmfile.rssoafterAllResolvedandpreResolutionshare the same node-spawn / pipe / wait scaffolding, and acommands::run_pnpmfile_pre_resolutionhelper incrates/aube/src/commands/mod.rsso install and update build the context from the same sources.Also adds three more ports from
hooks.ts(test/pnpm_install_hooks.bats) — these are the originals that surfaced the divergences during the port and pass once the gaps above are closed:readPackageduringaube update(hooks.ts:263)--ignore-pnpmfileonaube update(hooks.ts:338)preResolutionhook fires before resolve (hooks.ts:624)Test plan
mise run test:bats test/pnpm_install_hooks.bats— 8 ok, 2 skip (the two pre-existing divergences from test: port hook tests from pnpm install/hooks.ts #419), 0 fail.mise run test:bats test/pnpmfile.bats— 9 ok.mise run test:bats test/update.bats— 10 ok.mise run test:bats test/install.bats— 61 ok.cargo test -p aube— 330 unit tests + 4 e2e, 0 failures.cargo clippy --all-targets -- -D warningsclean.cargo fmt --checkclean.🤖 Generated with Claude Code
Note
Medium Risk
Changes when and how
.pnpmfile.*hooks execute (including spawningnode) duringupdateand early install resolution, which can affect dependency graphs and lockfile output.Overview
aube updatenow runs the pnpmfile hook lifecycle (runspreResolution, attachesreadPackage, then runsafterAllResolved) so hook-driven dependency mutations are reflected in the updated lockfile.Adds support for the pnpmfile
preResolutionhook with a pnpm-shaped context snapshot, and factors one-shot hook execution into a sharedrun_one_shot_hookhelper. Introducesupdate --ignore-pnpmfileand propagates it through the chained frozen-prefer install.Updates CLI usage/docs and adds new Bats coverage for
readPackageduring update,--ignore-pnpmfileon update, andpreResolutionfiring before resolve.Reviewed by Cursor Bugbot for commit 1ad36a5. Bugbot is set up for automated code reviews on this repo. Configure here.