update-all.sh 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. #!/usr/bin/env bash
  2. # ============================================================
  3. # Claude Code — Update all components
  4. # Pulls latest config, updates submodules, refreshes symlinks,
  5. # and runs doctor to verify.
  6. # ============================================================
  7. set -euo pipefail
  8. RED='\033[0;31m'; GREEN='\033[0;32m'; YELLOW='\033[1;33m'; BLUE='\033[0;34m'; NC='\033[0m'
  9. ok() { echo -e "${GREEN}✓${NC} $1"; }
  10. warn() { echo -e "${YELLOW}⚠${NC} $1"; }
  11. info() { echo -e "${BLUE}→${NC} $1"; }
  12. REPO="$(cd "$(dirname "$0")" && pwd)"
  13. VERSION=$(cat "$REPO/version.txt" 2>/dev/null || echo "unknown")
  14. echo ""
  15. echo "═══ claude-config update (v${VERSION}) ═══"
  16. echo ""
  17. # ── 1. Pull latest config ──
  18. echo "── Pulling latest config..."
  19. cd "$REPO"
  20. if git pull --rebase 2>/dev/null; then
  21. ok "Config repo updated"
  22. else
  23. warn "git pull failed — check for uncommitted changes"
  24. fi
  25. # ── 2. Update GStack submodule ──
  26. echo ""
  27. echo "── Updating GStack submodule..."
  28. if git submodule update --remote skills-external/gstack 2>/dev/null; then
  29. if [ -d "skills-external/gstack" ]; then
  30. cd skills-external/gstack && ./setup 2>/dev/null && cd "$REPO"
  31. ok "GStack updated"
  32. fi
  33. else
  34. warn "GStack submodule update failed — run: git submodule update --init"
  35. fi
  36. # ── 3. Update RTK (if pinned version available) ──
  37. echo ""
  38. echo "── Updating RTK..."
  39. if command -v cargo &>/dev/null; then
  40. RTK_VERSION=""
  41. if [ -f "$REPO/plugins.lock.json" ] && command -v python3 &>/dev/null; then
  42. RTK_VERSION=$(python3 -c "
  43. import json
  44. with open('$REPO/plugins.lock.json') as f:
  45. d = json.load(f)
  46. print(d.get('rtk',{}).get('version',''))
  47. " 2>/dev/null || true)
  48. fi
  49. if [ -n "$RTK_VERSION" ] && [ "$RTK_VERSION" != "latest" ]; then
  50. info "Pinned version: $RTK_VERSION"
  51. cargo install --git https://github.com/rtk-ai/rtk --tag "$RTK_VERSION" --force 2>/dev/null \
  52. && ok "RTK updated to $RTK_VERSION" \
  53. || warn "RTK update failed"
  54. else
  55. info "No pinned version — installing latest"
  56. cargo install --git https://github.com/rtk-ai/rtk --force 2>/dev/null \
  57. && ok "RTK updated (latest)" \
  58. || warn "RTK update failed"
  59. fi
  60. else
  61. warn "Cargo not available — skipping RTK"
  62. fi
  63. # ── 4. Refresh symlinks ──
  64. echo ""
  65. echo "── Refreshing symlinks..."
  66. bash "$REPO/link.sh"
  67. # ── 5. Run doctor ──
  68. echo ""
  69. bash "$REPO/doctor.sh"