| 49 | } |
| 50 | |
| 51 | export async function fetchAllRepos(token: string): Promise<GitHubRepo[]> { |
| 52 | const allRepos: GitHubRepo[] = []; |
| 53 | let page = 1; |
| 54 | while (page <= 10) { |
| 55 | const res = await ghFetch( |
| 56 | `/user/repos?per_page=100&page=${page}&sort=updated&affiliation=owner,collaborator,organization_member`, |
| 57 | token |
| 58 | ); |
| 59 | if (!res.ok) break; |
| 60 | const data = await res.json(); |
| 61 | if (!Array.isArray(data) || data.length === 0) break; |
| 62 | allRepos.push(...data); |
| 63 | if (data.length < 100) break; |
| 64 | page++; |
| 65 | } |
| 66 | return allRepos; |
| 67 | } |
| 68 | |
| 69 | export async function testRepoPermission( |
| 70 | token: string, |