(
owner: string,
repo: string,
opts: FetchOptions = {},
)
| 253 | } |
| 254 | |
| 255 | export async function fetchGitHubRepoMeta( |
| 256 | owner: string, |
| 257 | repo: string, |
| 258 | opts: FetchOptions = {}, |
| 259 | ): Promise<GitHubRepoMeta | null> { |
| 260 | try { |
| 261 | const res = await fetchWithRateLimit( |
| 262 | `https://api.github.com/repos/${owner}/${repo}`, |
| 263 | { |
| 264 | cache: "no-store", |
| 265 | headers: { |
| 266 | Accept: "application/vnd.github.v3+json", |
| 267 | ...githubAuthHeaders(), |
| 268 | }, |
| 269 | maxWaitMs: opts.maxWaitMs, |
| 270 | }, |
| 271 | ); |
| 272 | if (!res.ok) return null; |
| 273 | const data = await res.json(); |
| 274 | return { |
| 275 | id: Number(data.id), |
| 276 | stars: Number(data.stargazers_count ?? 0), |
| 277 | fork: Boolean(data.fork), |
| 278 | archived: Boolean(data.archived), |
| 279 | default_branch: String(data.default_branch ?? "HEAD"), |
| 280 | license_spdx: data.license?.spdx_id ?? null, |
| 281 | }; |
| 282 | } catch { |
| 283 | return null; |
| 284 | } |
| 285 | } |
| 286 | |
| 287 | export async function parseGitHubPlugin( |
| 288 | url: string, |
no test coverage detected