web/utils/contributors.js

77 lines
1.6 KiB
JavaScript
Raw Normal View History

2023-11-13 03:03:34 +01:00
import "https://deno.land/std@0.206.0/dotenv/load.ts";
const contributorRepos = [
2024-01-31 01:57:12 +01:00
// main repos
"web3privacy/web3privacy",
"web3privacy/data",
"web3privacy/docs",
"web3privacy/web",
"web3privacy/brand",
2024-02-14 13:28:36 +01:00
"web3privacy/association",
2024-01-25 23:45:59 +01:00
2024-01-31 01:57:12 +01:00
// events workgroup
"web3privacy/events",
// explorer
"web3privacy/explorer",
"web3privacy/explorer-data",
"web3privacy/explorer-app",
2024-02-09 16:35:26 +01:00
// news project
"web3privacy/news",
2024-03-01 08:34:41 +01:00
// jobs
"web3privacy/jobs",
2024-01-31 01:57:12 +01:00
// old - deprecated
"web3privacy/w3ps1",
"web3privacy/grants",
"web3privacy/old-website",
"web3privacy/web3privacy-app-old",
2024-02-14 13:28:36 +01:00
"web3privacy/news-app",
2024-01-31 01:57:12 +01:00
];
function isBlacklisted(login) {
if (login.match(/\[bot\]$/)) {
return true;
}
2024-01-31 01:56:05 +01:00
}
2024-01-31 01:57:12 +01:00
async function getContributors() {
const output = [];
for (const cr of contributorRepos) {
const response = await fetch(
`https://api.github.com/repos/${cr}/contributors`,
{
//headers: {
// "Authorization": `Token ${Deno.env.get('GITHUB_TOKEN')}`
//}
},
);
const arr = await response.json();
for (const item of arr) {
if (isBlacklisted(item.login)) {
continue;
}
const found = output.find((i) => i.login === item.login);
if (!found) {
output.push(item);
} else {
found.contributions += item.contributions;
}
}
}
return output.sort((x, y) => y.contributions > x.contributions ? 1 : -1);
2023-11-13 03:03:34 +01:00
}
2024-02-14 13:24:14 +01:00
const contributors = {
repos: contributorRepos,
items: await getContributors(),
};
2024-01-31 01:57:12 +01:00
await Deno.writeTextFile(
"./src/contributors.json",
JSON.stringify(contributors, null, 2),
);
console.log(`File ./src/contributors.json saved`);