Understand any codebase instantly. System intelligence for codebases, built for humans and AI.
TypeScript aiai-memoryclaude-codeclicode-analysiscode-mappingcode-memorycodebase-understandingcodexdeveloper-toolsllmopenclawpersistent-memoryprogram-analysissoftware-architecturesystem-intelligencesystem-mapping
fix(install): auto-install Node.js when missing or outdated (#98)
Riley Thompson57d44e2efc36
diff --git a/scripts/install/install.ps1 b/scripts/install/install.ps1index ca886f58..bd1172e6 100644--- a/scripts/install/install.ps1+++ b/scripts/install/install.ps1@@ -2,9 +2,10 @@# Ix — Windows Installer (PowerShell)## Installs everything needed to run Ix:-# 1. Docker Desktop (checks / prompts)-# 2. Backend (ArangoDB + Memory Layer via Docker)-# 3. ix CLI+# 1. Node.js (checks / installs / upgrades)+# 2. Docker Desktop (checks / prompts)+# 3. Backend (ArangoDB + Memory Layer via Docker)+# 4. ix CLI## Usage:# irm https://ix-infra.com/install.ps1 | iex@@ -26,6 +27,7 @@ $IxBin = "$IxHome\bin"$ComposeDir = "$IxHome\backend"$HealthUrl = "http://localhost:8090/v1/health"$ArangoUrl = "http://localhost:8529/_api/version"+$NodeMinMajor = 18# ── Helpers ──────────────────────────────────────────────────────────────────@@ -70,10 +72,94 @@ $Version = Get-LatestVersionWrite-Host " Version: $Version"Write-Host " Platform: windows-amd64"-# ── Step 1: Docker ───────────────────────────────────────────────────────────+# ── Step 1: Node.js ──────────────────────────────────────────────────────────Write-Host ""-Write-Host "-- 1. Docker --" -ForegroundColor White+Write-Host "-- 1. Node.js (runtime) --" -ForegroundColor White++function Get-NodeMajorVersion {+ try {+ $ver = & node -v 2>&1+ return [int]($ver -replace '^v','').Split('.')[0]+ } catch {+ return 0+ }+}++function Install-NodeJS($action) {+ $wingetAvailable = Get-Command winget -ErrorAction SilentlyContinue+ $chocoAvailable = Get-Command choco -ErrorAction SilentlyContinue++ if ($wingetAvailable) {+ Write-Host " $action Node.js via winget..."+ if ($action -eq "Upgrading") {+ winget upgrade OpenJS.NodeJS.LTS --accept-source-agreements --accept-package-agreements --silent+ } else {+ winget install OpenJS.NodeJS.LTS --accept-source-agreements --accept-package-agreements --silent+ }+ } elseif ($chocoAvailable) {+ Write-Host " $action Node.js via Chocolatey..."+ if ($action -eq "Upgrading") {+ choco upgrade nodejs-lts -y+ } else {+ choco install nodejs-lts -y+ }+ } else {+ Write-Host " $action Node.js via official installer..."+ $nodeInstaller = "$env:TEMP\node-install.msi"+ Write-Host " Downloading Node.js LTS installer..."+ # Resolve latest LTS version+ try {+ $nodeIndex = Invoke-RestMethod -Uri "https://nodejs.org/dist/index.json" -ErrorAction Stop+ $ltsEntry = $nodeIndex | Where-Object { $_.lts -ne $false } | Select-Object -First 1+ $nodeVer = $ltsEntry.version -replace '^v', ''+ } catch {+ $nodeVer = "22.14.0"+ }+ Invoke-WebRequest -Uri "https://nodejs.org/dist/v$nodeVer/node-v$nodeVer-x64.msi" `+ -OutFile $nodeInstaller -UseBasicParsing+ Write-Host " Running installer (this may take a moment)..."+ Start-Process msiexec.exe -ArgumentList "/i", $nodeInstaller, "/qn", "/norestart" -Wait -NoNewWindow+ Remove-Item $nodeInstaller -Force -ErrorAction SilentlyContinue+ }++ # Refresh PATH for current session+ $machinePath = [Environment]::GetEnvironmentVariable("PATH", "Machine")+ $userPath = [Environment]::GetEnvironmentVariable("PATH", "User")+ $env:Path = "$machinePath;$userPath"+}++$nodeCmd = Get-Command node -ErrorAction SilentlyContinue+if ($nodeCmd) {+ $currentMajor = Get-NodeMajorVersion+ if ($currentMajor -ge $NodeMinMajor) {+ $nodeVer = & node -v 2>&1+ Write-Ok "Node.js $nodeVer is installed (>= $NodeMinMajor required)"+ } else {+ $nodeVer = & node -v 2>&1+ Write-Warn "Node.js $nodeVer is too old (>= $NodeMinMajor required)"+ Install-NodeJS "Upgrading"+ $currentMajor = Get-NodeMajorVersion+ if ($currentMajor -lt $NodeMinMajor) {+ Write-Err "Node.js upgrade failed. Install Node.js $NodeMinMajor+ manually: https://nodejs.org/"+ }+ $nodeVer = & node -v 2>&1+ Write-Ok "Node.js upgraded to $nodeVer"+ }+} else {+ Install-NodeJS "Installing"+ $nodeCmd = Get-Command node -ErrorAction SilentlyContinue+ if (-not $nodeCmd) {+ Write-Err "Node.js installation failed. Install Node.js $NodeMinMajor+ manually: https://nodejs.org/"+ }+ $nodeVer = & node -v 2>&1+ Write-Ok "Node.js $nodeVer installed"+}++# ── Step 2: Docker ───────────────────────────────────────────────────────────++Write-Host ""+Write-Host "-- 2. Docker --" -ForegroundColor Whiteif ($env:IX_SKIP_BACKEND -eq "1") {Write-Host " (skipped via IX_SKIP_BACKEND=1)"@@ -104,10 +190,10 @@ if ($env:IX_SKIP_BACKEND -eq "1") {}}-# ── Step 2: Backend ──────────────────────────────────────────────────────────+# ── Step 3: Backend ──────────────────────────────────────────────────────────Write-Host ""-Write-Host "-- 2. Backend (ArangoDB + Memory Layer) --" -ForegroundColor White+Write-Host "-- 3. Backend (ArangoDB + Memory Layer) --" -ForegroundColor Whiteif ($env:IX_SKIP_BACKEND -eq "1") {Write-Host " (skipped via IX_SKIP_BACKEND=1)"@@ -145,10 +231,10 @@ if ($env:IX_SKIP_BACKEND -eq "1") {Write-Host " ArangoDB: http://localhost:8529"}-# ── Step 3: ix CLI ───────────────────────────────────────────────────────────+# ── Step 4: ix CLI ───────────────────────────────────────────────────────────Write-Host ""-Write-Host "-- 3. ix CLI --" -ForegroundColor White+Write-Host "-- 4. ix CLI --" -ForegroundColor White$TarballName = "ix-$Version-windows-amd64.zip"$TarballUrl = "https://github.com/$GithubOrg/$GithubRepo/releases/download/v$Version/$TarballName"diff --git a/scripts/install/install.sh b/scripts/install/install.shindex 9548de62..bc20b106 100755--- a/scripts/install/install.sh+++ b/scripts/install/install.sh@@ -2,9 +2,10 @@# Ix — Standalone Installer## Installs everything needed to run Ix without cloning the repo:-# 1. Docker (checks / prompts)-# 2. Backend (ArangoDB + Memory Layer via Docker)-# 3. ix CLI+# 1. Node.js (checks / installs / upgrades)+# 2. Docker (checks / prompts)+# 3. Backend (ArangoDB + Memory Layer via Docker)+# 4. ix CLI## Usage:# curl -fsSL https://ix-infra.com/install.sh | sh@@ -28,6 +29,8 @@ COMPOSE_DIR="$IX_HOME/backend"HEALTH_URL="http://localhost:8090/v1/health"ARANGO_URL="http://localhost:8529/_api/version"+NODE_MIN_MAJOR=18+# Pick a bin dir that's already in PATH and writablepick_bin_dir() {# Prefer /usr/local/bin (already in PATH everywhere)@@ -127,9 +130,116 @@ PLATFORM=$(detect_platform)echo " Version: $VERSION"echo " Platform: $PLATFORM"-# -- Step 1: Check / Install Docker --+# -- Step 1: Check / Install Node.js --++step "1. Node.js (runtime)"++node_version_major() {+ node -v 2>/dev/null | sed 's/^v//' | cut -d. -f1+}++install_or_upgrade_node() {+ local action="$1" # "Installing" or "Upgrading"+ case "$(uname -s)" in+ Darwin)+ if command -v brew >/dev/null 2>&1; then+ echo " ${action} Node.js via Homebrew..."+ if [ "$action" = "Upgrading" ]; then+ brew upgrade node 2>/dev/null || brew install node+ else+ brew install node+ fi+ else+ echo " ${action} Node.js via official installer..."+ local node_pkg arch node_ver+ node_pkg=$(mktemp /tmp/node-XXXXXX.pkg)+ arch="$(uname -m)"+ # Resolve latest LTS version dynamically+ node_ver=$(curl -fsSL "https://nodejs.org/dist/index.json" \+ | sed -n 's/.*"version":"v\([^"]*\)".*"lts":[^f].*/\1/p' \+ | head -1)+ if [ -z "$node_ver" ]; then node_ver="22.14.0"; fi+ if [ "$arch" = "arm64" ]; then+ curl -fsSL "https://nodejs.org/dist/v${node_ver}/node-v${node_ver}-darwin-arm64.pkg" -o "$node_pkg"+ else+ curl -fsSL "https://nodejs.org/dist/v${node_ver}/node-v${node_ver}-darwin-x64.pkg" -o "$node_pkg"+ fi+ sudo installer -pkg "$node_pkg" -target /+ rm -f "$node_pkg"+ fi+ ;;+ Linux)+ if command -v apt-get >/dev/null 2>&1; then+ echo " ${action} Node.js via NodeSource (apt)..."+ curl -fsSL https://deb.nodesource.com/setup_22.x | sudo -E bash -+ sudo apt-get install -y nodejs+ elif command -v dnf >/dev/null 2>&1; then+ echo " ${action} Node.js via NodeSource (dnf)..."+ curl -fsSL https://rpm.nodesource.com/setup_22.x | sudo bash -+ sudo dnf install -y nodejs+ elif command -v yum >/dev/null 2>&1; then+ echo " ${action} Node.js via NodeSource (yum)..."+ curl -fsSL https://rpm.nodesource.com/setup_22.x | sudo bash -+ sudo yum install -y nodejs+ elif command -v apk >/dev/null 2>&1; then+ echo " ${action} Node.js via apk..."+ sudo apk add --update nodejs npm+ else+ err "Could not detect a supported package manager (apt, dnf, yum, apk). Install Node.js ${NODE_MIN_MAJOR}+ manually: https://nodejs.org/"+ fi+ ;;+ MINGW*|MSYS*|CYGWIN*)+ echo ""+ echo " Node.js ${NODE_MIN_MAJOR}+ is required."+ echo " Download from: https://nodejs.org/"+ echo ""+ err "Install Node.js and re-run this installer."+ ;;+ *)+ err "Unsupported OS. Install Node.js ${NODE_MIN_MAJOR}+ manually: https://nodejs.org/"+ ;;+ esac+}++if command -v node >/dev/null 2>&1; then+ CURRENT_NODE=$(node_version_major)+ if [ "$CURRENT_NODE" -ge "$NODE_MIN_MAJOR" ]; then+ info "Node.js $(node -v) is installed (>= ${NODE_MIN_MAJOR} required)"+ else+ warn "Node.js $(node -v) is too old (>= ${NODE_MIN_MAJOR} required)"+ install_or_upgrade_node "Upgrading"+ # Re-check after upgrade+ if ! command -v node >/dev/null 2>&1; then+ err "Node.js upgrade failed. Install Node.js ${NODE_MIN_MAJOR}+ manually: https://nodejs.org/"+ fi+ CURRENT_NODE=$(node_version_major)+ if [ "$CURRENT_NODE" -lt "$NODE_MIN_MAJOR" ]; then+ err "Node.js upgrade resulted in $(node -v), still below ${NODE_MIN_MAJOR}. Install manually: https://nodejs.org/"+ fi+ info "Node.js upgraded to $(node -v)"+ fi+else+ install_or_upgrade_node "Installing"+ # Rehash PATH — brew/apt may have just added node+ hash -r 2>/dev/null || true+ if ! command -v node >/dev/null 2>&1; then+ # Try common install locations+ for p in /usr/local/bin/node /opt/homebrew/bin/node; do+ if [ -x "$p" ]; then+ export PATH="$(dirname "$p"):$PATH"+ break+ fi+ done+ fi+ if ! command -v node >/dev/null 2>&1; then+ err "Node.js installation failed. Install Node.js ${NODE_MIN_MAJOR}+ manually: https://nodejs.org/"+ fi+ info "Node.js $(node -v) installed"+fi++# -- Step 2: Check / Install Docker ---step "1. Docker"+step "2. Docker"if [ "${IX_SKIP_BACKEND:-}" = "1" ]; thenecho " (skipped via IX_SKIP_BACKEND=1)"@@ -190,9 +300,9 @@ elseinfo "Docker is running"fi-# -- Step 2: Start Backend --+# -- Step 3: Start Backend ---step "2. Backend (ArangoDB + Memory Layer)"+step "3. Backend (ArangoDB + Memory Layer)"if [ "${IX_SKIP_BACKEND:-}" = "1" ]; thenecho " (skipped via IX_SKIP_BACKEND=1)"@@ -248,9 +358,9 @@ elseecho " ArangoDB: http://localhost:8529"fi-# -- Step 3: Install ix CLI --+# -- Step 4: Install ix CLI ---step "3. ix CLI"+step "4. ix CLI"if [ "$PLATFORM" = "windows-amd64" ]; thenTARBALL_NAME="ix-${VERSION}-${PLATFORM}.zip"