Skip to content

fix: install pkg.pr.new preview builds via VP_PR_VERSION#100

Merged
fengmk2 merged 4 commits into
mainfrom
fix/pkg-pr-new-commit-version
Jul 1, 2026
Merged

fix: install pkg.pr.new preview builds via VP_PR_VERSION#100
fengmk2 merged 4 commits into
mainfrom
fix/pkg-pr-new-commit-version

Conversation

@fengmk2

@fengmk2 fengmk2 commented Jul 1, 2026

Copy link
Copy Markdown
Member

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 that vp migrate writes into .npmrc) fails:

error: Failed to fetch version '0.0.0-commit.<sha>': version not found
  URL: https://registry.npmjs.org/vite-plus/0.0.0-commit.<sha>

These commit builds only exist on pkg.pr.new, not on the npm registry. The install.sh script the action pipes does not read .npmrc; it resolves VP_VERSION straight 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 pass VP_PR_VERSION=<sha> to the install script. That routes the CLI bootstrap through the script's pkg.pr.new path (documented VP_PR_VERSION env var), which bypasses the npm registry. Regular published versions are unaffected.

Testing

  • Added a test asserting a 0.0.0-commit.<sha> version sets env.VP_PR_VERSION, plus a guard that regular versions do not.
  • vp run test (152 passed), vp run check, and vp run build all pass. dist/index.mjs rebuilt.

Seen in the wild: https://github.com/fengmk2/vinext/actions/runs/28490499678/job/84445918005

Copilot AI review requested due to automatic review settings July 1, 2026 03:31

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_VERSION to the install script when the input version is a pkg.pr.new commit build.
  • Add tests to assert VP_PR_VERSION is 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.

Comment thread src/install-viteplus.ts Outdated
Comment thread src/install-viteplus.test.ts Outdated
Comment thread src/install-viteplus.test.ts Outdated
Copilot AI review requested due to automatic review settings July 1, 2026 04:07

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 3 changed files in this pull request and generated no new comments.

fengmk2 added 3 commits July 1, 2026 12:15
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.
@fengmk2 fengmk2 force-pushed the fix/pkg-pr-new-commit-version branch from c4d9786 to 8eff1f5 Compare July 1, 2026 04:16
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.
Copilot AI review requested due to automatic review settings July 1, 2026 04:25

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 3 changed files in this pull request and generated no new comments.

@fengmk2 fengmk2 merged commit 35171c9 into main Jul 1, 2026
35 checks passed
@fengmk2 fengmk2 deleted the fix/pkg-pr-new-commit-version branch July 1, 2026 04:30
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.

2 participants