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. diff --git a/package.json b/package.json index 94457fd..5256672 100644 --- a/package.json +++ b/package.json @@ -16,6 +16,9 @@ "activationEvents": [ "onLanguage:smithy" ], + "extensionKind": [ + "workspace" + ], "main": "./out/src/extension", "contributes": { "configuration": { @@ -105,6 +108,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" }, "devDependencies": { diff --git a/src/coursier/coursier.ts b/src/coursier/coursier.ts index 8a0c72e..1d695cd 100644 --- a/src/coursier/coursier.ts +++ b/src/coursier/coursier.ts @@ -9,7 +9,11 @@ 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 + // See https://github.com/coursier/coursier/issues/2998 + "56971135cd9b08eaefed13b4d6b7a95ba9cce572", + "v2.1.10" ); } }); diff --git a/src/coursier/download-coursier.ts b/src/coursier/download-coursier.ts index 7034866..bcb7830 100644 --- a/src/coursier/download-coursier.ts +++ b/src/coursier/download-coursier.ts @@ -3,11 +3,15 @@ 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 unzip from "unzip-stream"; 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 +27,34 @@ 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 +96,11 @@ function downloadFile(url: string, targetFile: string): Promise { flags: "wx", mode: 0o755, }); - response.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."); }); 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"