GitHub-Repo-Analyzer-CLI-tool

Stars
8
Language
TypeScript
Updated

šŸ” GitHub Repo Analyzer CLI

A powerful, feature-rich command-line tool built with Node.js and TypeScript to analyze GitHub repositories and users. Get comprehensive insights including repository statistics, language breakdowns, commit activity, and detailed user profiles.

✨ Features

  • šŸ“ Repository Analysis: Detailed stats including stars, forks, issues, languages, and commit history
  • šŸ‘¤ User Analysis: Comprehensive user profiles with top repositories and statistics
  • šŸ¤– Auto-Detection: Automatically detects whether input is a repository URL or username
  • šŸŽØ Beautiful Output: Colorful, formatted console output with progress indicators
  • šŸ’¾ Export Options: Save results as JSON or Markdown reports
  • ⚔ Fast & Efficient: Concurrent API calls and smart caching
  • šŸ” Token Support: GitHub personal access token support for higher rate limits
  • šŸ“Š Rate Limit Monitoring: Built-in rate limit checking and warnings

šŸš€ Quick Start

Prerequisites

  • Node.js (v16 or higher)
  • npm (v7 or higher)

Installation

  1. Extract the project from the ZIP file

  2. Navigate to project directory:

    cd github-repo-analyzer
    
  3. Install dependencies:

    npm install
    
  4. Build the project:

    npm run build
    
  5. (Optional) Set up GitHub token for higher rate limits:

    # Copy the example environment file
    cp .env.example .env
    
    # Edit .env and add your GitHub token
    # Get a token from: https://github.com/settings/tokens
    

Usage

šŸ“ Analyze a Repository
# Using owner/repo format
npm start repo facebook/react

# Using full GitHub URL
npm start repo https://github.com/microsoft/vscode

# Save as JSON report
npm start repo facebook/react --output json --save react-analysis.json

# Save as Markdown report  
npm start repo facebook/react --output md --save react-report.md
šŸ‘¤ Analyze a User
# Analyze user with default settings (top 10 repos)
npm start user octocat

# Analyze user with custom repo limit
npm start user torvalds --repos 5

# Save user analysis as Markdown
npm start user octocat --output md --save octocat-profile.md
šŸ¤– Auto-Detection
# Automatically detect if input is a repo or user
npm start analyze facebook/react
npm start analyze octocat
npm start analyze https://github.com/microsoft/typescript
šŸ“Š Check Rate Limits
# Check your current GitHub API rate limit status
npm start rate-limit --token your_github_token

šŸ› ļø Development

Project Structure

github-repo-analyzer/
ā”œā”€ā”€ src/
│   ā”œā”€ā”€ index.ts          # CLI entry point with Commander.js
│   ā”œā”€ā”€ api.ts            # GitHub API client with Axios
│   └── utils.ts          # Utility functions and formatters
ā”œā”€ā”€ types/
│   └── index.ts          # TypeScript type definitions
ā”œā”€ā”€ dist/                 # Compiled JavaScript output
ā”œā”€ā”€ package.json          # Dependencies and scripts
ā”œā”€ā”€ tsconfig.json         # TypeScript configuration
ā”œā”€ā”€ .env.example          # Environment variables template
└── README.md            # This file

Development Commands

# Install dependencies
npm install

# Build TypeScript to JavaScript
npm run build

# Run in development mode with ts-node
npm run dev

# Build and run
npm run build:start

# Run the compiled version
npm start

āš™ļø Configuration

Environment Variables

Create a .env file in the project root:

# GitHub Personal Access Token (optional but recommended)
# Get one from: https://github.com/settings/tokens
# Scopes needed: public_repo (or repo for private repos)
GITHUB_TOKEN=ghp_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

GitHub Token Setup

  1. Go to GitHub Settings → Personal Access Tokens
  2. Click "Generate new token (classic)"
  3. Give it a descriptive name like "GitHub Repo Analyzer CLI"
  4. Select scopes:
    • public_repo (for public repositories)
    • repo (if you need access to private repositories)
  5. Copy the generated token and add it to your .env file

Benefits of using a token:

  • Higher rate limits (5,000 requests/hour vs 60 requests/hour)
  • Access to private repositories (if token has appropriate scopes)
  • More detailed repository information

šŸ“– API Reference

Repository Analysis Output

interface RepositoryAnalysis {
  name: string;              // Repository name
  full_name: string;         // Full name (owner/repo)
  description: string;       // Repository description
  url: string;              // GitHub URL
  stars: number;            // Star count
  forks: number;            // Fork count
  open_issues: number;      // Open issues count
  last_commit_date: string; // Last commit timestamp
  languages: {              // Language breakdown (percentages)
    [language: string]: number;
  };
  created_at: string;       // Creation date
  updated_at: string;       // Last update date
  license: string;          // License name
  topics: string[];         // Repository topics
  size: number;             // Repository size in KB
  default_branch: string;   // Default branch name
}

User Analysis Output

interface UserAnalysis {
  username: string;         // GitHub username
  name: string;            // Display name
  bio: string;             // User bio
  location: string;        // Location
  email: string;           // Public email
  blog: string;            // Blog/website URL
  company: string;         // Company
  public_repos: number;    // Public repository count
  followers: number;       // Follower count
  following: number;       // Following count
  created_at: string;      // Account creation date
  repositories: RepositoryAnalysis[]; // Top repositories
}

šŸŽØ Output Examples

Console Output

The tool provides beautiful, colorful console output with:

  • šŸŽÆ Progress indicators with Ora spinners
  • 🌈 Color-coded information using Chalk
  • šŸ“Š Visual language breakdown with progress bars
  • šŸ“ˆ Formatted statistics and dates
  • šŸ·ļø Highlighted topics and tags

JSON Export

{
  "name": "react",
  "full_name": "facebook/react",
  "description": "A declarative, efficient, and flexible JavaScript library for building user interfaces.",
  "url": "https://github.com/facebook/react",
  "stars": 219000,
  "forks": 45000,
  "open_issues": 800,
  "languages": {
    "JavaScript": 93.2,
    "TypeScript": 4.1,
    "HTML": 2.7
  }
}

Markdown Export

# react

## Repository Information
- **Full Name**: facebook/react
- **Description**: A declarative, efficient, and flexible JavaScript library...
- **URL**: [https://github.com/facebook/react](https://github.com/facebook/react)

## Repository Statistics
| Metric | Value |
|--------|--------|
| ⭐ Stars | 219,000 |
| šŸ“ Forks | 45,000 |
| šŸ› Open Issues | 800 |

šŸ“„ License

This project is licensed under the MIT License.

šŸ™ Acknowledgments

  • GitHub API for providing comprehensive repository and user data
  • Commander.js for excellent CLI framework
  • Chalk for beautiful terminal colors
  • Ora for elegant loading spinners
  • Axios for reliable HTTP requests
  • TypeScript for type safety and better development experience

šŸ“ž Support

If you encounter any issues:

  1. Make sure you have Node.js v16+ installed
  2. Run npm install to install dependencies
  3. Run npm run build to compile TypeScript
  4. Check that your GitHub token (if using) has correct permissions

Made with ā¤ļø using Node.js, TypeScript, and the GitHub API

GitHub-Repo-Analyzer-CLI-tool