| Feature | TypeScript Script | GitHub CLI Script | Winner |
|---|---|---|---|
| Lines of Code | ~336 lines | ~150 lines | 🥇 GH CLI |
| Dependencies | 8+ npm packages | Just gh CLI |
🥇 GH CLI |
| Setup Complexity | npm install, .env, tokens | Just gh auth login |
🥇 GH CLI |
| API Rate Limiting | Manual handling | Built-in | 🥇 GH CLI |
| Error Handling | Custom implementation | Built-in | 🥇 GH CLI |
| Pagination | Manual logic | Automatic | 🥇 GH CLI |
| JSON Filtering | Custom code | Built-in jq | 🥇 GH CLI |
| Maintenance | High (API changes) | Low (GitHub maintains) | 🥇 GH CLI |
| Performance | Good | Excellent | 🥇 GH CLI |
| Testing | 9 test cases needed | Simple shell testing | 🥇 GH CLI |
# TypeScript approach (complex)
npm install, configure .env, write 336 lines, 9 tests
# GitHub CLI approach (simple)
./rerun-with-gh.sh --help# Get PRs by author
gh pr list --author "username" --json number,headRefOid
# Get failed runs for commit
gh run list --commit "sha" --status failure --json databaseId,name
# Rerun failed jobs
gh run rerun 123456 --failed# TypeScript: Manual token in .env
GITHUB_TOKEN=ghp_xxxxxxxxxxxx
# GitHub CLI: Automatic auth
gh auth login # Done once# Filter by author, status, commit, branch, etc.
gh pr list --author "user" --state open
gh run list --commit "sha" --status failure# Complex data manipulation in one line
gh pr list --json number,title,author | jq '.[] | select(.author.login == "target")'- 336 lines for something GitHub CLI does in 150 lines
- Complex type definitions, interfaces, error handling
- Manual API pagination and rate limiting
- GitHub API changes require code updates
- Security vulnerabilities in dependencies
- Complex testing requirements (9 test cases)
- Multiple npm dependencies
- Token management
- Environment configuration
- TypeScript compilation
# Setup (5+ minutes)
npm install
cp .env.example .env
# Edit .env with token
npm run build
# Usage
AUTHOR=user npm start# Setup (30 seconds)
gh auth login
# Usage
AUTHOR=user ./rerun-with-gh.sh- Author Filtering:
AUTHOR=username - Mode Selection:
MODE=workflowsorMODE=jobs - Dry Run:
DRY_RUN=true/false - PR Number Targeting:
PR_NUMBERS=123,456 - Repository Targeting:
REPO=owner/repo - Colorized Output: Better UX
- Built-in Help:
--helpflag - Error Handling: Automatic retries and error messages
- Automatic Authentication: Uses
gh auth - Built-in Rate Limiting: GitHub CLI handles this
- Automatic Pagination: No manual logic needed
- Native JSON Processing: Built-in jq support
- Shell Scripting Power: Easy to extend and customize
Why?
- ✅ 90% less code (150 vs 336 lines)
- ✅ No dependencies (just gh CLI)
- ✅ Better UX (colors, help, error handling)
- ✅ More reliable (GitHub maintains the CLI)
- ✅ Easier to maintain (shell script vs TypeScript project)
- ✅ Faster execution (native gh commands)
- ✅ Better error handling (built-in)
The TypeScript script was a good learning exercise, but GitHub CLI is the production solution! 🎉
- Keep TypeScript script for learning/reference
- Use GitHub CLI script for actual workflow reruns
- Archive TypeScript approach - it served its purpose as a deep-dive into GitHub API
GitHub CLI wins in every category. The TypeScript script taught us about the GitHub API, but GitHub CLI is the right tool for the job. It's:
- Simpler to write and maintain
- More reliable and robust
- Better documented and supported
- Faster to execute
- Easier to extend
Bottom line: Use the GitHub CLI script for real workflows! 🚀