A simple TypeScript CLI tool to fetch and display a GitHub user’s recent public activity in a human-readable format.
- Fetches a user’s public events from GitHub.
- Supports common event types:
- Pushes, Pull Requests, Issues, Issue Comments, Stars, Forks, and Repositories/Branches/Tags creation.
- Falls back gracefully for unknown event types.
- Minimal dependencies, written in TypeScript.
# Clone the repository
git clone https://github.com/CamelJohn/github-user-activity-cli.git
cd github-user-activity-cli
# Install dependencies
npm install
# Build the project
npm run build
# Link CLI globally
npm linkgithub-activity <username>Example:
github-activity octocatOutput:
Output:
- Pushed 3 commit(s) to octocat/Hello-World
- Opened pull request in octocat/Hello-World
- Starred octocat/Spoon-Knife
- Created branch in octocat/Hello-World
- Commented on issue #42 in octocat/Hello-WorldStart the CLI without building using tsx:
npm start -- <username>Build:
npm run buildsrc/
├─ index.ts # Main CLI logic
├─ events-map.ts # Mapping from GitHub event types to description functions
└─ types.ts # TypeScript interfaces for GitHub API eventsThe CLI handles the following event types:
PushEventPullRequestEventIssuesEventIssueCommentEventWatchEvent(starring a repository)ForkEventCreateEvent(repository, branch, tag creation)
Other event types are displayed in a simple fallback format:
<EventType> in <repository>
IGitHubEvent interface:
interface IGitHubEvent {
id: string;
type: string;
actor: IGithubActor;
repo: IGitHubRepo;
payload: any;
public: boolean;
created_at: string;
org?: IGitHubOrg;
}
interface IGithubActor {
id: number;
login: string;
display_login?: string;
gravatar_id: string;
url: string;
avatar_url: string;
}
interface IGitHubRepo {
id: number;
name: string;
url: string;
}
interface IGitHubOrg {
id: number;
login: string;
gravatar_id: string;
url: string;
avatar_url: string;
}