Skip to content

Commit 5ba62a3

Browse files
committed
refactor: merge packages/global into packages/cli
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 6345b05 commit 5ba62a3

628 files changed

Lines changed: 614 additions & 2271 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: 5 additions & 15 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 }}
@@ -51,7 +48,6 @@ runs:
5148
pnpm --filter=@voidzero-dev/vite-plus-core build
5249
pnpm --filter=@voidzero-dev/vite-plus-test build
5350
pnpm --filter=vite-plus build-ts
54-
pnpm --filter=vite-plus-cli build-ts
5551
5652
# NAPI builds - only run on cache miss (slow, especially on Windows)
5753
# Must run before vite-plus/vite-plus-cli TypeScript builds which depend on the bindings
@@ -60,7 +56,6 @@ runs:
6056
if: steps.cache-restore.outputs.cache-hit != 'true' && inputs.target == 'x86_64-unknown-linux-gnu'
6157
run: |
6258
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
6459
env:
6560
TARGET_CC: clang
6661
DEBUG: napi:*
@@ -70,7 +65,6 @@ runs:
7065
if: steps.cache-restore.outputs.cache-hit != 'true' && inputs.target == 'aarch64-unknown-linux-gnu'
7166
run: |
7267
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
7468
env:
7569
TARGET_CC: clang
7670
TARGET_CFLAGS: '-D_BSD_SOURCE'
@@ -81,7 +75,6 @@ runs:
8175
if: steps.cache-restore.outputs.cache-hit != 'true' && !contains(inputs.target, 'linux')
8276
run: |
8377
pnpm --filter=vite-plus build-native --target ${{ inputs.target }}
84-
pnpm --filter=vite-plus-cli build-native --target ${{ inputs.target }}
8578
env:
8679
DEBUG: napi:*
8780

@@ -119,29 +112,26 @@ runs:
119112
packages/cli/binding/index.d.ts
120113
packages/cli/binding/index.cjs
121114
packages/cli/binding/index.d.cts
122-
packages/global/binding/*.node
123-
packages/global/binding/index.js
124-
packages/global/binding/index.d.ts
125115
target/${{ inputs.target }}/release/vp
126116
target/${{ inputs.target }}/release/vp.exe
127117
key: ${{ steps.cache-key.outputs.key }}
128118

129-
# Copy Rust CLI binary to packages/global/bin/ (runs on both cache hit and miss)
119+
# Copy Rust CLI binary to packages/cli/vp-binary/ (runs on both cache hit and miss)
130120
- name: Copy Rust CLI binary
131121
shell: bash
132122
run: |
123+
mkdir -p packages/cli/vp-binary
133124
if [[ "${{ inputs.target }}" == *"windows"* ]]; then
134-
cp target/${{ inputs.target }}/release/vp.exe packages/global/bin/vp.exe
125+
cp target/${{ inputs.target }}/release/vp.exe packages/cli/vp-binary/vp.exe
135126
else
136-
cp target/${{ inputs.target }}/release/vp packages/global/bin/vp
127+
cp target/${{ inputs.target }}/release/vp packages/cli/vp-binary/vp
137128
fi
138129
139130
# Build vite-plus TypeScript after native bindings are ready
140131
- name: Build vite-plus TypeScript packages
141132
shell: bash
142133
run: |
143134
pnpm --filter=vite-plus build-ts
144-
pnpm --filter=vite-plus-cli build-ts
145135
146136
- name: Print output after build
147137
shell: bash

.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`

Cargo.lock

Lines changed: 3 additions & 18 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[workspace]
22
resolver = "3"
3-
members = ["bench", "crates/*", "packages/cli/binding", "packages/global/binding"]
3+
members = ["bench", "crates/*", "packages/cli/binding"]
44

55
[workspace.package]
66
authors = ["Vite+ Authors"]

crates/vite_global_cli/src/commands/create.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ pub async fn execute(cwd: AbsolutePathBuf, args: &[String]) -> Result<ExitStatus
1212

1313
// Execute the bundled JS script with the "create" command
1414
// The JS script handles all argument parsing, template discovery, and execution
15-
executor.execute_cli_script("index.js", "create", args, &cwd).await
15+
executor.execute_cli_script("global-entry.js", "create", args, &cwd).await
1616
}
1717

1818
#[cfg(test)]

crates/vite_global_cli/src/commands/migrate.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ pub async fn execute(cwd: AbsolutePathBuf, args: &[String]) -> Result<ExitStatus
1212

1313
// Execute the bundled JS script with the "migrate" command
1414
// The JS script handles all migration logic
15-
executor.execute_cli_script("index.js", "migrate", args, &cwd).await
15+
executor.execute_cli_script("global-entry.js", "migrate", args, &cwd).await
1616
}
1717

1818
#[cfg(test)]

crates/vite_global_cli/src/commands/upgrade/registry.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ pub struct ResolvedVersion {
3636
pub platform_integrity: String,
3737
}
3838

39-
const MAIN_PACKAGE_NAME: &str = "vite-plus-cli";
39+
const MAIN_PACKAGE_NAME: &str = "vite-plus";
4040
const PLATFORM_PACKAGE_SCOPE: &str = "@voidzero-dev";
4141

4242
/// Resolve a version from the npm registry.
@@ -105,7 +105,7 @@ mod tests {
105105
fn test_package_name_construction() {
106106
let suffix = "darwin-arm64";
107107
let name = format!("{PLATFORM_PACKAGE_SCOPE}/{MAIN_PACKAGE_NAME}-{suffix}");
108-
assert_eq!(name, "@voidzero-dev/vite-plus-cli-darwin-arm64");
108+
assert_eq!(name, "@voidzero-dev/vite-plus-darwin-arm64");
109109
}
110110

111111
#[test]

crates/vite_global_cli/src/commands/version.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use crate::{error::Error, js_executor::JsExecutor};
99
/// Execute the `--version` command by delegating to the bundled JavaScript implementation.
1010
pub async fn execute(cwd: AbsolutePathBuf) -> Result<ExitStatus, Error> {
1111
let mut executor = JsExecutor::new(None);
12-
executor.execute_cli_script("index.js", "--version", &[], &cwd).await
12+
executor.execute_cli_script("global-entry.js", "--version", &[], &cwd).await
1313
}
1414

1515
#[cfg(test)]

crates/vite_global_cli/src/js_executor.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@ impl JsExecutor {
5555
}
5656

5757
// 3. Auto-detect from binary location
58-
// JS scripts are at ../dist relative to bin/
59-
// e.g., packages/global/bin/vp -> packages/global/dist/
58+
// JS scripts are at ../dist relative to the binary directory
59+
// e.g., packages/cli/vp-binary/vp -> packages/cli/dist/
6060
let exe_path = std::env::current_exe().map_err(|_| Error::JsScriptsDirNotFound)?;
6161
// Resolve symlinks to get the real binary path (Unix only)
6262
// Skip on Windows to avoid path resolution issues
@@ -111,7 +111,7 @@ impl JsExecutor {
111111
/// from `devEngines.runtime` in the CLI's package.json.
112112
fn get_cli_package_dir(&self) -> Result<AbsolutePathBuf, Error> {
113113
let scripts_dir = self.get_scripts_dir()?;
114-
// scripts_dir is typically packages/global/dist, so parent is packages/global
114+
// scripts_dir is typically packages/cli/dist, so parent is packages/cli
115115
scripts_dir
116116
.parent()
117117
.map(vite_path::AbsolutePath::to_absolute_path_buf)
@@ -222,7 +222,7 @@ impl JsExecutor {
222222

223223
// Get the JS entry point (dist/index.js)
224224
let scripts_dir = self.get_scripts_dir()?;
225-
let entry_point = scripts_dir.join("index.js");
225+
let entry_point = scripts_dir.join("global-entry.js");
226226

227227
tracing::debug!("Delegating to local CLI via JS entry point: {:?} {:?}", entry_point, args);
228228

package.json

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,11 @@
44
"license": "BUSL-1.1",
55
"type": "module",
66
"scripts": {
7-
"build": "pnpm -F @voidzero-dev/* -F vite-plus build && pnpm -F vite-plus-cli build",
7+
"build": "pnpm -F @voidzero-dev/* -F vite-plus build",
88
"bootstrap-cli": "pnpm build && cargo build -p vite_global_cli --release && pnpm copy-vp-binary && pnpm install-global-cli",
99
"bootstrap-cli:ci": "pnpm install-global-cli",
10-
"copy-vp-binary": "rm -f packages/global/bin/vp packages/global/bin/vp.exe && (cp target/release/vp packages/global/bin/vp || cp target/release/vp.exe packages/global/bin/vp.exe)",
11-
"copy-cli-binding": "pnpm --filter=vite-plus-cli copy-binding",
12-
"install-global-cli": "pnpm copy-cli-binding && tool install-global-cli",
10+
"copy-vp-binary": "mkdir -p packages/cli/vp-binary && rm -f packages/cli/vp-binary/vp packages/cli/vp-binary/vp.exe && (cp target/release/vp packages/cli/vp-binary/vp || cp target/release/vp.exe packages/cli/vp-binary/vp.exe)",
11+
"install-global-cli": "tool install-global-cli",
1312
"tsgo": "tsgo -b tsconfig.json",
1413
"lint": "vp lint --type-aware --threads 4",
1514
"test": "vp test run && pnpm -r snap-test",

0 commit comments

Comments
 (0)