From cc3a7b84dfc13e129cb9b343e17c7fc5d2550d5f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Elan=20Ruusam=C3=A4e?= Date: Fri, 18 Mar 2022 10:09:33 +0200 Subject: [PATCH 1/7] Bump @types/node to ^14 --- package.json | 2 +- yarn.lock | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index 80090ebfe..7c9286324 100644 --- a/package.json +++ b/package.json @@ -111,7 +111,7 @@ "@types/lodash.memoize": "^4.1.3", "@types/micromatch": "^3.1.0", "@types/nock": "^10.0.3", - "@types/node": "^10.11.3", + "@types/node": "^14", "@types/node-fetch": "^2.5.12", "@types/p-limit": "^2.0.0", "@types/prettier": "^1.16.1", diff --git a/yarn.lock b/yarn.lock index d35c48ba0..d928b995a 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1232,10 +1232,10 @@ 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@^14": + version "14.18.12" + resolved "https://registry.yarnpkg.com/@types/node/-/node-14.18.12.tgz#0d4557fd3b94497d793efd4e7d92df2f83b4ef24" + integrity sha512-q4jlIR71hUpWTnGhXWcakgkZeHa3CCjcQcnuzU8M891BAWA2jHiziiWEPEkdS5pFsz7H9HJiy8BrK7tBRNrY7A== "@types/p-limit@^2.0.0": version "2.0.0" From b52c05e5f4b7a33e7619962e5e4a199f86c0f0b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Elan=20Ruusam=C3=A4e?= Date: Fri, 18 Mar 2022 10:19:49 +0200 Subject: [PATCH 2/7] Remove callback for server.listen(), callback doesn't have err parameter --- source/api/_tests/fetch.test.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/api/_tests/fetch.test.ts b/source/api/_tests/fetch.test.ts index a28d735b6..6b0ab81d9 100644 --- a/source/api/_tests/fetch.test.ts +++ b/source/api/_tests/fetch.test.ts @@ -50,9 +50,9 @@ class TestProxy { private server = http.createServer(this.router) start = async (): Promise => { - return new Promise((resolve, reject) => { + return new Promise(() => { this.isRunning = true - this.server.listen(this.port, this.hostname, (err: any) => (err ? reject(err) : resolve())) + this.server.listen(this.port, this.hostname) }) } stop = async (): Promise => { From be889f1df6c3f6a614c620fdc7c5546755470ce2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Elan=20Ruusam=C3=A4e?= Date: Fri, 18 Mar 2022 10:20:49 +0200 Subject: [PATCH 3/7] fixup! Remove callback for server.listen(), callback doesn't have err parameter --- source/api/_tests/fetch.test.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/api/_tests/fetch.test.ts b/source/api/_tests/fetch.test.ts index 6b0ab81d9..e52bc0338 100644 --- a/source/api/_tests/fetch.test.ts +++ b/source/api/_tests/fetch.test.ts @@ -27,8 +27,8 @@ class TestServer { start = async (response: ResponseMock): Promise => { this.response = response - return new Promise((resolve, reject) => { - this.server.listen(this.port, this.hostname, (err: any) => (err ? reject(err) : resolve())) + return new Promise(() => { + this.server.listen(this.port, this.hostname) }) } stop = async (): Promise => { From f5fba9b8ec7767755ef3a987c35c1c5cd66c3b44 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Elan=20Ruusam=C3=A4e?= Date: Fri, 18 Mar 2022 10:58:20 +0200 Subject: [PATCH 4/7] Use default encoding for Buffer.from --- source/platforms/github/GitHubUtils.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/platforms/github/GitHubUtils.ts b/source/platforms/github/GitHubUtils.ts index 72a9a3dad..f16316d0c 100644 --- a/source/platforms/github/GitHubUtils.ts +++ b/source/platforms/github/GitHubUtils.ts @@ -89,7 +89,7 @@ export const fileContentsGenerator = ( return "" } if (isFileContents(response.data) && response.data.content) { - const buffer = Buffer.from(response.data.content, response.data.encoding) + const buffer = Buffer.from(response.data.content) return buffer.toString() } else { return "" From 1af112a64f5aac5cc453ada0f47b18bffe293e64 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Elan=20Ruusam=C3=A4e?= Date: Fri, 18 Mar 2022 10:58:33 +0200 Subject: [PATCH 5/7] Add debug for response.data.encoding value tracing --- source/platforms/github/GitHubUtils.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/source/platforms/github/GitHubUtils.ts b/source/platforms/github/GitHubUtils.ts index f16316d0c..240c95d7b 100644 --- a/source/platforms/github/GitHubUtils.ts +++ b/source/platforms/github/GitHubUtils.ts @@ -89,6 +89,9 @@ export const fileContentsGenerator = ( return "" } if (isFileContents(response.data) && response.data.content) { + if (response.data.encoding) { +throw new Error(response.data.encoding); + } const buffer = Buffer.from(response.data.content) return buffer.toString() } else { From 002884b36dc2a0518cb7211fddbc4e73b7347053 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Elan=20Ruusam=C3=A4e?= Date: Fri, 18 Mar 2022 11:01:31 +0200 Subject: [PATCH 6/7] fixup! Use default encoding for Buffer.from --- source/platforms/github/GitHubUtils.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/platforms/github/GitHubUtils.ts b/source/platforms/github/GitHubUtils.ts index 240c95d7b..53db2cc69 100644 --- a/source/platforms/github/GitHubUtils.ts +++ b/source/platforms/github/GitHubUtils.ts @@ -92,7 +92,7 @@ export const fileContentsGenerator = ( if (response.data.encoding) { throw new Error(response.data.encoding); } - const buffer = Buffer.from(response.data.content) + const buffer = Buffer.from(response.data.content, "base64") return buffer.toString() } else { return "" From 96b2d020a8645757ae4026263909850c8d52dc3e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Elan=20Ruusam=C3=A4e?= Date: Fri, 18 Mar 2022 11:05:36 +0200 Subject: [PATCH 7/7] fixup! Add debug for response.data.encoding value tracing --- source/platforms/github/GitHubUtils.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/platforms/github/GitHubUtils.ts b/source/platforms/github/GitHubUtils.ts index 53db2cc69..7ba38992a 100644 --- a/source/platforms/github/GitHubUtils.ts +++ b/source/platforms/github/GitHubUtils.ts @@ -89,8 +89,8 @@ export const fileContentsGenerator = ( return "" } if (isFileContents(response.data) && response.data.content) { - if (response.data.encoding) { -throw new Error(response.data.encoding); + if (response.data.encoding !== "bsae64") { + throw new Error(`Unsupported encoding: ${response.data.encoding}`); } const buffer = Buffer.from(response.data.content, "base64") return buffer.toString()