fix: install pkg.pr.new preview builds via VP_PR_VERSION#100
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes installing pkg.pr.new preview builds of Vite+ (versions shaped like 0.0.0-commit.<sha>) by detecting that version format and passing VP_PR_VERSION=<sha> into the upstream install script so it fetches from pkg.pr.new instead of attempting an npm registry resolve.
Changes:
- Detect
0.0.0-commit.<sha>versions and extract the commit SHA for pkg.pr.new routing. - Pass
VP_PR_VERSIONto the install script when the input version is a pkg.pr.new commit build. - Add tests to assert
VP_PR_VERSIONis set for commit builds and not set for normal versions.
Reviewed changes
Copilot reviewed 2 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| src/install-viteplus.ts | Adds pkg.pr.new commit-build detection and sets env.VP_PR_VERSION to route installs through pkg.pr.new. |
| src/install-viteplus.test.ts | Adds coverage for the new VP_PR_VERSION behavior in installVitePlus. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Preview builds published as `0.0.0-commit.<sha>` (for example from the vite-plus registry bridge that `vp migrate` writes into `.npmrc`) only exist on pkg.pr.new, not on the npm registry. The install script does not read `.npmrc` and resolves `VP_VERSION` from the npm registry, so a commit build 404s with "version not found". Detect the `0.0.0-commit.<sha>` shape and pass `VP_PR_VERSION=<sha>` so the install script uses its pkg.pr.new path and bypasses the npm registry.
CI sets VP_PR_VERSION at the workflow level, so the "regular version" test saw an inherited empty string instead of undefined. Clear and restore process.env.VP_PR_VERSION around each test so they only pass when installVitePlus itself sets the value. Also require 7-40 hex chars in the commit matcher so trivial suffixes like `0.0.0-commit.a` are not routed through pkg.pr.new.
Replace the hand-rolled process.env.VP_PR_VERSION save/restore with the vi.stubEnv/vi.unstubAllEnvs pattern already used in auth.test.ts and utils.test.ts, and collapse the three near-identical routing tests into a single it.each table.
c4d9786 to
8eff1f5
Compare
The registry bridge only publishes `0.0.0-commit.<full 40-char sha>`, and the upcoming install script maps a 40-char SHA straight to that build, so tighten the matcher from 7-40 to exactly 40 hex chars.
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.
Problem
Installing a pkg.pr.new preview build of Vite+ (version
0.0.0-commit.<sha>, for example produced by the vite-plus registry bridge thatvp migratewrites into.npmrc) fails:These commit builds only exist on pkg.pr.new, not on the npm registry. The
install.shscript the action pipes does not read.npmrc; it resolvesVP_VERSIONstraight from the npm registry, so the commit build 404s and the install exhausts all retries.Fix
Detect the
0.0.0-commit.<sha>version shape and passVP_PR_VERSION=<sha>to the install script. That routes the CLI bootstrap through the script's pkg.pr.new path (documentedVP_PR_VERSIONenv var), which bypasses the npm registry. Regular published versions are unaffected.Testing
0.0.0-commit.<sha>version setsenv.VP_PR_VERSION, plus a guard that regular versions do not.vp run test(152 passed),vp run check, andvp run buildall pass.dist/index.mjsrebuilt.Seen in the wild: https://github.com/fengmk2/vinext/actions/runs/28490499678/job/84445918005