Skip to content

Commit f42a724

Browse files
committed
[GitLab] Move to gitbeaker/rest
Major version 36 of gitbeaker contains changes to the type system and the structure of the framework. Moved to gitbeaker/rest which is the expected package to consume going forward, and adjusted our usage of the types to match the changes in the framework. Additionally gitbeaker now leverages native-fetch under the hood which nock does not support. Version 4.0.0 of nock in beta can handle testing native-fetch, but does not yet support recording fixtures. To continue using nock for testing without updating to the beta-version, a fetch polyfill has been introduced to use for the gitlab api tests.
1 parent 3f3f7ec commit f42a724

19 files changed

+5565
-2005
lines changed

CHANGELOG.md

+2
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
<!-- Your comment below this -->
1818
- Upgrade `node` engine from `>=14.13.1` to `>=18` [@heltoft]
1919
- Upgrade `@types/node` from `^10.11.3` to `18.19.18` [@heltoft]
20+
- GitLab: [#1386] Move from `@gitbeaker/node` to `@gitbeaker/rest` [@heltoft]
21+
- GitLab: [#1412] Danger fails to create inline comments on Gitlab [@heltoft]
2022
<!-- Your comment above this -->
2123

2224
## 11.3.1

package.json

+1-2
Original file line numberDiff line numberDiff line change
@@ -150,8 +150,7 @@
150150
"debug": "^4.1.1",
151151
"fast-json-patch": "^3.0.0-1",
152152
"get-stdin": "^6.0.0",
153-
"@gitbeaker/core": "^35.8.1",
154-
"@gitbeaker/node": "^35.8.1",
153+
"@gitbeaker/rest": "^38.0.0",
155154
"http-proxy-agent": "^5.0.0",
156155
"https-proxy-agent": "^5.0.1",
157156
"hyperlinker": "^1.0.0",

scripts/danger-dts.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@ const createDTS = () => {
99
//
1010
1111
import { Octokit as GitHub } from "@octokit/rest"
12-
import { Gitlab, Types } from "@gitbeaker/node"
13-
import { Types as CoreTypes } from "@gitbeaker/core/dist"
12+
import type * as Types from "@gitbeaker/rest"
1413
import { File } from "parse-diff"
1514
1615
`

source/commands/danger-pr.ts

+4-6
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import { prepareDangerDSL } from "./utils/runDangerSubprocess"
1313
import { runRunner } from "./ci/runner"
1414
import { Platform, getPlatformForEnv } from "../platforms/platform"
1515
import { CISource } from "../ci_source/ci_source"
16-
import { getGitLabAPICredentialsFromEnv } from "../platforms/gitlab/GitLabAPI"
16+
import { getGitLabHostFromEnv } from "../platforms/gitlab/GitLabAPI"
1717

1818
const d = debug("pr")
1919
const log = console.log
@@ -25,8 +25,6 @@ interface App extends SharedCLI {
2525
js?: boolean
2626
}
2727

28-
const gitLabApiCredentials = getGitLabAPICredentialsFromEnv(process.env)
29-
3028
program
3129
.usage("[options] <pr_url>")
3230
.description("Emulate running Danger against an existing GitHub Pull Request.")
@@ -43,8 +41,8 @@ program
4341
!process.env["DANGER_BITBUCKETCLOUD_OAUTH_KEY"] &&
4442
!process.env["DANGER_BITBUCKETCLOUD_USERNAME"] &&
4543
!process.env["DANGER_BITBUCKETCLOUD_REPO_ACCESSTOKEN"] &&
46-
!gitLabApiCredentials.token &&
47-
!gitLabApiCredentials.oauthToken
44+
!process.env["DANGER_GITLAB_API_TOKEN"] &&
45+
!process.env["DANGER_GITLAB_API_OAUTH_TOKEN"]
4846
) {
4947
log("")
5048
log(
@@ -74,7 +72,7 @@ if (program.args.length === 0) {
7472
process.exitCode = 1
7573
} else {
7674
const customHost =
77-
process.env["DANGER_GITHUB_HOST"] || process.env["DANGER_BITBUCKETSERVER_HOST"] || gitLabApiCredentials.host // this defaults to https://gitlab.com
75+
process.env["DANGER_GITHUB_HOST"] || process.env["DANGER_BITBUCKETSERVER_HOST"] || getGitLabHostFromEnv(process.env) // This defaults to https://www.gitlab.com
7876

7977
// Allow an ambiguous amount of args to find the PR reference
8078
const findPR = program.args.find((a) => a.includes(customHost) || a.includes("github") || a.includes("bitbucket.org"))

0 commit comments

Comments
 (0)