fix(install-plugins): guarantee npm present, not just node>=22

BLK-013 fix-forward. Step 1 checked `node >=22` but never verified npm.
On a host where node was already recent, NODE_OK short-circuited the
installer and npm was never touched — yet GSD (gsd-pi) and ctx7 install
via `npm install -g`, so a missing npm made `make plugin` die Error 127
mid-run (distro `apt install nodejs` can ship npm as a separate package).

Add an unconditional npm guard right after the Node block:
corepack enable npm → distro package-manager install fallback → fatal
exit 1 with an actionable message if still absent. Happy path (npm
present) skips the whole block: zero behavior change on healthy machines.

shellcheck clean (only pre-existing SC1091 infos), bash -n OK. Fresh
npm-less apt host validation still pending. Closes TODO (a) 2026-06-30.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VeBXkDr74N9whdiJyjzyVN
This commit is contained in:
Bastien Chanot
2026-07-01 21:07:38 +02:00
co-authored by Claude Opus 4.8
parent 2393ca536c
commit 1f2c1cc6e7
2 changed files with 28 additions and 1 deletions
+26
View File
@@ -162,6 +162,32 @@ if [ "$NODE_OK" = false ]; then
fi
fi
# --- npm (bundled with Node, but distro `apt install nodejs` can ship it separately) ---
# BLK-013 fix-forward: node>=22 present does NOT imply npm present. GSD (gsd-pi)
# and ctx7 install via `npm install -g`, so a missing npm makes `make plugin`
# die with Error 127 mid-run. The Node block above short-circuits when node is
# already recent (NODE_OK=true) and never checks npm, so guarantee it here.
if ! command -v npm &>/dev/null; then
info "npm missing (Node without npm) — enabling via corepack, else package manager..."
if command -v corepack &>/dev/null; then
sudo corepack enable npm 2>/dev/null || corepack enable npm 2>/dev/null || true
fi
if ! command -v npm &>/dev/null; then
case $OS in
linux-apt) sudo apt-get install -y npm || true ;;
linux-dnf) sudo dnf install -y npm || true ;;
linux-pacman) sudo pacman -S --noconfirm npm || true ;;
macos) brew install node || true ;; # brew's node bundles npm
*) : ;;
esac
fi
if command -v npm &>/dev/null; then
ok "npm $(npm --version)"
else
err "npm still missing — GSD/ctx7 need it; install npm manually then re-run"; exit 1
fi
fi
# --- Rust + Cargo (for RTK) ---
if command -v cargo &>/dev/null; then
ok "Rust/Cargo $(cargo --version | awk '{print $2}')"