| e93a978 | | | 1 | import { hubRequest } from "../api.js"; |
| e93a978 | | | 2 | |
| e93a978 | | | 3 | interface Repo { |
| e93a978 | | | 4 | id: number; |
| e93a978 | | | 5 | owner_name: string; |
| e93a978 | | | 6 | name: string; |
| e93a978 | | | 7 | description: string | null; |
| e93a978 | | | 8 | default_branch: string; |
| e93a978 | | | 9 | created_at: string; |
| e93a978 | | | 10 | } |
| e93a978 | | | 11 | |
| e93a978 | | | 12 | export async function repoList() { |
| e93a978 | | | 13 | const { repos } = await hubRequest<{ repos: Repo[] }>("/api/repos"); |
| e93a978 | | | 14 | |
| e93a978 | | | 15 | if (repos.length === 0) { |
| e93a978 | | | 16 | console.log("No repositories."); |
| e93a978 | | | 17 | return; |
| e93a978 | | | 18 | } |
| e93a978 | | | 19 | |
| e93a978 | | | 20 | for (const repo of repos) { |
| e93a978 | | | 21 | const desc = repo.description ? ` ${repo.description}` : ""; |
| e93a978 | | | 22 | console.log(`${repo.owner_name}/${repo.name}${desc}`); |
| e93a978 | | | 23 | } |
| e93a978 | | | 24 | } |