Skip to content

Commit ea2ea77

Browse files
committed
chore(vite-plus): đź”§ update installation instructions for devcontainer user
- clarify installation path for Vite+ CLI in README - modify devcontainer-feature.json description for clarity - enhance install.sh to ensure per-user installation - simplify test.sh to check for vp CLI availability
1 parent 5dc091f commit ea2ea77

File tree

4 files changed

+69
-30
lines changed

4 files changed

+69
-30
lines changed

‎src/vite-plus/README.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ Add this feature to your `devcontainer.json`:
4747
```
4848

4949
This will:
50-
1. Install `vp` (Vite+ unified CLI) globally
50+
1. Install `vp` (Vite+ unified CLI) for the devcontainer user
5151
2. Install Oxc and Vitest VS Code extensions
5252
3. Configure Oxc as the default formatter
5353
4. Enable format-on-save and auto-fix
@@ -76,7 +76,7 @@ If you prefer standalone tools instead of or alongside `vp`:
7676

7777
| Option | Type | Default | Description |
7878
|--------|------|---------|-------------|
79-
| `installVitePlus` | boolean | `true` | Install Vite+ unified CLI (`vp`) via the official installer |
79+
| `installVitePlus` | boolean | `true` | Install Vite+ unified CLI (`vp`) for the devcontainer user (`~/.vite-plus/bin`) |
8080
| `installVite` | boolean | `false` | Install standalone Vite CLI via npm (not needed with `vp`) |
8181
| `installVitest` | boolean | `false` | Install standalone Vitest CLI via npm (not needed with `vp`) |
8282
| `installOxc` | boolean | `false` | Install Oxc language server via npm (not needed with `vp`) |

‎src/vite-plus/devcontainer-feature.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"installVitePlus": {
99
"type": "boolean",
1010
"default": true,
11-
"description": "Install Vite+ unified CLI (vp) globally via the official installer"
11+
"description": "Install Vite+ unified CLI (vp) for the devcontainer user (~/.vite-plus/bin)"
1212
},
1313
"installVite": {
1414
"type": "boolean",

‎src/vite-plus/install.sh‎

Lines changed: 63 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,25 @@ if [ "$USERNAME" = "automatic" ] || [ "$USERNAME" = "root" ]; then
3434
fi
3535
fi
3636

37+
# Ensure apt is in non-interactive mode
38+
export DEBIAN_FRONTEND=noninteractive
39+
40+
# Update apt if needed
41+
apt_get_update() {
42+
if [ "$(find /var/lib/apt/lists/* | wc -l)" = "0" ]; then
43+
echo "Running apt-get update..."
44+
apt-get update -y
45+
fi
46+
}
47+
48+
# Check and install packages
49+
check_packages() {
50+
if ! dpkg -s "$@" > /dev/null 2>&1; then
51+
apt_get_update
52+
apt-get -y install --no-install-recommends "$@"
53+
fi
54+
}
55+
3756
# Check if node/npm is available (needed for fallback tools and npm-based installs)
3857
if ! command -v npm >/dev/null 2>&1; then
3958
echo "❌ npm not found. Please ensure Node.js feature is installed first."
@@ -44,30 +63,55 @@ fi
4463
if [ "$INSTALL_VITE_PLUS" = "true" ]; then
4564
echo "📦 Installing Vite+ unified CLI (vp) via official installer..."
4665

47-
# Install vp using the official installer
48-
if curl -fsSL https://vite.plus | bash 2>/dev/null; then
49-
echo "âś… Vite+ CLI (vp) installed"
50-
51-
# Source environment to make vp available
52-
VP_HOME="${HOME}/.vite-plus"
53-
if [ -d "$VP_HOME" ]; then
54-
export PATH="${VP_HOME}/bin:${PATH}"
55-
fi
66+
# Ensure curl and ca-certificates are available
67+
check_packages curl ca-certificates
5668

57-
# Also install for the non-root user if different
58-
if [ "$USERNAME" != "root" ]; then
59-
su - "$USERNAME" -c 'curl -fsSL https://vite.plus | bash' 2>/dev/null || true
60-
fi
69+
# Download installer to a temp file to avoid pipefail issues
70+
INSTALLER_SCRIPT=$(mktemp)
71+
trap 'rm -f "$INSTALLER_SCRIPT"' EXIT
6172

62-
# Verify installation
63-
if command -v vp >/dev/null 2>&1; then
64-
VP_VERSION=$(vp --version 2>/dev/null || echo "unknown")
65-
echo " Version: ${VP_VERSION}"
73+
if ! curl -fsSL https://vite.plus -o "$INSTALLER_SCRIPT"; then
74+
echo "❌ Failed to download Vite+ installer."
75+
exit 1
76+
fi
77+
chmod 644 "$INSTALLER_SCRIPT"
78+
79+
# Install vp for the devcontainer user (per-user install in ~/.vite-plus/bin)
80+
if [ "$USERNAME" != "root" ]; then
81+
if su - "$USERNAME" -c "bash '$INSTALLER_SCRIPT'"; then
82+
USER_HOME=$(eval echo "~${USERNAME}")
83+
USER_VP_HOME="${USER_HOME}/.vite-plus"
84+
if [ -d "$USER_VP_HOME" ]; then
85+
echo "âś… Vite+ CLI (vp) installed at ${USER_VP_HOME}/bin"
86+
fi
87+
88+
# Verify vp is available for the user
89+
if su - "$USERNAME" -c 'command -v vp' >/dev/null 2>&1; then
90+
VP_VERSION=$(su - "$USERNAME" -c 'vp --version 2>/dev/null' || echo "unknown")
91+
echo " Version: ${VP_VERSION}"
92+
else
93+
echo " vp installed, will be available in new shell sessions for ${USERNAME}"
94+
fi
6695
else
67-
echo " vp installed, will be available in new shell sessions"
96+
echo "❌ Failed to install Vite+ CLI via official installer."
97+
exit 1
6898
fi
6999
else
70-
echo "⚠️ Failed to install Vite+ CLI via official installer, but continuing..."
100+
# Root-only fallback
101+
if bash "$INSTALLER_SCRIPT"; then
102+
echo "âś… Vite+ CLI (vp) installed"
103+
VP_HOME="${HOME}/.vite-plus"
104+
if [ -d "$VP_HOME" ]; then
105+
export PATH="${VP_HOME}/bin:${PATH}"
106+
fi
107+
if command -v vp >/dev/null 2>&1; then
108+
VP_VERSION=$(vp --version 2>/dev/null || echo "unknown")
109+
echo " Version: ${VP_VERSION}"
110+
fi
111+
else
112+
echo "❌ Failed to install Vite+ CLI via official installer."
113+
exit 1
114+
fi
71115
fi
72116
fi
73117

‎test/vite-plus/test.sh‎

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,9 @@ check "node is available" command -v node
1717
check "npm is available" command -v npm
1818

1919
# Check vp (Vite+ unified CLI) installation
20-
if command -v vp >/dev/null 2>&1; then
21-
check "vp CLI is available" command -v vp
22-
check "vp version displays" vp --version
23-
elif [ -f "${HOME}/.vite-plus/bin/vp" ]; then
24-
check "vp binary exists in ~/.vite-plus/bin" test -f "${HOME}/.vite-plus/bin/vp"
25-
else
26-
echo "⚠️ vp CLI not found (installVitePlus=false or installer path not in PATH)"
27-
fi
20+
# vp is required by default (installVitePlus=true), so this must pass
21+
check "vp CLI is available" command -v vp
22+
check "vp version displays" vp --version
2823

2924
# Check standalone Vite CLI (optional, not needed with vp)
3025
if command -v vite >/dev/null 2>&1; then

0 commit comments

Comments
 (0)