Skip to content

Commit 47ea157

Browse files
committed
fix(install): only cleanup semver-format version directories
The cleanup_old_versions function was deleting non-semver directories like 'local-dev' when they had the oldest birth time and there were 5+ other versions. This caused intermittent failures in bootstrap-cli when the binary was deleted between install and setup_node_manager. Fix: Only consider directories matching semver format (X.Y.Z or X.Y.Z-prerelease) for cleanup, naturally preserving 'current' symlink and development directories like 'local-dev'.
1 parent 1944f16 commit 47ea157

5 files changed

Lines changed: 35 additions & 8 deletions

File tree

.github/workflows/ci.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,7 @@ jobs:
195195
run: pnpm tsgo
196196

197197
- name: Build CLI
198+
shell: bash
198199
run: |
199200
pnpm bootstrap-cli:ci
200201
if [[ "$RUNNER_OS" == "Windows" ]]; then

.github/workflows/e2e-test.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,7 @@ jobs:
264264
path: tmp/tgz
265265

266266
- name: Install vp CLI
267+
shell: bash
267268
run: |
268269
node $GITHUB_WORKSPACE/packages/tools/src/install-global-cli.ts vp --tgz $GITHUB_WORKSPACE/tmp/tgz/vite-plus-cli-0.0.0.tgz
269270
if [[ "$RUNNER_OS" == "Windows" ]]; then

.github/workflows/test-standalone-install.yml

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,16 @@ jobs:
7070
vp new create-vite --no-interactive --no-agent -- hello --no-interactive -t vanilla
7171
cd hello && vp run build
7272
73+
- name: Set PATH
74+
shell: bash
75+
run: |
76+
echo "$HOME/.vite-plus/bin" >> $GITHUB_PATH
77+
7378
- name: Verify bin setup
7479
run: |
7580
# Verify bin directory was created by vp env --setup
7681
BIN_PATH="$HOME/.vite-plus/bin"
82+
ls -al "$BIN_PATH"
7783
if [ ! -d "$BIN_PATH" ]; then
7884
echo "Error: Bin directory not found: $BIN_PATH"
7985
exit 1
@@ -89,10 +95,14 @@ jobs:
8995
done
9096
9197
# Verify vp env doctor works
92-
export PATH="$HOME/.vite-plus/bin:$PATH"
9398
vp env doctor
9499
vp env run --node 24 -- node -p "process.versions"
95100
101+
which node
102+
which npm
103+
which npx
104+
which vp
105+
96106
test-install-sh-arm64:
97107
name: Test install.sh (Linux ARM64 glibc via QEMU)
98108
runs-on: ubuntu-latest
@@ -165,24 +175,30 @@ jobs:
165175
run: |
166176
& ./packages/global/install.ps1
167177
168-
- name: Verify installation
178+
- name: Set PATH
179+
shell: bash
180+
run: |
181+
echo "$USERPROFILE\.vite-plus\bin" >> $GITHUB_PATH
182+
183+
- name: Verify installation on powershell
169184
shell: pwsh
170185
working-directory: ${{ runner.temp }}
171186
run: |
172-
# Refresh PATH from environment
173-
$env:Path = "$env:USERPROFILE\.vite-plus\bin;$env:Path"
187+
# Print PATH from environment
188+
echo "PATH: $env:Path"
174189
vp --version
175190
vp --help
176191
# $env:VITE_LOG = "trace"
177192
# test new command
178193
vp new create-vite --no-interactive --no-agent -- hello --no-interactive -t vanilla
179194
cd hello && vp run build
180195
181-
- name: Verify bin setup
196+
- name: Verify bin setup on powershell
182197
shell: pwsh
183198
run: |
184199
# Verify bin directory was created by vp env --setup
185200
$binPath = "$env:USERPROFILE\.vite-plus\bin"
201+
Get-ChildItem -Force $binPath
186202
if (-not (Test-Path $binPath)) {
187203
Write-Error "Bin directory not found: $binPath"
188204
exit 1
@@ -198,6 +214,10 @@ jobs:
198214
}
199215
Write-Host "Found shim: $shimFile"
200216
}
217+
where.exe node
218+
where.exe npm
219+
where.exe npx
220+
where.exe vp
201221
202222
# Verify vp env doctor works
203223
$env:Path = "$env:USERPROFILE\.vite-plus\bin;$env:Path"

packages/global/install.ps1

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,8 +170,11 @@ function Cleanup-OldVersions {
170170
param([string]$InstallDir)
171171

172172
$maxVersions = 5
173+
# Only cleanup semver format directories (0.1.0, 1.2.3-beta.1, etc.)
174+
# This excludes 'current' symlink and non-semver directories like 'local-dev'
175+
$semverPattern = '^\d+\.\d+\.\d+(-[a-zA-Z0-9.-]+)?$'
173176
$versions = Get-ChildItem -Path $InstallDir -Directory -ErrorAction SilentlyContinue |
174-
Where-Object { $_.Name -ne "current" }
177+
Where-Object { $_.Name -match $semverPattern }
175178

176179
if ($null -eq $versions -or $versions.Count -le $maxVersions) {
177180
return

packages/global/install.sh

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -452,11 +452,13 @@ cleanup_old_versions() {
452452
local max_versions=5
453453
local versions=()
454454

455-
# List version directories (exclude 'current' symlink)
455+
# List version directories (only semver format like 0.1.0, 1.2.3-beta.1)
456+
# This excludes 'current' symlink and non-semver directories like 'local-dev'
457+
local semver_regex='^[0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z0-9.-]+)?$'
456458
for dir in "$INSTALL_DIR"/*/; do
457459
local name
458460
name=$(basename "$dir")
459-
if [ "$name" != "current" ] && [ -d "$dir" ]; then
461+
if [ -d "$dir" ] && [[ "$name" =~ $semver_regex ]]; then
460462
versions+=("$dir")
461463
fi
462464
done

0 commit comments

Comments
 (0)