()
| 14 | main() |
| 15 | |
| 16 | async function main() { |
| 17 | const fetch = (await import("node-fetch")).default |
| 18 | |
| 19 | const contributors = [] |
| 20 | let page = 1 |
| 21 | |
| 22 | // eslint-disable-next-line no-constant-condition |
| 23 | while (true) { |
| 24 | const res = await fetch(`${base}?per_page=100&page=${page++}`, { |
| 25 | headers: {Authorization: `token ${GH_TOKEN_PUBLIC}`}, |
| 26 | }) |
| 27 | const list = await res.json() |
| 28 | if (list.length === 0) break |
| 29 | contributors.push(...list) |
| 30 | } |
| 31 | |
| 32 | const bots = ["dependabot-preview[bot]", "greenkeeper[bot]", "greenkeeperio-bot"] |
| 33 | |
| 34 | const authors = contributors |
| 35 | .filter((a) => !bots.includes(a.login)) |
| 36 | .sort((a, b) => b.contributions - a.contributions) |
| 37 | |
| 38 | const sprite = new Jimp(SIZE * authors.length, SIZE) |
| 39 | |
| 40 | for (let i = 0; i < authors.length; i += 1) { |
| 41 | const author = authors[i] |
| 42 | console.log(`${i + 1} / ${authors.length}: ${author.login}`) |
| 43 | const image_data = await fetch(author.avatar_url) |
| 44 | const buffer = await image_data.arrayBuffer() |
| 45 | const image = await Jimp.read(buffer) |
| 46 | image.resize(SIZE, SIZE) |
| 47 | sprite.composite(image, i * SIZE, 0) |
| 48 | } |
| 49 | |
| 50 | await sprite.quality(80).write(`../docs/.vuepress/components/Contributors/contributors.jpg`) |
| 51 | |
| 52 | const str = `[\n ${authors.map((a) => `"${a.login}"`).join(",\n ")},\n]\n` |
| 53 | |
| 54 | fs.writeFileSync( |
| 55 | `../docs/.vuepress/components/Contributors/_contributors.js`, |
| 56 | `module.exports = ${str}` |
| 57 | ) |
| 58 | } |
no test coverage detected
searching dependent graphs…