vitest/scripts/update-contributors.ts
Vladimir 1cbc24dca6
fix: don't resolve builtin Node modules (#2538)
* fix: use "node:" prefix in Vitest imports

* chore: add test for prefix

* chore: cleanup

* chore: use more node protocol

* chore: cleanup

* chore: cleanup
2022-12-20 12:57:48 +03:00

28 lines
846 B
TypeScript

import { promises as fs } from 'node:fs'
import { $fetch } from 'ohmyfetch'
interface Contributor {
login: string
}
async function fetchContributors(page = 1) {
const collaborators: string[] = []
const data = await $fetch<Contributor[]>(`https://api.github.com/repos/vitest-dev/vitest/contributors?per_page=100&page=${page}`, {
method: 'get',
headers: {
'content-type': 'application/json',
},
}) || []
collaborators.push(...data.map(i => i.login))
if (data.length === 100)
collaborators.push(...(await fetchContributors(page + 1)))
return collaborators.filter(name => !name.includes('[bot]'))
}
async function generate() {
const collaborators = await fetchContributors()
await fs.writeFile('./docs/.vitepress/contributor-names.json', `${JSON.stringify(collaborators, null, 2)}\n`, 'utf8')
}
generate()