Skip to content

Commit

Permalink
chore(docs): remove 'ohmyfetch' dependency and use 'tsx' instead of '…
Browse files Browse the repository at this point in the history
…esno' (unovue#788)
  • Loading branch information
MellKam authored Mar 27, 2024
1 parent 82d5aef commit 63ad899
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 87 deletions.
7 changes: 3 additions & 4 deletions docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
"docs:dev": "vitepress dev",
"docs:build": "vitepress build",
"docs:preview": "vitepress preview",
"docs:contributors": "esno scripts/update-contributors.ts",
"docs:gen": "esno scripts/autogen.ts"
"docs:contributors": "tsx scripts/update-contributors.ts",
"docs:gen": "tsx scripts/autogen.ts"
},
"peerDependencies": {
"typescript": "*"
Expand All @@ -29,12 +29,11 @@
"@vue/tsconfig": "^0.4.0",
"autoprefixer": "^10.4.16",
"codesandbox": "^2.2.3",
"esno": "^0.17.0",
"fast-glob": "^3.3.2",
"markdown-it": "^14.0.0",
"ohmyfetch": "^0.4.21",
"postcss": "^8.4.31",
"tailwindcss": "^3.3.3",
"tsx": "^4.7.1",
"vitepress": "1.0.0-rc.40",
"vue-component-meta": "^1.8.25"
},
Expand Down
29 changes: 16 additions & 13 deletions docs/scripts/update-contributors.ts
Original file line number Diff line number Diff line change
@@ -1,24 +1,27 @@
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/radix-vue/radix-vue/contributors?per_page=100&page=${page}`,
{
method: 'get',
headers: {
'content-type': 'application/json',
},
},
)) || []
collaborators.push(...data.map(i => i.login))
if (data.length === 100)

const res = await fetch(`https://api.github.com/repos/radix-vue/radix-vue/contributors?per_page=100&page=${page}`, {
headers: {
Accept: 'application/vnd.github+json',
},
})

if (!res.ok) {
console.error(`Failed to fetch contributors page #${page}: ${res.status} ${res.statusText} ${await res.text()}`)
return []
}

const data: Contributor[] = await res.json()

collaborators.push(...data.map(contributor => contributor.login))
if (res.headers.get('Link')?.includes('rel=\"next\"'))
collaborators.push(...(await fetchContributors(page + 1)))
return collaborators.filter(name => !name.includes('[bot]'))
}
Expand Down
74 changes: 4 additions & 70 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 63ad899

Please sign in to comment.