diff --git a/tools/getIssue.ts b/tools/getIssue.ts index 62c27b3..706a7d4 100644 --- a/tools/getIssue.ts +++ b/tools/getIssue.ts @@ -1,15 +1,6 @@ #! /usr/bin/env deno run --allow-net --allow-env +import {Issue} from "./githubType.ts"; -type Issue = { - id: number; - url: string; - title: string; - body: string; - number: number, - labels: { - name: string; - }[] -} /** * get issue from github * @param repo repository name with owner (e.g. denoland/deno) @@ -21,8 +12,9 @@ type Issue = { * console.log(issues); * ``` */ -async function getIssues(repo: string, token: string): Promise { - const res = await fetch(`https://api.github.com/repos/${repo}/issues?per_page=100`, { +export async function getIssues(repo: string, token: string): Promise { + //check https://docs.github.com/en/rest/reference/issues#list-repository-issues + const res = await fetch(`https://api.github.com/repos/${repo}/issues?per_page=100&labels=feature`, { headers: { Accept: 'application/vnd.github.v3+json', Authorization: `Token ${token}` diff --git a/tools/githubType.ts b/tools/githubType.ts new file mode 100644 index 0000000..b8cd893 --- /dev/null +++ b/tools/githubType.ts @@ -0,0 +1,81 @@ +export type User = { + login: string; + id: number; + node_id: string; + avatar_url: string; + gravatar_id: string; + url: string; + html_url: string; + followers_url: string; + following_url: string; + gists_url: string; + starred_url: string; + subscriptions_url: string; + organizations_url: string; + repos_url: string; + events_url: string; + received_events_url: string; + type: string; + site_admin: boolean; +}; +export type Label = { + id: number; + node_id: string; + url: string; + name: string; + description: string; + color: string; + default: boolean; +}; +export type Milestone = { + url: string; + html_url: string; + labels_url: string; + id: number; + node_id: string; + number: number; + state: string; + title: string; + description: string; + creator: User; + open_issues: number; + closed_issues: number; + created_at: string; + updated_at: string; + closed_at?: string; + due_on: string; +}; +export type PullRequest = { + url: string; + html_url: string; + diff_url: string; + patch_url: string; +}; +export type Issue = { + id: number; + node_id: string; + url: string; + repository_url: string; + labels_url: string; + comments_url: string; + events_url: string; + html_url: string; + number: number; + state: string; + title: string; + body: string; + user: User; + labels: Label[]; + assignee: User; + assignees: User[]; + milestone: any; + locked: boolean; + active_lock_reason: string; + comments: number; + pull_request: PullRequest; + closed_at?: string; + created_at: string; + updated_at: string; + closed_by: User; + author_association: string; +}; \ No newline at end of file