Skip to content

Latest commit

 

History

History
156 lines (120 loc) · 4.57 KB

COMPARISON.md

File metadata and controls

156 lines (120 loc) · 4.57 KB

GitHub CLI vs TypeScript Script Comparison

🏆 Winner: GitHub CLI Script

📊 Comparison Table

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

✅ GitHub CLI Advantages

1. Simplicity

# TypeScript approach (complex)
npm install, configure .env, write 336 lines, 9 tests

# GitHub CLI approach (simple)  
./rerun-with-gh.sh --help

2. One-Line Operations

# 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

3. No Token Management

# TypeScript: Manual token in .env
GITHUB_TOKEN=ghp_xxxxxxxxxxxx

# GitHub CLI: Automatic auth
gh auth login  # Done once

4. Built-in Filtering

# Filter by author, status, commit, branch, etc.
gh pr list --author "user" --state open
gh run list --commit "sha" --status failure

5. Native JSON + jq

# Complex data manipulation in one line
gh pr list --json number,title,author | jq '.[] | select(.author.login == "target")'

❌ TypeScript Script Disadvantages

1. Over-Engineering

  • 336 lines for something GitHub CLI does in 150 lines
  • Complex type definitions, interfaces, error handling
  • Manual API pagination and rate limiting

2. Maintenance Burden

  • GitHub API changes require code updates
  • Security vulnerabilities in dependencies
  • Complex testing requirements (9 test cases)

3. Setup Complexity

  • Multiple npm dependencies
  • Token management
  • Environment configuration
  • TypeScript compilation

🎯 Real-World Usage Comparison

TypeScript Version:

# Setup (5+ minutes)
npm install
cp .env.example .env
# Edit .env with token
npm run build

# Usage
AUTHOR=user npm start

GitHub CLI Version:

# Setup (30 seconds)
gh auth login

# Usage
AUTHOR=user ./rerun-with-gh.sh

🚀 GitHub CLI Script Features

✅ Everything the TypeScript script does, but better:

  1. Author Filtering: AUTHOR=username
  2. Mode Selection: MODE=workflows or MODE=jobs
  3. Dry Run: DRY_RUN=true/false
  4. PR Number Targeting: PR_NUMBERS=123,456
  5. Repository Targeting: REPO=owner/repo
  6. Colorized Output: Better UX
  7. Built-in Help: --help flag
  8. Error Handling: Automatic retries and error messages

✅ Plus additional features:

  1. Automatic Authentication: Uses gh auth
  2. Built-in Rate Limiting: GitHub CLI handles this
  3. Automatic Pagination: No manual logic needed
  4. Native JSON Processing: Built-in jq support
  5. Shell Scripting Power: Easy to extend and customize

🎯 Recommendation: Use GitHub CLI Script

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! 🎉

📝 Migration Path

  1. Keep TypeScript script for learning/reference
  2. Use GitHub CLI script for actual workflow reruns
  3. Archive TypeScript approach - it served its purpose as a deep-dive into GitHub API

🏁 Conclusion

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! 🚀