Skip to content

πŸ“Œ Update a gist to contain your GitHub stats

License

Notifications You must be signed in to change notification settings

dxas90/github-stats-box

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

19 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

github-stats-box (TypeScript)

βš‘οΈπŸ“Œ Update a pinned gist to contain your GitHub stats

Modernized fork with TypeScript, Node.js 24, and enhanced error handling


πŸš€ What's New in This Fork

  • βœ… Full TypeScript with strict type checking
  • βœ… Node.js 24 support
  • βœ… ES Modules (modern import/export)
  • βœ… Enhanced Error Handling with retry logic and exponential backoff
  • βœ… Better Developer Experience with tsx and comprehensive type safety

See TYPESCRIPT_MIGRATION.md for migration details.


Prep Work

  1. Create a new public GitHub Gist (https://gist.github.com/new)
  2. Create a token with the gist and repo scopes and copy it (https://github.com/settings/tokens/new)

Project Setup

For GitHub Actions (Automated)

  1. Fork this repository

  2. From your new fork, go to Settings > Secrets and variables > Actions

  3. Add the following secret using the New repository secret button:

    • GH_TOKEN: The GitHub token generated above.
  4. Go to the Actions tab of your fork and click the "enable" button

  5. Edit the environment variables at the end of the file .github/workflows/run.yml

    • GIST_ID: The ID portion from your gist url: https://gist.github.com/bokub/1cc900d92b9acc15786d7553b46a2cdf.
    • ALL_COMMITS: Boolean value, If true it will count all commits instead of last year commits
    • K_FORMAT: Boolean value, If true, large numbers will be formatted with a "k", for example 1.5k

That's it! Your gist will be updated immediately, and every 3 hours after that.

For Local Development

  1. Clone this repository:

    git clone https://github.com/dxas90/github-stats-box.git
    cd github-stats-box
  2. Install dependencies (requires Node.js >= 24):

    npm install
  3. Copy the sample environment file and configure it:

    cp sample.env .env
    # Edit .env with your GIST_ID and GH_TOKEN
  4. Build and run:

    npm run build
    npm start

    Or for development:

    npm run dev

Environment Variables

Variable Required Default Description
GIST_ID βœ… Yes - Your GitHub Gist ID
GH_TOKEN βœ… Yes - GitHub token with gist and repo scopes
ALL_COMMITS No false Count all commits (true) or just past year (false)
K_FORMAT No false Format large numbers with 'k' suffix (e.g., 1.5k)
DEBUG No false Enable debug mode with stack traces

Development

# Install dependencies
npm install

# Run in development mode (no build needed)
npm run dev

# Build TypeScript
npm run build

# Run built version
npm start

# Type check
npm run typecheck

# Watch mode
npm run watch

# Format code
npm run prettier

Requirements

  • Node.js >= 24.0.0
  • npm or yarn

Project Structure

src/
  β”œβ”€β”€ fetch.ts     # API client with retry logic and types
  └── index.ts     # Main application logic
dist/              # Compiled JavaScript (generated by build)
tsconfig.json      # TypeScript configuration
mise.toml          # Node version configuration (for mise users)

Features

  • Type-safe API calls with full TypeScript support
  • Automatic retry logic with exponential backoff for API failures
  • Comprehensive error handling with detailed error messages
  • Input validation for tokens and configuration
  • Structured logging with emoji icons for better readability
  • Smart number formatting with optional k-format (1.5k instead of 1500)

License

MIT - See LICENSE for details.

Original project by bokub

About

πŸ“Œ Update a gist to contain your GitHub stats

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •