install.sh 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. #!/usr/bin/env bash
  2. # ============================================================
  3. # Claude Code — Bootstrap installer
  4. # Installs Claude Code CLI, authenticates, then sets up
  5. # symlinks and plugins for the claude-config repo.
  6. # ============================================================
  7. set -euo pipefail
  8. RED='\033[0;31m'; GREEN='\033[0;32m'
  9. YELLOW='\033[1;33m'; BLUE='\033[0;34m'; NC='\033[0m'
  10. ok() { echo -e "${GREEN}✓${NC} $1"; }
  11. warn() { echo -e "${YELLOW}⚠${NC} $1"; }
  12. info() { echo -e "${BLUE}→${NC} $1"; }
  13. err() { echo -e "${RED}✗${NC} $1"; exit 1; }
  14. REPO="$(cd "$(dirname "$0")" && pwd)"
  15. echo ""
  16. echo "═══ claude-config bootstrap installer ═══"
  17. echo ""
  18. # ── 1. Check prerequisites ──
  19. echo "── Checking prerequisites..."
  20. if ! command -v node &>/dev/null; then
  21. err "Node.js not found. Install it first: https://nodejs.org"
  22. fi
  23. NODE_MAJOR=$(node -v | sed 's/v//' | cut -d. -f1)
  24. if [ "$NODE_MAJOR" -lt 18 ]; then
  25. err "Node.js >= 18 required (found $(node -v))"
  26. fi
  27. ok "Node.js $(node -v)"
  28. if ! command -v npm &>/dev/null; then
  29. err "npm not found"
  30. fi
  31. ok "npm $(npm -v)"
  32. # ── 2. Install Claude Code CLI ──
  33. echo ""
  34. echo "── Installing Claude Code (latest)..."
  35. if npm install -g @anthropic-ai/claude-code@latest; then
  36. ok "Claude Code installed: $(claude --version 2>/dev/null || echo 'unknown')"
  37. else
  38. err "Claude Code installation failed"
  39. fi
  40. # ── 3. Authenticate ──
  41. echo ""
  42. echo "── Authentication"
  43. echo ""
  44. echo " You need to log in to Claude Code."
  45. echo " This will open an interactive session."
  46. echo ""
  47. printf " Press Enter to launch 'claude login'... "
  48. read -r
  49. if claude login; then
  50. ok "Authenticated"
  51. else
  52. warn "Login exited with non-zero status"
  53. warn "You can retry later with: claude login"
  54. fi
  55. # ── 4. Init git submodules ──
  56. echo ""
  57. echo "── Initializing submodules..."
  58. cd "$REPO"
  59. if git submodule update --init 2>/dev/null; then
  60. ok "Submodules initialized"
  61. else
  62. warn "Submodule init failed — some plugins may be unavailable"
  63. fi
  64. # ── 5. Symlink config into ~/.claude/ ──
  65. echo ""
  66. echo "── Setting up symlinks..."
  67. bash "$REPO/link.sh"
  68. # ── 6. Install plugins ──
  69. echo ""
  70. echo "── Installing plugins..."
  71. bash "$REPO/install-plugins.sh"
  72. # ── Done ──
  73. echo ""
  74. echo "═══════════════════════════════════════════"
  75. echo ""
  76. ok "Bootstrap complete!"
  77. echo ""
  78. echo " Start Claude Code in any project with:"
  79. echo " claude"
  80. echo ""