Skip to content

Commit

Permalink
chore: rename new ReposFromGithub interface to GithubRepos
Browse files Browse the repository at this point in the history
Co-authored-by: Dylan Spyer <[email protected]>
  • Loading branch information
benhancock and dylanspyer committed Oct 17, 2024
1 parent 44ef7ae commit 36fb446
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
8 changes: 4 additions & 4 deletions src/commands/sites/sites-create-template.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@ import { configureRepo } from '../../utils/init/config.js'
import { createRepo, getTemplatesFromGitHub, validateTemplate } from '../../utils/sites/utils.js'
import { track } from '../../utils/telemetry/index.js'
import BaseCommand from '../base-command.js'
import { RepoFromGithub, Template } from '../../utils/types.js'
import { GithubRepo, Template } from '../../utils/types.js'
import { getSiteNameInput } from './sites-create.js'

export const fetchTemplates = async (token: string): Promise<Template[]> => {
const templatesFromGithubOrg: RepoFromGithub[] = await getTemplatesFromGitHub(token)
const templatesFromGithubOrg: GithubRepo[] = await getTemplatesFromGitHub(token)

return templatesFromGithubOrg
.filter((repo: RepoFromGithub) => !repo.archived && !repo.disabled)
.map((template: RepoFromGithub) => ({
.filter((repo: GithubRepo) => !repo.archived && !repo.disabled)
.map((template: GithubRepo) => ({
name: template.name,
sourceCodeUrl: template.html_url,
slug: template.full_name,
Expand Down
8 changes: 4 additions & 4 deletions src/utils/sites/utils.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import fetch from 'node-fetch'
import { error } from '../../utils/command-helpers.js'
import { RepoFromGithub } from '../../utils/types.js'
import { GithubRepo } from '../../utils/types.js'

export const getTemplatesFromGitHub = async (token: string): Promise<RepoFromGithub[]> => {
export const getTemplatesFromGitHub = async (token: string): Promise<GithubRepo[]> => {
const getPublicGitHubReposFromOrg = new URL(`https://api.github.com/orgs/netlify-templates/repos`)
// GitHub returns 30 by default and we want to avoid our limit
// due to our archived repositories at any given time
Expand All @@ -13,15 +13,15 @@ export const getTemplatesFromGitHub = async (token: string): Promise<RepoFromGit
// @ts-expect-error TS(2345) FIXME: Argument of type 'number' is not assignable to par... Remove this comment to see the full error message
getPublicGitHubReposFromOrg.searchParams.set('per_page', REPOS_PER_PAGE)

let allTemplates: RepoFromGithub[] = []
let allTemplates: GithubRepo[] = []
try {
const templates = await fetch(getPublicGitHubReposFromOrg, {
method: 'GET',
headers: {
Authorization: `token ${token}`,
},
})
allTemplates = (await templates.json()) as RepoFromGithub[]
allTemplates = (await templates.json()) as GithubRepo[]
} catch (error_) {
// @ts-expect-error TS(2345) FIXME: Argument of type 'unknown' is not assignable to pa... Remove this comment to see the full error message
error(error_)
Expand Down
2 changes: 1 addition & 1 deletion src/utils/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ export interface Account {
updated_at: string
}

export interface RepoFromGithub {
export interface GithubRepo {
name: string
html_url: string
full_name: string
Expand Down

0 comments on commit 36fb446

Please sign in to comment.