diff --git a/CHANGELOG.md b/CHANGELOG.md index c67b529d8..641a9b0d6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,13 +15,22 @@ ## Main + + +## 12.0.0 + +Bumping to 12.x because we've raised the minimum to node version from 14 to 18. This is due to some of our dependencies +requiring a newer version of node. This is a breaking change for some folk! Also, 14 has been out of support for quite a while +now and Node 18 gives us a full year. - [@orta] + +- Remove the user checks in GitHub comment/inline comment lookups, to allow using app tokens [#1433] - [@orta] - Upgrade `node` engine from `>=14.13.1` to `>=18` [@heltoft] - Upgrade `@types/node` from `^10.11.3` to `18.19.18` [@heltoft] - GitLab: [#1386] Move from `@gitbeaker/node` to `@gitbeaker/rest` [@heltoft] - GitLab: [#1412] Danger fails to create inline comments on Gitlab [@heltoft] - GitLab: [#1405] Can't post multiple inline comments [@heltoft] - GitLab: Do not delete system resolved danger inline comments [@heltoft] - + ## 11.3.1 diff --git a/package.json b/package.json index 0982b5ae3..a2b7a1241 100644 --- a/package.json +++ b/package.json @@ -1,19 +1,19 @@ { "name": "danger", - "version": "11.3.1", + "version": "12.0.0", "description": "Unit tests for Team Culture", "main": "distribution/danger.js", "typings": "distribution/danger.d.ts", "bin": { "danger": "distribution/commands/danger.js", - "danger-js": "distribution/commands/danger.js", - "danger-pr": "distribution/commands/danger-pr.js", - "danger-runner": "distribution/commands/danger-runner.js", - "danger-process": "distribution/commands/danger-process.js", "danger-ci": "distribution/commands/danger-ci.js", "danger-init": "distribution/commands/danger-init.js", + "danger-js": "distribution/commands/danger.js", "danger-local": "distribution/commands/danger-local.js", - "danger-reset-status": "distribution/commands/danger-reset-status.js" + "danger-pr": "distribution/commands/danger-pr.js", + "danger-process": "distribution/commands/danger-process.js", + "danger-reset-status": "distribution/commands/danger-reset-status.js", + "danger-runner": "distribution/commands/danger-runner.js" }, "jest": { "preset": "ts-jest", @@ -77,6 +77,7 @@ "type": "git", "url": "git+https://github.com/danger/danger-js.git" }, + "packageManager": "yarn@1.22.19", "keywords": [ "danger", "ci" @@ -142,6 +143,7 @@ "typescript-json-schema": "^0.53.0" }, "dependencies": { + "@gitbeaker/rest": "^38.0.0", "@octokit/rest": "^18.12.0", "async-retry": "1.2.3", "chalk": "^2.3.0", @@ -150,7 +152,6 @@ "debug": "^4.1.1", "fast-json-patch": "^3.0.0-1", "get-stdin": "^6.0.0", - "@gitbeaker/rest": "^38.0.0", "http-proxy-agent": "^5.0.0", "https-proxy-agent": "^5.0.1", "hyperlinker": "^1.0.0", @@ -180,7 +181,6 @@ "require-from-string": "^2.0.2", "supports-hyperlinks": "^1.0.1" }, - "optionalDependencies": {}, "husky": { "hooks": { "pre-commit": "lint-staged", diff --git a/source/platforms/github/GitHubAPI.ts b/source/platforms/github/GitHubAPI.ts index 9c8e7e327..0c8ab70d2 100644 --- a/source/platforms/github/GitHubAPI.ts +++ b/source/platforms/github/GitHubAPI.ts @@ -83,14 +83,11 @@ export class GitHubAPI { // The above is the API for Platform getDangerCommentIDs = async (dangerID: string): Promise => { - const userID = await this.getUserID() const allComments = await this.getPullRequestComments() const dangerIDMessage = dangerIDToString(dangerID) - this.d(`User ID: ${userID}`) this.d(`Looking at ${allComments.length} comments for ${dangerIDMessage}`) return allComments .filter((comment) => comment.body.includes(dangerIDMessage)) // does it contain the right danger ID? - .filter((comment) => comment.user.id === userID) // Does it have the right user ID? .filter((comment) => comment.body.includes("Generated by")) // Does it look like a danger message? .map((comment) => comment.id) // only return IDs } @@ -318,15 +315,15 @@ export class GitHubAPI { getPullRequestInlineComments = async ( dangerID: string ): Promise<(GitHubIssueComment & { ownedByDanger: boolean })[]> => { - const userID = await this.getUserID() const repo = this.repoMetadata.repoSlug const prID = this.repoMetadata.pullRequestID const dangerIDMessage = dangerIDToString(dangerID) return await this.getAllOfResource(`repos/${repo}/pulls/${prID}/comments`).then((v: GitHubIssueComment[]) => { return v - .filter(Boolean) + .filter((i) => !!i) .map((i) => { - return { ...i, ownedByDanger: i.user.id == userID && i.body.includes(dangerIDMessage) } + // Can't use && i.body.includes("Generated by") because it's not there on an inline comment + return { ...i, ownedByDanger: i.body.includes(dangerIDMessage) } }) .filter((i) => i.ownedByDanger) }) diff --git a/source/platforms/github/_tests/_github_api.test.ts b/source/platforms/github/_tests/_github_api.test.ts index b67f29e86..6c3782705 100644 --- a/source/platforms/github/_tests/_github_api.test.ts +++ b/source/platforms/github/_tests/_github_api.test.ts @@ -108,9 +108,8 @@ describe("API testing", () => { expect(commentIDs.length).toEqual(0) }) - it("getPullRequestInlineComment gets only comments for given DangerId", async () => { + it("getPullRequestInlineComment gets only comments for given dangerID", async () => { api.getAllOfResource = await requestWithFixturedJSON("github_inline_comments_with_danger.json") - api.getUserID = () => new Promise((r) => r(20229914)) const comments = await api.getPullRequestInlineComments("default") @@ -118,11 +117,10 @@ describe("API testing", () => { expect(comments[0].ownedByDanger).toBeTruthy() }) - it("getPullRequestInlineComment doesn't get comments as the DangerId is different", async () => { + it("getPullRequestInlineComment doesn't get comments as the dangerID is different", async () => { api.getAllOfResource = await requestWithFixturedJSON("github_inline_comments_with_danger.json") - api.getUserID = () => new Promise((r) => r(123)) - const comments = await api.getPullRequestInlineComments("default") + const comments = await api.getPullRequestInlineComments("other-danger-id") expect(comments.length).toEqual(0) })