Skip to content

Commit 6f46668

Browse files
committed
Merge remote-tracking branch 'origin/main' into feat/cwd-flag
2 parents ada28ff + 0af68ff commit 6f46668

59 files changed

Lines changed: 1026 additions & 465 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/e2e-test.yml

Lines changed: 15 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -147,32 +147,19 @@ jobs:
147147
- name: Pack packages into tgz
148148
run: |
149149
mkdir -p tmp/tgz
150-
# Every tgz consumer below references fixed `*-0.0.0.tgz` filenames.
151-
# A release commit can leave `packages/{core,cli}` at a published
152-
# version (e.g. 0.1.22), which would make `pnpm pack` emit
153-
# `*-0.1.22.tgz` instead. Pin both to 0.0.0 so the names stay stable.
150+
# patch-project.ts serves these tgz through a local npm registry
151+
# (packages/tools/src/local-npm-registry.ts), so `vp migrate` pins
152+
# and installs them like a real release, with every package manager
153+
# (including bun) resolving the standard
154+
# `vite -> npm:@voidzero-dev/vite-plus-core@<version>` alias. Pin
155+
# both packages to 0.0.0 so a correctly installed local build is
156+
# always distinguishable from any published version
157+
# (verify-install.ts asserts it), even on a release commit that
158+
# leaves packages/{core,cli} at a published version.
154159
(cd packages/core && npm pkg set version=0.0.0)
155160
(cd packages/cli && npm pkg set version=0.0.0)
156161
cd packages/core && pnpm pack --pack-destination ../../tmp/tgz && cd ../..
157162
cd packages/cli && pnpm pack --pack-destination ../../tmp/tgz && cd ../..
158-
# Bun is uniquely strict about peer-dep resolution:
159-
# 1. It checks the *resolved target's* package name and version
160-
# against the peer range (vitest 4.1.9 declares peer
161-
# `vite ^6 || ^7 || ^8`).
162-
# 2. A file: override pointing at the vite-plus-core tgz fails
163-
# both the name check (target is `@voidzero-dev/vite-plus-core`,
164-
# not `vite`) and the version check (0.0.0 is outside `^6|^7|^8`).
165-
# pnpm/npm/yarn don't enforce either, and using the same core tgz as
166-
# the file: target for both `vite` and `@voidzero-dev/vite-plus-core`
167-
# is the only configuration they install cleanly. See
168-
# https://github.com/oven-sh/bun/issues/8406.
169-
#
170-
# Generate a sibling vite-7.99.0.tgz: a copy of the core tgz with
171-
# `package.json#name` rewritten to "vite" and `version` to 7.99.0.
172-
# ecosystem-ci/patch-project.ts points its vite override at this
173-
# tgz only for bun-based projects (e.g. bun-vite-template); pnpm-,
174-
# npm- and yarn-based ecosystem projects use the real core tgz.
175-
pnpm exec tool repack-vite-tgz tmp/tgz/voidzero-dev-vite-plus-core-0.0.0.tgz tmp/tgz/vite-7.99.0.tgz vite 7.99.0
176163
# Copy vp binary for e2e-test job (findVpBinary expects it in target/)
177164
cp target/${{ matrix.target }}/release/vp tmp/tgz/vp 2>/dev/null || cp target/${{ matrix.target }}/release/vp.exe tmp/tgz/vp.exe 2>/dev/null || true
178165
cp target/${{ matrix.target }}/release/vp-shim.exe tmp/tgz/vp-shim.exe 2>/dev/null || true
@@ -476,13 +463,14 @@ jobs:
476463
- name: Migrate in ${{ matrix.project.name }}
477464
working-directory: ${{ runner.temp }}/vite-plus-ecosystem-ci/${{ matrix.project.name }}${{ matrix.project.directory && format('/{0}', matrix.project.directory) || '' }}
478465
shell: bash
479-
# patch-project.ts runs `vp migrate` and the follow-up `vp install`,
480-
# handling pnpm's minimumReleaseAge gate per project (disabled so
481-
# freshly published deps install, kept off for dify's time-based
482-
# resolution policy). See its comments for the details.
466+
# patch-project.ts starts a local npm registry serving the packed
467+
# local build (it stays up for the later steps; the registry env is
468+
# exported via GITHUB_ENV), then runs `vp migrate` and the follow-up
469+
# `vp install` through it, with pnpm's minimumReleaseAge gate disabled
470+
# so freshly published upstream deps install. See its comments.
483471
run: node $GITHUB_WORKSPACE/ecosystem-ci/patch-project.ts ${{ matrix.project.name }}
484472

485-
- name: Verify local tgz packages installed
473+
- name: Verify local packages installed
486474
working-directory: ${{ runner.temp }}/vite-plus-ecosystem-ci/${{ matrix.project.name }}${{ matrix.project.directory && format('/{0}', matrix.project.directory) || '' }}
487475
shell: bash
488476
run: node $GITHUB_WORKSPACE/ecosystem-ci/verify-install.ts

.github/workflows/test-vp-create.yml

Lines changed: 54 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -95,34 +95,19 @@ jobs:
9595
- name: Pack packages into tgz
9696
run: |
9797
mkdir -p tmp/tgz
98-
# Every tgz consumer below references fixed `*-0.0.0.tgz` filenames.
99-
# A release commit can leave `packages/{core,cli}` at a published
100-
# version (e.g. 0.1.22), which would make `pnpm pack` emit
101-
# `*-0.1.22.tgz` instead. Pin both to 0.0.0 so the names stay stable.
98+
# The test jobs serve these tgz through a local npm registry
99+
# (packages/tools/src/local-npm-registry.ts), so `vp create` pins
100+
# and installs them like a real release, with every package manager
101+
# (including bun) resolving the standard
102+
# `vite -> npm:@voidzero-dev/vite-plus-core@<version>` alias. Pin
103+
# both packages to 0.0.0 so a correctly installed local build is
104+
# always distinguishable from any published version, even on a
105+
# release commit that leaves packages/{core,cli} at a published
106+
# version.
102107
(cd packages/core && npm pkg set version=0.0.0)
103108
(cd packages/cli && npm pkg set version=0.0.0)
104109
cd packages/core && pnpm pack --pack-destination ../../tmp/tgz && cd ../..
105110
cd packages/cli && pnpm pack --pack-destination ../../tmp/tgz && cd ../..
106-
# Bun is uniquely strict about peer-dep resolution:
107-
# 1. It checks the *resolved target's* package name and version
108-
# against the peer range (vitest 4.1.9 declares peer
109-
# `vite ^6 || ^7 || ^8`).
110-
# 2. A file: override pointing at the vite-plus-core tgz fails
111-
# both the name check (target is `@voidzero-dev/vite-plus-core`,
112-
# not `vite`) and the version check (0.0.0 is outside `^6|^7|^8`).
113-
# pnpm/npm/yarn don't enforce either, and using the same core tgz as
114-
# the file: target for both `vite` and `@voidzero-dev/vite-plus-core`
115-
# is the only configuration they install cleanly. See
116-
# https://github.com/oven-sh/bun/issues/8406.
117-
#
118-
# Generate a sibling vite-7.99.0.tgz: a copy of the core tgz with
119-
# `package.json#name` rewritten to "vite" and `version` to 7.99.0.
120-
# Only the bun matrix entry below points its vite override at this
121-
# alias tgz; pnpm/npm/yarn keep pointing at the real core tgz so
122-
# pnpm's workspace resolver doesn't trip on a "vite@<version>"
123-
# registry lookup (the renamed tgz makes pnpm register the dep as
124-
# vite@7.99.0 and then probe npmjs.org to validate the version).
125-
pnpm exec tool repack-vite-tgz tmp/tgz/voidzero-dev-vite-plus-core-0.0.0.tgz tmp/tgz/vite-7.99.0.tgz vite 7.99.0
126111
# Copy vp binary for test jobs
127112
cp target/x86_64-unknown-linux-gnu/release/vp tmp/tgz/vp
128113
ls -la tmp/tgz
@@ -179,15 +164,12 @@ jobs:
179164
- yarn
180165
- bun
181166
env:
182-
# Bun's strict peer check requires the `vite` override target's tgz to be
183-
# named "vite" with a version satisfying vitest's `peer vite ^6 || ^7 || ^8`.
184-
# The bun matrix entry uses the masquerade tgz (vite-7.99.0.tgz). pnpm/npm/yarn
185-
# point at the real core tgz — anything else trips a registry lookup for
186-
# vite@<version> when sub-package and override targets are both file: tgz aliases.
187-
VITE_OVERRIDE_TGZ: ${{ matrix.package-manager == 'bun' && 'vite-7.99.0.tgz' || 'voidzero-dev-vite-plus-core-0.0.0.tgz' }}
188-
VP_VERSION: 'file:${{ github.workspace }}/tmp/tgz/vite-plus-0.0.0.tgz'
167+
# The local registry serves the packed 0.0.0 build, so create pins the
168+
# exact version like a real release. The vp binary was built before the
169+
# pack step pinned the package versions, so align the version explicitly.
170+
VP_VERSION: '0.0.0'
189171
# Force full dependency rewriting so the library template's existing
190-
# vite-plus dep gets overridden with the local tgz
172+
# vite-plus dep gets overridden with the local build
191173
VP_FORCE_MIGRATE: '1'
192174
# yarn 4 quarantines packages published within `npmMinimalAgeGate`
193175
# (default 1440 min / 24h). When an oxlint bump landed <24h ago, the
@@ -221,10 +203,34 @@ jobs:
221203
which vp
222204
vp --version
223205
206+
- name: Start local npm registry
207+
# Serve the packed local build behind a real registry interface for
208+
# the create's install and every later step (the registry env is
209+
# exported via GITHUB_ENV; the detached server lives for the job).
210+
# Both output fds go to a file, not this step's pipes, so the step
211+
# completes while the server keeps running.
212+
run: |
213+
node "$GITHUB_WORKSPACE/packages/tools/src/local-npm-registry.ts" --serve --packages-dir "$GITHUB_WORKSPACE/tmp/tgz" > "$RUNNER_TEMP/local-registry.out" 2>&1 &
214+
server_pid=$!
215+
until grep -q '"registry"' "$RUNNER_TEMP/local-registry.out" 2>/dev/null; do
216+
if ! kill -0 "$server_pid" 2>/dev/null; then
217+
echo "local registry failed to start:"
218+
cat "$RUNNER_TEMP/local-registry.out"
219+
exit 1
220+
fi
221+
sleep 0.2
222+
done
223+
handshake=$(head -1 "$RUNNER_TEMP/local-registry.out")
224+
echo "$handshake"
225+
echo "$handshake" | node -e 'const { env } = JSON.parse(require("node:fs").readFileSync(0, "utf8")); for (const [k, v] of Object.entries(env)) console.log(`${k}=${v}`)' >> "$GITHUB_ENV"
226+
227+
# No VP_OVERRIDE_PACKAGES: with VP_VERSION=0.0.0 the product default
228+
# override map already pins `vite` to npm:@voidzero-dev/vite-plus-core@0.0.0
229+
# and `vitest` to the bundled version (see VITE_PLUS_OVERRIDE_PACKAGES in
230+
# packages/cli/src/utils/constants.ts), and stays correct across vitest
231+
# bumps without editing this workflow.
224232
- name: Run vp create ${{ matrix.template.name }} with ${{ matrix.package-manager }}
225233
working-directory: ${{ runner.temp }}
226-
env:
227-
VP_OVERRIDE_PACKAGES: '{"vite":"file:${{ github.workspace }}/tmp/tgz/${{ env.VITE_OVERRIDE_TGZ }}","@voidzero-dev/vite-plus-core":"file:${{ github.workspace }}/tmp/tgz/voidzero-dev-vite-plus-core-0.0.0.tgz","vitest":"4.1.9","@vitest/expect":"4.1.9","@vitest/runner":"4.1.9","@vitest/snapshot":"4.1.9","@vitest/spy":"4.1.9","@vitest/utils":"4.1.9","@vitest/mocker":"4.1.9","@vitest/pretty-format":"4.1.9","@vitest/coverage-v8":"4.1.9","@vitest/coverage-istanbul":"4.1.9"}'
228234
run: |
229235
vp create ${{ matrix.template.create-args }} \
230236
--no-interactive \
@@ -334,7 +340,7 @@ jobs:
334340
fi
335341
echo "✓ vite-plus, vite, vitest are all single instances"
336342
337-
- name: Verify local tgz packages installed
343+
- name: Verify local packages installed
338344
working-directory: ${{ runner.temp }}/test-project
339345
run: |
340346
node -e "
@@ -459,18 +465,23 @@ jobs:
459465
if: matrix.template.name == 'monorepo'
460466
working-directory: ${{ runner.temp }}/test-project
461467
run: |
462-
# Under npm, `vp run ready` reaches 100% cache hit only on the
463-
# third invocation (#1638): vite-task's directory-listing
468+
# Under npm and yarn, `vp run ready` reaches 100% cache hit only on
469+
# the third invocation (#1638): vite-task's directory-listing
464470
# fingerprint and fspy read/write tracking surface false-positive
465471
# misses on run #2 because `packages/utils/node_modules/` is born
466-
# during run #1. pnpm/yarn/bun pre-create per-package
467-
# `node_modules/` at install time and reach 100% on run #2.
472+
# during run #1. pnpm and bun pre-create per-package
473+
# `node_modules/` at install time and reach 100% on run #2; Yarn
474+
# Berry did too under the old file: overrides (per-package copies),
475+
# but with registry-resolved semver specs it hoists the workspace
476+
# deps like a real install, so it now behaves like npm here.
468477
# The preceding `Verify project builds` step already invoked
469478
# `vp run ready` once (verify-command for monorepo), so one
470-
# extra warm-up here is enough under npm.
471-
if [ "${{ matrix.package-manager }}" = "npm" ]; then
472-
vp run ready >/dev/null 2>&1
473-
fi
479+
# extra warm-up here is enough.
480+
case "${{ matrix.package-manager }}" in
481+
npm|yarn)
482+
vp run ready >/dev/null 2>&1
483+
;;
484+
esac
474485
output=$(vp run ready 2>&1)
475486
echo "$output"
476487
if ! echo "$output" | grep -q 'cache hit (100%)'; then

AGENTS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ vite-plus/
5454
- **Generated project agent guidance**: `packages/cli/AGENTS.md` and `packages/cli/src/utils/agent.ts`; do not edit these when the task is only to improve root repo guidance.
5555
- **Product/repo docs**: root contributor docs live at the repo root and the VitePress site under `docs/` (`docs/guide/`, `docs/config/`); generated agent guidance is separate.
5656
- **CLI output behavior**: inspect the relevant code plus `packages/cli/snap-tests/` or `packages/cli/snap-tests-global/`.
57+
- **Install-testing against the local build**: `packages/tools/src/local-npm-registry.ts` serves the packed checkout behind a real registry interface; used by install snap fixtures (`localVitePlusPackages`), ecosystem e2e (`ecosystem-ci/patch-project.ts`), and local `vp migrate`/`vp create` iteration (see `CONTRIBUTING.md`).
5758

5859
## Command and Config Model
5960

CONTRIBUTING.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,29 @@ Verify the link with `ls -l node_modules/vite-plus` (it should be a symlink into
9898
- `pnpm link` may also add a `packageManager` field to the test project's `package.json`; revert it if unwanted.
9999
- Undo with `pnpm unlink vite-plus`, or remove the override and run `pnpm install`.
100100

101+
### Test `vp migrate` / `vp create` through a local npm registry
102+
103+
`pnpm link` swaps the code inside an existing project, but `vp migrate` and `vp create` pin the exact CLI version and then _install_ it, so the checkout's `vite-plus` / `@voidzero-dev/vite-plus-core` must be resolvable from a registry. `packages/tools/src/local-npm-registry.ts` provides that: it packs the checkout, serves the tarballs behind a real registry HTTP interface, and proxies every other package upstream. This replaces the old pkg.pr.new publish + registry-bridge round-trip for local iteration; you can verify migrate/create logic immediately after a build.
104+
105+
```bash
106+
pnpm build # the served packages are built artifacts; rebuild after JS changes
107+
108+
# One-shot: wrap any command (from the project you want to migrate)
109+
cd /path/to/test-project
110+
node /path/to/vite-plus/packages/tools/src/local-npm-registry.ts --pack -- vp migrate --no-interactive
111+
node /path/to/vite-plus/packages/tools/src/local-npm-registry.ts --pack -- vp create vite:application --no-interactive
112+
113+
# Or keep a server running for repeated commands (from the vite-plus checkout)
114+
pnpm local-registry --pack --serve
115+
# copy the printed `export ...` lines into the shell where you run vp
116+
```
117+
118+
Notes:
119+
120+
- The served versions carry an old publish time, so `minimumReleaseAge` gates never quarantine them, and wrapped runs get throwaway Yarn Berry / bun caches (both cache registry state in ways that would otherwise leak stale local builds between runs).
121+
- The same server backs the install snap fixtures (`localVitePlusPackages` in `steps.json`) and ecosystem e2e (`ecosystem-ci/patch-project.ts`), so a flow that works here works there too.
122+
- `pnpm local-registry:ps` lists any registry processes still running (e.g. a `--serve` you forgot, or a wrapper that was killed mid-run); `pnpm local-registry:kill` stops them all and removes their leftover temp caches.
123+
101124
### Global CLI (Rust) changes
102125

103126
`pnpm link` only swaps the JS side; the `vp` binary on `PATH` (and the Rust-backed commands it handles directly, such as package-manager commands) is still whatever is installed in `~/.vite-plus`. For changes to the Rust global CLI (`crates/`), install it from source, and combine with `pnpm link` when the change spans both layers:

0 commit comments

Comments
 (0)