UNPKG

@c0dez/github-repo-fetcher

Version:

šŸ” A lightweight GitHub profile analyzer that fetches repositories, READMEs, and comprehensive user statistics with TypeScript support. Perfect for building GitHub analytics tools and portfolio sites.

49 lines (48 loc) • 1.98 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const index_1 = require("./index"); async function displayGitHubProfile(username) { const fetcher = new index_1.GitHubRepoFetcher(); try { console.log('\nšŸ” Fetching GitHub profile for:', username); console.log('----------------------------------------'); // Fetch user stats const stats = await fetcher.getUserStats(username); console.log('\nšŸ“Š Profile Statistics:'); console.log('Name:', stats.name); console.log('Bio:', stats.bio); console.log('Followers:', stats.followers); console.log('Following:', stats.following); console.log('Public Repos:', stats.public_repos); console.log('Total Stars:', stats.totalStars); // Display language statistics if (stats.languages) { console.log('\nšŸ’» Language Usage:'); Object.entries(stats.languages) .sort(([, a], [, b]) => b - a) .forEach(([lang, bytes]) => { console.log(`${lang}: ${(bytes / 1024).toFixed(2)} KB`); }); } // Fetch repositories const repos = await fetcher.getReposWithReadme(username); console.log('\nšŸ“š Latest Repositories:'); repos.slice(0, 5).forEach(repo => { console.log('\n-', repo.name); console.log(' Description:', repo.description); console.log(' Stars:', repo.stargazers_count); console.log(' URL:', repo.html_url); }); } catch (error) { console.error('āŒ Error:', error.message); } } // Get username from command line argument const username = process.argv[2]; if (!username) { console.error('Please provide a GitHub username as an argument'); console.log('Example: npm run example octocat'); process.exit(1); } displayGitHubProfile(username);