refactor: make Node.js installation automatic in setup.sh
- setup.sh now automatically installs Node 22 via NodeSource if not found - No more separate manual Node installation step required - Simplified to single command: bash scripts/setup.sh - Works for apt/pacman/brew systems - Updated SETUP_GUIDE.md with simplified instructions - Better logging during Node installation process Users can now simply run: bash scripts/setup.sh And everything (including Node 22) will be installed automatically.
This commit is contained in:
+22
-7
@@ -268,9 +268,10 @@ if has node; then
|
||||
if [ "$NODE_MAJOR" = "22" ]; then
|
||||
skip "node v$NODE_VER (system-wide)"
|
||||
else
|
||||
warn "Node $NODE_VER found but v22 is required — upgrading via NodeSource..."
|
||||
warn "Node $NODE_VER found but v22 is required — upgrading..."
|
||||
case $PM in
|
||||
apt)
|
||||
echo " Setting up NodeSource repository..."
|
||||
curl -fsSL https://deb.nodesource.com/setup_22.x | sudo -E bash -
|
||||
sudo apt-get install -y nodejs
|
||||
if has node && [ "$(node -v | cut -d. -f1 | tr -d 'v')" = "22" ]; then
|
||||
@@ -279,26 +280,40 @@ if has node; then
|
||||
fail "Node.js upgrade failed"
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
warn "Manual upgrade needed for $PM: install Node.js 22 from official sources"
|
||||
pacman)
|
||||
install_pkg nodejs npm
|
||||
if has node; then ok "node v$(node -v) installed"; else fail "node install failed"; fi
|
||||
;;
|
||||
brew)
|
||||
install_pkg node
|
||||
if has node; then ok "node v$(node -v) installed"; else fail "node install failed"; fi
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
else
|
||||
warn "Node.js not found — installing v22 via NodeSource..."
|
||||
echo " Node.js not found — installing v22..."
|
||||
case $PM in
|
||||
apt)
|
||||
echo " Setting up NodeSource repository (this may take a moment)..."
|
||||
curl -fsSL https://deb.nodesource.com/setup_22.x | sudo -E bash -
|
||||
echo " Installing nodejs from apt..."
|
||||
sudo apt-get install -y nodejs
|
||||
if has node; then ok "node v$(node -v) installed"; else fail "node install failed"; fi
|
||||
if has node; then
|
||||
ok "node v$(node -v) installed from NodeSource"
|
||||
else
|
||||
fail "Node.js install failed"
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
pacman)
|
||||
echo " Installing nodejs from pacman..."
|
||||
install_pkg nodejs npm
|
||||
if has node; then ok "node v$(node -v) installed"; else fail "node install failed"; fi
|
||||
if has node; then ok "node v$(node -v) installed"; else fail "node install failed"; exit 1; fi
|
||||
;;
|
||||
brew)
|
||||
echo " Installing node from brew..."
|
||||
install_pkg node
|
||||
if has node; then ok "node v$(node -v) installed"; else fail "node install failed"; fi
|
||||
if has node; then ok "node v$(node -v) installed"; else fail "node install failed"; exit 1; fi
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user