A high-performance, professional-grade Command Line Interface (CLI) designed to retrieve and visualize public activity streams from any GitHub user. This tool is engineered for speed, efficiency, and readability, utilizing concurrent network requests and a local caching layer to provide a seamless developer experience.
Repository: https://github.com/CW-Ankit/github-user-activity.git
- Concurrent Data Fetching: Instead of sequential requests, the tool utilizes
Promise.all()to fetch user profiles and activity events simultaneously, reducing the total wait time by approximately 50%. - Intelligent Caching Layer: Implements a 'Cache-Aside' pattern. API responses are persisted to the system's temporary directory with a configurable Time-To-Live (TTL), preventing redundant network calls and protecting against GitHub API rate limits.
- Structured Table Layout: Activity is presented in a strictly aligned columnar format, ensuring that repository names and event types remain visually consistent across the feed.
- Semantic Color Coding: Uses ANSI escape codes to categorize events (e.g., Green for Pushes, Magenta for Stars, Yellow for Issues), allowing users to scan activity at a glance.
- Dynamic Filtering: Ability to isolate specific event types (e.g., only viewing
PushEvent) via command-line flags.
- Dual-Command Access: Supports both the full command
github-activityand the ultra-fast shorthandgha. - Graceful Error Handling: Comprehensive try-catch blocks manage everything from 404 (User Not Found) to network timeouts and DNS failures.
- Node.js: Version 18.0.0 or higher.
- npm: Version 8.0.0 or higher.
-
Clone the repository:
git clone https://github.com/CW-Ankit/github-user-activity.git cd github-user-activity -
Install dependencies:
npm install
-
Link the package globally: This step registers the
github-activityandghacommands in your system's binary path.npm link
Fetch all public activity for a specific user:
gha <username>
# OR
github-activity <username>If you only want to see specific types of events (e.g., PushEvent, WatchEvent, IssuesEvent):
gha <username> --filter=PushEventTo view all available options and examples:
gha --help👤 USER PROFILE
----------------------------------------------------------------------
Name: Gaearon
Bio: Creator of Redux, React-Three-Fiber
Repos: 150
Followers: 25000
----------------------------------------------------------------------
⚡ Loaded from local cache
Recent Activity:
Date | Type | Repository | Detail
---------------------------------------------------------------------------
Oct 27, 10:00 am | 🚀 PUSH | reduxjs/redux | 3 commit(s)
Oct 27, 11:30 am | ⭐ STAR | pmndrs/react-three-fiber | Starred
Oct 27, 12:15 pm | 🎫 ISSUE | facebook/react | Opened
- Argument Parsing: The
cli.jsmodule extracts inputs fromprocess.argv. - Cache Validation:
api.jsgenerates a unique key based on the endpoint and username. It checks theos.tmpdir()for a matching.jsonfile. - Network Execution: Upon a cache miss,
node:httpsis used to perform a GET request. A customUser-Agentis sent to comply with GitHub's API requirements. - Data Normalization: The
formatter.jsmodule maps raw JSON event types to human-readable labels and applies padding for terminal alignment.
The cache uses a Time-To-Live (TTL) mechanism. By default, data is considered fresh for 10 minutes. After this window, the tool automatically invalidates the local file and performs a fresh network fetch to ensure data accuracy.
This project was built as part of the roadmap.sh GitHub User Activity project, implementing the requested functionality with professional architectural enhancements.
This project is licensed under the ISC License. See the LICENSE file for details.