β‘οΈπ Update a pinned gist to contain your GitHub stats
Modernized fork with TypeScript, Node.js 24, and enhanced error handling
- β 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.
- Create a new public GitHub Gist (https://gist.github.com/new)
- Create a token with the
gistandreposcopes and copy it (https://github.com/settings/tokens/new)
-
Fork this repository
-
From your new fork, go to Settings > Secrets and variables > Actions
-
Add the following secret using the New repository secret button:
- GH_TOKEN: The GitHub token generated above.
-
Go to the Actions tab of your fork and click the "enable" button
-
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
trueit will count all commits instead of last year commits - K_FORMAT: Boolean value, If
true, large numbers will be formatted with a "k", for example1.5k
- GIST_ID: The ID portion from your gist url:
That's it! Your gist will be updated immediately, and every 3 hours after that.
-
Clone this repository:
git clone https://github.com/dxas90/github-stats-box.git cd github-stats-box -
Install dependencies (requires Node.js >= 24):
npm install
-
Copy the sample environment file and configure it:
cp sample.env .env # Edit .env with your GIST_ID and GH_TOKEN -
Build and run:
npm run build npm start
Or for development:
npm run dev
| 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 |
# 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- Node.js >= 24.0.0
- npm or yarn
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)
- 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)
MIT - See LICENSE for details.
Original project by bokub