fix contributors script

pull/2678/head
Richard Harris 5 years ago
parent 548fd039d9
commit be1fec4619

@ -5,15 +5,26 @@ const Jimp = require('jimp');
process.chdir(__dirname);
const base = `https://api.github.com/repos/sveltejs/svelte/contributors`;
const { GITHUB_CLIENT_ID, GITHUB_CLIENT_SECRET } = process.env;
const SIZE = 64;
async function main() {
const res = await fetch(`https://api.github.com/repos/sveltejs/svelte/stats/contributors?client_id=${process.env.GITHUB_CLIENT_ID}&client_secret=${process.env.GITHUB_CLIENT_SECRET}`);
const contributors = await res.json();
const contributors = [];
let page = 1;
while (true) {
const res = await fetch(`${base}?client_id=${GITHUB_CLIENT_ID}&client_secret=${GITHUB_CLIENT_SECRET}&per_page=100&page=${page++}`);
const list = await res.json();
if (list.length === 0) break;
contributors.push(...list);
}
const authors = contributors
.sort((a, b) => b.total - a.total)
.map(({ author }) => author);
.sort((a, b) => b.contributions - a.contributions);
const sprite = new Jimp(SIZE * authors.length, SIZE);

Loading…
Cancel
Save