master
1import { task } from '../../task.js'
2import { paginate } from '../../utils.js'
3import { StarsQuery } from './stars.graphql.js'
4
5export default task({
6 name: 'stars' as const,
7 run: async ({ octokit, data }, { username }: { username: string }) => {
8 const stars = paginate(octokit, StarsQuery, {
9 login: username,
10 })
11
12 data.starredRepositories = []
13 for await (const resp of stars) {
14 if (!resp.user?.starredRepositories.nodes) {
15 throw new Error('Failed to load stars')
16 }
17
18 for (const repo of resp.user.starredRepositories.nodes) {
19 data.starredRepositories.push(repo)
20 }
21 octokit.log.info(
22 `| stars ${data.starredRepositories.length}/${resp.user.starredRepositories.totalCount} (cost: ${resp.rateLimit?.cost}, remaining: ${resp.rateLimit?.remaining})`,
23 )
24 }
25 },
26})