@@ -34,6 +34,25 @@ if [ "$USERNAME" = "automatic" ] || [ "$USERNAME" = "root" ]; then
3434 fi
3535fi
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)
3857if ! command -v npm > /dev/null 2>&1 ; then
3958 echo " ❌ npm not found. Please ensure Node.js feature is installed first."
4463if [ " $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
72116fi
73117
0 commit comments