Skip to content

Instantly share code, notes, and snippets.

@MaTriXy
Created March 31, 2026 06:00
Show Gist options
  • Select an option

  • Save MaTriXy/b2863f44c9379dec3ad1076eb0f920e3 to your computer and use it in GitHub Desktop.

Select an option

Save MaTriXy/b2863f44c9379dec3ad1076eb0f920e3 to your computer and use it in GitHub Desktop.
Find axios in repos
#!/bin/bash
#
# find-axios-repos.sh
# Scans all repos in a GitHub org for axios dependency usage.
# Searches package.json files for axios in dependencies and devDependencies.
#
# Requirements: gh CLI (authenticated)
#
# Usage: ./find-axios-repos.sh <org-name>
set -euo pipefail
usage() {
echo "Usage: $0 <github-org-name>"
echo ""
echo "Scans all repos in a GitHub org for axios npm package usage."
echo ""
echo "Arguments:"
echo " github-org-name The GitHub organization to scan (required)"
echo ""
echo "Examples:"
echo " $0 my-company"
echo " $0 facebook"
exit 1
}
if [ $# -eq 0 ]; then
usage
fi
# Validate gh CLI is installed and authenticated
if ! command -v gh &> /dev/null; then
echo "Error: GitHub CLI (gh) is not installed."
echo "Install it from https://cli.github.com"
exit 1
fi
if ! gh auth status &> /dev/null; then
echo "Error: GitHub CLI is not authenticated."
echo "Run 'gh auth login' first."
exit 1
fi
ORG="$1"
FOUND_REPOS=()
CHECKED=0
echo "============================================"
echo " Scanning GitHub org: $ORG for axios usage"
echo "============================================"
echo ""
# Fetch all repo names (handles pagination)
echo "Fetching repo list..."
REPOS=$(gh repo list "$ORG" --limit 500 --json name,isArchived --jq '.[] | select(.isArchived == false) | .name')
TOTAL=$(echo "$REPOS" | wc -l | tr -d ' ')
echo "Found $TOTAL active (non-archived) repos."
echo ""
for REPO in $REPOS; do
CHECKED=$((CHECKED + 1))
FULL_NAME="$ORG/$REPO"
printf "[%3d/%d] Checking %-50s" "$CHECKED" "$TOTAL" "$FULL_NAME"
# Search for "axios" in package.json files in the repo
MATCH=$(gh api "search/code?q=axios+filename:package.json+repo:$FULL_NAME" --jq '.total_count' 2>/dev/null || echo "0")
if [ "$MATCH" -gt 0 ] 2>/dev/null; then
echo " ✅ FOUND (axios in $MATCH file(s))"
FOUND_REPOS+=("$FULL_NAME")
else
echo " —"
fi
# Small delay to avoid GitHub API rate limits
sleep 0.5
done
echo ""
echo "============================================"
echo " RESULTS: Repos using axios"
echo "============================================"
echo ""
if [ ${#FOUND_REPOS[@]} -eq 0 ]; then
echo "No repos found with axios dependency."
else
echo "Found ${#FOUND_REPOS[@]} repo(s) with axios:"
echo ""
for REPO in "${FOUND_REPOS[@]}"; do
echo " • $REPO"
done
fi
echo ""
echo "Checked $CHECKED repos total."
@MaTriXy
Copy link
Copy Markdown
Author

MaTriXy commented Mar 31, 2026

# Usage: ./find-axios-repos.sh <org-name>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment