Skip to content

Commit d0b0d3e

Browse files
committed
fix(install): support non-interactive installation for devcontainers (#1092)
Auto-detect devcontainer environments (GitHub Codespaces, VS Code Remote Containers, DevPod) alongside CI to skip the interactive Node.js manager prompt. Add VITE_PLUS_NODE_MANAGER env var for explicit override in other non-interactive contexts. Add postCreateCommand to devcontainer.json. Closes #1079
1 parent 7e8d95e commit d0b0d3e

3 files changed

Lines changed: 33 additions & 5 deletions

File tree

.devcontainer/devcontainer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@
2626
}
2727
}
2828
}
29-
}
29+
},
30+
"postCreateCommand": "curl -fsSL https://vite.plus | bash"
3031
// Use 'mounts' to make the cargo cache persistent in a Docker Volume.
3132
// "mounts": [
3233
// {

packages/cli/install.ps1

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -205,15 +205,27 @@ function Setup-NodeManager {
205205

206206
$binPath = "$InstallDir\bin"
207207

208+
# Explicit override via environment variable
209+
if ($env:VITE_PLUS_NODE_MANAGER -eq "yes") {
210+
Refresh-Shims -BinDir $BinDir
211+
return "true"
212+
} elseif ($env:VITE_PLUS_NODE_MANAGER -eq "no") {
213+
return "false"
214+
}
215+
208216
# Check if Vite+ is already managing Node.js (bin\node.exe exists)
209217
if (Test-Path "$binPath\node.exe") {
210218
# Already managing Node.js, just refresh shims
211219
Refresh-Shims -BinDir $BinDir
212220
return "already"
213221
}
214222

215-
# Auto-enable on CI environment
216-
if ($env:CI) {
223+
# Auto-enable on CI or devcontainer environments
224+
# CI: standard CI environment variable (GitHub Actions, Travis, CircleCI, etc.)
225+
# CODESPACES: set by GitHub Codespaces (https://docs.github.com/en/codespaces)
226+
# REMOTE_CONTAINERS: set by VS Code Dev Containers extension
227+
# DEVPOD: set by DevPod (https://devpod.sh)
228+
if ($env:CI -or $env:CODESPACES -or $env:REMOTE_CONTAINERS -or $env:DEVPOD) {
217229
Refresh-Shims -BinDir $BinDir
218230
return "true"
219231
}

packages/cli/install.sh

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
# VITE_PLUS_VERSION - Version to install (default: latest)
1010
# VITE_PLUS_HOME - Installation directory (default: ~/.vite-plus)
1111
# NPM_CONFIG_REGISTRY - Custom npm registry URL (default: https://registry.npmjs.org)
12+
# VITE_PLUS_NODE_MANAGER - Set to "yes" or "no" to skip interactive prompt (for CI/devcontainers)
1213
# VITE_PLUS_LOCAL_TGZ - Path to local vite-plus.tgz (for development/testing)
1314

1415
set -e
@@ -442,15 +443,29 @@ setup_node_manager() {
442443
vp_bin="$bin_dir/vp.exe"
443444
fi
444445

446+
# Explicit override via environment variable
447+
if [ "$VITE_PLUS_NODE_MANAGER" = "yes" ]; then
448+
refresh_shims "$vp_bin"
449+
NODE_MANAGER_ENABLED="true"
450+
return 0
451+
elif [ "$VITE_PLUS_NODE_MANAGER" = "no" ]; then
452+
NODE_MANAGER_ENABLED="false"
453+
return 0
454+
fi
455+
445456
# Check if Vite+ is already managing Node.js (bin/node or bin/node.exe exists)
446457
if [ -e "$bin_path/node" ] || [ -e "$bin_path/node.exe" ]; then
447458
refresh_shims "$vp_bin"
448459
NODE_MANAGER_ENABLED="already"
449460
return 0
450461
fi
451462

452-
# Auto-enable on CI environment
453-
if [ -n "$CI" ]; then
463+
# Auto-enable on CI or devcontainer environments
464+
# CI: standard CI environment variable (GitHub Actions, Travis, CircleCI, etc.)
465+
# CODESPACES: set by GitHub Codespaces (https://docs.github.com/en/codespaces)
466+
# REMOTE_CONTAINERS: set by VS Code Dev Containers extension
467+
# DEVPOD: set by DevPod (https://devpod.sh)
468+
if [ -n "$CI" ] || [ -n "$CODESPACES" ] || [ -n "$REMOTE_CONTAINERS" ] || [ -n "$DEVPOD" ]; then
454469
refresh_shims "$vp_bin"
455470
NODE_MANAGER_ENABLED="true"
456471
return 0

0 commit comments

Comments
 (0)