Created
April 5, 2024 02:29
-
-
Save jitran/953f4957c1a61145bc0598684d2ae530 to your computer and use it in GitHub Desktop.
User statistics
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Octokit } from "octokit"; | |
import dotenv from "dotenv"; | |
dotenv.config(); | |
const octokit = new Octokit({ | |
auth: process.env.GITHUB_TOKEN, | |
}); | |
const username = process.argv[2] | |
const response = await octokit.rest.repos.listForUser({ username: username }); | |
const followers = await octokit.rest.users.listFollowersForUser({ username: username }); | |
let set = new Set(); | |
response.data.map(repo => { | |
if (repo.language) { | |
set.add(repo.language); | |
} | |
}); | |
console.log("User public statistics: %s", username); | |
console.log("Repositories: %d", response.data.length) | |
console.log("Languages used: %s", Array.from(set).join(", ")); | |
console.log("Followers: %d", followers.data.length); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Exercise:
Install node packages:
Create .env file with a PAT that has public_repo and read:user access:
Run:
References: