Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .github/actions/build-upstream/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
packages/cli/binding/index.d.cts
target/${{ inputs.target }}/release/vp
target/${{ inputs.target }}/release/vp.exe
target/${{ inputs.target }}/release/vp-shim.exe
key: ${{ steps.cache-key.outputs.key }}

# Apply Vite+ branding patches to rolldown-vite source (CI checks out
Expand Down Expand Up @@ -111,6 +112,11 @@
shell: bash
run: cargo build --release --target ${{ inputs.target }} -p vite_global_cli

- name: Build trampoline shim binary (Windows only)
if: steps.cache-restore.outputs.cache-hit != 'true' && contains(inputs.target, 'windows')
shell: bash
run: cargo build --release --target ${{ inputs.target }} -p vite_trampoline

- name: Save NAPI binding cache
if: steps.cache-restore.outputs.cache-hit != 'true'
uses: actions/cache/save@94b89442628ad1d101e352b7ee38f30e1bef108e # v5
Expand All @@ -123,6 +129,7 @@
packages/cli/binding/index.d.cts
target/${{ inputs.target }}/release/vp
target/${{ inputs.target }}/release/vp.exe
target/${{ inputs.target }}/release/vp-shim.exe
key: ${{ steps.cache-key.outputs.key }}

# Build vite-plus TypeScript after native bindings are ready
Expand Down
7 changes: 6 additions & 1 deletion .github/workflows/e2e-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ jobs:
cd packages/cli && pnpm pack --pack-destination ../../tmp/tgz && cd ../..
# Copy vp binary for e2e-test job (findVpBinary expects it in target/)
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
cp target/${{ matrix.target }}/release/vp-shim.exe tmp/tgz/vp-shim.exe 2>/dev/null || true
ls -la tmp/tgz

- name: Upload tgz artifacts
Expand Down Expand Up @@ -289,12 +290,16 @@ jobs:
# Place vp binary where install-global-cli.ts expects it (target/release/)
mkdir -p target/release
cp tmp/tgz/vp target/release/vp 2>/dev/null || cp tmp/tgz/vp.exe target/release/vp.exe 2>/dev/null || true
cp tmp/tgz/vp-shim.exe target/release/vp-shim.exe 2>/dev/null || true
chmod +x target/release/vp 2>/dev/null || true
node $GITHUB_WORKSPACE/packages/tools/src/install-global-cli.ts --tgz $GITHUB_WORKSPACE/tmp/tgz/vite-plus-0.0.0.tgz
echo "$HOME/.vite-plus/bin" >> $GITHUB_PATH
# Use USERPROFILE (native Windows path) instead of HOME (Git Bash path /c/Users/...)
# so cmd.exe and Node.js execSync can resolve binaries in PATH
echo "${USERPROFILE:-$HOME}/.vite-plus/bin" >> $GITHUB_PATH

- name: Migrate in ${{ matrix.project.name }}
working-directory: ${{ runner.temp }}/vite-plus-ecosystem-ci/${{ matrix.project.name }}${{ matrix.project.directory && format('/{0}', matrix.project.directory) || '' }}
shell: bash
run: |
node $GITHUB_WORKSPACE/ecosystem-ci/patch-project.ts ${{ matrix.project.name }}
vp install --no-frozen-lockfile
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ jobs:
path: |
./target/${{ matrix.settings.target }}/release/vp
./target/${{ matrix.settings.target }}/release/vp.exe
./target/${{ matrix.settings.target }}/release/vp-shim.exe
if-no-files-found: error

- name: Remove .node files before upload dist
Expand Down
33 changes: 12 additions & 21 deletions .github/workflows/test-standalone-install.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ defaults:
shell: bash

env:
VITE_PLUS_VERSION: latest
VITE_PLUS_VERSION: alpha

jobs:
test-install-sh:
Expand Down Expand Up @@ -131,7 +131,7 @@ jobs:
run: |
docker run --rm --platform linux/arm64 \
-v "${{ github.workspace }}:/workspace" \
-e VITE_PLUS_VERSION=latest \
-e VITE_PLUS_VERSION=alpha \
ubuntu:20.04 bash -c "
ls -al ~/
apt-get update && apt-get install -y curl ca-certificates
Expand Down Expand Up @@ -233,7 +233,7 @@ jobs:
exit 1
}

$expectedShims = @("node.cmd", "npm.cmd", "npx.cmd")
$expectedShims = @("node.exe", "npm.exe", "npx.exe")
foreach ($shim in $expectedShims) {
$shimFile = Join-Path $binPath $shim
if (-not (Test-Path $shimFile)) {
Expand Down Expand Up @@ -300,7 +300,7 @@ jobs:
exit 1
}

$expectedShims = @("node.cmd", "npm.cmd", "npx.cmd")
$expectedShims = @("node.exe", "npm.exe", "npx.exe")
foreach ($shim in $expectedShims) {
$shimFile = Join-Path $binPath $shim
if (-not (Test-Path $shimFile)) {
Expand Down Expand Up @@ -380,8 +380,8 @@ jobs:
exit 1
}

# Verify shim executables exist (all use .cmd wrappers on Windows)
$expectedShims = @("node.cmd", "npm.cmd", "npx.cmd")
# Verify shim executables exist (trampoline .exe files on Windows)
$expectedShims = @("node.exe", "npm.exe", "npx.exe")
foreach ($shim in $expectedShims) {
$shimFile = Join-Path $binPath $shim
if (-not (Test-Path $shimFile)) {
Expand Down Expand Up @@ -419,8 +419,8 @@ jobs:
set "BIN_PATH=%USERPROFILE%\.vite-plus\bin"
dir "%BIN_PATH%"

REM Verify shim executables exist (Windows uses .cmd wrappers)
for %%s in (node.cmd npm.cmd npx.cmd vp.cmd) do (
REM Verify shim executables exist (Windows uses trampoline .exe files)
for %%s in (node.exe npm.exe npx.exe vp.exe) do (
if not exist "%BIN_PATH%\%%s" (
echo Error: Shim not found: %BIN_PATH%\%%s
exit /b 1
Expand Down Expand Up @@ -462,22 +462,13 @@ jobs:
exit 1
fi

# Verify .cmd wrappers exist (for cmd.exe/PowerShell)
for shim in node.cmd npm.cmd npx.cmd vp.cmd; do
# Verify trampoline .exe files exist
for shim in node.exe npm.exe npx.exe vp.exe; do
if [ ! -f "$BIN_PATH/$shim" ]; then
echo "Error: .cmd wrapper not found: $BIN_PATH/$shim"
echo "Error: Trampoline shim not found: $BIN_PATH/$shim"
exit 1
fi
echo "Found .cmd wrapper: $BIN_PATH/$shim"
done

# Verify shell scripts exist (for Git Bash)
for shim in node npm npx vp; do
if [ ! -f "$BIN_PATH/$shim" ]; then
echo "Error: Shell script not found: $BIN_PATH/$shim"
exit 1
fi
echo "Found shell script: $BIN_PATH/$shim"
echo "Found trampoline shim: $BIN_PATH/$shim"
done

# Verify vp env doctor works
Expand Down
Empty file modified .husky/pre-commit
100644 → 100755
Empty file.
4 changes: 4 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -318,3 +318,8 @@ codegen-units = 1
strip = "symbols" # set to `false` for debug information
debug = false # set to `true` for debug information
panic = "abort" # Let it crash and force ourselves to write safe Rust.

# The trampoline binary is copied per shim tool (~5-10 copies), so optimize for
# size instead of speed. This reduces it from ~200KB to ~100KB on Windows.
[profile.release.package.vite_trampoline]
opt-level = "z"
12 changes: 6 additions & 6 deletions crates/vite_global_cli/src/commands/env/doctor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -239,8 +239,8 @@ async fn check_bin_dir() -> bool {
fn shim_filename(tool: &str) -> String {
#[cfg(windows)]
{
// All tools use .cmd wrappers on Windows (including node)
format!("{tool}.cmd")
// All tools use trampoline .exe files on Windows
format!("{tool}.exe")
}

#[cfg(not(windows))]
Expand Down Expand Up @@ -739,10 +739,10 @@ mod tests {

#[cfg(windows)]
{
// All shims should use .cmd on Windows (matching setup.rs)
assert_eq!(node, "node.cmd");
assert_eq!(npm, "npm.cmd");
assert_eq!(npx, "npx.cmd");
// All shims should use .exe on Windows (trampoline executables)
assert_eq!(node, "node.exe");
assert_eq!(npm, "npm.exe");
assert_eq!(npx, "npx.exe");
}

#[cfg(not(windows))]
Expand Down
Loading
Loading