mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-09-13 20:39:38 +02:00
WIP Adding contributors page from vitest
This commit is contained in:
40
scripts/updateContributors.ts
Normal file
40
scripts/updateContributors.ts
Normal file
@@ -0,0 +1,40 @@
|
||||
// Adapted from https://github.dev/vitest-dev/vitest/blob/991ff33ab717caee85ef6cbe1c16dc514186b4cc/scripts/update-contributors.ts#L6
|
||||
|
||||
import { writeFile } from 'node:fs/promises';
|
||||
import { $fetch } from 'ohmyfetch';
|
||||
|
||||
interface Contributor {
|
||||
login: string;
|
||||
}
|
||||
|
||||
async function fetchContributors() {
|
||||
const collaborators: string[] = [];
|
||||
let page = 1;
|
||||
let data: Contributor[] = [];
|
||||
do {
|
||||
data =
|
||||
(await $fetch<Contributor[]>(
|
||||
`https://api.github.com/repos/mermaid-js/mermaid/contributors?per_page=100&page=${page}`,
|
||||
{
|
||||
method: 'get',
|
||||
headers: {
|
||||
'content-type': 'application/json',
|
||||
},
|
||||
}
|
||||
)) || [];
|
||||
collaborators.push(...data.map((i) => i.login));
|
||||
page++;
|
||||
} while (data.length === 100);
|
||||
return collaborators.filter((name) => !name.includes('[bot]'));
|
||||
}
|
||||
|
||||
async function generate() {
|
||||
const collaborators = await fetchContributors();
|
||||
await writeFile(
|
||||
'./packages/mermaid/src/docs/.vitepress/contributor-names.json',
|
||||
`${JSON.stringify(collaborators, null, 2)}\n`,
|
||||
'utf8'
|
||||
);
|
||||
}
|
||||
|
||||
void generate();
|
Reference in New Issue
Block a user