Skip to content

Commit 5fff361

Browse files
authored
refactor: merge packages/global into packages/cli (#607)
Merge the global CLI package (vite-plus-cli) into the local CLI package (vite-plus), consolidating two npm packages into one. Key changes: - Move global source files into packages/cli/src/ with renames to avoid conflicts (global-entry.ts, global-utils/, global-types/) - Merge NAPI binding crates (migration.rs, package_manager.rs, global_utils.rs) into packages/cli/binding/ - Update rolldown config to bundle global entry with code splitting - Update Rust binary to reference global-entry.js instead of index.js - Update install scripts and wrapper.js for vite-plus package names - Update publish-native-addons.ts to include Rust vp binary - Remove packages/global/ entirely - Update CI workflows and root scripts to remove global-specific steps - Add snap-test-global script for running global CLI snap tests
1 parent 2621113 commit 5fff361

735 files changed

Lines changed: 1964 additions & 3278 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/actions/build-upstream/action.yml

Lines changed: 10 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ runs:
2121
id: cache-key
2222
shell: bash
2323
run: |
24-
echo "key=napi-binding-v2-${{ inputs.target }}-${{ env.RELEASE_BUILD }}-${{ env.DEBUG }}-${{ env.VERSION }}-${{ env.NPM_TAG }}-${{ hashFiles('packages/tools/.upstream-versions.json', 'Cargo.lock', 'crates/**/*.rs', 'crates/*/Cargo.toml', 'packages/*/binding/**/*.rs', 'packages/*/binding/Cargo.toml', 'Cargo.toml', '.cargo/config.toml', 'packages/cli/package.json', 'packages/cli/build.ts', 'packages/global/package.json', 'packages/global/build.ts') }}" >> $GITHUB_OUTPUT
24+
echo "key=napi-binding-v3-${{ inputs.target }}-${{ env.RELEASE_BUILD }}-${{ env.DEBUG }}-${{ env.VERSION }}-${{ env.NPM_TAG }}-${{ hashFiles('packages/tools/.upstream-versions.json', 'Cargo.lock', 'crates/**/*.rs', 'crates/*/Cargo.toml', 'packages/cli/binding/**/*.rs', 'packages/cli/binding/Cargo.toml', 'Cargo.toml', '.cargo/config.toml', 'packages/cli/package.json', 'packages/cli/build.ts') }}" >> $GITHUB_OUTPUT
2525
2626
# Cache NAPI bindings and Rust CLI binary (the slow parts, especially on Windows)
2727
- name: Restore NAPI binding cache
@@ -34,9 +34,6 @@ runs:
3434
packages/cli/binding/index.d.ts
3535
packages/cli/binding/index.cjs
3636
packages/cli/binding/index.d.cts
37-
packages/global/binding/*.node
38-
packages/global/binding/index.js
39-
packages/global/binding/index.d.ts
4037
target/${{ inputs.target }}/release/vp
4138
target/${{ inputs.target }}/release/vp.exe
4239
key: ${{ steps.cache-key.outputs.key }}
@@ -48,19 +45,16 @@ runs:
4845
pnpm --filter @rolldown/pluginutils build
4946
pnpm --filter rolldown build-node
5047
pnpm --filter vite build-types
51-
pnpm --filter=@voidzero-dev/vite-plus-core build
52-
pnpm --filter=@voidzero-dev/vite-plus-test build
53-
pnpm --filter=vite-plus build-ts
54-
pnpm --filter=vite-plus-cli build-ts
48+
pnpm --filter "@voidzero-dev/*" build
49+
pnpm --filter vite-plus build-ts
5550
5651
# NAPI builds - only run on cache miss (slow, especially on Windows)
57-
# Must run before vite-plus/vite-plus-cli TypeScript builds which depend on the bindings
52+
# Must run before vite-plus TypeScript builds which depend on the bindings
5853
- name: Build NAPI bindings (x86_64-linux)
5954
shell: bash
6055
if: steps.cache-restore.outputs.cache-hit != 'true' && inputs.target == 'x86_64-unknown-linux-gnu'
6156
run: |
6257
pnpm --filter=vite-plus build-native --target ${{ inputs.target }} --use-napi-cross
63-
pnpm --filter=vite-plus-cli build-native --target ${{ inputs.target }} --use-napi-cross
6458
env:
6559
TARGET_CC: clang
6660
DEBUG: napi:*
@@ -70,7 +64,6 @@ runs:
7064
if: steps.cache-restore.outputs.cache-hit != 'true' && inputs.target == 'aarch64-unknown-linux-gnu'
7165
run: |
7266
pnpm --filter=vite-plus build-native --target ${{ inputs.target }} --use-napi-cross
73-
pnpm --filter=vite-plus-cli build-native --target ${{ inputs.target }} --use-napi-cross
7467
env:
7568
TARGET_CC: clang
7669
TARGET_CFLAGS: '-D_BSD_SOURCE'
@@ -81,7 +74,6 @@ runs:
8174
if: steps.cache-restore.outputs.cache-hit != 'true' && !contains(inputs.target, 'linux')
8275
run: |
8376
pnpm --filter=vite-plus build-native --target ${{ inputs.target }}
84-
pnpm --filter=vite-plus-cli build-native --target ${{ inputs.target }}
8577
env:
8678
DEBUG: napi:*
8779

@@ -119,37 +111,23 @@ runs:
119111
packages/cli/binding/index.d.ts
120112
packages/cli/binding/index.cjs
121113
packages/cli/binding/index.d.cts
122-
packages/global/binding/*.node
123-
packages/global/binding/index.js
124-
packages/global/binding/index.d.ts
125114
target/${{ inputs.target }}/release/vp
126115
target/${{ inputs.target }}/release/vp.exe
127116
key: ${{ steps.cache-key.outputs.key }}
128117

129-
# Copy Rust CLI binary to packages/global/bin/ (runs on both cache hit and miss)
130-
- name: Copy Rust CLI binary
131-
shell: bash
132-
run: |
133-
if [[ "${{ inputs.target }}" == *"windows"* ]]; then
134-
cp target/${{ inputs.target }}/release/vp.exe packages/global/bin/vp.exe
135-
else
136-
cp target/${{ inputs.target }}/release/vp packages/global/bin/vp
137-
fi
138-
139118
# Build vite-plus TypeScript after native bindings are ready
140119
- name: Build vite-plus TypeScript packages
141120
shell: bash
142121
run: |
143122
pnpm --filter=vite-plus build-ts
144-
pnpm --filter=vite-plus-cli build-ts
145123
146124
- name: Print output after build
147125
shell: bash
148126
if: inputs.print-after-build == 'true'
149127
run: |
150-
pnpm vite -h
151-
pnpm vite run -h
152-
pnpm vite lint -h
153-
pnpm vite test -h
154-
pnpm vite build -h
155-
pnpm vite fmt -h
128+
pnpm vp -h
129+
pnpm vp run -h
130+
pnpm vp lint -h
131+
pnpm vp test -h
132+
pnpm vp build -h
133+
pnpm vp fmt -h

.github/workflows/ci.yml

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -210,13 +210,6 @@ jobs:
210210
vp --version
211211
vp -h
212212
213-
- name: Check CLI JS execution on Windows rust binary
214-
if: ${{ matrix.os == 'windows-latest' }}
215-
run: |
216-
ls -al packages/global/bin
217-
VITE_LOG=trace ./packages/global/bin/vp.exe -V
218-
VITE_LOG=trace ./packages/global/bin/vp.exe pm cache dir
219-
220213
- name: Run CLI fmt
221214
run: vp fmt --check
222215

@@ -368,7 +361,7 @@ jobs:
368361
run: |
369362
# Helper to read the installed CLI version from package.json
370363
get_cli_version() {
371-
node -p "require(require('path').resolve(process.env.USERPROFILE || process.env.HOME, '.vite-plus', 'current', 'package.json')).version"
364+
node -p "require(require('path').resolve(process.env.USERPROFILE || process.env.HOME, '.vite-plus', 'current', 'node_modules', 'vite-plus', 'package.json')).version"
372365
}
373366
374367
# Save initial (dev build) version
@@ -414,7 +407,7 @@ jobs:
414407
415408
# Helper to read the installed CLI version from package.json
416409
function Get-CliVersion {
417-
node -p "require(require('path').resolve(process.env.USERPROFILE, '.vite-plus', 'current', 'package.json')).version"
410+
node -p "require(require('path').resolve(process.env.USERPROFILE, '.vite-plus', 'current', 'node_modules', 'vite-plus', 'package.json')).version"
418411
}
419412
420413
# Save initial (dev build) version
@@ -457,7 +450,7 @@ jobs:
457450
shell: cmd
458451
run: |
459452
REM Save initial (dev build) version
460-
for /f "usebackq delims=" %%v in (`node -p "require(require('path').resolve(process.env.USERPROFILE, '.vite-plus', 'current', 'package.json')).version"`) do set INITIAL_VERSION=%%v
453+
for /f "usebackq delims=" %%v in (`node -p "require(require('path').resolve(process.env.USERPROFILE, '.vite-plus', 'current', 'node_modules', 'vite-plus', 'package.json')).version"`) do set INITIAL_VERSION=%%v
461454
echo Initial version: %INITIAL_VERSION%
462455
463456
REM --check queries npm registry and prints update status
@@ -471,7 +464,7 @@ jobs:
471464
dir "%USERPROFILE%\.vite-plus\"
472465
473466
REM Verify version changed after update
474-
for /f "usebackq delims=" %%v in (`node -p "require(require('path').resolve(process.env.USERPROFILE, '.vite-plus', 'current', 'package.json')).version"`) do set UPDATED_VERSION=%%v
467+
for /f "usebackq delims=" %%v in (`node -p "require(require('path').resolve(process.env.USERPROFILE, '.vite-plus', 'current', 'node_modules', 'vite-plus', 'package.json')).version"`) do set UPDATED_VERSION=%%v
475468
echo Updated version: %UPDATED_VERSION%
476469
if "%UPDATED_VERSION%"=="%INITIAL_VERSION%" (
477470
echo Error: version should have changed after upgrade, still %INITIAL_VERSION%
@@ -484,7 +477,7 @@ jobs:
484477
vp env doctor
485478
486479
REM Verify version restored after rollback
487-
for /f "usebackq delims=" %%v in (`node -p "require(require('path').resolve(process.env.USERPROFILE, '.vite-plus', 'current', 'package.json')).version"`) do set ROLLBACK_VERSION=%%v
480+
for /f "usebackq delims=" %%v in (`node -p "require(require('path').resolve(process.env.USERPROFILE, '.vite-plus', 'current', 'node_modules', 'vite-plus', 'package.json')).version"`) do set ROLLBACK_VERSION=%%v
488481
echo Rollback version: %ROLLBACK_VERSION%
489482
if not "%ROLLBACK_VERSION%"=="%INITIAL_VERSION%" (
490483
echo Error: version should have been restored after rollback, expected %INITIAL_VERSION%, got %ROLLBACK_VERSION%
@@ -533,7 +526,7 @@ jobs:
533526
- name: Run local CLI `vite install`
534527
run: |
535528
export PATH=$PWD/node_modules/.bin:$PATH
536-
vite -h
529+
vp -h
537530
# Test vite install on various repositories with different package managers
538531
repos=(
539532
# pnpm workspace
@@ -556,9 +549,9 @@ jobs:
556549
fi
557550
git clone --depth 1 "https://github.com/$repo.git" "$RUNNER_TEMP/$dir_name"
558551
cd "$RUNNER_TEMP/$dir_name"
559-
vite install
552+
vp install
560553
# run again to show install cache increase by time
561-
time vite install
554+
time vp install
562555
echo "✓ Successfully installed dependencies for $repo"
563556
echo ""
564557
done

.github/workflows/e2e-test.yml

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -103,19 +103,19 @@ jobs:
103103

104104
- name: Pack packages into tgz
105105
run: |
106-
pnpm copy-cli-binding
107106
mkdir -p tmp/tgz
108107
cd packages/core && pnpm pack --pack-destination ../../tmp/tgz && cd ../..
109108
cd packages/test && pnpm pack --pack-destination ../../tmp/tgz && cd ../..
110109
cd packages/cli && pnpm pack --pack-destination ../../tmp/tgz && cd ../..
111-
cd packages/global && pnpm pack --pack-destination ../../tmp/tgz && cd ../..
110+
# Copy vp binary for e2e-test job (findVpBinary expects it in target/)
111+
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
112112
ls -la tmp/tgz
113113
114114
- name: Upload tgz artifacts
115115
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
116116
with:
117117
name: vite-plus-packages-${{ matrix.os }}
118-
path: tmp/tgz/*.tgz
118+
path: tmp/tgz/
119119
retention-days: 1
120120

121121
e2e-test:
@@ -266,7 +266,11 @@ jobs:
266266
- name: Install vp CLI
267267
shell: bash
268268
run: |
269-
node $GITHUB_WORKSPACE/packages/tools/src/install-global-cli.ts --tgz $GITHUB_WORKSPACE/tmp/tgz/vite-plus-cli-0.0.0.tgz
269+
# Place vp binary where install-global-cli.ts expects it (target/release/)
270+
mkdir -p target/release
271+
cp tmp/tgz/vp target/release/vp 2>/dev/null || cp tmp/tgz/vp.exe target/release/vp.exe 2>/dev/null || true
272+
chmod +x target/release/vp 2>/dev/null || true
273+
node $GITHUB_WORKSPACE/packages/tools/src/install-global-cli.ts --tgz $GITHUB_WORKSPACE/tmp/tgz/vite-plus-0.0.0.tgz
270274
echo "$HOME/.vite-plus/bin" >> $GITHUB_PATH
271275
272276
- name: Migrate in ${{ matrix.project.name }}

.github/workflows/release.yml

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,6 @@ jobs:
7777
- name: Set binding version
7878
run: |
7979
pnpm exec tool replace-file-content packages/cli/binding/Cargo.toml 'version = "0.0.0"' 'version = "${{ env.VERSION }}"'
80-
pnpm exec tool replace-file-content packages/global/binding/Cargo.toml 'version = "0.0.0"' 'version = "${{ env.VERSION }}"'
8180
pnpm exec tool replace-file-content crates/vite_global_cli/Cargo.toml 'version = "0.0.0"' 'version = "${{ env.VERSION }}"'
8281
8382
- name: Configure Git for access to vite-task
@@ -95,13 +94,6 @@ jobs:
9594
path: ./packages/cli/binding/*.node
9695
if-no-files-found: error
9796

98-
- name: Upload Vite+ global binding artifact
99-
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
100-
with:
101-
name: vite-plus-cli-native-${{ matrix.settings.target }}
102-
path: ./packages/global/binding/*.node
103-
if-no-files-found: error
104-
10597
- name: Upload Rust CLI binary artifact
10698
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
10799
with:
@@ -132,14 +124,6 @@ jobs:
132124
path: ./packages/cli/dist
133125
if-no-files-found: error
134126

135-
- name: Upload global dist
136-
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
137-
if: ${{ matrix.settings.target == 'x86_64-unknown-linux-gnu' }}
138-
with:
139-
name: global
140-
path: ./packages/global/dist
141-
if-no-files-found: error
142-
143127
Release:
144128
runs-on: ubuntu-latest
145129
needs: [prepare, build-rust]
@@ -194,19 +178,6 @@ jobs:
194178
target: x86_64-unknown-linux-gnu
195179
upload: 'false'
196180

197-
- name: Download global dist
198-
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
199-
with:
200-
path: packages/global/dist
201-
pattern: global
202-
merge-multiple: true
203-
204-
- name: Download global binding to artifacts
205-
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
206-
with:
207-
path: packages/global/artifacts
208-
pattern: vite-plus-cli-native-*
209-
210181
- name: Download Rust CLI binaries
211182
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
212183
with:
@@ -242,7 +213,6 @@ jobs:
242213
sed -i 's/"version": "0.0.0"/"version": "${{ env.VERSION }}"/' packages/core/package.json
243214
sed -i 's/"version": "0.0.0"/"version": "${{ env.VERSION }}"/' packages/test/package.json
244215
sed -i 's/"version": "0.0.0"/"version": "${{ env.VERSION }}"/' packages/cli/package.json
245-
sed -i 's/"version": "0.0.0"/"version": "${{ env.VERSION }}"/' packages/global/package.json
246216
247217
- name: Build test
248218
run: pnpm --filter=@voidzero-dev/vite-plus-test build
@@ -254,14 +224,12 @@ jobs:
254224
- name: Publish native addons
255225
run: |
256226
node ./packages/cli/publish-native-addons.ts
257-
node ./packages/global/publish-native-addons.ts
258227
259228
- name: Publish
260229
run: |
261230
pnpm publish --filter=./packages/core --tag ${{ inputs.npm_tag }} --access public --no-git-checks
262231
pnpm publish --filter=./packages/test --tag ${{ inputs.npm_tag }} --access public --no-git-checks
263232
pnpm publish --filter=./packages/cli --tag ${{ inputs.npm_tag }} --access public --no-git-checks
264-
pnpm publish --filter=./packages/global --tag ${{ inputs.npm_tag }} --access public --no-git-checks
265233
266234
- name: Create release body
267235
run: |
@@ -282,7 +250,6 @@ jobs:
282250
- \`@voidzero-dev/vite-plus-core@${{ env.VERSION }}\`
283251
- \`@voidzero-dev/vite-plus-test@${{ env.VERSION }}\`
284252
- \`vite-plus@${{ env.VERSION }}\`
285-
- \`vite-plus-cli@${{ env.VERSION }}\`
286253
287254
### Installation
288255
@@ -324,7 +291,6 @@ jobs:
324291
• @voidzero-dev/vite-plus-core@${{ env.VERSION }}
325292
• @voidzero-dev/vite-plus-test@${{ env.VERSION }}
326293
• vite-plus@${{ env.VERSION }}
327-
• vite-plus-cli@${{ env.VERSION }}
328294
329295
**Install:**
330296
• macOS/Linux: `curl -fsSL https://staging.viteplus.dev/install.sh | bash`

0 commit comments

Comments
 (0)