Skip to content

Commit

Permalink
fix: use proper octokit package
Browse files Browse the repository at this point in the history
This fixes a problem where we were using the base packages that make up the octokit package
  • Loading branch information
ajhenry committed Feb 15, 2024
1 parent dad7319 commit 9d16aa5
Show file tree
Hide file tree
Showing 12 changed files with 537 additions and 389 deletions.
183 changes: 181 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@
"dependencies": {
"@octokit/auth-app": "6.0.3",
"@octokit/auth-token": "4.0.0",
"@octokit/core": "5.0.2",
"@octokit/plugin-throttling": "8.1.3",
"@octokit/types": "12.4.0",
"@primer/octicons-react": "19.8.0",
"@primer/react": "35.32.2",
Expand All @@ -31,6 +29,7 @@
"@trpc/server": "10.44.1",
"next": "13.5.5",
"next-auth": "4.24.5",
"octokit": "^3.1.2",
"probot": "12.3.3",
"react": "18.2.0",
"react-dom": "18.2.0",
Expand Down
2 changes: 1 addition & 1 deletion src/bot/octokit.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { createAppAuth } from '@octokit/auth-app'
import { Octokit } from 'octokit'
import { logger } from 'utils/logger'
import { Octokit } from './rest'

const personalOctokitLogger = logger.getSubLogger({ name: 'personal-octokit' })
const appOctokitLogger = logger.getSubLogger({ name: 'app-octokit' })
Expand Down
17 changes: 0 additions & 17 deletions src/bot/rest.ts

This file was deleted.

2 changes: 1 addition & 1 deletion src/pages/api/auth/[...nextauth].ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export const verifySession = async (token: string | undefined) => {

const octokit = personalOctokit(token)
try {
await octokit.users.getAuthenticated()
await octokit.rest.users.getAuthenticated()
return true
} catch (error) {
return false
Expand Down
2 changes: 1 addition & 1 deletion src/pages/organizations.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const Organizations: FC<OrganizationsProps> = () => {
// fetch all the organizations a user is in via octokit
const getAllOrganizations = async (accessToken: string) => {
const octokit = personalOctokit(accessToken)
const data = await octokit.orgs.listForAuthenticatedUser()
const data = await octokit.rest.orgs.listForAuthenticatedUser()
return data.data
}

Expand Down
8 changes: 4 additions & 4 deletions src/pages/orgs/[organizationId]/forks/[forkId].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,18 @@ import { getAuthServerSideProps } from 'components/auth-guard'
import { CreateMirrorDialog } from 'components/create-mirror'
import { useRouter } from 'next/router'
import type { InferGetServerSidePropsType } from 'next/types'
import { Octokit } from 'octokit'
import { useCallback, useEffect, useState } from 'react'
import { trpc } from 'utils/trpc'
import { Octokit } from '../../../../bot/rest'

const getOrgInformation = async (accessToken: string, orgId: string) => {
return (await personalOctokit(accessToken).orgs.get({ org: orgId })).data
return (await personalOctokit(accessToken).rest.orgs.get({ org: orgId })).data
}

const getForkById = async (
accessToken: string,
repoId: string,
): Promise<Awaited<ReturnType<Octokit['repos']['get']>>['data']> => {
): Promise<Awaited<ReturnType<Octokit['rest']['repos']['get']>>['data']> => {
return (
await personalOctokit(accessToken).request('GET /repositories/:id', {
id: repoId,
Expand All @@ -30,7 +30,7 @@ const findMirrors = async (
forkName: string,
) => {
return (
await personalOctokit(accessToken).search.repos({
await personalOctokit(accessToken).rest.search.repos({
q: `org:${orgName} in:description "mirror:${orgName}/${forkName}"`,
})
).data
Expand Down
6 changes: 3 additions & 3 deletions src/pages/orgs/[organizationId]/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ const getOrganizationInformation = async (
accessToken: string,
orgId: string,
) => {
return (await personalOctokit(accessToken).orgs.get({ org: orgId })).data
return (await personalOctokit(accessToken).rest.orgs.get({ org: orgId })).data
}

const getForksInOrg = async (accessToken: string, owner: string) => {
return (
await personalOctokit(accessToken).repos.listForOrg({
await personalOctokit(accessToken).rest.repos.listForOrg({
per_page: 100,
type: 'forks',
org: owner,
Expand All @@ -29,7 +29,7 @@ const getForksInOrg = async (accessToken: string, owner: string) => {

const getParent = async (accessToken: string, owner: string, repo: string) => {
return (
await personalOctokit(accessToken).repos.get({
await personalOctokit(accessToken).rest.repos.get({
owner,
repo,
})
Expand Down
Loading

0 comments on commit 9d16aa5

Please sign in to comment.