-
Notifications
You must be signed in to change notification settings - Fork 0
/
repos.ts
76 lines (63 loc) · 2.14 KB
/
repos.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
import dotenv from "dotenv";
import { sleep } from "./utils";
import { Octokit } from "octokit";
import { intro, log } from "@clack/prompts";
import picocolors from "picocolors";
dotenv.config();
const STANDARD_GITHUB_REPOS = [
// solana labs
// "https://github.com/solana-labs/solana",
// "https://github.com/solana-labs/solana-program-library",
// anza
"https://github.com/anza-xyz/agave",
// solana foundation
// "https://github.com/solana-foundation/solana-improvement-documents",
// "https://github.com/solana-foundation/developer-content",
// community repos
// "https://github.com/coral-xyz/anchor",
];
const accessToken = process.env.GITHUB_ACCESS_TOKEN || null;
// initializing octokit with the user's github auth token will allow us to read their private repos
const octokit = new Octokit({
auth: accessToken,
});
const dateToStopChecking = new Date(Date.now() - 7 * 24 * 60 * 60 * 1000);
console.log();
intro(picocolors.bgMagenta(" Solana Changelog "));
log.info("hi");
/**
* Begin the loop of all standard repos to collect the standard data
*/
for (let i = 0; i < STANDARD_GITHUB_REPOS.length; i++) {
const [_, owner, repo] = STANDARD_GITHUB_REPOS[i].split(
/^https?\:\/\/github.com\/([\w-]*)\/([\w-]*)/i,
);
const fullRepo = `${owner}/${repo}`;
console.log("\n-------------------------------------------");
console.log("[BEGIN]", `Checking ${fullRepo}...`);
/**
* get the recent commits on the repo
*/
try {
// console.log("[FETCH]", `${fullRepo} commits for ${username}`);
const commits = await octokit
.request("GET /repos/{owner}/{repo}/commits", {
owner,
repo,
per_page: 100,
page: 1,
since: dateToStopChecking.toISOString(),
})
.then(res => res.data);
console.log("total commits:", commits.length);
} catch (err) {
if (err instanceof Error) console.warn("[WARN]", err.message);
else console.warn("[WARN]", err);
}
console.log("[FINISH]", `Checking ${fullRepo}`);
// no reason to sleep on the very last repo check
if (i + 1 != STANDARD_GITHUB_REPOS.length) {
console.log("[DELAY]", "sleep");
await sleep(5000);
}
}