Skip to content

Commit

Permalink
refactor: use named { Octokit } export from @octokit/rest
Browse files Browse the repository at this point in the history
  • Loading branch information
gr2m committed Feb 3, 2020
1 parent a64f0b4 commit 849af55
Show file tree
Hide file tree
Showing 9 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion source/danger.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Autogenerated from scripts/danger-dts.ts
//

import * as GitHub from "@octokit/rest"
import { Octokit as GitHub } from "@octokit/rest"

type MarkdownString = string
// TODO: extract out from BitBucket specifically, or create our own type
Expand Down
2 changes: 1 addition & 1 deletion source/dsl/GitHubDSL.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Please don't have includes in here that aren't inside the DSL folder, or the d.ts/flow defs break

import { GitCommit } from "./Commit"
import * as GitHub from "@octokit/rest"
import { Octokit as GitHub } from "@octokit/rest"

// This is `danger.github` inside the JSON

Expand Down
2 changes: 1 addition & 1 deletion source/platforms/GitHub.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { GitHubAPI } from "./github/GitHubAPI"
import GitHubUtils from "./github/GitHubUtils"
import gitDSLForGitHub from "./github/GitHubGit"

import NodeGitHub from "@octokit/rest"
import { Octokit as NodeGitHub } from "@octokit/rest"
import { Platform } from "./platform"

import { GitHubIssueCommenter } from "./github/comms/issueCommenter"
Expand Down
2 changes: 1 addition & 1 deletion source/platforms/github/GitHubAPI.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import GitHubNodeAPI from "@octokit/rest"
import { Octokit as GitHubNodeAPI } from "@octokit/rest"
import { debug } from "../../debug"
import * as node_fetch from "node-fetch"
import parse from "parse-link-header"
Expand Down
2 changes: 1 addition & 1 deletion source/platforms/github/GitHubUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { filepathContentsMapToUpdateGitHubBranch, BranchCreationConfig } from "m

const d = debug("GitHub::Utils")

import * as GitHub from "@octokit/rest"
import { Octokit as GitHub } from "@octokit/rest"

// We need to curry in access to the GitHub PR metadata

Expand Down
2 changes: 1 addition & 1 deletion source/platforms/github/_tests/_github_git.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { readFileSync } from "fs"
import { resolve, join as pathJoin } from "path"
import { gitHubGitDSL as gitJSONToGitDSL } from "../GitHubGit"

import NodeGitHub from "@octokit/rest"
import { Octokit as NodeGitHub } from "@octokit/rest"
import { GitHubDSL } from "../../../dsl/GitHubDSL"
import { GitDSL, GitJSONDSL } from "../../../dsl/GitDSL"

Expand Down
2 changes: 1 addition & 1 deletion source/platforms/github/_tests/fixturedGitHubDSL.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { readFileSync } from "fs"
import { resolve, join as pathJoin } from "path"
import { gitHubGitDSL as gitJSONToGitDSL } from "../GitHubGit"

import NodeGitHub from "@octokit/rest"
import { Octokit as NodeGitHub } from "@octokit/rest"
import { GitHubDSL } from "../../../dsl/GitHubDSL"
import { GitDSL, GitJSONDSL } from "../../../dsl/GitDSL"
import { DangerDSLType } from "../../../dsl/DangerDSL"
Expand Down
2 changes: 1 addition & 1 deletion source/platforms/github/comms/checks/resultsToCheck.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { DangerResults, regularResults, inlineResults, resultsIntoInlineResults
import { GitHubPRDSL } from "../../../../dsl/GitHubDSL"
import { ExecutorOptions } from "../../../../runner/Executor"
import { template as githubResultsTemplate } from "../../../../runner/templates/githubIssueTemplate"
import GitHubNodeAPI from "@octokit/rest"
import { Octokit as GitHubNodeAPI } from "@octokit/rest"
import { debug } from "../../../../debug"

const d = debug("GitHub::ResultsToCheck")
Expand Down
10 changes: 5 additions & 5 deletions source/runner/jsonToDSL.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import OctoKit from "@octokit/rest"
import { Octokit } from "@octokit/rest"

import { DangerDSLJSONType, DangerDSLType } from "../dsl/DangerDSL"
import { gitHubGitDSL as githubJSONToGitDSL } from "../platforms/github/GitHubGit"
Expand Down Expand Up @@ -31,7 +31,7 @@ export const jsonToDSL = async (dsl: DangerDSLJSONType, source: CISource): Promi

const api = apiForDSL(dsl)
const platformExists = [dsl.github, dsl.bitbucket_server, dsl.gitlab, dsl.bitbucket_cloud].some(p => !!p)
const github = dsl.github && githubJSONToGitHubDSL(dsl.github, api as OctoKit)
const github = dsl.github && githubJSONToGitHubDSL(dsl.github, api as Octokit)
const bitbucket_server =
dsl.bitbucket_server && bitbucketServerJSONToBitBucketServerDSL(dsl.bitbucket_server, api as BitBucketServerAPI)
const bitbucket_cloud = dsl.bitbucket_cloud
Expand Down Expand Up @@ -67,7 +67,7 @@ export const jsonToDSL = async (dsl: DangerDSLJSONType, source: CISource): Promi
}
}

const apiForDSL = (dsl: DangerDSLJSONType): OctoKit | BitBucketServerAPI | GitLabAPI | BitBucketCloudAPI => {
const apiForDSL = (dsl: DangerDSLJSONType): Octokit | BitBucketServerAPI | GitLabAPI | BitBucketCloudAPI => {
if (process.env["DANGER_BITBUCKETSERVER_HOST"]) {
return new BitBucketServerAPI(dsl.bitbucket_server!.metadata, bitbucketServerRepoCredentialsFromEnv(process.env))
}
Expand All @@ -82,7 +82,7 @@ const apiForDSL = (dsl: DangerDSLJSONType): OctoKit | BitBucketServerAPI | GitLa
return new GitLabAPI(gitlab.metadata, getGitLabAPICredentialsFromEnv(process.env))
}

const options: OctoKit.Options & { debug: boolean } = {
const options: Octokit.Options & { debug: boolean } = {
debug: !!process.env.LOG_FETCH_REQUESTS,
baseUrl: dsl.settings.github.baseURL,
}
Expand All @@ -102,6 +102,6 @@ const apiForDSL = (dsl: DangerDSLJSONType): OctoKit | BitBucketServerAPI | GitLa
options.auth = `token ${dsl.settings.github.accessToken}`
}

const api = new OctoKit(options)
const api = new Octokit(options)
return api
}

0 comments on commit 849af55

Please sign in to comment.