|
| 1 | +# Homebrew Formula |
| 2 | + |
| 3 | +Cette Formula permet l'installation de `claude-switch` via Homebrew. |
| 4 | + |
| 5 | +## Pour les Utilisateurs |
| 6 | + |
| 7 | +**Installation** : |
| 8 | +```bash |
| 9 | +brew tap FlorianBruniaux/tap |
| 10 | +brew install claude-switch |
| 11 | +eval "$(claude-switch --shell-config)" |
| 12 | +``` |
| 13 | + |
| 14 | +**Mise à jour** : |
| 15 | +```bash |
| 16 | +brew update |
| 17 | +brew upgrade claude-switch |
| 18 | +``` |
| 19 | + |
| 20 | +**Désinstallation** : |
| 21 | +```bash |
| 22 | +brew uninstall claude-switch |
| 23 | +brew untap FlorianBruniaux/tap |
| 24 | +``` |
| 25 | + |
| 26 | +## Pour les Mainteneurs |
| 27 | + |
| 28 | +### Structure du Tap |
| 29 | + |
| 30 | +Le Homebrew tap se trouve dans un repo séparé : `FlorianBruniaux/homebrew-tap` |
| 31 | + |
| 32 | +``` |
| 33 | +homebrew-tap/ |
| 34 | +├── Formula/ |
| 35 | +│ └── claude-switch.rb # Copié depuis cc-copilot-bridge/Formula/ |
| 36 | +└── README.md |
| 37 | +``` |
| 38 | + |
| 39 | +### Workflow de Release |
| 40 | + |
| 41 | +**Automatique via GitHub Actions** : |
| 42 | + |
| 43 | +1. **Tag push** déclenche `.github/workflows/build-packages.yml` |
| 44 | +2. GitHub Actions : |
| 45 | + - Compute SHA256 du tarball |
| 46 | + - Build packages (.deb, .rpm) |
| 47 | + - Update `Formula/claude-switch.rb` avec SHA256 |
| 48 | + - Create GitHub Release |
| 49 | + - **Commit Formula update** dans `cc-copilot-bridge` |
| 50 | + |
| 51 | +3. **Copie manuelle vers tap** : |
| 52 | + ```bash |
| 53 | + cd ~/Sites/perso/homebrew-tap |
| 54 | + cp ../cc-copilot-bridge/Formula/claude-switch.rb Formula/ |
| 55 | + git add Formula/claude-switch.rb |
| 56 | + git commit -m "Update claude-switch to v1.5.3" |
| 57 | + git push |
| 58 | + ``` |
| 59 | + |
| 60 | +### Tester la Formula Localement |
| 61 | + |
| 62 | +**Avant de pusher vers tap** : |
| 63 | + |
| 64 | +```bash |
| 65 | +# 1. Build from local formula |
| 66 | +brew install --build-from-source ./Formula/claude-switch.rb |
| 67 | + |
| 68 | +# 2. Vérifier |
| 69 | +claude-switch --version |
| 70 | +eval "$(claude-switch --shell-config)" |
| 71 | +ccd --help |
| 72 | + |
| 73 | +# 3. Tester les dépendances |
| 74 | +which nc # Netcat doit être installé |
| 75 | + |
| 76 | +# 4. Désinstaller |
| 77 | +brew uninstall claude-switch |
| 78 | +``` |
| 79 | + |
| 80 | +### Valider la Formula |
| 81 | + |
| 82 | +```bash |
| 83 | +# Linter Homebrew |
| 84 | +brew audit --strict ./Formula/claude-switch.rb |
| 85 | + |
| 86 | +# Style check |
| 87 | +brew style ./Formula/claude-switch.rb |
| 88 | + |
| 89 | +# Test installation |
| 90 | +brew install --build-from-source ./Formula/claude-switch.rb |
| 91 | +brew test claude-switch |
| 92 | +``` |
| 93 | + |
| 94 | +### Dépendances |
| 95 | + |
| 96 | +**Requises** : |
| 97 | +- `netcat` : Pour health checks de provider |
| 98 | + |
| 99 | +**Optionnelles** : |
| 100 | +- `ollama` : Pour provider Ollama local |
| 101 | +- `node` : Pour copilot-api (GitHub Copilot provider) |
| 102 | + |
| 103 | +### SHA256 Checksum |
| 104 | + |
| 105 | +**Pourquoi ?** |
| 106 | +- Sécurité : Vérifie l'intégrité du téléchargement |
| 107 | +- Prévient les attaques man-in-the-middle |
| 108 | + |
| 109 | +**Comment calculer ?** |
| 110 | + |
| 111 | +GitHub Actions calcule automatiquement : |
| 112 | +```bash |
| 113 | +git archive --format=tar.gz --prefix=cc-copilot-bridge-1.5.2/ HEAD > release.tar.gz |
| 114 | +sha256sum release.tar.gz | awk '{print $1}' |
| 115 | +``` |
| 116 | + |
| 117 | +**Manuellement** : |
| 118 | +```bash |
| 119 | +wget https://github.com/FlorianBruniaux/cc-copilot-bridge/archive/refs/tags/v1.5.2.tar.gz |
| 120 | +sha256sum v1.5.2.tar.gz |
| 121 | +``` |
| 122 | + |
| 123 | +**Si mismatch** : |
| 124 | +```bash |
| 125 | +# Recalculer |
| 126 | +wget https://github.com/FlorianBruniaux/cc-copilot-bridge/archive/refs/tags/v1.5.2.tar.gz |
| 127 | +NEW_SHA=$(sha256sum v1.5.2.tar.gz | awk '{print $1}') |
| 128 | + |
| 129 | +# Update Formula |
| 130 | +sed -i "s/sha256 \".*\"/sha256 \"${NEW_SHA}\"/" Formula/claude-switch.rb |
| 131 | + |
| 132 | +# Commit et push |
| 133 | +git add Formula/claude-switch.rb |
| 134 | +git commit -m "Fix SHA256 checksum for v1.5.2" |
| 135 | +git push |
| 136 | +``` |
| 137 | + |
| 138 | +### Troubleshooting |
| 139 | + |
| 140 | +#### "SHA256 mismatch" |
| 141 | + |
| 142 | +**Cause** : GitHub tarball change entre calcul et download |
| 143 | + |
| 144 | +**Solution** : Recalculer SHA256 (voir ci-dessus) |
| 145 | + |
| 146 | +#### "Could not resolve dependencies" |
| 147 | + |
| 148 | +**Cause** : Netcat pas trouvé |
| 149 | + |
| 150 | +**Solution** : |
| 151 | +```bash |
| 152 | +brew install netcat |
| 153 | +``` |
| 154 | + |
| 155 | +#### "File already exists" |
| 156 | + |
| 157 | +**Cause** : Installation précédente |
| 158 | + |
| 159 | +**Solution** : |
| 160 | +```bash |
| 161 | +brew uninstall claude-switch |
| 162 | +brew install claude-switch |
| 163 | +``` |
| 164 | + |
| 165 | +### Ressources |
| 166 | + |
| 167 | +**Documentation officielle Homebrew** : |
| 168 | +- [Formula Cookbook](https://docs.brew.sh/Formula-Cookbook) |
| 169 | +- [Adding Software to Homebrew](https://docs.brew.sh/Adding-Software-to-Homebrew) |
| 170 | +- [Homebrew Terminology](https://docs.brew.sh/Formula-Cookbook#homebrew-terminology) |
| 171 | + |
| 172 | +**Guides du projet** : |
| 173 | +- [PACKAGE-MANAGERS.md](../docs/PACKAGE-MANAGERS.md) : Guide utilisateur |
| 174 | +- [PACKAGE-MANAGERS-EXPLAINED.md](../docs/PACKAGE-MANAGERS-EXPLAINED.md) : Détails techniques |
| 175 | +- [RELEASE-PROCESS.md](../docs/RELEASE-PROCESS.md) : Process de release |
| 176 | + |
| 177 | +### Exemples de Formulas |
| 178 | + |
| 179 | +Pour inspiration, voir : |
| 180 | +- [fzf](https://github.com/Homebrew/homebrew-core/blob/master/Formula/f/fzf.rb) |
| 181 | +- [ripgrep](https://github.com/Homebrew/homebrew-core/blob/master/Formula/r/ripgrep.rb) |
| 182 | +- [bat](https://github.com/Homebrew/homebrew-core/blob/master/Formula/b/bat.rb) |
0 commit comments