Skip to content

Commit

Permalink
Upgrade node engine to >=18.19.0 & @types/node to ^18.19.14
Browse files Browse the repository at this point in the history
The currently used node environment has reached end of life. Updating to 18.x which is the version with Maintenance status for Node.js.

- Upgraded node engine to >= 18.19.0
- Upgraded @types/node to ^18.19.14
  • Loading branch information
heltoft committed Feb 5, 2024
1 parent 5edb114 commit 1ff40fd
Show file tree
Hide file tree
Showing 10 changed files with 85 additions and 44 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
## Main

<!-- Your comment below this -->
- Upgrade `node` engine from `>=14.13.1` to `>=18.19.0` [@heltoft]
- Upgrade `@types/node` from `^10.11.3` to `^18.19.14` [@heltoft]
<!-- Your comment above this -->

## 11.3.1
Expand Down Expand Up @@ -2002,6 +2004,7 @@ Not usable for others, only stubs of classes etc. - [@orta]
[@hanneskaeufler]: https://github.com/hanneskaeufler
[@happylinks]: https://github.com/happylinks
[@hellocore]: https://github.com/HelloCore
[@heltoft]: https://github.com/heltoft
[@hiroppy]: https://github.com/hiroppy
[@hmcc]: https://github.com/hmcc
[@hmschreiner]: https://github.com/hmschreiner
Expand Down
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM node:14-slim as build
FROM node:18-slim as build

LABEL maintainer="Orta Therox"
LABEL "com.github.actions.name"="Danger JS Action"
Expand All @@ -16,7 +16,7 @@ RUN yarn install --production --frozen-lockfile
RUN chmod +x distribution/commands/danger.js


FROM node:14-slim
FROM node:18-slim
WORKDIR /usr/src/danger
ENV PATH="/usr/src/danger/node_modules/.bin:$PATH"
COPY package.json ./
Expand Down
2 changes: 1 addition & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Test against this version of Node.js
environment:
nodejs_version: "14"
nodejs_version: "18"

# Install scripts. (runs after repo cloning)
install:
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@
},
"homepage": "https://github.com/danger/danger-js#readme",
"engines": {
"node": ">=14.13.1"
"node": ">=18.19.0"
},
"devDependencies": {
"@babel/cli": "7.16.7",
Expand All @@ -109,7 +109,7 @@
"@types/lodash.mapvalues": "^4.6.6",
"@types/lodash.memoize": "^4.1.3",
"@types/micromatch": "^3.1.0",
"@types/node": "^10.11.3",
"@types/node": "^18.19.14",
"@types/node-fetch": "^2.5.12",
"@types/p-limit": "^2.0.0",
"@types/prettier": "^1.16.1",
Expand All @@ -123,7 +123,7 @@
"eslint": "^8.8.0",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-jest": "^26.0.0",
"eslint-plugin-jsdoc": "^37.7.0",
"eslint-plugin-jsdoc": "^39.9.1",
"flow-bin": "^0.77.0",
"husky": "^1.0.1",
"jest": "^24.0.0",
Expand Down
10 changes: 8 additions & 2 deletions source/api/_tests/fetch.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,10 @@ class TestServer {
start = async (response: ResponseMock): Promise<void> => {
this.response = response
return new Promise<void>((resolve, reject) => {
this.server.listen(this.port, this.hostname, (err: any) => (err ? reject(err) : resolve()))
this.server.on("error", (e) => {
reject(e)
})
this.server.listen(this.port, this.hostname, undefined, () => resolve())
})
}
stop = async (): Promise<void> => {
Expand All @@ -52,7 +55,10 @@ class TestProxy {
start = async (): Promise<void> => {
return new Promise<void>((resolve, reject) => {
this.isRunning = true
this.server.listen(this.port, this.hostname, (err: any) => (err ? reject(err) : resolve()))
this.server.on("error", (e) => {
reject(e)
})
this.server.listen(this.port, this.hostname, undefined, () => resolve())
})
}
stop = async (): Promise<void> => {
Expand Down
17 changes: 17 additions & 0 deletions source/platforms/_tests/_encoding_parser.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { encodingParser } from "../encodingParser"

describe("parsing encoding", () => {
it("handles base64", () => {
expect(encodingParser("base64")).toEqual("base64")
})

it("handles utf8", () => {
expect(encodingParser("utf8")).toEqual("utf8")
})

it("throws on unknown encoding", () => {
expect(() => {
encodingParser("unknownencoding")
}).toThrowError()
})
})
10 changes: 10 additions & 0 deletions source/platforms/encodingParser.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/**
* Verifies that the given encoding is a valid BufferEncoding.
* @throws in case the encoding is unsupported.
*/
export function encodingParser(encoding: string): BufferEncoding {
if (Buffer.isEncoding(encoding)) {
return encoding as BufferEncoding
}
throw new Error(`Unsupported buffer encoding ${encoding}`)
}
4 changes: 3 additions & 1 deletion source/platforms/github/GitHubUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { filepathContentsMapToUpdateGitHubBranch, BranchCreationConfig } from "m
import { sentence, href } from "../../runner/DangerUtils"
import { GitHubPRDSL, GitHubUtilsDSL } from "./../../dsl/GitHubDSL"
import { debug } from "../../debug"
import { encodingParser } from "../encodingParser"

export type GetContentResponseData =
| OctokitOpenApiTypes["schemas"]["content-file"]
Expand Down Expand Up @@ -87,7 +88,8 @@ export const fileContentsGenerator =
return ""
}
if (isFileContents(response.data) && response.data.content) {
const buffer = Buffer.from(response.data.content, response.data.encoding)
const encoding = encodingParser(response.data.encoding)
const buffer = Buffer.from(response.data.content, encoding)
return buffer.toString()
} else {
return ""
Expand Down
4 changes: 3 additions & 1 deletion source/platforms/gitlab/GitLabAPI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { Gitlab, Types } from "@gitbeaker/node"
import { Types as CoreTypes } from "@gitbeaker/core/dist"
import { Env } from "../../ci_source/ci_source"
import { debug } from "../../debug"
import { encodingParser } from "../encodingParser"

export type GitLabAPIToken = string
export type GitLabOAuthToken = string
Expand Down Expand Up @@ -209,7 +210,8 @@ class GitLabAPI {
try {
this.d("getFileContents", projectId, path, ref)
const response = await api.show(projectId, path, ref)
const result: string = Buffer.from(response.content, response.encoding).toString()
const encoding = encodingParser(response.encoding)
const result: string = Buffer.from(response.content, encoding).toString()
this.d("getFileContents", result)
return result
} catch (e) {
Expand Down
69 changes: 35 additions & 34 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1162,14 +1162,14 @@
dependencies:
"@cspotcode/source-map-consumer" "0.8.0"

"@es-joy/jsdoccomment@~0.18.0":
version "0.18.0"
resolved "https://registry.yarnpkg.com/@es-joy/jsdoccomment/-/jsdoccomment-0.18.0.tgz#2532b2ecb8576d694011b157c447ed6b12534c70"
integrity sha512-TjT8KJULV4I6ZiwIoKr6eMs+XpRejqwJ/VA+QPDeFGe9j6bZFKmMJ81EeFsGm6JNZhnzm37aoxVROmTh2PZoyA==
"@es-joy/jsdoccomment@~0.36.1":
version "0.36.1"
resolved "https://registry.yarnpkg.com/@es-joy/jsdoccomment/-/jsdoccomment-0.36.1.tgz#c37db40da36e4b848da5fd427a74bae3b004a30f"
integrity sha512-922xqFsTpHs6D0BUiG4toiyPOMc8/jafnWKxz1KWgS4XzKPy2qXf1Pe6UFuNSCQqt6tOuhAWXBNuuyUhJmw9Vg==
dependencies:
comment-parser "1.3.0"
comment-parser "1.3.1"
esquery "^1.4.0"
jsdoc-type-pratt-parser "~2.2.2"
jsdoc-type-pratt-parser "~3.1.0"

"@eslint/eslintrc@^1.0.5":
version "1.0.5"
Expand Down Expand Up @@ -1685,16 +1685,18 @@
resolved "https://registry.yarnpkg.com/@types/node/-/node-13.7.0.tgz#b417deda18cf8400f278733499ad5547ed1abec4"
integrity sha512-GnZbirvmqZUzMgkFn70c74OQpTTUcCzlhQliTzYjQMqg+hVKcDnxdL19Ne3UdYzdMA/+W3eb646FWn/ZaT1NfQ==

"@types/node@^10.11.3":
version "10.17.55"
resolved "https://registry.yarnpkg.com/@types/node/-/node-10.17.55.tgz#a147f282edec679b894d4694edb5abeb595fecbd"
integrity sha512-koZJ89uLZufDvToeWO5BrC4CR4OUfHnUz2qoPs/daQH6qq3IN62QFxCTZ+bKaCE0xaoCAJYE4AXre8AbghCrhg==

"@types/node@^16.9.2":
version "16.11.27"
resolved "https://registry.yarnpkg.com/@types/node/-/node-16.11.27.tgz#5da19383bdbeda99bc0d09cfbb88cab7297ebc51"
integrity sha512-C1pD3kgLoZ56Uuy5lhfOxie4aZlA3UMGLX9rXteq4WitEZH6Rl80mwactt9QG0w0gLFlN/kLBTFnGXtDVWvWQw==

"@types/node@^18.19.14":
version "18.19.14"
resolved "https://registry.yarnpkg.com/@types/node/-/node-18.19.14.tgz#1880ff1b3ac913f3877f711588e5ed227da01886"
integrity sha512-EnQ4Us2rmOS64nHDWr0XqAD8DsO6f3XR6lf9UIIrZQpUzPVdN/oPuEzfDWNHSyXLvoGgjuEm/sPwFGSSs35Wtg==
dependencies:
undici-types "~5.26.4"

"@types/p-limit@^2.0.0":
version "2.0.0"
resolved "https://registry.yarnpkg.com/@types/p-limit/-/p-limit-2.0.0.tgz#c076b7daa9163108a35899ea6a9d927526943ea2"
Expand Down Expand Up @@ -3011,10 +3013,10 @@ commander@~2.17.1:
resolved "https://registry.yarnpkg.com/commander/-/commander-2.17.1.tgz#bd77ab7de6de94205ceacc72f1716d29f20a77bf"
integrity sha512-wPMUt6FnH2yzG95SA6mzjQOEKUU3aLaDEmzs1ti+1E9h+CsrZghRlqEM/EJ4KscsQVG8uNN4uVreUeT8+drlgg==

[email protected].0:
version "1.3.0"
resolved "https://registry.yarnpkg.com/comment-parser/-/comment-parser-1.3.0.tgz#68beb7dbe0849295309b376406730cd16c719c44"
integrity sha512-hRpmWIKgzd81vn0ydoWoyPoALEOnF4wt8yKD35Ib1D6XC2siLiYaiqfGkYrunuKdsXGwpBpHU3+9r+RVw2NZfA==
[email protected].1:
version "1.3.1"
resolved "https://registry.yarnpkg.com/comment-parser/-/comment-parser-1.3.1.tgz#3d7ea3adaf9345594aedee6563f422348f165c1b"
integrity sha512-B52sN2VNghyq5ofvUsqZjmk6YkihBX5vMSChmSK9v4ShjKf3Vk5Xcmgpw4o+iIgtrnM/u5FiMpz9VKb8lpBveA==

commondir@^1.0.1:
version "1.0.1"
Expand Down Expand Up @@ -3293,7 +3295,7 @@ [email protected], debug@^2.2.0, debug@^2.3.3, debug@^2.6.0:
dependencies:
ms "2.0.0"

debug@4, debug@^4.0.0, debug@^4.3.1:
debug@4, debug@^4.0.0, debug@^4.3.1, debug@^4.3.4:
version "4.3.4"
resolved "https://registry.yarnpkg.com/debug/-/debug-4.3.4.tgz#1319f6579357f2338d3337d2cdd4914bb5dcc865"
integrity sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==
Expand Down Expand Up @@ -3817,18 +3819,17 @@ eslint-plugin-jest@^26.0.0:
dependencies:
"@typescript-eslint/utils" "^5.10.0"

eslint-plugin-jsdoc@^37.7.0:
version "37.7.0"
resolved "https://registry.yarnpkg.com/eslint-plugin-jsdoc/-/eslint-plugin-jsdoc-37.7.0.tgz#975d9f18cb0520dde7a2b0db5f4421dfee3fdd17"
integrity sha512-vzy3/ltXoGtabRnjLogaEmhGxxIv5B8HK5MJLIrdxFJUvhBppZjuVuLr71DjIBi0jg6bFomwkYKjojt29cN8PA==
eslint-plugin-jsdoc@^39.9.1:
version "39.9.1"
resolved "https://registry.yarnpkg.com/eslint-plugin-jsdoc/-/eslint-plugin-jsdoc-39.9.1.tgz#e9ce1723411fd7ea0933b3ef0dd02156ae3068e2"
integrity sha512-Rq2QY6BZP2meNIs48aZ3GlIlJgBqFCmR55+UBvaDkA3ZNQ0SvQXOs2QKkubakEijV8UbIVbVZKsOVN8G3MuqZw==
dependencies:
"@es-joy/jsdoccomment" "~0.18.0"
comment-parser "1.3.0"
debug "^4.3.3"
"@es-joy/jsdoccomment" "~0.36.1"
comment-parser "1.3.1"
debug "^4.3.4"
escape-string-regexp "^4.0.0"
esquery "^1.4.0"
regextras "^0.8.0"
semver "^7.3.5"
semver "^7.3.8"
spdx-expression-parse "^3.0.1"

eslint-scope@^5.1.1:
Expand Down Expand Up @@ -6083,10 +6084,10 @@ jsbn@~0.1.0:
resolved "https://registry.yarnpkg.com/jsbn/-/jsbn-0.1.1.tgz#a5e654c2e5a2deb5f201d96cefbca80c0ef2f513"
integrity sha1-peZUwuWi3rXyAdls77yoDA7y9RM=

jsdoc-type-pratt-parser@~2.2.2:
version "2.2.2"
resolved "https://registry.yarnpkg.com/jsdoc-type-pratt-parser/-/jsdoc-type-pratt-parser-2.2.2.tgz#a85e407ac502b444dc23333aa4d6d0dc83f76187"
integrity sha512-zRokSWcPLSWkoNzsWn9pq7YYSwDhKyEe+cJYT2qaPqLOOJb5sFSi46BPj81vP+e8chvCNdQL9RG86Bi9EI6MDw==
jsdoc-type-pratt-parser@~3.1.0:
version "3.1.0"
resolved "https://registry.yarnpkg.com/jsdoc-type-pratt-parser/-/jsdoc-type-pratt-parser-3.1.0.tgz#a4a56bdc6e82e5865ffd9febc5b1a227ff28e67e"
integrity sha512-MgtD0ZiCDk9B+eI73BextfRrVQl0oyzRG8B2BjORts6jbunj4ScKPcyXGTbB6eXL4y9TzxCm6hyeLq/2ASzNdw==

jsdom@^11.5.1:
version "11.5.1"
Expand Down Expand Up @@ -8171,11 +8172,6 @@ regexpu-core@^5.0.1:
unicode-match-property-ecmascript "^2.0.0"
unicode-match-property-value-ecmascript "^2.0.0"

regextras@^0.8.0:
version "0.8.0"
resolved "https://registry.yarnpkg.com/regextras/-/regextras-0.8.0.tgz#ec0f99853d4912839321172f608b544814b02217"
integrity sha512-k519uI04Z3SaY0fLX843MRXnDeG2+vHOFsyhiPZvNLe7r8rD2YNRjq4BQLZZ0oAr2NrtvZlICsXysGNFPGa3CQ==

registry-auth-token@^3.0.1:
version "3.3.1"
resolved "https://registry.yarnpkg.com/registry-auth-token/-/registry-auth-token-3.3.1.tgz#fb0d3289ee0d9ada2cbb52af5dfe66cb070d3006"
Expand Down Expand Up @@ -9667,6 +9663,11 @@ uglify-to-browserify@~1.0.0:
resolved "https://registry.yarnpkg.com/uglify-to-browserify/-/uglify-to-browserify-1.0.2.tgz#6e0924d6bda6b5afe349e39a6d632850a0f882b7"
integrity sha1-bgkk1r2mta/jSeOabWMoUKD4grc=

undici-types@~5.26.4:
version "5.26.5"
resolved "https://registry.yarnpkg.com/undici-types/-/undici-types-5.26.5.tgz#bcd539893d00b56e964fd2657a4866b221a65617"
integrity sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==

unicode-canonical-property-names-ecmascript@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/unicode-canonical-property-names-ecmascript/-/unicode-canonical-property-names-ecmascript-2.0.0.tgz#301acdc525631670d39f6146e0e77ff6bbdebddc"
Expand Down

0 comments on commit 1ff40fd

Please sign in to comment.