Files
akai-utils/scripts/check-toolchain.sh
T
david 4f03524668 chore: add JS/ESLint toolchain, refactor onclick to event delegation
- Add ESLint config for web/ui (flat config, golangci-lint-compatible)
- Add js-lint task to mise.toml (npm run lint in web/ui)
- Add ESLint check to check-toolchain.sh
- Add .golangci.yml for golangci-lint v2 with correct exclusions
- Refactor app.js: replace inline onclick with data-action + event delegation
- Add null checks and HTTP status checks to browseWavs
- Add web/ui/node_modules/ to .gitignore
2026-06-22 00:10:49 -07:00

139 lines
4.6 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 ""
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 ==="