Skip to content

Commit 8f7f7f4

Browse files
committed
fix(install): keep bootstrap compatible with released vp
1 parent 8b2838d commit 8f7f7f4

2 files changed

Lines changed: 33 additions & 16 deletions

File tree

packages/cli/install.ps1

Lines changed: 31 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ $PrVersion = $env:VP_PR_VERSION
3535
# pulls a coherent, clearly-defined test build.
3636
$BridgeDownloadBase = "https://registry-bridge.viteplus.dev/voidzero-dev/vite-plus"
3737
$BridgeRegistry = "https://registry-bridge.viteplus.dev/"
38-
$BootstrapNpmVersion = "10.9.4"
3938
$BootstrapPnpmVersion = "10.33.0"
4039

4140
function Write-Info {
@@ -381,6 +380,29 @@ function Resolve-BridgeCommitVersion {
381380
return "0.0.0-commit.$sha"
382381
}
383382

383+
function Invoke-BootstrapInstall {
384+
param(
385+
[string]$VpPath,
386+
[string]$PnpmVersion
387+
)
388+
389+
# PowerShell surfaces native stderr as error records. Keep warnings and
390+
# pnpm diagnostics in the captured output, then rely on the process exit code.
391+
$previousErrorActionPreference = $ErrorActionPreference
392+
try {
393+
$ErrorActionPreference = "Continue"
394+
$output = cmd /c "set CI=true && `"$VpPath`" env exec --node lts cmd.exe /d /c npx --yes pnpm@$PnpmVersion install" 2>&1
395+
$exitCode = $LASTEXITCODE
396+
} finally {
397+
$ErrorActionPreference = $previousErrorActionPreference
398+
}
399+
400+
return [PSCustomObject]@{
401+
Output = $output
402+
ExitCode = $exitCode
403+
}
404+
}
405+
384406
function Write-InstallFailure {
385407
param(
386408
[string]$LogPath,
@@ -884,32 +906,28 @@ function Main {
884906
$installLog = Join-Path $VersionDir "install.log"
885907
Push-Location $VersionDir
886908
try {
887-
# Use cmd /c so CI=true is scoped to the child process only,
888-
# avoiding leaking it into the user's shell session.
889909
# Do not pass --silent to the inner install: pnpm suppresses the
890910
# release-age error body in silent mode, which would leave
891911
# install.log empty and make the release-age gate impossible to
892912
# detect. Output is already captured to install.log here.
893-
$output = cmd /c "set CI=true && `"$BinDir\vp.exe`" env exec --node lts --npm $BootstrapNpmVersion npx --yes pnpm@$BootstrapPnpmVersion install" 2>&1
894-
$installExitCode = $LASTEXITCODE
895-
$output | Out-File $installLog
896-
if ($installExitCode -ne 0) {
913+
$result = Invoke-BootstrapInstall -VpPath "$BinDir\vp.exe" -PnpmVersion $BootstrapPnpmVersion
914+
$result.Output | Out-File $installLog
915+
if ($result.ExitCode -ne 0) {
897916
if (Test-ReleaseAgeError $installLog) {
898917
if (Confirm-ReleaseAgeOverride) {
899918
# Write the override only after explicit consent, then retry once.
900919
Write-ReleaseAgeOverride
901-
$retryOutput = cmd /c "set CI=true && `"$BinDir\vp.exe`" env exec --node lts --npm $BootstrapNpmVersion npx --yes pnpm@$BootstrapPnpmVersion install" 2>&1
902-
$retryExitCode = $LASTEXITCODE
903-
$retryOutput | Out-File $installLog
904-
if ($retryExitCode -ne 0) {
905-
Write-InstallFailure -LogPath $installLog -ExitCode $retryExitCode
920+
$retryResult = Invoke-BootstrapInstall -VpPath "$BinDir\vp.exe" -PnpmVersion $BootstrapPnpmVersion
921+
$retryResult.Output | Out-File $installLog
922+
if ($retryResult.ExitCode -ne 0) {
923+
Write-InstallFailure -LogPath $installLog -ExitCode $retryResult.ExitCode
906924
}
907925
} else {
908926
Write-ReleaseAgeFailure $installLog
909927
Exit-Installer
910928
}
911929
} else {
912-
Write-InstallFailure -LogPath $installLog -ExitCode $installExitCode
930+
Write-InstallFailure -LogPath $installLog -ExitCode $result.ExitCode
913931
}
914932
}
915933
} finally {

packages/cli/install.sh

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ PR_VERSION="${VP_PR_VERSION:-}"
4444
# pulls a coherent, clearly-defined test build.
4545
BRIDGE_DOWNLOAD_BASE="https://registry-bridge.viteplus.dev/voidzero-dev/vite-plus"
4646
BRIDGE_REGISTRY="https://registry-bridge.viteplus.dev/"
47-
BOOTSTRAP_NPM_VERSION="10.9.4"
4847
BOOTSTRAP_PNPM_VERSION="10.33.0"
4948

5049
# Colors for output
@@ -1152,12 +1151,12 @@ WRAPPER_EOF
11521151
# release-age error body in silent mode, which would leave install.log
11531152
# empty and make the release-age gate impossible to detect. Output is
11541153
# already redirected to install.log here.
1155-
if ! (cd "$VERSION_DIR" && CI=true "$vp_install_bin" env exec --node lts --npm "$BOOTSTRAP_NPM_VERSION" npx --yes "pnpm@$BOOTSTRAP_PNPM_VERSION" install > "$install_log" 2>&1); then
1154+
if ! (cd "$VERSION_DIR" && CI=true "$vp_install_bin" env exec --node lts npx --yes "pnpm@$BOOTSTRAP_PNPM_VERSION" install > "$install_log" 2>&1); then
11561155
if is_release_age_error "$install_log"; then
11571156
if confirm_release_age_override; then
11581157
# Write the override only after explicit consent, then retry once.
11591158
write_release_age_override
1160-
if ! (cd "$VERSION_DIR" && CI=true "$vp_install_bin" env exec --node lts --npm "$BOOTSTRAP_NPM_VERSION" npx --yes "pnpm@$BOOTSTRAP_PNPM_VERSION" install > "$install_log" 2>&1); then
1159+
if ! (cd "$VERSION_DIR" && CI=true "$vp_install_bin" env exec --node lts npx --yes "pnpm@$BOOTSTRAP_PNPM_VERSION" install > "$install_log" 2>&1); then
11611160
print_install_failure "$install_log"
11621161
exit 1
11631162
fi

0 commit comments

Comments
 (0)