From 0e6eb71f933e7ea85e5d38401aaa35d1e2513259 Mon Sep 17 00:00:00 2001 From: Eric Meisel Date: Fri, 31 May 2024 10:18:25 -0500 Subject: [PATCH 1/9] Update coursier version, support arm64 --- src/coursier/coursier.ts | 5 ++++- src/coursier/download-coursier.ts | 26 ++++++++++++++++++++------ 2 files changed, 24 insertions(+), 7 deletions(-) diff --git a/src/coursier/coursier.ts b/src/coursier/coursier.ts index 8a0c72e..b1f864a 100644 --- a/src/coursier/coursier.ts +++ b/src/coursier/coursier.ts @@ -9,7 +9,10 @@ export function getCoursierExecutable(extensionPath: string): Promise { return downloadCoursierIfRequired( extensionPath, process.platform, - "v2.0.13" + process.arch, + // Have to use a commit hash for now since the launchers repository is untagged + "56971135cd9b08eaefed13b4d6b7a95ba9cce572", + "v2.1.10" ); } }); diff --git a/src/coursier/download-coursier.ts b/src/coursier/download-coursier.ts index 7034866..855bf2e 100644 --- a/src/coursier/download-coursier.ts +++ b/src/coursier/download-coursier.ts @@ -3,11 +3,14 @@ import { https } from "follow-redirects"; import { IncomingMessage } from "http"; import * as fs from "fs"; import { access, mkdir } from "fs/promises"; +import * as zlib from "zlib" export function downloadCoursierIfRequired( extensionPath: string, platform: string, - versionPath: string + arch: String, + versionPath: string, + versionPathArm64: String, ): Promise { function binPath(filename: string) { return path.join(extensionPath, filename); @@ -23,20 +26,31 @@ export function downloadCoursierIfRequired( const supportedTargets = { darwin: { - url: `https://github.com/coursier/coursier/releases/download/${versionPath}/cs-x86_64-apple-darwin`, + url: `https://github.com/coursier/launchers/raw/${versionPath}/cs-x86_64-apple-darwin.gz`, bin: binPath("coursier"), }, linux: { - url: `https://github.com/coursier/coursier/releases/download/${versionPath}/cs-x86_64-pc-linux`, + url: `https://github.com/coursier/launchers/raw/${versionPath}/cs-x86_64-pc-linux.gz`, bin: binPath("coursier"), }, win32: { - url: `https://github.com/coursier/coursier/releases/download/${versionPath}/cs-x86_64-pc-win32.exe`, + url: `https://github.com/coursier/launchers/raw/${versionPath}/cs-x86_64-pc-win32.zip`, bin: binPath("coursier.exe"), }, }; - const target = supportedTargets[platform]; + const supportedTargetsArm64 = { + darwin: { + url: `https://github.com/VirtusLab/coursier-m1/releases/download/${versionPathArm64}/cs-aarch64-apple-darwin.gz`, + bin: binPath("coursier"), + }, + linux: { + url: `https://github.com/VirtusLab/coursier-m1/releases/download/${versionPathArm64}/cs-aarch64-pc-linux.gz`, + bin: binPath("coursier"), + } + } + + const target = arch === "arm64" ? supportedTargetsArm64[platform] : supportedTargets[platform]; if (target === undefined) { return Promise.reject(`Unsupported platform ${platform}.`); } else { @@ -78,7 +92,7 @@ function downloadFile(url: string, targetFile: string): Promise { flags: "wx", mode: 0o755, }); - response.pipe(file); + response.pipe(zlib.createUnzip()).pipe(file); file.on("finish", () => { console.log(`Finished downloaded file at ${targetFile}`); From 4ab487153bd88855f6eb53ab49c33e9137fe520a Mon Sep 17 00:00:00 2001 From: Eric Meisel Date: Fri, 31 May 2024 10:24:18 -0500 Subject: [PATCH 2/9] Prettier --- src/coursier/download-coursier.ts | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/coursier/download-coursier.ts b/src/coursier/download-coursier.ts index 855bf2e..db1b1b3 100644 --- a/src/coursier/download-coursier.ts +++ b/src/coursier/download-coursier.ts @@ -3,14 +3,14 @@ import { https } from "follow-redirects"; import { IncomingMessage } from "http"; import * as fs from "fs"; import { access, mkdir } from "fs/promises"; -import * as zlib from "zlib" +import * as zlib from "zlib"; export function downloadCoursierIfRequired( extensionPath: string, platform: string, arch: String, versionPath: string, - versionPathArm64: String, + versionPathArm64: String ): Promise { function binPath(filename: string) { return path.join(extensionPath, filename); @@ -47,10 +47,13 @@ export function downloadCoursierIfRequired( linux: { url: `https://github.com/VirtusLab/coursier-m1/releases/download/${versionPathArm64}/cs-aarch64-pc-linux.gz`, bin: binPath("coursier"), - } - } + }, + }; - const target = arch === "arm64" ? supportedTargetsArm64[platform] : supportedTargets[platform]; + const target = + arch === "arm64" + ? supportedTargetsArm64[platform] + : supportedTargets[platform]; if (target === undefined) { return Promise.reject(`Unsupported platform ${platform}.`); } else { From 75696bfc040b76def8a36320452a3f9806917fa0 Mon Sep 17 00:00:00 2001 From: Eric Meisel Date: Fri, 31 May 2024 10:52:49 -0500 Subject: [PATCH 3/9] Fix test / windows --- package.json | 3 +- src/coursier/download-coursier.ts | 7 ++++- tests/coursier/download-coursier.spec.ts | 38 ++++++++++++++++++++++-- 3 files changed, 44 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index 94457fd..077a549 100644 --- a/package.json +++ b/package.json @@ -105,7 +105,8 @@ "concat-map": "^0.0.2", "follow-redirects": "^1.14.9", "semver": "^7.5.0", - "vscode-languageclient": "^8.0.0" + "vscode-languageclient": "^8.0.0", + "unzip-stream": "^0.3.4" }, "devDependencies": { "@types/follow-redirects": "^1.14.1", diff --git a/src/coursier/download-coursier.ts b/src/coursier/download-coursier.ts index db1b1b3..bcb7830 100644 --- a/src/coursier/download-coursier.ts +++ b/src/coursier/download-coursier.ts @@ -4,6 +4,7 @@ import { IncomingMessage } from "http"; import * as fs from "fs"; import { access, mkdir } from "fs/promises"; import * as zlib from "zlib"; +import * as unzip from "unzip-stream"; export function downloadCoursierIfRequired( extensionPath: string, @@ -95,7 +96,11 @@ function downloadFile(url: string, targetFile: string): Promise { flags: "wx", mode: 0o755, }); - response.pipe(zlib.createUnzip()).pipe(file); + targetFile.endsWith(".exe") + ? response.pipe(unzip.Parse()).on("entry", (entry) => { + entry.pipe(file); + }) + : response.pipe(zlib.createUnzip()).pipe(file); file.on("finish", () => { console.log(`Finished downloaded file at ${targetFile}`); diff --git a/tests/coursier/download-coursier.spec.ts b/tests/coursier/download-coursier.spec.ts index 68ff79c..7326591 100644 --- a/tests/coursier/download-coursier.spec.ts +++ b/tests/coursier/download-coursier.spec.ts @@ -10,7 +10,35 @@ import { join } from "path"; const dir = join(tmpdir(), p); rmSync(dir, { recursive: true, force: true }); mkdirSync(dir, { recursive: true }); - return downloadCoursierIfRequired(dir, p, "v2.0.13").then((x) => { + return downloadCoursierIfRequired( + dir, + p, + "x64", + "56971135cd9b08eaefed13b4d6b7a95ba9cce572", + "v2.1.10" + ).then((x) => { + expect(existsSync(x)).toBeTruthy(); + accessSync(x, constants.X_OK); + }); + }, + 25 * 1000 + ); +}); + +["darwin", "linux"].forEach((p) => { + test( + `download on platform: ${p}`, + () => { + const dir = join(tmpdir(), p); + rmSync(dir, { recursive: true, force: true }); + mkdirSync(dir, { recursive: true }); + return downloadCoursierIfRequired( + dir, + p, + "arm64", + "56971135cd9b08eaefed13b4d6b7a95ba9cce572", + "v2.1.10" + ).then((x) => { expect(existsSync(x)).toBeTruthy(); accessSync(x, constants.X_OK); }); @@ -21,6 +49,12 @@ import { join } from "path"; test(`fails on unknown platform`, () => { return expect( - downloadCoursierIfRequired(tmpdir(), "unsupported", "v2.0.13") + downloadCoursierIfRequired( + tmpdir(), + "unsupported", + "x64", + "56971135cd9b08eaefed13b4d6b7a95ba9cce572", + "v2.1.10" + ) ).rejects.toEqual("Unsupported platform unsupported."); }); From 92e2cf8640f0f9dfd35c888f73708b4cb5ee172d Mon Sep 17 00:00:00 2001 From: Eric Meisel Date: Fri, 31 May 2024 11:55:37 -0500 Subject: [PATCH 4/9] Add extensionKind --- package.json | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/package.json b/package.json index 077a549..1b5c3dc 100644 --- a/package.json +++ b/package.json @@ -16,6 +16,10 @@ "activationEvents": [ "onLanguage:smithy" ], + "extensionKind": [ + "workspace", + "ui" + ], "main": "./out/src/extension", "contributes": { "configuration": { From d264bba08d4adc26f3039284ae1cf983e4746892 Mon Sep 17 00:00:00 2001 From: Eric Meisel Date: Fri, 31 May 2024 13:22:24 -0500 Subject: [PATCH 5/9] Finish up --- package.json | 6 ++---- yarn.lock | 12 ++++++++++-- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/package.json b/package.json index 1b5c3dc..72b8275 100644 --- a/package.json +++ b/package.json @@ -16,10 +16,7 @@ "activationEvents": [ "onLanguage:smithy" ], - "extensionKind": [ - "workspace", - "ui" - ], + "extensionKind": ["workspace"], "main": "./out/src/extension", "contributes": { "configuration": { @@ -109,6 +106,7 @@ "concat-map": "^0.0.2", "follow-redirects": "^1.14.9", "semver": "^7.5.0", + "unzip-stream": "^0.3.4", "vscode-languageclient": "^8.0.0", "unzip-stream": "^0.3.4" }, diff --git a/yarn.lock b/yarn.lock index b2ff5ea..41e2aa3 100644 --- a/yarn.lock +++ b/yarn.lock @@ -911,7 +911,7 @@ big-integer@^1.6.17: resolved "https://registry.yarnpkg.com/big-integer/-/big-integer-1.6.51.tgz#0df92a5d9880560d3ff2d5fd20245c889d130686" integrity sha512-GPEid2Y9QU1Exl1rpO9B2IPJGHPSupF5GnVIP0blYvNOMer2bTvSWs1jGOUg04hTmu67nmLsQ9TBo1puaotBHg== -binary@~0.3.0: +binary@^0.3.0, binary@~0.3.0: version "0.3.0" resolved "https://registry.yarnpkg.com/binary/-/binary-0.3.0.tgz#9f60553bc5ce8c3386f3b553cff47462adecaa79" integrity sha512-D4H1y5KYwpJgK8wk1Cue5LLPgmwHKYSChkbspQg5JtVuR5ulGckxfR62H3AE9UDkdMC8yyXlqYihuz3Aqg2XZg== @@ -2667,7 +2667,7 @@ mkdirp-classic@^0.5.2, mkdirp-classic@^0.5.3: resolved "https://registry.yarnpkg.com/mkdirp-classic/-/mkdirp-classic-0.5.3.tgz#fa10c9115cc6d8865be221ba47ee9bed78601113" integrity sha512-gKLcREMhtuZRwRAfqP3RFW+TK4JqApVBtOIftVgjuABpAtpxhPGaDcfvbhNvD0B8iD1oUr/txX35NjcaY6Ns/A== -"mkdirp@>=0.5 0": +"mkdirp@>=0.5 0", mkdirp@^0.5.1: version "0.5.6" resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-0.5.6.tgz#7def03d2432dcae4ba1d611445c48396062255f6" integrity sha512-FP+p8RB8OWpF3YZBCrP5gtADmtXApB5AMLn+vdyA+PyxCjrCs00mjyUozssO33cwDeT3wNGdLxJ5M//YqtHAJw== @@ -3501,6 +3501,14 @@ universalify@^0.1.2: resolved "https://registry.yarnpkg.com/universalify/-/universalify-0.1.2.tgz#b646f69be3942dabcecc9d6639c80dc105efaa66" integrity sha512-rBJeI5CXAlmy1pV+617WB9J63U6XcazHHF2f2dbJix4XzpUF0RS3Zbj0FGIOCAva5P/d/GBOYaACQ1w+0azUkg== +unzip-stream@^0.3.4: + version "0.3.4" + resolved "https://registry.yarnpkg.com/unzip-stream/-/unzip-stream-0.3.4.tgz#b4576755061809cf210b776cf26888d6a7823ead" + integrity sha512-PyofABPVv+d7fL7GOpusx7eRT9YETY2X04PhwbSipdj6bMxVCFJrr+nm0Mxqbf9hUiTin/UsnuFWBXlDZFy0Cw== + dependencies: + binary "^0.3.0" + mkdirp "^0.5.1" + unzipper@^0.10.11: version "0.10.11" resolved "https://registry.yarnpkg.com/unzipper/-/unzipper-0.10.11.tgz#0b4991446472cbdb92ee7403909f26c2419c782e" From be7fedd3a80cbe778b0337e60152a69955c9f4b4 Mon Sep 17 00:00:00 2001 From: Eric Meisel Date: Fri, 31 May 2024 13:25:01 -0500 Subject: [PATCH 6/9] Pretty --- package.json | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 72b8275..9edf70b 100644 --- a/package.json +++ b/package.json @@ -16,7 +16,9 @@ "activationEvents": [ "onLanguage:smithy" ], - "extensionKind": ["workspace"], + "extensionKind": [ + "workspace" + ], "main": "./out/src/extension", "contributes": { "configuration": { From 84a177b24e0f07cb168b5a2ac6a6f0ced2c6a1da Mon Sep 17 00:00:00 2001 From: Eric Meisel Date: Fri, 31 May 2024 13:27:22 -0500 Subject: [PATCH 7/9] Dupe --- package.json | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/package.json b/package.json index 9edf70b..5256672 100644 --- a/package.json +++ b/package.json @@ -109,8 +109,7 @@ "follow-redirects": "^1.14.9", "semver": "^7.5.0", "unzip-stream": "^0.3.4", - "vscode-languageclient": "^8.0.0", - "unzip-stream": "^0.3.4" + "vscode-languageclient": "^8.0.0" }, "devDependencies": { "@types/follow-redirects": "^1.14.1", From 7592519801fec2274f86e86e218b411f1e798ce6 Mon Sep 17 00:00:00 2001 From: Eric Meisel Date: Fri, 31 May 2024 13:31:59 -0500 Subject: [PATCH 8/9] Update README --- README.md | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 5362bc1..406391b 100644 --- a/README.md +++ b/README.md @@ -90,4 +90,14 @@ Error in `Log(Extension Host)` channel: at Pipe.onStreamRead (node:internal/stream_base_commons:190:23) ``` -This happens because the extension exchange with the language server via std in/out of the child process. If any of the code that runs in the language server prints to the standard out, VS Code will complain (unless it is specifically formatted that way). \ No newline at end of file +This happens because the extension exchange with the language server via std in/out of the child process. If any of the code that runs in the language server prints to the standard out, VS Code will complain (unless it is specifically formatted that way). + +Error in `Log(Remote Extension Host)` channel when downloading Coursier: + +``` +Failed to establish a socket connection to proxies extension +``` + +This happens when using the extension in a remote environment (e.g. devcontainers), and the proxy support is set to `override`. This can be resolved by setting this to `off`. + +See this related [github issue](https://github.com/microsoft/vscode-pull-request-github/issues/4624#issuecomment-1845285077) for more information. From a160fba1cba14ef5c59718cfe42d93c23b83f25c Mon Sep 17 00:00:00 2001 From: Eric Meisel Date: Mon, 3 Jun 2024 09:16:37 -0500 Subject: [PATCH 9/9] Add comment --- src/coursier/coursier.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/coursier/coursier.ts b/src/coursier/coursier.ts index b1f864a..1d695cd 100644 --- a/src/coursier/coursier.ts +++ b/src/coursier/coursier.ts @@ -11,6 +11,7 @@ export function getCoursierExecutable(extensionPath: string): Promise { process.platform, process.arch, // Have to use a commit hash for now since the launchers repository is untagged + // See https://github.com/coursier/coursier/issues/2998 "56971135cd9b08eaefed13b4d6b7a95ba9cce572", "v2.1.10" );