@octokit/types#Endpoints TypeScript Examples

The following examples show how to use @octokit/types#Endpoints. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: repos.ts    From dataset with The Unlicense 6 votes vote down vote up
async function getRepos(org: string) {
  let repos: Endpoints['GET /orgs/{org}/repos']['response']['data'] = [];
  let page = 0;
  while (true) {
    const { data } = await github.repos.listForOrg({ org, per_page: 100, page });
    repos.push(...data);
    if (data.length < 100) {
      break;
    }
    page++;
  }
  return repos;
}
Example #2
Source File: proposals.ts    From dataset with The Unlicense 5 votes vote down vote up
export async function getProposals() {
  const repos = await getTC39Repos();
  const records: BundleProposals = [];
  for (const proposal of await readAllProposals()) {
    let data: Endpoints['GET /repos/{owner}/{repo}']['response']['data'] | Endpoints['GET /orgs/{org}/repos']['response']['data'][number] | undefined;
    if (proposal.url?.includes('github.com')) {
      const result = parseGithubURL(proposal.url)!;
      data = repos.find(({ owner, name }) => owner?.login === result.owner && name === result.name);
      if (_.isNil(data)) {
        try {
          const response = await github.repos.get({ owner: result.owner!, repo: result.name! });
          data = response.data;
        } catch (error) {
          console.error('::error::[Skip]', proposal.url, error.message);
          continue;
        }
      }
      if (data.owner?.login !== result.owner || data.name !== result.name) {
        console.error('::error::[Transferred]', proposal.url, '->', data.html_url);
      }
    }
    console.log(`Added \`${proposal.name}\``);
    let spec: string | undefined;
    if (data?.owner?.login === 'tc39' && /^proposal-/.test(data.name)) {
      spec = `https://tc39.es/${data.name}/`;
      const response = await fetch(spec, { method: 'HEAD', redirect: 'manual' });
      if (response.status !== 200) {
        spec = undefined;
      }
    } else if (data?.owner?.login !== 'tc39') {
      spec = `https://${data?.owner?.login}.github.io/${data?.name}/`;
      const response = await fetch(spec, { method: 'HEAD', redirect: 'manual' });
      if (response.status !== 200) {
        spec = undefined;
      }
    }
    if (proposal.rationale && /withdrawn/i.test(proposal.rationale)) {
      proposal.tags.push('withdrawn');
    } else if (proposal.stage === -1) {
      proposal.tags.push('inactive');
    }
    if (data?.archived) {
      proposal.tags.push('archived');
    }
    records.push({
      'tags': proposal.tags,
      'stage': proposal.stage,
      'name': proposal.name,

      'id': data?.name && /^proposal-/.test(data?.name) ? data?.name : undefined,
      'description': data?.description?.trim() ?? undefined,

      'url': proposal.url?.includes('/blob/master/') ? proposal.url : data?.html_url ?? proposal.url,
      'tests': proposal.tests,
      'notes': proposal.notes,

      'has-specification': Boolean(spec),

      'authors': proposal.authors,
      'champions': proposal.champions,

      'rationale': proposal.rationale,
      'edition': proposal.edition ? +proposal.edition : undefined,

      'pushed_at': data?.pushed_at ? new Date(data?.pushed_at).toISOString() : undefined,
    });
  }
  return _.chain(records)
    .sortBy(({ pushed_at }) => (pushed_at ? new Date(pushed_at).getTime() : 0))
    .reverse()
    .value();
}