High-performance browser automation bridge and multi-instance orchestrator with advanced stealth injection and real-time dashboard.
chore: doctor.sh interactive install prompts + install.sh style
Data3684a27bb10b
diff --git a/doctor.sh b/doctor.shindex afe78f17..97b1da20 100755--- a/doctor.sh+++ b/doctor.sh@@ -1,168 +1,216 @@#!/usr/bin/env bashset -euo pipefail-# doctor.sh - Verify and setup development environment for pinchtab-# Checks requirements and auto-installs what it can (hooks, dependencies)-# Tells you what you need to install manually (Go, golangci-lint)+# doctor.sh — Verify and setup development environment for pinchtab+# Interactive: asks before installing anything+# Style: matches install.sh conventions+BOLD='\033[1m'+DIM='\033[2m'RED='\033[0;31m'YELLOW='\033[1;33m'GREEN='\033[0;32m'BLUE='\033[0;34m'-NC='\033[0m' # No Color+CYAN='\033[0;36m'+NC='\033[0m'-CRITICAL_FAIL=0+CRITICAL=0WARNINGS=0-INSTALLED_SOMETHING=false-echo -e "${BLUE}🩺 Pinchtab Doctor${NC}"-echo -e "${BLUE}Verifying and setting up development environment...${NC}"-echo ""+# ── Helpers ──────────────────────────────────────────────────────────-# Critical check-check_critical() {- local name="$1"- local result="$2"-- if [ "$result" = "ok" ]; then- echo -e "${GREEN}✅${NC} $name"- else- echo -e "${RED}❌${NC} $name"- echo -e " ${RED}$3${NC}"- CRITICAL_FAIL=$((CRITICAL_FAIL + 1))- fi+ok() { echo -e " ${GREEN}✅${NC} $1"; }+fail() { echo -e " ${RED}❌${NC} $1"; [ -n "${2:-}" ] && echo -e " ${DIM}$2${NC}"; CRITICAL=$((CRITICAL + 1)); }+warn() { echo -e " ${YELLOW}⚠️${NC} $1"; [ -n "${2:-}" ] && echo -e " ${DIM}$2${NC}"; WARNINGS=$((WARNINGS + 1)); }+info() { echo -e " ${CYAN}→${NC} $1"; }++confirm() {+ local prompt="$1"+ echo -ne " ${BOLD}$prompt [y/N]${NC} "+ read -r answer+ [[ "$answer" =~ ^[Yy]$ ]]}-# Warning check-check_warning() {- local name="$1"- local result="$2"-- if [ "$result" = "ok" ]; then- echo -e "${GREEN}✅${NC} $name"- else- echo -e "${YELLOW}⚠️${NC} $name"- echo -e " ${YELLOW}$3${NC}"- WARNINGS=$((WARNINGS + 1))- fi+section() {+ echo ""+ echo -e "${BLUE}━━━ $1 ━━━${NC}"+ echo ""}-echo -e "${BLUE}━━━ Go Backend Requirements ━━━${NC}"+# ── Detect OS & package manager ──────────────────────────────────────++OS="$(uname -s)"+HAS_BREW=false+HAS_APT=false+command -v brew &>/dev/null && HAS_BREW=true+command -v apt-get &>/dev/null && HAS_APT=true++# ── Start ────────────────────────────────────────────────────────────+echo ""+echo -e "${BOLD}Verifying and setting up development environment...${NC}"++section "Go Backend Requirements"++# ── Go ───────────────────────────────────────────────────────────────-# Go version (critical)if command -v go &>/dev/null; thenGO_VERSION=$(go version | awk '{print $3}' | sed 's/go//')GO_MAJOR=$(echo "$GO_VERSION" | cut -d. -f1)GO_MINOR=$(echo "$GO_VERSION" | cut -d. -f2)-+if [ "$GO_MAJOR" -ge 1 ] && [ "$GO_MINOR" -ge 25 ]; then- check_critical "Go $GO_VERSION" "ok"+ ok "Go $GO_VERSION"else- check_critical "Go $GO_VERSION" "fail" "Go 1.25+ required. Install from https://go.dev/dl/"+ fail "Go $GO_VERSION" "Go 1.25+ required."+ if $HAS_BREW && confirm "Install latest Go via brew?"; then+ brew install go+ ok "Go installed"+ else+ info "Install from https://go.dev/dl/"+ fifielse- check_critical "Go" "fail" "Go not found. Install from https://go.dev/dl/"+ fail "Go not found"+ if $HAS_BREW && confirm "Install Go via brew?"; then+ brew install go+ ok "Go installed"+ else+ info "Install from https://go.dev/dl/"+ fifi-# golangci-lint (critical)+# ── golangci-lint ────────────────────────────────────────────────────+if command -v golangci-lint &>/dev/null; then- LINT_VERSION=$(golangci-lint --version 2>/dev/null | head -1 | awk '{print $4}')- check_critical "golangci-lint $LINT_VERSION" "ok"+ LINT_VERSION=$(golangci-lint version --short 2>/dev/null || golangci-lint --version 2>/dev/null | head -1 | awk '{print $4}')+ ok "golangci-lint $LINT_VERSION"else- check_critical "golangci-lint" "fail" "Required for pre-commit checks. Install: brew install golangci-lint or go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest"+ fail "golangci-lint" "Required for pre-commit hooks and CI."+ if $HAS_BREW && confirm "Install golangci-lint via brew?"; then+ brew install golangci-lint+ ok "golangci-lint installed"+ elif command -v go &>/dev/null && confirm "Install golangci-lint via go install?"; then+ go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest+ ok "golangci-lint installed"+ else+ info "Install: brew install golangci-lint"+ info " or: go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest"+ fifi-# Git hooks (auto-install if missing)+# ── Git hooks ────────────────────────────────────────────────────────+if [ -f ".git/hooks/pre-commit" ]; then- check_warning "Git hooks installed" "ok"+ ok "Git hooks installed"else- echo -e "${YELLOW}⚠️${NC} Git hooks not installed"- echo -e " ${BLUE}Installing git hooks...${NC}"- ./scripts/install-hooks.sh- echo -e "${GREEN} ✅ Git hooks installed${NC}"- INSTALLED_SOMETHING=true+ warn "Git hooks not installed"+ if confirm "Install git hooks now?"; then+ ./scripts/install-hooks.sh 2>/dev/null || {+ cp scripts/pre-commit .git/hooks/pre-commit+ chmod +x .git/hooks/pre-commit+ }+ ok "Git hooks installed"+ fifi-# Go modules (auto-download if needed)+# ── Go dependencies ─────────────────────────────────────────────────+if [ -f "go.mod" ]; then- # Check if dependencies are downloaded- if go list -m all &>/dev/null; then- check_warning "Go dependencies" "ok"+ if go list -m all &>/dev/null 2>&1; then+ ok "Go dependencies"else- echo -e "${YELLOW}⚠️${NC} Go dependencies not downloaded"- echo -e " ${BLUE}Downloading dependencies...${NC}"- go mod download- echo -e "${GREEN} ✅ Dependencies downloaded${NC}"- INSTALLED_SOMETHING=true+ warn "Go dependencies not downloaded"+ if confirm "Download Go dependencies now?"; then+ go mod download+ ok "Go dependencies downloaded"+ fifi-else- check_warning "go.mod" "fail" "go.mod not found"fi-echo ""-echo -e "${BLUE}━━━ Dashboard Requirements (React/TypeScript) ━━━${NC}"-echo ""+section "Dashboard Requirements (React/TypeScript)"-# Check if dashboard directory existsif [ -d "dashboard" ]; then- # Node.js (critical for dashboard)++ # ── Node.js ──────────────────────────────────────────────────────+if command -v node &>/dev/null; thenNODE_VERSION=$(node -v | sed 's/v//')NODE_MAJOR=$(echo "$NODE_VERSION" | cut -d. -f1)-+if [ "$NODE_MAJOR" -ge 18 ]; then- check_warning "Node.js $NODE_VERSION" "ok"+ ok "Node.js $NODE_VERSION"else- check_warning "Node.js $NODE_VERSION" "fail" "Node 18+ recommended. Current: $NODE_VERSION"+ warn "Node.js $NODE_VERSION" "Node 18+ recommended."fielse- check_warning "Node.js" "fail" "Optional for dashboard. Install from https://nodejs.org"+ warn "Node.js not found" "Optional — needed for dashboard development."+ if $HAS_BREW && confirm "Install Node.js via brew?"; then+ brew install node+ ok "Node.js installed"+ else+ info "Install from https://nodejs.org"+ fifi- # Bun (warning)+ # ── Bun ────────────────────────────────────────────────────────+if command -v bun &>/dev/null; thenBUN_VERSION=$(bun -v)- check_warning "Bun $BUN_VERSION" "ok"+ ok "Bun $BUN_VERSION"else- check_warning "Bun" "fail" "Optional for dashboard. Install: curl -fsSL https://bun.sh/install | bash"+ warn "Bun not found" "Optional — used for fast dashboard builds."+ if confirm "Install Bun?"; then+ curl -fsSL https://bun.sh/install | bash+ ok "Bun installed (restart shell to use)"+ else+ info "Install: curl -fsSL https://bun.sh/install | bash"+ fifi- # Dashboard deps installed+ # ── Dashboard deps ─────────────────────────────────────────────+if [ -d "dashboard/node_modules" ]; then- check_warning "Dashboard dependencies" "ok"+ ok "Dashboard dependencies"else- check_warning "Dashboard dependencies" "fail" "Run: cd dashboard && bun install (or npm install)"+ warn "Dashboard dependencies not installed"+ if command -v bun &>/dev/null; then+ if confirm "Install dashboard dependencies via bun?"; then+ (cd dashboard && bun install)+ ok "Dashboard dependencies installed"+ fi+ elif command -v npm &>/dev/null; then+ if confirm "Install dashboard dependencies via npm?"; then+ (cd dashboard && npm install)+ ok "Dashboard dependencies installed"+ fi+ else+ info "Run: cd dashboard && bun install"+ fifi+else- echo -e "${YELLOW}⚠️${NC} Dashboard not found (optional)"+ echo -e " ${DIM}Dashboard not found (optional)${NC}"fi-echo ""-echo -e "${BLUE}━━━ Summary ━━━${NC}"-echo ""+section "Summary"-if [ $CRITICAL_FAIL -eq 0 ] && [ $WARNINGS -eq 0 ]; then- if [ "$INSTALLED_SOMETHING" = true ]; then- echo -e "${GREEN}✅ Setup complete! Auto-installed missing components.${NC}"- else- echo -e "${GREEN}✅ All checks passed! You're ready to develop.${NC}"- fi+if [ $CRITICAL -eq 0 ] && [ $WARNINGS -eq 0 ]; then+ echo -e " ${GREEN}${BOLD}All checks passed!${NC} You're ready to develop."echo ""- echo "Next steps:"- echo " go build ./cmd/pinchtab # Build pinchtab"- echo " go test ./... # Run tests"- exit 0-elif [ $CRITICAL_FAIL -eq 0 ]; then- if [ "$INSTALLED_SOMETHING" = true ]; then- echo -e "${GREEN}✅ Auto-installed what I could.${NC}"- fi- echo -e "${YELLOW}⚠️ $WARNINGS warning(s). Development is possible but some tools are missing.${NC}"+ echo -e " ${DIM}Next steps:${NC}"+ echo -e " go build ./cmd/pinchtab ${DIM}# Build${NC}"+ echo -e " go test ./... ${DIM}# Test${NC}"exit 0-else- echo -e "${RED}❌ $CRITICAL_FAIL critical issue(s). Install these manually:${NC}"- [ $WARNINGS -gt 0 ] && echo -e "${YELLOW}⚠️ $WARNINGS warning(s).${NC}"+fi++[ $CRITICAL -gt 0 ] && echo -e " ${RED}❌ $CRITICAL critical issue(s) remaining${NC}"+[ $WARNINGS -gt 0 ] && echo -e " ${YELLOW}⚠️ $WARNINGS warning(s)${NC}"++if [ $CRITICAL -gt 0 ]; thenecho ""- echo "After installing, run ./doctor.sh again."+ echo -e " ${DIM}After installing, run ./doctor.sh again.${NC}"exit 1fi++exit 0