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
35 changes: 22 additions & 13 deletions .github/workflows/test-standalone-install.yml
Original file line number Diff line number Diff line change
Expand Up @@ -361,32 +361,33 @@ jobs:
test "$CONFIG_DIR" = "$(dump_dir config)"
test "$STATE_DIR" = "$(dump_dir state)"

- name: Custom shared bin preserves an unrelated Node executable
- name: Custom shared bin refreshes Node even in system-first mode
run: |
set -euo pipefail
FOREIGN=$(mktemp -d)
FAKE_TGZ=$(mktemp)
mkdir -p "$FOREIGN/.local/bin"
mkdir -p "$FOREIGN/.local/bin" "$FOREIGN/user-bin"
printf '#!/bin/sh\necho foreign-node\n' > "$FOREIGN/.local/bin/node"
chmod +x "$FOREIGN/.local/bin/node"
cp "$FOREIGN/.local/bin/node" "$FOREIGN/user-bin/node"
export HOME="$FOREIGN"
export USERPROFILE="$FOREIGN"
export GITHUB_ACTION_REPOSITORY=voidzero-dev/setup-vp
unset VP_VPDIRS_AWARE
export VP_BIN_DIR="$FOREIGN/.local/bin"
export VP_DATA_DIR="$FOREIGN/.local/share/vite-plus"
export VP_CACHE_DIR="$FOREIGN/.cache/vite-plus"
# Override the setting for this job. A custom bin can be shared. CI
# must not replace a Node executable that Vite+ does not own.
export VP_NODE_MANAGER=
# Explicitly sharing the Vite+ bin directory accepts replacement there; system-first tools elsewhere stay intact.
export VP_NODE_MANAGER=no
export PATH="$FOREIGN/user-bin:$PATH"
unset VP_HOME
unset XDG_DATA_HOME XDG_CACHE_HOME XDG_CONFIG_HOME XDG_STATE_HOME
VP_LOCAL_TGZ="$FAKE_TGZ" VP_VERSION=local-foreign-node bash packages/cli/install.sh

test ! -d "$FOREIGN/.vite-plus"
test -f "$FOREIGN/.local/bin/node"
test ! -L "$FOREIGN/.local/bin/node"
test "$("$FOREIGN/.local/bin/node")" = "foreign-node"
test -L "$FOREIGN/.local/bin/node"
test "$("$FOREIGN/user-bin/node")" = "foreign-node"

- name: Existing ~/.vite-plus is reused
run: |
Expand Down Expand Up @@ -1522,7 +1523,7 @@ jobs:
if (Test-Path $legacyRoot) { throw "implode left the monolithic root" }
if ($removingRoots.Count -ne 0) { throw "implode left a renamed monolithic root" }

- name: PowerShell installer rejects an unversioned Node sidecar
- name: PowerShell installer refreshes shared-bin Node even in system-first mode
shell: pwsh
run: |
$ErrorActionPreference = "Stop"
Expand All @@ -1532,10 +1533,13 @@ jobs:
$cache = Join-Path $root "cache"
$node = Join-Path $bin "node.exe"
$pointer = Join-Path $bin "node.shim"
$externalNode = Join-Path $root "user-bin/node.exe"
$fakeTgz = Join-Path $root "vite-plus.tgz"
Remove-Item -Recurse -Force $root -ErrorAction SilentlyContinue
New-Item -ItemType Directory -Force -Path $bin | Out-Null
New-Item -ItemType Directory -Force -Path (Split-Path $externalNode) | Out-Null
[System.IO.File]::WriteAllText($node, "foreign-node")
[System.IO.File]::WriteAllText($externalNode, "external-node")
[System.IO.File]::WriteAllText($pointer, "$data`n")
New-Item -ItemType File -Force -Path $fakeTgz | Out-Null

Expand All @@ -1547,16 +1551,21 @@ jobs:
$env:VP_LOCAL_TGZ = $fakeTgz
$env:VP_SKIP_DEPS_INSTALL = "1"
$env:VP_VERSION = "local-foreign-node"
$env:VP_NODE_MANAGER = ""
# Explicitly sharing the Vite+ bin directory accepts replacement there; system-first tools elsewhere stay intact.
$env:VP_NODE_MANAGER = "no"
$env:CI = "true"

& ./packages/cli/install.ps1

if ([System.IO.File]::ReadAllText($node) -ne "foreign-node") {
Write-Error "install.ps1 replaced an unrelated node.exe"
$trampoline = Join-Path $data "current/bin/vp-shim.exe"
if ((Get-FileHash $node).Hash -ne (Get-FileHash $trampoline).Hash) {
Write-Error "install.ps1 did not refresh node.exe in the configured bin directory"
}
if ([System.IO.File]::ReadAllText($pointer) -ne [System.IO.File]::ReadAllText((Join-Path $bin "vp.shim"))) {
Write-Error "install.ps1 did not refresh the Node shim pointer"
}
if ([System.IO.File]::ReadAllText($pointer) -ne "$data`n") {
Write-Error "install.ps1 changed the unversioned node.shim"
if ([System.IO.File]::ReadAllText($externalNode) -ne "external-node") {
Write-Error "install.ps1 replaced node.exe outside the configured bin directory"
}

- name: Complete directory overrides keep the split layout through the trampoline
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,35 @@ steps = [
["vpt", "stat-file", "user/.zshenv", "--assert", "missing"],
]

[[case]]
name = "command_self_setup_combined_default"
vp = "global"
skip-platforms = ["windows"]
steps = [
{ argv = ["vpt", "mkdir", "-p", "external", "home"], snapshot = false },
{ argv = ["vpt", "cp", "$VP_HOME/bin/vp", "external/vp"], snapshot = false },
{ argv = ["vpt", "chmod", "+x", "external/vp"], snapshot = false },
{ argv = ["./external/vp"], tty = false, envs = [["VP_HOME", "${workspace}/home"], ["VP_SKIP_DEPS_INSTALL", "1"], ["VP_VERSION", "combined-default"], ["VP_SELF_SETUP_NO_MODIFY_PATH", "1"], ["CI", "true"], ["VP_PNPM_MANAGER", "no"]], comment = "Without an explicit Node override, automatic setup still enables both; a family override takes precedence", snapshot = false },
["vpt", "print-file", "home/config.json"],
]

[[case]]
name = "command_self_setup_package_manager_choices"
vp = "global"
skip-platforms = ["windows"]
env = { VP_SKIP_DEPS_INSTALL = "1", VP_SELF_SETUP_NO_MODIFY_PATH = "1", VP_NODE_MANAGER = "no" }
steps = [
{ argv = ["vpt", "mkdir", "-p", "external", "home"], snapshot = false },
{ argv = ["vpt", "cp", "$VP_HOME/bin/vp", "external/vp"], snapshot = false },
{ argv = ["vpt", "chmod", "+x", "external/vp"], snapshot = false },
{ argv = ["./external/vp"], tty = false, envs = [["VP_HOME", "${workspace}/home"], ["VP_VERSION", "pm-default"], ["VP_PM_MANAGER", "yes"], ["VP_PNPM_MANAGER", "no"], ["VP_YARN_MANAGER", "no"]], comment = "Package-manager choices are independent of Node; pnpm and Yarn override the group default", snapshot = false },
["vpt", "print-file", "home/config.json"],
{ argv = ["./external/vp"], tty = false, envs = [["VP_HOME", "${workspace}/home"], ["VP_VERSION", "pm-overrides"], ["VP_PM_MANAGER", "no"], ["VP_NPM_MANAGER", "yes"], ["VP_BUN_MANAGER", "yes"]], comment = "npm and Bun can opt into management while the other families prefer system tools", snapshot = false },
["vpt", "print-file", "home/config.json"],
{ argv = ["./external/vp"], tty = false, envs = [["VP_HOME", "${workspace}/home"], ["VP_VERSION", "pm-preserved"], ["VP_NODE_MANAGER", "yes"]], comment = "Changing only Node management preserves all saved package-manager choices", snapshot = false },
["vpt", "print-file", "home/config.json"],
]

[[case]]
name = "command_self_setup_shell_warning"
vp = "global"
Expand All @@ -68,3 +97,28 @@ steps = [
["vpt", "stat-file", "user/.bashrc", "--assert", "dir"],
{ argv = ["./home/bin/vp", "--help"], envs = [["VP_HOME", "${workspace}/home"]], comment = "The installed CLI accepts commands after the warning", snapshot = false },
]

[[case]]
name = "command_self_setup_mixed_shim_refresh"
vp = "global"
skip-platforms = ["windows"]
env = { VP_SKIP_DEPS_INSTALL = "1", VP_SELF_SETUP_NO_MODIFY_PATH = "1" }
steps = [
{ argv = ["vpt", "mkdir", "-p", "external", "home/bin", "user-bin"], snapshot = false },
{ argv = ["vpt", "cp", "$VP_HOME/bin/vp", "external/vp"], snapshot = false },
{ argv = ["vpt", "chmod", "+x", "external/vp"], snapshot = false },
{ argv = ["vpt", "write-file", "home/bin/node", "old-node-shim"], snapshot = false },
{ argv = ["vpt", "write-file", "home/bin/npm", "old-npm-shim"], snapshot = false },
{ argv = ["vpt", "write-file", "home/bin/pnpm", "old-pnpm-shim"], snapshot = false },
{ argv = ["vpt", "write-file", "home/bin/pnpx", "old-pnpx-shim"], snapshot = false },
{ argv = ["vpt", "write-file", "user-bin/node", "user-node-shim"], snapshot = false },
{ argv = ["vpt", "write-file", "user-bin/pnpm", "user-pnpm-shim"], snapshot = false },
{ argv = ["./external/vp"], tty = false, envs = [["VP_HOME", "${workspace}/home"], ["VP_VERSION", "mixed-shims"], ["VP_NODE_MANAGER", "no"], ["VP_PM_MANAGER", "no"], ["VP_PNPM_MANAGER", "yes"], ["PATH", "${workspace}/user-bin${PATH_SEPARATOR}${PATH}"]], comment = "Installation refreshes every Vite+ shim regardless of management preferences, leaving user tools elsewhere on PATH untouched", snapshot = false },
["vpt", "stat-file", "home/bin/node", "--assert", "symlink"],
["vpt", "stat-file", "home/bin/npm", "--assert", "symlink"],
["vpt", "stat-file", "home/bin/pnpm", "--assert", "symlink"],
["vpt", "stat-file", "home/bin/pnpx", "--assert", "symlink"],
["vpt", "print-file", "user-bin/node"],
["vpt", "print-file", "user-bin/pnpm"],
["vpt", "print-file", "home/config.json"],
]
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,7 @@ home/current/bin/.vp-setup-complete: file

```
{
"nodeShimMode": "system_first",
"packageManagerShimModes": {
"bun": "system_first",
"npm": "system_first",
"pnpm": "system_first",
"yarn": "system_first"
}
"nodeShimMode": "system_first"
}
```

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# command_self_setup_combined_default

## `vpt mkdir -p external home`


## `vpt cp $VP_HOME/bin/vp external/vp`


## `vpt chmod +x external/vp`


## `VP_HOME=${workspace}/home VP_SKIP_DEPS_INSTALL=1 VP_VERSION=combined-default VP_SELF_SETUP_NO_MODIFY_PATH=1 CI=true VP_PNPM_MANAGER=no ./external/vp`

Without an explicit Node override, automatic setup still enables both; a family override takes precedence


## `vpt print-file home/config.json`

```
{
"packageManagerShimModes": {
"bun": "managed",
"npm": "managed",
"pnpm": "system_first",
"yarn": "managed"
}
}
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
# command_self_setup_mixed_shim_refresh

## `vpt mkdir -p external home/bin user-bin`


## `vpt cp $VP_HOME/bin/vp external/vp`


## `vpt chmod +x external/vp`


## `vpt write-file home/bin/node old-node-shim`


## `vpt write-file home/bin/npm old-npm-shim`


## `vpt write-file home/bin/pnpm old-pnpm-shim`


## `vpt write-file home/bin/pnpx old-pnpx-shim`


## `vpt write-file user-bin/node user-node-shim`


## `vpt write-file user-bin/pnpm user-pnpm-shim`


## `VP_HOME=${workspace}/home VP_VERSION=mixed-shims VP_NODE_MANAGER=no VP_PM_MANAGER=no VP_PNPM_MANAGER=yes PATH=${workspace}/user-bin${PATH_SEPARATOR}${PATH} ./external/vp`

Installation refreshes every Vite+ shim regardless of management preferences, leaving user tools elsewhere on PATH untouched


## `vpt stat-file home/bin/node --assert symlink`

```
home/bin/node: symlink
```

## `vpt stat-file home/bin/npm --assert symlink`

```
home/bin/npm: symlink
```

## `vpt stat-file home/bin/pnpm --assert symlink`

```
home/bin/pnpm: symlink
```

## `vpt stat-file home/bin/pnpx --assert symlink`

```
home/bin/pnpx: symlink
```

## `vpt print-file user-bin/node`

```
user-node-shim
```

## `vpt print-file user-bin/pnpm`

```
user-pnpm-shim
```

## `vpt print-file home/config.json`

```
{
"nodeShimMode": "system_first",
"packageManagerShimModes": {
"bun": "system_first",
"npm": "system_first",
"pnpm": "managed",
"yarn": "system_first"
}
}
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# command_self_setup_package_manager_choices

## `vpt mkdir -p external home`


## `vpt cp $VP_HOME/bin/vp external/vp`


## `vpt chmod +x external/vp`


## `VP_HOME=${workspace}/home VP_VERSION=pm-default VP_PM_MANAGER=yes VP_PNPM_MANAGER=no VP_YARN_MANAGER=no ./external/vp`

Package-manager choices are independent of Node; pnpm and Yarn override the group default


## `vpt print-file home/config.json`

```
{
"nodeShimMode": "system_first",
"packageManagerShimModes": {
"bun": "managed",
"npm": "managed",
"pnpm": "system_first",
"yarn": "system_first"
}
}
```

## `VP_HOME=${workspace}/home VP_VERSION=pm-overrides VP_PM_MANAGER=no VP_NPM_MANAGER=yes VP_BUN_MANAGER=yes ./external/vp`

npm and Bun can opt into management while the other families prefer system tools


## `vpt print-file home/config.json`

```
{
"nodeShimMode": "system_first",
"packageManagerShimModes": {
"bun": "managed",
"npm": "managed",
"pnpm": "system_first",
"yarn": "system_first"
}
}
```

## `VP_HOME=${workspace}/home VP_VERSION=pm-preserved VP_NODE_MANAGER=yes ./external/vp`

Changing only Node management preserves all saved package-manager choices


## `vpt print-file home/config.json`

```
{
"packageManagerShimModes": {
"bun": "managed",
"npm": "managed",
"pnpm": "system_first",
"yarn": "system_first"
}
}
```
Loading
Loading