Files
david f804ad8a41 feat: expanded toolchain check + install-all task
check-toolchain.sh now covers:
- golangci-lint
- npm
- web/ui node_modules (JS deps)
- electron node_modules (electron deps)

New install-all task (scripts/install-deps.sh):
- mise install (go, node, golangci-lint)
- cd web/ui && npm install
- cd electron && npm install

Usage:
  mise run check-toolchain   # audit everything
  mise run install-all       # install all deps from scratch
2026-06-22 03:08:40 -07:00

187 lines
6.3 KiB
Bash
Executable File

#!/usr/bin/env bash
# Check core toolchain: gcc, homebrew, mise, go, node.
# Usage: ./scripts/check-toolchain.sh
set -euo pipefail
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
NC='\033[0m'
ok() { echo -e " ${GREEN}${NC} $1"; }
warn() { echo -e " ${YELLOW}!${NC} $1"; }
fail() { echo -e " ${RED}${NC} $1"; }
echo "=== Core Toolchain Check ==="
echo ""
# ─── GCC / C Compiler ──────────────────────────────────────────────────
echo "C Compiler:"
if command -v gcc &>/dev/null; then
gcc_ver=$(gcc --version 2>/dev/null | head -1)
ok "gcc found: $gcc_ver"
elif command -v cc &>/dev/null; then
cc_ver=$(cc --version 2>/dev/null | head -1)
ok "cc found: $cc_ver"
elif command -v clang &>/dev/null; then
clang_ver=$(clang --version 2>/dev/null | head -1)
ok "clang found: $clang_ver"
else
fail "No C compiler found"
echo " Install: brew install gcc (macOS) or sudo apt install build-essential (Linux)"
exit 1
fi
# Verify gcc can compile (catches broken Xcode toolchain on macOS)
tmp_src=$(mktemp /tmp/toolchain_test.XXXXXX.c)
tmp_bin=$(mktemp /tmp/toolchain_test.XXXXXX)
trap 'rm -f "$tmp_src" "$tmp_bin"' EXIT
cat > "$tmp_src" << 'EOF'
int main(void) { return 0; }
EOF
if cc "$tmp_src" -o "$tmp_bin" 2>/dev/null || gcc "$tmp_src" -o "$tmp_bin" 2>/dev/null; then
ok "gcc can compile test program"
rm -f "$tmp_bin"
else
fail "gcc cannot compile — toolchain may be broken"
echo " Fix: xcode-select --install (macOS) or reinstall gcc"
exit 1
fi
echo ""
# ─── Homebrew ──────────────────────────────────────────────────────────
echo "Homebrew:"
if command -v brew &>/dev/null; then
brew_path=$(which brew)
ok "brew found at $brew_path"
else
warn "brew not found"
if [[ "$(uname)" == "Darwin" ]]; then
echo " Install: /bin/bash -c \"\$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)\""
fi
fi
echo ""
# ─── Mise ──────────────────────────────────────────────────────────────
echo "Mise:"
if command -v mise &>/dev/null; then
mise_ver=$(mise --version 2>/dev/null)
ok "mise found: $mise_ver"
else
warn "mise not found"
if command -v brew &>/dev/null; then
echo " Install: brew install mise"
else
echo " Install: curl https://mise.run | sh"
fi
fi
echo ""
# ─── Go ────────────────────────────────────────────────────────────────
echo "Go:"
if command -v go &>/dev/null; then
go_ver=$(go version 2>/dev/null)
ok "go found: $go_ver"
else
fail "go not found"
if command -v mise &>/dev/null; then
echo " Install: mise install go"
else
echo " Install: brew install go (macOS) or use mise"
fi
exit 1
fi
echo ""
# ─── gopls (Go LSP) ────────────────────────────────────────────────────
echo "gopls (Go language server):"
if command -v gopls &>/dev/null; then
gopls_ver=$(gopls version 2>/dev/null)
ok "gopls found: $gopls_ver"
else
warn "gopls not found (recommended for IDE support)"
echo " Install: go install golang.org/x/tools/gopls@latest"
echo " (ensure $(go env GOPATH)/bin is in PATH)"
fi
echo ""
# ─── Node ──────────────────────────────────────────────────────────────
echo "Node:"
if command -v node &>/dev/null; then
node_ver=$(node --version 2>/dev/null)
ok "node found: $node_ver"
else
warn "node not found (required only for Electron)"
if command -v mise &>/dev/null; then
echo " Install: mise install node"
fi
fi
echo ""
# ─── golangci-lint ──────────────────────────────────────────────────────
echo "golangci-lint:"
if command -v golangci-lint &>/dev/null; then
gcl_ver=$(golangci-lint --version 2>/dev/null)
ok "golangci-lint found: $gcl_ver"
else
warn "golangci-lint not found"
echo " Install: mise install golangci-lint"
fi
echo ""
echo "=== JS / Node ==="
echo ""
# ─── npm ────────────────────────────────────────────────────────────────
echo "npm:"
if command -v npm &>/dev/null; then
npm_ver=$(npm --version 2>/dev/null)
ok "npm found: v$npm_ver"
else
warn "npm not found"
echo " Install: mise install node"
fi
echo ""
# ─── web/ui deps (eslint, globals) ──────────────────────────────────────
echo "web/ui dependencies:"
if [ -d web/ui/node_modules ] && [ -f web/ui/node_modules/.bin/eslint ]; then
ok "web/ui/node_modules installed"
else
warn "web/ui/node_modules not installed"
echo " Install: cd web/ui && npm install"
fi
echo ""
# ─── electron deps ──────────────────────────────────────────────────────
echo "electron dependencies:"
if [ -d electron/node_modules ] && [ -f electron/node_modules/.bin/electron ]; then
ok "electron/node_modules installed"
else
warn "electron/node_modules not installed"
echo " Install: cd electron && npm install"
fi
echo ""
echo "=== JS Linting (ESLint) ==="
if [ -f web/ui/node_modules/.bin/eslint ]; then
ok "ESLint installed at web/ui/node_modules/.bin/eslint"
eslint_ver=$(cd web/ui && ./node_modules/.bin/eslint --version 2>/dev/null)
ok "ESLint: $eslint_ver"
else
warn "ESLint not installed (needed for web UI linting)"
echo " Install: cd web/ui && npm install"
fi
echo ""
echo "=== Core toolchain check complete ==="