fix(cli): expose vpr as a package bin#1988
Open
kvnwolf wants to merge 1 commit into
Open
Conversation
`vpr` (the `vp run` shorthand) only existed as a global PATH shim created
by `vp env setup`. The npm package shipped only `vp`, `oxfmt`, and `oxlint`
bins, so clean CI installs without the global shims (Vercel build image,
generic CI runners) failed with `vpr: command not found` (exit 127).
Add a `bin/vpr` Node shim that injects `run` into argv and delegates to the
existing CLI entry, and register it in the package `bin` map so a normal
install creates `node_modules/.bin/vpr`. The shim splices `run` before a
dynamic `await import('../dist/bin.js')` so the entry reads the spliced
argv and dispatches the `run` subcommand — byte-for-byte equivalent to
`vp run`.
`vpx` is intentionally not shipped this way: its npx-equivalent resolution
chain lives only in the global CLI crate with no JS entrypoint.
Closes voidzero-dev#1827
✅ Deploy Preview for viteplus-preview canceled.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
vpr(thevp runshorthand) only existed as a global PATH shim created byvp env setup. Thevite-plusnpm package shipped onlyvp,oxfmt, andoxlintbins, so a clean install without the global shims (Vercel build image, generic CI runners) failed withvpr: command not found(exit 127).This is the maintainer-preferred Option 1 from #1827.
packages/cli/bin/vpr— a Node ESM shim that injectsruninto argv and delegates to the existing CLI entry. It splicesrunbefore a dynamicawait import('../dist/bin.js')so the entry reads the spliced argv and dispatches therunsubcommand (a static import would be hoisted and run before the splice)."vpr": "./bin/vpr"in the packagebinmap, so a normal install createsnode_modules/.bin/vpr. Thefilesarray already includesbin/, so no change there.command-vprsnap fixture mirroring the existing global one (snap-tests-global/command-vpr).The binding consumes args explicitly and never inspects the invoked binary name, so prepending
runis byte-for-byte thevp runpath.Why not
vpxA collaborator asked whether
vpxshould be shipped the same way. It should not:vpxis a full npx-equivalent whose resolution chain (local.bin→ global vp-installed packages → system PATH →vp dlxfallback) lives only in the global CLI crate with no JS entrypoint. A splice trick can't reproduce it; that's a separate change.Test plan
package.jsonbin.vpr === "./bin/vpr";filesuntouchedbin/vpris executable (mode 755, matchingbin/vp); splice precedes the dynamic importcommand-vprfixture inputs byte-identical to the global fixturepnpm -F vite-plus snap-test-local command-vprgeneratessnap.txtand confirmsvpr -hshowsvp runhelp,vpr helloruns the script,vpr greet --arg1 value1forwards args,vpr nonexistentexits 1 (could not run locally —vite/source tree absent, so dist + NAPI binding can't be built)Closes #1827