From b828edc7f162988fa49535184769cdf61f3ba32c Mon Sep 17 00:00:00 2001 From: Simon Lydell Date: Sat, 7 Jan 2023 14:06:58 +0100 Subject: [PATCH 01/10] Support different architectures --- docs/contributing.md | 4 +- scripts/HashUrls.ts | 57 ++++++++++++--------- src/KnownTools.ts | 106 +++++++++++++++++++--------------------- src/Parse.ts | 88 +++++++++++++++------------------ src/commands/Init.ts | 10 +--- src/commands/Install.ts | 24 ++++----- 6 files changed, 140 insertions(+), 149 deletions(-) diff --git a/docs/contributing.md b/docs/contributing.md index f9082ce..acdddbf 100644 --- a/docs/contributing.md +++ b/docs/contributing.md @@ -22,7 +22,7 @@ It’s much easier to work on this project if your editor can run these tools fo There’s a script that can help you do it. ``` - npx ts-node scripts/HashUrls.ts LINUX_URL MAC_URL WINDOWS_URL + npx ts-node scripts/HashUrls.ts URL... ``` Example: @@ -31,7 +31,7 @@ It’s much easier to work on this project if your editor can run these tools fo npx ts-node scripts/HashUrls.ts https://github.com/mpizenberg/elm-test-rs/releases/download/v1.0/elm-test-rs_{linux.tar.gz,macos.tar.gz,windows.zip} ``` - The above example assumes your shell has brace expansion. Either way, it expects 3 URLs: One for linux, one for mac and one for windows (in that order). It downloads the files to memory (verifying that they exist) and hashes them. When done, it prints some JSON that you can paste into the code. Run Prettier afterwards. + The above example assumes your shell has brace expansion. Either way, it expects several URLs: One for each platform you support. It downloads the files to memory (verifying that they exist) and hashes them. When done, it prints some JSON that you can paste into the code. Run Prettier afterwards. 2. Run `npx jest -u` to update snapshots and look them through quickly to see if they seem legit. diff --git a/scripts/HashUrls.ts b/scripts/HashUrls.ts index a5b73ac..ff528b0 100644 --- a/scripts/HashUrls.ts +++ b/scripts/HashUrls.ts @@ -2,15 +2,13 @@ import * as crypto from "crypto"; import { downloadFile } from "../src/commands/Install"; import { fromEntries } from "../src/Helpers"; -import type { Asset, AssetType, OSName } from "../src/KnownTools"; - -const OS_LIST: Array = ["linux", "mac", "windows"]; +import type { Asset, AssetType } from "../src/KnownTools"; async function run(urls: Array): Promise { const progress: Array = urls.map(() => 0); - const assets: Array<[OSName, Asset]> = await Promise.all( - urls.map((url, index): Promise<[OSName, Asset]> => { + const assets: Array<[string, Asset]> = await Promise.all( + urls.map((url, index): Promise<[string, Asset]> => { const hash = crypto.createHash("sha256"); let fileSize = 0; return new Promise((resolve, reject) => { @@ -32,15 +30,15 @@ async function run(urls: Array): Promise { }, onSuccess: () => { progress[index] = 1; - const osName = OS_LIST[index] ?? ("UNKNOWN" as OSName); + const platform = guessPlatform(url); const asset: Asset = { hash: hash.digest("hex"), url, fileSize, - fileName: guessFileName(url, osName), + fileName: guessFileName(url, platform), type: guessAssetType(url), }; - resolve([osName, asset]); + resolve([platform, asset]); }, }); }); @@ -51,16 +49,38 @@ async function run(urls: Array): Promise { return JSON.stringify(fromEntries(assets), null, 2); } -function guessFileName(url: string, osName: OSName): string { +function guessPlatform(url: string): string { + return `${guessPlatformName(url)}-${guessPlatformArch(url)}`; +} + +function guessPlatformName(passedUrl: string): string { + const url = passedUrl.toLowerCase(); + return url.includes("mac") || url.includes("darwin") + ? "darwin" + : url.includes("linux") + ? "linux" + : url.includes("win") + ? "win32" + : "UNKNOWN"; +} + +function guessPlatformArch(passedUrl: string): string { + const url = passedUrl.toLowerCase(); + return url.includes("arm") || url.includes("aarch") + ? url.includes("32") + ? "arm" + : "arm64" + : "x64"; +} + +function guessFileName(url: string, platform: string): string { const match = /github\.com\/[^/]+\/([^/]+)/.exec(url); const name = match === null || match[1] === undefined ? "UNKNOWN" : match[1]; - return osName === "windows" ? `${name}.exe` : name; + return platform.startsWith("win32-") ? `${name}.exe` : name; } function guessAssetType(url: string): AssetType { - return url.endsWith(".tgz") - ? "tgz" - : url.endsWith(".tar.gz") + return url.endsWith(".tgz") || url.endsWith(".tar.gz") ? "tgz" : url.endsWith(".gz") ? "gz" @@ -70,16 +90,7 @@ function guessAssetType(url: string): AssetType { } if (require.main === module) { - const urls = process.argv.slice(2); - if (urls.length !== 3) { - process.stderr.write( - `\nExpected 3 urls (${OS_LIST.join(", ")}, in that order) but got ${ - urls.length - }\n` - ); - process.exit(1); - } - run(urls) + run(process.argv.slice(2)) .then((json) => { process.stdout.write(`\n${json}\n`); process.exit(0); diff --git a/src/KnownTools.ts b/src/KnownTools.ts index ca4b61a..2e31d0b 100644 --- a/src/KnownTools.ts +++ b/src/KnownTools.ts @@ -2,15 +2,9 @@ import type { NonEmptyArray } from "./Helpers"; export type KnownTools = Record; -export type Versions = Record; +export type Versions = Record; -export type OSAssets = { - linux: Asset; - mac: Asset; - windows: Asset; -}; - -export type OSName = keyof OSAssets; +export type PlatformAssets = Record; export type Asset = { hash: string; @@ -25,21 +19,21 @@ export type AssetType = "gz" | "tgz" | "zip"; const knownTools = { elm: { "0.19.0": { - linux: { + "linux-x64": { hash: "d359adbee89823c641cda326938708d7227dc79aa1f162e0d8fe275f182f528a", url: "https://github.com/elm/compiler/releases/download/0.19.0/binary-for-linux-64-bit.gz", fileSize: 10958261, fileName: "elm", type: "gz", }, - mac: { + "darwin-x64": { hash: "f1fa4dd9021e94c5a58b2be8843e3329095232ee3bd21a23524721a40eaabd35", url: "https://github.com/elm/compiler/releases/download/0.19.0/binary-for-mac-64-bit.gz", fileSize: 6051435, fileName: "elm", type: "gz", }, - windows: { + "win32-x64": { hash: "0e27d80537418896cf98326224159a45b6d36bf08e608e3a174ab6d2c572c5ae", url: "https://github.com/elm/compiler/releases/download/0.19.0/binary-for-windows-64-bit.gz", fileSize: 12639872, @@ -48,21 +42,21 @@ const knownTools = { }, }, "0.19.1": { - linux: { + "linux-x64": { hash: "e44af52bb27f725a973478e589d990a6428e115fe1bb14f03833134d6c0f155c", url: "https://github.com/elm/compiler/releases/download/0.19.1/binary-for-linux-64-bit.gz", fileSize: 6806857, fileName: "elm", type: "gz", }, - mac: { + "darwin-x64": { hash: "05289f0e3d4f30033487c05e689964c3bb17c0c48012510dbef1df43868545d1", url: "https://github.com/elm/compiler/releases/download/0.19.1/binary-for-mac-64-bit.gz", fileSize: 6034616, fileName: "elm", type: "gz", }, - windows: { + "win32-x64": { hash: "d1bf666298cbe3c5447b9ca0ea608552d750e5d232f9845c2af11907b654903b", url: "https://github.com/elm/compiler/releases/download/0.19.1/binary-for-windows-64-bit.gz", fileSize: 12727488, @@ -73,21 +67,21 @@ const knownTools = { }, "elm-format": { "0.8.1": { - linux: { + "linux-x64": { hash: "13d06e0c3f3a9ef585c828ac5761ead148ea2f203573309306393e2d8066e1fd", url: "https://github.com/avh4/elm-format/releases/download/0.8.1/elm-format-0.8.1-linux-x64.tgz", fileSize: 2110405, fileName: "elm-format", type: "tgz", }, - mac: { + "darwin-x64": { hash: "e1beba5d3090968cbbd879384617506f4c71a3ea3b01ce94d298e4893e82a640", url: "https://github.com/avh4/elm-format/releases/download/0.8.1/elm-format-0.8.1-mac-x64.tgz", fileSize: 1325147, fileName: "elm-format", type: "tgz", }, - windows: { + "win32-x64": { hash: "29b8989918e5804b538c411a92f3da8d15337ec28003b033b3be0de2d2d636d2", url: "https://github.com/avh4/elm-format/releases/download/0.8.1/elm-format-0.8.1-win-i386.zip", fileSize: 2281778, @@ -96,21 +90,21 @@ const knownTools = { }, }, "0.8.2": { - linux: { + "linux-x64": { hash: "a69a4d3c49ccb0dffb3067b35464dc492563274e5778c40625220f9f6b3fd06d", url: "https://github.com/avh4/elm-format/releases/download/0.8.2/elm-format-0.8.2-linux-x64.tgz", fileSize: 2128375, fileName: "elm-format", type: "tgz", }, - mac: { + "darwin-x64": { hash: "1f6cc8663922e546645c0536fc9bf7a49351d0b2963d26fc8fcb43e5bc92d733", url: "https://github.com/avh4/elm-format/releases/download/0.8.2/elm-format-0.8.2-mac-x64.tgz", fileSize: 1298447, fileName: "elm-format", type: "tgz", }, - windows: { + "win32-x64": { hash: "5009fd26b59a785738dd82c8d90ea8fd0bb7fe65fbd562097d906ee04061ef7f", url: "https://github.com/avh4/elm-format/releases/download/0.8.2/elm-format-0.8.2-win-i386.zip", fileSize: 4243045, @@ -119,21 +113,21 @@ const knownTools = { }, }, "0.8.3": { - linux: { + "linux-x64": { hash: "9012f3a372488d4a118dc5f8ff57cc61cd1753d7d878b393fa7f60d496e37084", url: "https://github.com/avh4/elm-format/releases/download/0.8.3/elm-format-0.8.3-linux-x64.tgz", fileSize: 2137733, fileName: "elm-format", type: "tgz", }, - mac: { + "darwin-x64": { hash: "66c9d4c2fcc7e435726f25ca44509cdf2caff5000dd215b5a086db514576efc7", url: "https://github.com/avh4/elm-format/releases/download/0.8.3/elm-format-0.8.3-mac-x64.tgz", fileSize: 1308986, fileName: "elm-format", type: "tgz", }, - windows: { + "win32-x64": { hash: "da9c013e27faccd14d6395db638af111097f171a45705a8978a28e30c115778f", url: "https://github.com/avh4/elm-format/releases/download/0.8.3/elm-format-0.8.3-win-i386.zip", fileSize: 4136741, @@ -142,21 +136,21 @@ const knownTools = { }, }, "0.8.4": { - linux: { + "linux-x64": { hash: "aa6bb9d11672d8d27398746e831266c565e9837b4da6abe5d8286c2ab69ace9d", url: "https://github.com/avh4/elm-format/releases/download/0.8.4/elm-format-0.8.4-linux-x64.tgz", fileSize: 1956444, fileName: "elm-format", type: "tgz", }, - mac: { + "darwin-x64": { hash: "df2a85da6870e8c8f7b052c9b81279fd9cbbab2bc738c2e14adf95ef777edd21", url: "https://github.com/avh4/elm-format/releases/download/0.8.4/elm-format-0.8.4-mac-x64.tgz", fileSize: 1283871, fileName: "elm-format", type: "tgz", }, - windows: { + "win32-x64": { hash: "0afe91bba2951c675f7484ae8d3d45792ed802d2eac9110b2afc18e3ed1a888d", url: "https://github.com/avh4/elm-format/releases/download/0.8.4/elm-format-0.8.4-win-x64.zip", fileSize: 2105708, @@ -165,21 +159,21 @@ const knownTools = { }, }, "0.8.5": { - linux: { + "linux-x64": { hash: "147c479e375b9bae8dd633e526677fbd2a87e5445b3638ebee86c1319ffe8e23", url: "https://github.com/avh4/elm-format/releases/download/0.8.5/elm-format-0.8.5-linux-x64.tgz", fileSize: 3870971, fileName: "elm-format", type: "tgz", }, - mac: { + "darwin-x64": { hash: "380c5f36b1fdeb2f1cda7c208dc788cb676675b3d5d43d907efc3f0821c010d6", url: "https://github.com/avh4/elm-format/releases/download/0.8.5/elm-format-0.8.5-mac-x64.tgz", fileSize: 1334367, fileName: "elm-format", type: "tgz", }, - windows: { + "win32-x64": { hash: "3cb6f74f24b401314480227b1ccbb2049cceb4a365ac7abb50cd3cfe0e64bbdc", url: "https://github.com/avh4/elm-format/releases/download/0.8.5/elm-format-0.8.5-win-x64.zip", fileSize: 1737291, @@ -190,21 +184,21 @@ const knownTools = { }, "elm-json": { "0.2.8": { - linux: { + "linux-x64": { hash: "d4561a9a2bd70e1a4a4c61e75cac03d3bb1a3b5f99322afa720a2f2d84c194de", url: "https://github.com/zwilias/elm-json/releases/download/v0.2.8/elm-json-v0.2.8-x86_64-unknown-linux-musl.tar.gz", fileSize: 2255688, fileName: "elm-json", type: "tgz", }, - mac: { + "darwin-x64": { hash: "1ca3cde58730e87f2b73afb2432d5d8c88787ee3745bc81769ec0eef962ceaf6", url: "https://github.com/zwilias/elm-json/releases/download/v0.2.8/elm-json-v0.2.8-x86_64-apple-darwin.tar.gz", fileSize: 838159, fileName: "elm-json", type: "tgz", }, - windows: { + "win32-x64": { hash: "1ae0b8e9a9717bdfb05346d0b864868e3907cb83c54d6770f6c604972296384f", url: "https://github.com/zwilias/elm-json/releases/download/v0.2.8/elm-json-v0.2.8-x86_64-pc-windows-msvc.tar.gz", fileSize: 1375556, @@ -213,21 +207,21 @@ const knownTools = { }, }, "0.2.10": { - linux: { + "linux-x64": { hash: "6ee94f04bebeb66d5ef322d76fd3dc828015571b92f1259776f716feaaec359d", url: "https://github.com/zwilias/elm-json/releases/download/v0.2.10/elm-json-v0.2.10-x86_64-unknown-linux-musl.tar.gz", fileSize: 2307188, fileName: "elm-json", type: "tgz", }, - mac: { + "darwin-x64": { hash: "fcd39c7c014d95df033499d8a39720b38c9f93d0e3b7ecb821cfe3dbfd1affc1", url: "https://github.com/zwilias/elm-json/releases/download/v0.2.10/elm-json-v0.2.10-x86_64-apple-darwin.tar.gz", fileSize: 899328, fileName: "elm-json", type: "tgz", }, - windows: { + "win32-x64": { hash: "721084dd90042a2b7b99a1334a9dcfa753fcf166ade458e6a3bb5d6649f8e39b", url: "https://github.com/zwilias/elm-json/releases/download/v0.2.10/elm-json-v0.2.10-x86_64-pc-windows-msvc.tar.gz", fileSize: 1415941, @@ -236,21 +230,21 @@ const knownTools = { }, }, "0.2.13": { - linux: { + "linux-x64": { hash: "83cbab79f6c237d3f96b69baf519bdd7634d0e0373a390594d37591c0295f965", url: "https://github.com/zwilias/elm-json/releases/download/v0.2.13/elm-json-v0.2.13-x86_64-unknown-linux-musl.tar.gz", fileSize: 2294914, fileName: "elm-json", type: "tgz", }, - mac: { + "darwin-x64": { hash: "868d82cc5496ddc5e17303e85b198b29fe7a30c8ac8b22aa9607e23cc07a1884", url: "https://github.com/zwilias/elm-json/releases/download/v0.2.13/elm-json-v0.2.13-x86_64-apple-darwin.tar.gz", fileSize: 888281, fileName: "elm-json", type: "tgz", }, - windows: { + "win32-x64": { hash: "0494f0d813244bf43e3c6cad1d0428919e7e0a5430d21a4d8a65697af0c14527", url: "https://github.com/zwilias/elm-json/releases/download/v0.2.13/elm-json-v0.2.13-x86_64-pc-windows-msvc.tar.gz", fileSize: 1239097, @@ -261,21 +255,21 @@ const knownTools = { }, "elm-test-rs": { "1.0.0": { - linux: { + "linux-x64": { hash: "a914088083ea8bc004944c98d9a4767cc5225d5811480f49fe1ad2c491baaaaa", url: "https://github.com/mpizenberg/elm-test-rs/releases/download/v1.0/elm-test-rs_linux.tar.gz", fileSize: 3610634, fileName: "elm-test-rs", type: "tgz", }, - mac: { + "darwin-x64": { hash: "5f296888b7ba32c47830f00f6d38c56fc86f49d8c0c8998054b0842009a1173f", url: "https://github.com/mpizenberg/elm-test-rs/releases/download/v1.0/elm-test-rs_macos.tar.gz", fileSize: 2230430, fileName: "elm-test-rs", type: "tgz", }, - windows: { + "win32-x64": { hash: "c8a35e2e0049b691e4833a6e8ccb094688cdc49aa977c437a8289c57d92a5775", url: "https://github.com/mpizenberg/elm-test-rs/releases/download/v1.0/elm-test-rs_windows.zip", fileSize: 1939029, @@ -284,21 +278,21 @@ const knownTools = { }, }, "1.2.1": { - linux: { + "linux-x64": { hash: "6e5759f832a5e025898c9306ba47b2f9ed7f0c371dc69bd16c15c7ed8bfb1501", url: "https://github.com/mpizenberg/elm-test-rs/releases/download/v1.2.1/elm-test-rs_linux.tar.gz", fileSize: 3591932, fileName: "elm-test-rs", type: "tgz", }, - mac: { + "darwin-x64": { hash: "890c45a7eda24fd13169d349af9c835ee3ed04974eec36953baba5aefc3628a8", url: "https://github.com/mpizenberg/elm-test-rs/releases/download/v1.2.1/elm-test-rs_macos.tar.gz", fileSize: 2221267, fileName: "elm-test-rs", type: "tgz", }, - windows: { + "win32-x64": { hash: "26add13880af484a47cd182547f41370d3bfca812a7cc9e3db6f41ce13b7fc40", url: "https://github.com/mpizenberg/elm-test-rs/releases/download/v1.2.1/elm-test-rs_windows.zip", fileSize: 1880965, @@ -307,21 +301,21 @@ const knownTools = { }, }, "1.2.2": { - linux: { + "linux-x64": { hash: "f9b972b9dcb71b9957baf23e5bca5674dfdea73b4b3706ad2c501f507933e489", url: "https://github.com/mpizenberg/elm-test-rs/releases/download/v1.2.2/elm-test-rs_linux.tar.gz", fileSize: 3629469, fileName: "elm-test-rs", type: "tgz", }, - mac: { + "darwin-x64": { hash: "d3dc5f84a2b3c31a4a14a9da609c2f2e6824102d30249f883a97ea26c4eb9c35", url: "https://github.com/mpizenberg/elm-test-rs/releases/download/v1.2.2/elm-test-rs_macos.tar.gz", fileSize: 2227354, fileName: "elm-test-rs", type: "tgz", }, - windows: { + "win32-x64": { hash: "8469a05cdaf0be76e7cb7c9d8001a88df74a1db964a24d144554a925f8042600", url: "https://github.com/mpizenberg/elm-test-rs/releases/download/v1.2.2/elm-test-rs_windows.zip", fileSize: 1891939, @@ -330,21 +324,21 @@ const knownTools = { }, }, "2.0.0": { - linux: { + "linux-x64": { hash: "face27bfe2b886d3ba96ad77c3f52d312da0f6089163b6db1b1c76297518ec54", url: "https://github.com/mpizenberg/elm-test-rs/releases/download/v2.0/elm-test-rs_linux.tar.gz", fileSize: 3572480, fileName: "elm-test-rs", type: "tgz", }, - mac: { + "darwin-x64": { hash: "b8a5c487d7fc60c3bbb40bf8616b4da726ce0ad867ea6295a07a4726f9fe105a", url: "https://github.com/mpizenberg/elm-test-rs/releases/download/v2.0/elm-test-rs_macos.tar.gz", fileSize: 2233532, fileName: "elm-test-rs", type: "tgz", }, - windows: { + "win32-x64": { hash: "5f4ae45981750ac17cd72a2711bacc21fee763840d3f18c2e73614666f510ee8", url: "https://github.com/mpizenberg/elm-test-rs/releases/download/v2.0/elm-test-rs_windows.zip", fileSize: 1897927, @@ -353,21 +347,21 @@ const knownTools = { }, }, "2.0.1": { - linux: { + "linux-x64": { hash: "0d69a890819a55b341703369ee9a937720eba752625d41623dfc2d7acfc62d86", url: "https://github.com/mpizenberg/elm-test-rs/releases/download/v2.0.1/elm-test-rs_linux.tar.gz", fileSize: 3606139, fileName: "elm-test-rs", type: "tgz", }, - mac: { + "darwin-x64": { hash: "fc377b78dfe748417d0aea8619f77e255fd62e980cce387582496c8e0d10d24e", url: "https://github.com/mpizenberg/elm-test-rs/releases/download/v2.0.1/elm-test-rs_macos.tar.gz", fileSize: 2211725, fileName: "elm-test-rs", type: "tgz", }, - windows: { + "win32-x64": { hash: "ae2f0ec7911911e0b06f74138782b5f3874900936a66455daff0d5c4c7c2bef8", url: "https://github.com/mpizenberg/elm-test-rs/releases/download/v2.0.1/elm-test-rs_windows.zip", fileSize: 1909110, @@ -376,21 +370,21 @@ const knownTools = { }, }, "3.0.0": { - linux: { + "linux-x64": { hash: "c72702d32a2a9e051667febeeef486a1794798d0770be1a9da95895e10b6db0f", url: "https://github.com/mpizenberg/elm-test-rs/releases/download/v3.0/elm-test-rs_linux.tar.gz", fileSize: 3717002, fileName: "elm-test-rs", type: "tgz", }, - mac: { + "darwin-x64": { hash: "41e2be1d77fb587ac1336f4b8822feb3b914eff7364715f6cac0bc4a90c0948a", url: "https://github.com/mpizenberg/elm-test-rs/releases/download/v3.0/elm-test-rs_macos.tar.gz", fileSize: 2271033, fileName: "elm-test-rs", type: "tgz", }, - windows: { + "win32-x64": { hash: "8cb1ef9bfe3e80e12db7db7f176e3e9280c5ae3bbb54c8dcfbb4f298c3d8fc71", url: "https://github.com/mpizenberg/elm-test-rs/releases/download/v3.0/elm-test-rs_windows.zip", fileSize: 1917553, diff --git a/src/Parse.ts b/src/Parse.ts index 0ddfe0d..980fa07 100644 --- a/src/Parse.ts +++ b/src/Parse.ts @@ -20,8 +20,7 @@ import { Asset, KNOWN_TOOL_NAMES, KNOWN_TOOLS, - OSAssets, - OSName, + PlatformAssets, } from "./KnownTools"; import { absoluteDirname, @@ -60,7 +59,7 @@ export type ParseResult = // Preserved for legacy reasons: originalObject: Record; tools?: Tools; - osName: OSName; + platform: string; } | { tag: "ReadAsJsonObjectError"; @@ -74,7 +73,7 @@ export type ParseError = message: string; } | { - tag: "UnkownField"; + tag: "UnknownField"; field: string; } | { @@ -147,27 +146,13 @@ export function findReadAndParseElmToolingJson( }; } - const osName = getOSName(); - - // istanbul ignore if - if (osName instanceof Error) { - return { - tag: "ReadAsJsonObjectError", - elmToolingJsonPath, - errors: [ - { - tag: "Message", - message: osName.message, - }, - ], - }; - } + const platform = getPlatform(); const result: ParseResult = { tag: "Parsed", elmToolingJsonPath, originalObject: json, - osName, + platform, }; const errors: Array = []; @@ -179,7 +164,7 @@ export function findReadAndParseElmToolingJson( break; case "tools": { - const toolsResult = parseTools(cwd, env, osName, value); + const toolsResult = parseTools(cwd, env, platform, value); if (Array.isArray(toolsResult)) { errors.push(...toolsResult); } else { @@ -189,7 +174,7 @@ export function findReadAndParseElmToolingJson( } default: - errors.push({ tag: "UnkownField", field }); + errors.push({ tag: "UnknownField", field }); break; } } @@ -205,20 +190,8 @@ export function findReadAndParseElmToolingJson( return result; } -export function getOSName(): Error | OSName { - // istanbul ignore next - switch (os.platform()) { - case "linux": - return "linux"; - case "darwin": - return "mac"; - case "win32": - return "windows"; - default: - return new Error( - `Sorry, your platform (${os.platform()}) is not supported yet :(` - ); - } +function getPlatform(): string { + return `${os.platform()}-${os.arch()}`; } export type FileExists = @@ -264,7 +237,7 @@ export function validateFileExists(fullPath: AbsolutePath): FileExists { function parseTools( cwd: Cwd, env: Env, - osName: OSName, + platform: string, json: unknown ): NonEmptyArray | Tools { if (!isRecord(json)) { @@ -308,9 +281,9 @@ function parseTools( }; } - const osAssets = getOwn(versions, version); + const platformAssets = getOwn(versions, version); - if (osAssets === undefined) { + if (platformAssets === undefined) { return { tag: "Left", value: { @@ -324,7 +297,21 @@ function parseTools( }; } - const asset = osAssets[osName]; + const asset = platformAssets[platform]; + + if (asset === undefined) { + return { + tag: "Left", + value: { + tag: "WithPath", + path: ["tools", name], + message: `${name} ${version} does not support your platform ${platform}\nSupported platforms: ${join( + Object.keys(platformAssets), + ", " + )}`, + }, + }; + } const tool = makeTool(cwd, env, name, version, asset); @@ -401,7 +388,7 @@ export function printParseErrors(errors: NonEmptyArray): string { case "Message": return error.message; - case "UnkownField": + case "UnknownField": return `${bold(error.field)}\n${indent("Unknown field")}`; case "WithPath": @@ -449,12 +436,7 @@ export function getToolThrowing({ cwd: Cwd; env: Env; }): Tool { - const osName = getOSName(); - - // istanbul ignore if - if (osName instanceof Error) { - throw osName; - } + const platform = getPlatform(); const versions = getOwn(KNOWN_TOOLS, name); @@ -480,7 +462,17 @@ export function getToolThrowing({ // `matchingVersion` is derived from `Object.keys` above, so it’s safe to use // as index. - const asset = (versions[matchingVersion] as OSAssets)[osName]; + const platformAssets = versions[matchingVersion] as PlatformAssets; + const asset = platformAssets[platform]; + + if (asset === undefined) { + throw new Error( + `${name} ${matchingVersion} does not support your platform ${platform}\nSupported platforms: ${join( + Object.keys(platformAssets), + ", " + )}` + ); + } return makeTool(cwd, env, name, matchingVersion, asset); } diff --git a/src/commands/Init.ts b/src/commands/Init.ts index 7244bd3..a6cc227 100644 --- a/src/commands/Init.ts +++ b/src/commands/Init.ts @@ -15,7 +15,7 @@ import { } from "../Helpers"; import { getLastVersion, KNOWN_TOOLS, KnownToolNames } from "../KnownTools"; import type { Logger } from "../Logger"; -import { getLatestVersionInRange, getOSName, getToolThrowing } from "../Parse"; +import { getLatestVersionInRange, getToolThrowing } from "../Parse"; import { absolutePathFromString, Cwd, @@ -37,14 +37,6 @@ export function init(cwd: Cwd, env: Env, logger: Logger): number { theElmToolingJsonPath: absolutePathFromString(cwd.path, "elm-tooling.json"), }; - const osName = getOSName(); - - // istanbul ignore if - if (osName instanceof Error) { - logger.error(osName.message); - return 1; - } - if (fs.existsSync(elmToolingJsonPath.theElmToolingJsonPath.absolutePath)) { logger.error(bold(elmToolingJsonPath.theElmToolingJsonPath.absolutePath)); logger.error("Already exists!"); diff --git a/src/commands/Install.ts b/src/commands/Install.ts index 25f3921..dea8481 100644 --- a/src/commands/Install.ts +++ b/src/commands/Install.ts @@ -24,7 +24,6 @@ import { KNOWN_TOOL_NAMES, KNOWN_TOOLS, KnownToolNames, - OSName, } from "../KnownTools"; import { linkTool, unlinkTool } from "../Link"; import type { Logger } from "../Logger"; @@ -80,7 +79,7 @@ export async function install( cwd, env, logger, - parseResult.osName, + parseResult.platform, parseResult.elmToolingJsonPath, "missing" ); @@ -93,7 +92,7 @@ export async function install( cwd, env, logger, - parseResult.osName, + parseResult.platform, parseResult.elmToolingJsonPath, "empty" ); @@ -104,7 +103,7 @@ export async function install( env, logger, parseResult.elmToolingJsonPath, - parseResult.osName, + parseResult.platform, tools ); } @@ -116,7 +115,7 @@ async function installTools( env: Env, logger: Logger, elmToolingJsonPath: ElmToolingJsonPath, - osName: OSName, + platform: string, tools: Tools ): Promise { const nodeModulesBinPath = getNodeModulesBinPath(elmToolingJsonPath); @@ -206,7 +205,7 @@ async function installTools( ...tools.existing.map((tool) => linkTool(cwd, nodeModulesBinPath, tool)), - ...removeTools(cwd, env, osName, nodeModulesBinPath, toolsToRemove), + ...removeTools(cwd, env, platform, nodeModulesBinPath, toolsToRemove), ]; return printResults(logger, results); @@ -260,7 +259,7 @@ function removeAllTools( cwd: Cwd, env: Env, logger: Logger, - osName: OSName, + platform: string, elmToolingJsonPath: ElmToolingJsonPath, what: string ): number { @@ -272,7 +271,7 @@ function removeAllTools( const results = removeTools( cwd, env, - osName, + platform, nodeModulesBinPath, KNOWN_TOOL_NAMES ); @@ -288,14 +287,17 @@ function removeAllTools( function removeTools( cwd: Cwd, env: Env, - osName: OSName, + platform: string, nodeModulesBinPath: NodeModulesBinPath, names: Array ): Array { return flatMap(names, (name) => { const versions = KNOWN_TOOLS[name]; - return Object.entries(versions).map(([version, foo]) => { - const asset = foo[osName]; + return Object.entries(versions).map(([version, platformAssets]) => { + const asset = platformAssets[platform]; + if (asset === undefined) { + return undefined; + } const tool = makeTool(cwd, env, name, version, asset); return unlinkTool(cwd, nodeModulesBinPath, tool); }); From 5a9ae3c11ced8b59bd49b5396b7c4a1c178df488 Mon Sep 17 00:00:00 2001 From: Simon Lydell Date: Sat, 7 Jan 2023 14:16:49 +0100 Subject: [PATCH 02/10] Sort --- scripts/HashUrls.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/scripts/HashUrls.ts b/scripts/HashUrls.ts index ff528b0..42cb7d0 100644 --- a/scripts/HashUrls.ts +++ b/scripts/HashUrls.ts @@ -46,7 +46,11 @@ async function run(urls: Array): Promise { ); process.stderr.write("\r100%"); - return JSON.stringify(fromEntries(assets), null, 2); + return JSON.stringify( + fromEntries(assets.sort(([a], [b]) => a.localeCompare(b))), + null, + 2 + ); } function guessPlatform(url: string): string { From 22fa4a09210c683efbe0e53cc3cb212463c41a15 Mon Sep 17 00:00:00 2001 From: Simon Lydell Date: Sat, 7 Jan 2023 14:17:02 +0100 Subject: [PATCH 03/10] Sort KnownTools.ts --- src/KnownTools.ts | 224 +++++++++++++++++++++++----------------------- 1 file changed, 112 insertions(+), 112 deletions(-) diff --git a/src/KnownTools.ts b/src/KnownTools.ts index 2e31d0b..daee87d 100644 --- a/src/KnownTools.ts +++ b/src/KnownTools.ts @@ -19,13 +19,6 @@ export type AssetType = "gz" | "tgz" | "zip"; const knownTools = { elm: { "0.19.0": { - "linux-x64": { - hash: "d359adbee89823c641cda326938708d7227dc79aa1f162e0d8fe275f182f528a", - url: "https://github.com/elm/compiler/releases/download/0.19.0/binary-for-linux-64-bit.gz", - fileSize: 10958261, - fileName: "elm", - type: "gz", - }, "darwin-x64": { hash: "f1fa4dd9021e94c5a58b2be8843e3329095232ee3bd21a23524721a40eaabd35", url: "https://github.com/elm/compiler/releases/download/0.19.0/binary-for-mac-64-bit.gz", @@ -33,6 +26,13 @@ const knownTools = { fileName: "elm", type: "gz", }, + "linux-x64": { + hash: "d359adbee89823c641cda326938708d7227dc79aa1f162e0d8fe275f182f528a", + url: "https://github.com/elm/compiler/releases/download/0.19.0/binary-for-linux-64-bit.gz", + fileSize: 10958261, + fileName: "elm", + type: "gz", + }, "win32-x64": { hash: "0e27d80537418896cf98326224159a45b6d36bf08e608e3a174ab6d2c572c5ae", url: "https://github.com/elm/compiler/releases/download/0.19.0/binary-for-windows-64-bit.gz", @@ -42,13 +42,6 @@ const knownTools = { }, }, "0.19.1": { - "linux-x64": { - hash: "e44af52bb27f725a973478e589d990a6428e115fe1bb14f03833134d6c0f155c", - url: "https://github.com/elm/compiler/releases/download/0.19.1/binary-for-linux-64-bit.gz", - fileSize: 6806857, - fileName: "elm", - type: "gz", - }, "darwin-x64": { hash: "05289f0e3d4f30033487c05e689964c3bb17c0c48012510dbef1df43868545d1", url: "https://github.com/elm/compiler/releases/download/0.19.1/binary-for-mac-64-bit.gz", @@ -56,6 +49,13 @@ const knownTools = { fileName: "elm", type: "gz", }, + "linux-x64": { + hash: "e44af52bb27f725a973478e589d990a6428e115fe1bb14f03833134d6c0f155c", + url: "https://github.com/elm/compiler/releases/download/0.19.1/binary-for-linux-64-bit.gz", + fileSize: 6806857, + fileName: "elm", + type: "gz", + }, "win32-x64": { hash: "d1bf666298cbe3c5447b9ca0ea608552d750e5d232f9845c2af11907b654903b", url: "https://github.com/elm/compiler/releases/download/0.19.1/binary-for-windows-64-bit.gz", @@ -67,13 +67,6 @@ const knownTools = { }, "elm-format": { "0.8.1": { - "linux-x64": { - hash: "13d06e0c3f3a9ef585c828ac5761ead148ea2f203573309306393e2d8066e1fd", - url: "https://github.com/avh4/elm-format/releases/download/0.8.1/elm-format-0.8.1-linux-x64.tgz", - fileSize: 2110405, - fileName: "elm-format", - type: "tgz", - }, "darwin-x64": { hash: "e1beba5d3090968cbbd879384617506f4c71a3ea3b01ce94d298e4893e82a640", url: "https://github.com/avh4/elm-format/releases/download/0.8.1/elm-format-0.8.1-mac-x64.tgz", @@ -81,6 +74,13 @@ const knownTools = { fileName: "elm-format", type: "tgz", }, + "linux-x64": { + hash: "13d06e0c3f3a9ef585c828ac5761ead148ea2f203573309306393e2d8066e1fd", + url: "https://github.com/avh4/elm-format/releases/download/0.8.1/elm-format-0.8.1-linux-x64.tgz", + fileSize: 2110405, + fileName: "elm-format", + type: "tgz", + }, "win32-x64": { hash: "29b8989918e5804b538c411a92f3da8d15337ec28003b033b3be0de2d2d636d2", url: "https://github.com/avh4/elm-format/releases/download/0.8.1/elm-format-0.8.1-win-i386.zip", @@ -90,13 +90,6 @@ const knownTools = { }, }, "0.8.2": { - "linux-x64": { - hash: "a69a4d3c49ccb0dffb3067b35464dc492563274e5778c40625220f9f6b3fd06d", - url: "https://github.com/avh4/elm-format/releases/download/0.8.2/elm-format-0.8.2-linux-x64.tgz", - fileSize: 2128375, - fileName: "elm-format", - type: "tgz", - }, "darwin-x64": { hash: "1f6cc8663922e546645c0536fc9bf7a49351d0b2963d26fc8fcb43e5bc92d733", url: "https://github.com/avh4/elm-format/releases/download/0.8.2/elm-format-0.8.2-mac-x64.tgz", @@ -104,6 +97,13 @@ const knownTools = { fileName: "elm-format", type: "tgz", }, + "linux-x64": { + hash: "a69a4d3c49ccb0dffb3067b35464dc492563274e5778c40625220f9f6b3fd06d", + url: "https://github.com/avh4/elm-format/releases/download/0.8.2/elm-format-0.8.2-linux-x64.tgz", + fileSize: 2128375, + fileName: "elm-format", + type: "tgz", + }, "win32-x64": { hash: "5009fd26b59a785738dd82c8d90ea8fd0bb7fe65fbd562097d906ee04061ef7f", url: "https://github.com/avh4/elm-format/releases/download/0.8.2/elm-format-0.8.2-win-i386.zip", @@ -113,13 +113,6 @@ const knownTools = { }, }, "0.8.3": { - "linux-x64": { - hash: "9012f3a372488d4a118dc5f8ff57cc61cd1753d7d878b393fa7f60d496e37084", - url: "https://github.com/avh4/elm-format/releases/download/0.8.3/elm-format-0.8.3-linux-x64.tgz", - fileSize: 2137733, - fileName: "elm-format", - type: "tgz", - }, "darwin-x64": { hash: "66c9d4c2fcc7e435726f25ca44509cdf2caff5000dd215b5a086db514576efc7", url: "https://github.com/avh4/elm-format/releases/download/0.8.3/elm-format-0.8.3-mac-x64.tgz", @@ -127,6 +120,13 @@ const knownTools = { fileName: "elm-format", type: "tgz", }, + "linux-x64": { + hash: "9012f3a372488d4a118dc5f8ff57cc61cd1753d7d878b393fa7f60d496e37084", + url: "https://github.com/avh4/elm-format/releases/download/0.8.3/elm-format-0.8.3-linux-x64.tgz", + fileSize: 2137733, + fileName: "elm-format", + type: "tgz", + }, "win32-x64": { hash: "da9c013e27faccd14d6395db638af111097f171a45705a8978a28e30c115778f", url: "https://github.com/avh4/elm-format/releases/download/0.8.3/elm-format-0.8.3-win-i386.zip", @@ -136,13 +136,6 @@ const knownTools = { }, }, "0.8.4": { - "linux-x64": { - hash: "aa6bb9d11672d8d27398746e831266c565e9837b4da6abe5d8286c2ab69ace9d", - url: "https://github.com/avh4/elm-format/releases/download/0.8.4/elm-format-0.8.4-linux-x64.tgz", - fileSize: 1956444, - fileName: "elm-format", - type: "tgz", - }, "darwin-x64": { hash: "df2a85da6870e8c8f7b052c9b81279fd9cbbab2bc738c2e14adf95ef777edd21", url: "https://github.com/avh4/elm-format/releases/download/0.8.4/elm-format-0.8.4-mac-x64.tgz", @@ -150,6 +143,13 @@ const knownTools = { fileName: "elm-format", type: "tgz", }, + "linux-x64": { + hash: "aa6bb9d11672d8d27398746e831266c565e9837b4da6abe5d8286c2ab69ace9d", + url: "https://github.com/avh4/elm-format/releases/download/0.8.4/elm-format-0.8.4-linux-x64.tgz", + fileSize: 1956444, + fileName: "elm-format", + type: "tgz", + }, "win32-x64": { hash: "0afe91bba2951c675f7484ae8d3d45792ed802d2eac9110b2afc18e3ed1a888d", url: "https://github.com/avh4/elm-format/releases/download/0.8.4/elm-format-0.8.4-win-x64.zip", @@ -159,13 +159,6 @@ const knownTools = { }, }, "0.8.5": { - "linux-x64": { - hash: "147c479e375b9bae8dd633e526677fbd2a87e5445b3638ebee86c1319ffe8e23", - url: "https://github.com/avh4/elm-format/releases/download/0.8.5/elm-format-0.8.5-linux-x64.tgz", - fileSize: 3870971, - fileName: "elm-format", - type: "tgz", - }, "darwin-x64": { hash: "380c5f36b1fdeb2f1cda7c208dc788cb676675b3d5d43d907efc3f0821c010d6", url: "https://github.com/avh4/elm-format/releases/download/0.8.5/elm-format-0.8.5-mac-x64.tgz", @@ -173,6 +166,13 @@ const knownTools = { fileName: "elm-format", type: "tgz", }, + "linux-x64": { + hash: "147c479e375b9bae8dd633e526677fbd2a87e5445b3638ebee86c1319ffe8e23", + url: "https://github.com/avh4/elm-format/releases/download/0.8.5/elm-format-0.8.5-linux-x64.tgz", + fileSize: 3870971, + fileName: "elm-format", + type: "tgz", + }, "win32-x64": { hash: "3cb6f74f24b401314480227b1ccbb2049cceb4a365ac7abb50cd3cfe0e64bbdc", url: "https://github.com/avh4/elm-format/releases/download/0.8.5/elm-format-0.8.5-win-x64.zip", @@ -184,13 +184,6 @@ const knownTools = { }, "elm-json": { "0.2.8": { - "linux-x64": { - hash: "d4561a9a2bd70e1a4a4c61e75cac03d3bb1a3b5f99322afa720a2f2d84c194de", - url: "https://github.com/zwilias/elm-json/releases/download/v0.2.8/elm-json-v0.2.8-x86_64-unknown-linux-musl.tar.gz", - fileSize: 2255688, - fileName: "elm-json", - type: "tgz", - }, "darwin-x64": { hash: "1ca3cde58730e87f2b73afb2432d5d8c88787ee3745bc81769ec0eef962ceaf6", url: "https://github.com/zwilias/elm-json/releases/download/v0.2.8/elm-json-v0.2.8-x86_64-apple-darwin.tar.gz", @@ -198,6 +191,13 @@ const knownTools = { fileName: "elm-json", type: "tgz", }, + "linux-x64": { + hash: "d4561a9a2bd70e1a4a4c61e75cac03d3bb1a3b5f99322afa720a2f2d84c194de", + url: "https://github.com/zwilias/elm-json/releases/download/v0.2.8/elm-json-v0.2.8-x86_64-unknown-linux-musl.tar.gz", + fileSize: 2255688, + fileName: "elm-json", + type: "tgz", + }, "win32-x64": { hash: "1ae0b8e9a9717bdfb05346d0b864868e3907cb83c54d6770f6c604972296384f", url: "https://github.com/zwilias/elm-json/releases/download/v0.2.8/elm-json-v0.2.8-x86_64-pc-windows-msvc.tar.gz", @@ -207,13 +207,6 @@ const knownTools = { }, }, "0.2.10": { - "linux-x64": { - hash: "6ee94f04bebeb66d5ef322d76fd3dc828015571b92f1259776f716feaaec359d", - url: "https://github.com/zwilias/elm-json/releases/download/v0.2.10/elm-json-v0.2.10-x86_64-unknown-linux-musl.tar.gz", - fileSize: 2307188, - fileName: "elm-json", - type: "tgz", - }, "darwin-x64": { hash: "fcd39c7c014d95df033499d8a39720b38c9f93d0e3b7ecb821cfe3dbfd1affc1", url: "https://github.com/zwilias/elm-json/releases/download/v0.2.10/elm-json-v0.2.10-x86_64-apple-darwin.tar.gz", @@ -221,6 +214,13 @@ const knownTools = { fileName: "elm-json", type: "tgz", }, + "linux-x64": { + hash: "6ee94f04bebeb66d5ef322d76fd3dc828015571b92f1259776f716feaaec359d", + url: "https://github.com/zwilias/elm-json/releases/download/v0.2.10/elm-json-v0.2.10-x86_64-unknown-linux-musl.tar.gz", + fileSize: 2307188, + fileName: "elm-json", + type: "tgz", + }, "win32-x64": { hash: "721084dd90042a2b7b99a1334a9dcfa753fcf166ade458e6a3bb5d6649f8e39b", url: "https://github.com/zwilias/elm-json/releases/download/v0.2.10/elm-json-v0.2.10-x86_64-pc-windows-msvc.tar.gz", @@ -230,13 +230,6 @@ const knownTools = { }, }, "0.2.13": { - "linux-x64": { - hash: "83cbab79f6c237d3f96b69baf519bdd7634d0e0373a390594d37591c0295f965", - url: "https://github.com/zwilias/elm-json/releases/download/v0.2.13/elm-json-v0.2.13-x86_64-unknown-linux-musl.tar.gz", - fileSize: 2294914, - fileName: "elm-json", - type: "tgz", - }, "darwin-x64": { hash: "868d82cc5496ddc5e17303e85b198b29fe7a30c8ac8b22aa9607e23cc07a1884", url: "https://github.com/zwilias/elm-json/releases/download/v0.2.13/elm-json-v0.2.13-x86_64-apple-darwin.tar.gz", @@ -244,6 +237,13 @@ const knownTools = { fileName: "elm-json", type: "tgz", }, + "linux-x64": { + hash: "83cbab79f6c237d3f96b69baf519bdd7634d0e0373a390594d37591c0295f965", + url: "https://github.com/zwilias/elm-json/releases/download/v0.2.13/elm-json-v0.2.13-x86_64-unknown-linux-musl.tar.gz", + fileSize: 2294914, + fileName: "elm-json", + type: "tgz", + }, "win32-x64": { hash: "0494f0d813244bf43e3c6cad1d0428919e7e0a5430d21a4d8a65697af0c14527", url: "https://github.com/zwilias/elm-json/releases/download/v0.2.13/elm-json-v0.2.13-x86_64-pc-windows-msvc.tar.gz", @@ -255,13 +255,6 @@ const knownTools = { }, "elm-test-rs": { "1.0.0": { - "linux-x64": { - hash: "a914088083ea8bc004944c98d9a4767cc5225d5811480f49fe1ad2c491baaaaa", - url: "https://github.com/mpizenberg/elm-test-rs/releases/download/v1.0/elm-test-rs_linux.tar.gz", - fileSize: 3610634, - fileName: "elm-test-rs", - type: "tgz", - }, "darwin-x64": { hash: "5f296888b7ba32c47830f00f6d38c56fc86f49d8c0c8998054b0842009a1173f", url: "https://github.com/mpizenberg/elm-test-rs/releases/download/v1.0/elm-test-rs_macos.tar.gz", @@ -269,6 +262,13 @@ const knownTools = { fileName: "elm-test-rs", type: "tgz", }, + "linux-x64": { + hash: "a914088083ea8bc004944c98d9a4767cc5225d5811480f49fe1ad2c491baaaaa", + url: "https://github.com/mpizenberg/elm-test-rs/releases/download/v1.0/elm-test-rs_linux.tar.gz", + fileSize: 3610634, + fileName: "elm-test-rs", + type: "tgz", + }, "win32-x64": { hash: "c8a35e2e0049b691e4833a6e8ccb094688cdc49aa977c437a8289c57d92a5775", url: "https://github.com/mpizenberg/elm-test-rs/releases/download/v1.0/elm-test-rs_windows.zip", @@ -278,13 +278,6 @@ const knownTools = { }, }, "1.2.1": { - "linux-x64": { - hash: "6e5759f832a5e025898c9306ba47b2f9ed7f0c371dc69bd16c15c7ed8bfb1501", - url: "https://github.com/mpizenberg/elm-test-rs/releases/download/v1.2.1/elm-test-rs_linux.tar.gz", - fileSize: 3591932, - fileName: "elm-test-rs", - type: "tgz", - }, "darwin-x64": { hash: "890c45a7eda24fd13169d349af9c835ee3ed04974eec36953baba5aefc3628a8", url: "https://github.com/mpizenberg/elm-test-rs/releases/download/v1.2.1/elm-test-rs_macos.tar.gz", @@ -292,6 +285,13 @@ const knownTools = { fileName: "elm-test-rs", type: "tgz", }, + "linux-x64": { + hash: "6e5759f832a5e025898c9306ba47b2f9ed7f0c371dc69bd16c15c7ed8bfb1501", + url: "https://github.com/mpizenberg/elm-test-rs/releases/download/v1.2.1/elm-test-rs_linux.tar.gz", + fileSize: 3591932, + fileName: "elm-test-rs", + type: "tgz", + }, "win32-x64": { hash: "26add13880af484a47cd182547f41370d3bfca812a7cc9e3db6f41ce13b7fc40", url: "https://github.com/mpizenberg/elm-test-rs/releases/download/v1.2.1/elm-test-rs_windows.zip", @@ -301,13 +301,6 @@ const knownTools = { }, }, "1.2.2": { - "linux-x64": { - hash: "f9b972b9dcb71b9957baf23e5bca5674dfdea73b4b3706ad2c501f507933e489", - url: "https://github.com/mpizenberg/elm-test-rs/releases/download/v1.2.2/elm-test-rs_linux.tar.gz", - fileSize: 3629469, - fileName: "elm-test-rs", - type: "tgz", - }, "darwin-x64": { hash: "d3dc5f84a2b3c31a4a14a9da609c2f2e6824102d30249f883a97ea26c4eb9c35", url: "https://github.com/mpizenberg/elm-test-rs/releases/download/v1.2.2/elm-test-rs_macos.tar.gz", @@ -315,6 +308,13 @@ const knownTools = { fileName: "elm-test-rs", type: "tgz", }, + "linux-x64": { + hash: "f9b972b9dcb71b9957baf23e5bca5674dfdea73b4b3706ad2c501f507933e489", + url: "https://github.com/mpizenberg/elm-test-rs/releases/download/v1.2.2/elm-test-rs_linux.tar.gz", + fileSize: 3629469, + fileName: "elm-test-rs", + type: "tgz", + }, "win32-x64": { hash: "8469a05cdaf0be76e7cb7c9d8001a88df74a1db964a24d144554a925f8042600", url: "https://github.com/mpizenberg/elm-test-rs/releases/download/v1.2.2/elm-test-rs_windows.zip", @@ -324,13 +324,6 @@ const knownTools = { }, }, "2.0.0": { - "linux-x64": { - hash: "face27bfe2b886d3ba96ad77c3f52d312da0f6089163b6db1b1c76297518ec54", - url: "https://github.com/mpizenberg/elm-test-rs/releases/download/v2.0/elm-test-rs_linux.tar.gz", - fileSize: 3572480, - fileName: "elm-test-rs", - type: "tgz", - }, "darwin-x64": { hash: "b8a5c487d7fc60c3bbb40bf8616b4da726ce0ad867ea6295a07a4726f9fe105a", url: "https://github.com/mpizenberg/elm-test-rs/releases/download/v2.0/elm-test-rs_macos.tar.gz", @@ -338,6 +331,13 @@ const knownTools = { fileName: "elm-test-rs", type: "tgz", }, + "linux-x64": { + hash: "face27bfe2b886d3ba96ad77c3f52d312da0f6089163b6db1b1c76297518ec54", + url: "https://github.com/mpizenberg/elm-test-rs/releases/download/v2.0/elm-test-rs_linux.tar.gz", + fileSize: 3572480, + fileName: "elm-test-rs", + type: "tgz", + }, "win32-x64": { hash: "5f4ae45981750ac17cd72a2711bacc21fee763840d3f18c2e73614666f510ee8", url: "https://github.com/mpizenberg/elm-test-rs/releases/download/v2.0/elm-test-rs_windows.zip", @@ -347,13 +347,6 @@ const knownTools = { }, }, "2.0.1": { - "linux-x64": { - hash: "0d69a890819a55b341703369ee9a937720eba752625d41623dfc2d7acfc62d86", - url: "https://github.com/mpizenberg/elm-test-rs/releases/download/v2.0.1/elm-test-rs_linux.tar.gz", - fileSize: 3606139, - fileName: "elm-test-rs", - type: "tgz", - }, "darwin-x64": { hash: "fc377b78dfe748417d0aea8619f77e255fd62e980cce387582496c8e0d10d24e", url: "https://github.com/mpizenberg/elm-test-rs/releases/download/v2.0.1/elm-test-rs_macos.tar.gz", @@ -361,6 +354,13 @@ const knownTools = { fileName: "elm-test-rs", type: "tgz", }, + "linux-x64": { + hash: "0d69a890819a55b341703369ee9a937720eba752625d41623dfc2d7acfc62d86", + url: "https://github.com/mpizenberg/elm-test-rs/releases/download/v2.0.1/elm-test-rs_linux.tar.gz", + fileSize: 3606139, + fileName: "elm-test-rs", + type: "tgz", + }, "win32-x64": { hash: "ae2f0ec7911911e0b06f74138782b5f3874900936a66455daff0d5c4c7c2bef8", url: "https://github.com/mpizenberg/elm-test-rs/releases/download/v2.0.1/elm-test-rs_windows.zip", @@ -370,13 +370,6 @@ const knownTools = { }, }, "3.0.0": { - "linux-x64": { - hash: "c72702d32a2a9e051667febeeef486a1794798d0770be1a9da95895e10b6db0f", - url: "https://github.com/mpizenberg/elm-test-rs/releases/download/v3.0/elm-test-rs_linux.tar.gz", - fileSize: 3717002, - fileName: "elm-test-rs", - type: "tgz", - }, "darwin-x64": { hash: "41e2be1d77fb587ac1336f4b8822feb3b914eff7364715f6cac0bc4a90c0948a", url: "https://github.com/mpizenberg/elm-test-rs/releases/download/v3.0/elm-test-rs_macos.tar.gz", @@ -384,6 +377,13 @@ const knownTools = { fileName: "elm-test-rs", type: "tgz", }, + "linux-x64": { + hash: "c72702d32a2a9e051667febeeef486a1794798d0770be1a9da95895e10b6db0f", + url: "https://github.com/mpizenberg/elm-test-rs/releases/download/v3.0/elm-test-rs_linux.tar.gz", + fileSize: 3717002, + fileName: "elm-test-rs", + type: "tgz", + }, "win32-x64": { hash: "8cb1ef9bfe3e80e12db7db7f176e3e9280c5ae3bbb54c8dcfbb4f298c3d8fc71", url: "https://github.com/mpizenberg/elm-test-rs/releases/download/v3.0/elm-test-rs_windows.zip", From 458d14cc879aafb839a329b04949d548e0a303eb Mon Sep 17 00:00:00 2001 From: Simon Lydell Date: Sat, 7 Jan 2023 14:49:51 +0100 Subject: [PATCH 04/10] Add ARM entries --- src/KnownTools.ts | 219 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 219 insertions(+) diff --git a/src/KnownTools.ts b/src/KnownTools.ts index daee87d..59f5186 100644 --- a/src/KnownTools.ts +++ b/src/KnownTools.ts @@ -19,6 +19,14 @@ export type AssetType = "gz" | "tgz" | "zip"; const knownTools = { elm: { "0.19.0": { + // Rosetta. + "darwin-arm64": { + hash: "f1fa4dd9021e94c5a58b2be8843e3329095232ee3bd21a23524721a40eaabd35", + url: "https://github.com/elm/compiler/releases/download/0.19.0/binary-for-mac-64-bit.gz", + fileSize: 6051435, + fileName: "elm", + type: "gz", + }, "darwin-x64": { hash: "f1fa4dd9021e94c5a58b2be8843e3329095232ee3bd21a23524721a40eaabd35", url: "https://github.com/elm/compiler/releases/download/0.19.0/binary-for-mac-64-bit.gz", @@ -42,6 +50,13 @@ const knownTools = { }, }, "0.19.1": { + "darwin-arm64": { + hash: "c7d5322e39c938f5ba35c8a09c9f85387100d495bd0bd5011fc63c6c550b00d8", + url: "https://github.com/lydell/compiler/releases/download/0.19.1/binary-for-mac-arm-64-bit.gz", + fileSize: 14054287, + fileName: "elm", + type: "gz", + }, "darwin-x64": { hash: "05289f0e3d4f30033487c05e689964c3bb17c0c48012510dbef1df43868545d1", url: "https://github.com/elm/compiler/releases/download/0.19.1/binary-for-mac-64-bit.gz", @@ -49,6 +64,13 @@ const knownTools = { fileName: "elm", type: "gz", }, + "linux-arm64": { + hash: "a9123b40db040fc431ec8c2d275fa04ce260bc8d5eab5050ff5869477253605d", + url: "https://github.com/lydell/compiler/releases/download/0.19.1/binary-for-linux-arm-64-bit.gz", + fileSize: 4997442, + fileName: "elm", + type: "gz", + }, "linux-x64": { hash: "e44af52bb27f725a973478e589d990a6428e115fe1bb14f03833134d6c0f155c", url: "https://github.com/elm/compiler/releases/download/0.19.1/binary-for-linux-64-bit.gz", @@ -67,6 +89,14 @@ const knownTools = { }, "elm-format": { "0.8.1": { + // Rosetta. + "darwin-arm64": { + hash: "e1beba5d3090968cbbd879384617506f4c71a3ea3b01ce94d298e4893e82a640", + url: "https://github.com/avh4/elm-format/releases/download/0.8.1/elm-format-0.8.1-mac-x64.tgz", + fileSize: 1325147, + fileName: "elm-format", + type: "tgz", + }, "darwin-x64": { hash: "e1beba5d3090968cbbd879384617506f4c71a3ea3b01ce94d298e4893e82a640", url: "https://github.com/avh4/elm-format/releases/download/0.8.1/elm-format-0.8.1-mac-x64.tgz", @@ -90,6 +120,14 @@ const knownTools = { }, }, "0.8.2": { + // Rosetta. + "darwin-arm64": { + hash: "1f6cc8663922e546645c0536fc9bf7a49351d0b2963d26fc8fcb43e5bc92d733", + url: "https://github.com/avh4/elm-format/releases/download/0.8.2/elm-format-0.8.2-mac-x64.tgz", + fileSize: 1298447, + fileName: "elm-format", + type: "tgz", + }, "darwin-x64": { hash: "1f6cc8663922e546645c0536fc9bf7a49351d0b2963d26fc8fcb43e5bc92d733", url: "https://github.com/avh4/elm-format/releases/download/0.8.2/elm-format-0.8.2-mac-x64.tgz", @@ -113,6 +151,14 @@ const knownTools = { }, }, "0.8.3": { + // Rosetta. + "darwin-arm64": { + hash: "66c9d4c2fcc7e435726f25ca44509cdf2caff5000dd215b5a086db514576efc7", + url: "https://github.com/avh4/elm-format/releases/download/0.8.3/elm-format-0.8.3-mac-x64.tgz", + fileSize: 1308986, + fileName: "elm-format", + type: "tgz", + }, "darwin-x64": { hash: "66c9d4c2fcc7e435726f25ca44509cdf2caff5000dd215b5a086db514576efc7", url: "https://github.com/avh4/elm-format/releases/download/0.8.3/elm-format-0.8.3-mac-x64.tgz", @@ -136,6 +182,14 @@ const knownTools = { }, }, "0.8.4": { + // Rosetta. + "darwin-arm64": { + hash: "df2a85da6870e8c8f7b052c9b81279fd9cbbab2bc738c2e14adf95ef777edd21", + url: "https://github.com/avh4/elm-format/releases/download/0.8.4/elm-format-0.8.4-mac-x64.tgz", + fileSize: 1283871, + fileName: "elm-format", + type: "tgz", + }, "darwin-x64": { hash: "df2a85da6870e8c8f7b052c9b81279fd9cbbab2bc738c2e14adf95ef777edd21", url: "https://github.com/avh4/elm-format/releases/download/0.8.4/elm-format-0.8.4-mac-x64.tgz", @@ -159,6 +213,14 @@ const knownTools = { }, }, "0.8.5": { + // Rosetta. + "darwin-arm64": { + hash: "380c5f36b1fdeb2f1cda7c208dc788cb676675b3d5d43d907efc3f0821c010d6", + url: "https://github.com/avh4/elm-format/releases/download/0.8.5/elm-format-0.8.5-mac-x64.tgz", + fileSize: 1334367, + fileName: "elm-format", + type: "tgz", + }, "darwin-x64": { hash: "380c5f36b1fdeb2f1cda7c208dc788cb676675b3d5d43d907efc3f0821c010d6", url: "https://github.com/avh4/elm-format/releases/download/0.8.5/elm-format-0.8.5-mac-x64.tgz", @@ -184,6 +246,14 @@ const knownTools = { }, "elm-json": { "0.2.8": { + // Rosetta. + "darwin-arm64": { + hash: "1ca3cde58730e87f2b73afb2432d5d8c88787ee3745bc81769ec0eef962ceaf6", + url: "https://github.com/zwilias/elm-json/releases/download/v0.2.8/elm-json-v0.2.8-x86_64-apple-darwin.tar.gz", + fileSize: 838159, + fileName: "elm-json", + type: "tgz", + }, "darwin-x64": { hash: "1ca3cde58730e87f2b73afb2432d5d8c88787ee3745bc81769ec0eef962ceaf6", url: "https://github.com/zwilias/elm-json/releases/download/v0.2.8/elm-json-v0.2.8-x86_64-apple-darwin.tar.gz", @@ -191,6 +261,13 @@ const knownTools = { fileName: "elm-json", type: "tgz", }, + "linux-arm64": { + hash: "973405b81577889db391b7718d7bf7358e46be5cbecd4a7e72214f6388d2468e", + url: "https://github.com/zwilias/elm-json/releases/download/v0.2.8/elm-json-v0.2.8-armv7-unknown-linux-musleabihf.tar.gz", + fileSize: 2086957, + fileName: "elm-json", + type: "tgz", + }, "linux-x64": { hash: "d4561a9a2bd70e1a4a4c61e75cac03d3bb1a3b5f99322afa720a2f2d84c194de", url: "https://github.com/zwilias/elm-json/releases/download/v0.2.8/elm-json-v0.2.8-x86_64-unknown-linux-musl.tar.gz", @@ -207,6 +284,14 @@ const knownTools = { }, }, "0.2.10": { + // Rosetta. + "darwin-arm64": { + hash: "fcd39c7c014d95df033499d8a39720b38c9f93d0e3b7ecb821cfe3dbfd1affc1", + url: "https://github.com/zwilias/elm-json/releases/download/v0.2.10/elm-json-v0.2.10-x86_64-apple-darwin.tar.gz", + fileSize: 899328, + fileName: "elm-json", + type: "tgz", + }, "darwin-x64": { hash: "fcd39c7c014d95df033499d8a39720b38c9f93d0e3b7ecb821cfe3dbfd1affc1", url: "https://github.com/zwilias/elm-json/releases/download/v0.2.10/elm-json-v0.2.10-x86_64-apple-darwin.tar.gz", @@ -214,6 +299,13 @@ const knownTools = { fileName: "elm-json", type: "tgz", }, + "linux-arm64": { + hash: "4075fb5a486760d87615d5d78c1a4022669f673eb306dd9ff467ca3129ae6bec", + url: "https://github.com/zwilias/elm-json/releases/download/v0.2.10/elm-json-v0.2.10-armv7-unknown-linux-musleabihf.tar.gz", + fileSize: 2168765, + fileName: "elm-json", + type: "tgz", + }, "linux-x64": { hash: "6ee94f04bebeb66d5ef322d76fd3dc828015571b92f1259776f716feaaec359d", url: "https://github.com/zwilias/elm-json/releases/download/v0.2.10/elm-json-v0.2.10-x86_64-unknown-linux-musl.tar.gz", @@ -230,6 +322,13 @@ const knownTools = { }, }, "0.2.13": { + "darwin-arm64": { + hash: "4d917f21e40badc6d8f0f61e4cc0690e56b62c8c4280f379ead8da8e18de1760", + url: "https://github.com/zwilias/elm-json/releases/download/v0.2.13/elm-json-v0.2.13-aarch64-apple-darwin.tar.gz", + fileSize: 841664, + fileName: "elm-json", + type: "tgz", + }, "darwin-x64": { hash: "868d82cc5496ddc5e17303e85b198b29fe7a30c8ac8b22aa9607e23cc07a1884", url: "https://github.com/zwilias/elm-json/releases/download/v0.2.13/elm-json-v0.2.13-x86_64-apple-darwin.tar.gz", @@ -237,6 +336,13 @@ const knownTools = { fileName: "elm-json", type: "tgz", }, + "linux-arm64": { + hash: "acc093b8a5037f141c7870ec6d8bb1140b37031ccf4e99cea0280864d7f4831e", + url: "https://github.com/zwilias/elm-json/releases/download/v0.2.13/elm-json-v0.2.13-armv7-unknown-linux-musleabihf.tar.gz", + fileSize: 1978987, + fileName: "elm-json", + type: "tgz", + }, "linux-x64": { hash: "83cbab79f6c237d3f96b69baf519bdd7634d0e0373a390594d37591c0295f965", url: "https://github.com/zwilias/elm-json/releases/download/v0.2.13/elm-json-v0.2.13-x86_64-unknown-linux-musl.tar.gz", @@ -255,6 +361,14 @@ const knownTools = { }, "elm-test-rs": { "1.0.0": { + // Rosetta. + "darwin-arm64": { + hash: "5f296888b7ba32c47830f00f6d38c56fc86f49d8c0c8998054b0842009a1173f", + url: "https://github.com/mpizenberg/elm-test-rs/releases/download/v1.0/elm-test-rs_macos.tar.gz", + fileSize: 2230430, + fileName: "elm-test-rs", + type: "tgz", + }, "darwin-x64": { hash: "5f296888b7ba32c47830f00f6d38c56fc86f49d8c0c8998054b0842009a1173f", url: "https://github.com/mpizenberg/elm-test-rs/releases/download/v1.0/elm-test-rs_macos.tar.gz", @@ -278,6 +392,13 @@ const knownTools = { }, }, "1.2.1": { + "darwin-arm64": { + hash: "605dbe1976cd345a9a5cc3c77620cc268fef2a8ef701c5ac49157c4ac2c592eb", + url: "https://github.com/mpizenberg/elm-test-rs/releases/download/v1.2.1/elm-test-rs_macos-arm.tar.gz", + fileSize: 2098339, + fileName: "elm-test-rs", + type: "tgz", + }, "darwin-x64": { hash: "890c45a7eda24fd13169d349af9c835ee3ed04974eec36953baba5aefc3628a8", url: "https://github.com/mpizenberg/elm-test-rs/releases/download/v1.2.1/elm-test-rs_macos.tar.gz", @@ -285,6 +406,20 @@ const knownTools = { fileName: "elm-test-rs", type: "tgz", }, + "linux-arm": { + hash: "cc5a24f955a2e8f368374f725db25f3383ea6a008248117efd3393d5de915c5a", + url: "https://github.com/mpizenberg/elm-test-rs/releases/download/v1.2.1/elm-test-rs_linux-arm-32.tar.gz", + fileSize: 3490881, + fileName: "elm-test-rs", + type: "tgz", + }, + "linux-arm64": { + hash: "f2a476c075122321e627cb1603b23f76521810255182d2b18c035c96de718020", + url: "https://github.com/mpizenberg/elm-test-rs/releases/download/v1.2.1/elm-test-rs_linux-arm-64.tar.gz", + fileSize: 3298234, + fileName: "elm-test-rs", + type: "tgz", + }, "linux-x64": { hash: "6e5759f832a5e025898c9306ba47b2f9ed7f0c371dc69bd16c15c7ed8bfb1501", url: "https://github.com/mpizenberg/elm-test-rs/releases/download/v1.2.1/elm-test-rs_linux.tar.gz", @@ -301,6 +436,13 @@ const knownTools = { }, }, "1.2.2": { + "darwin-arm64": { + hash: "72df0a762a5b3da3f647992abde067d6c6764d408501a19ab8a7b4ee7698cfda", + url: "https://github.com/mpizenberg/elm-test-rs/releases/download/v1.2.2/elm-test-rs_macos-arm.tar.gz", + fileSize: 2098589, + fileName: "elm-test-rs", + type: "tgz", + }, "darwin-x64": { hash: "d3dc5f84a2b3c31a4a14a9da609c2f2e6824102d30249f883a97ea26c4eb9c35", url: "https://github.com/mpizenberg/elm-test-rs/releases/download/v1.2.2/elm-test-rs_macos.tar.gz", @@ -308,6 +450,20 @@ const knownTools = { fileName: "elm-test-rs", type: "tgz", }, + "linux-arm": { + hash: "57e6b6e2714dfd954914f095e74dc0f4d42e4f986c4771713841b055552c4a93", + url: "https://github.com/mpizenberg/elm-test-rs/releases/download/v1.2.2/elm-test-rs_linux-arm-32.tar.gz", + fileSize: 3494810, + fileName: "elm-test-rs", + type: "tgz", + }, + "linux-arm64": { + hash: "f51562da44d1aff85eaa108a5c3de9fd6c5e66b9c5cd2f120367b940c258ed30", + url: "https://github.com/mpizenberg/elm-test-rs/releases/download/v1.2.2/elm-test-rs_linux-arm-64.tar.gz", + fileSize: 3295097, + fileName: "elm-test-rs", + type: "tgz", + }, "linux-x64": { hash: "f9b972b9dcb71b9957baf23e5bca5674dfdea73b4b3706ad2c501f507933e489", url: "https://github.com/mpizenberg/elm-test-rs/releases/download/v1.2.2/elm-test-rs_linux.tar.gz", @@ -324,6 +480,13 @@ const knownTools = { }, }, "2.0.0": { + "darwin-arm64": { + hash: "04f7f0c338b6084f6208070edc548f8f012eb87462b714064236422522165714", + url: "https://github.com/mpizenberg/elm-test-rs/releases/download/v2.0/elm-test-rs_macos-arm.tar.gz", + fileSize: 2089766, + fileName: "elm-test-rs", + type: "tgz", + }, "darwin-x64": { hash: "b8a5c487d7fc60c3bbb40bf8616b4da726ce0ad867ea6295a07a4726f9fe105a", url: "https://github.com/mpizenberg/elm-test-rs/releases/download/v2.0/elm-test-rs_macos.tar.gz", @@ -331,6 +494,20 @@ const knownTools = { fileName: "elm-test-rs", type: "tgz", }, + "linux-arm": { + hash: "80687724f9f3901ba21b14e3abda8d80f6d0e7c444576b242cefa449a0e1f640", + url: "https://github.com/mpizenberg/elm-test-rs/releases/download/v2.0/elm-test-rs_linux-arm-32.tar.gz", + fileSize: 3478726, + fileName: "elm-test-rs", + type: "tgz", + }, + "linux-arm64": { + hash: "06d2885fc37aad084b3d8a8fca3032909b9a8a7716569587f207ba90590668cf", + url: "https://github.com/mpizenberg/elm-test-rs/releases/download/v2.0/elm-test-rs_linux-arm-64.tar.gz", + fileSize: 3363670, + fileName: "elm-test-rs", + type: "tgz", + }, "linux-x64": { hash: "face27bfe2b886d3ba96ad77c3f52d312da0f6089163b6db1b1c76297518ec54", url: "https://github.com/mpizenberg/elm-test-rs/releases/download/v2.0/elm-test-rs_linux.tar.gz", @@ -347,6 +524,13 @@ const knownTools = { }, }, "2.0.1": { + "darwin-arm64": { + hash: "9c3b87d118f8829924c80c00887cc8f4ce21dd1d94fd63a0a3deb9221f031af5", + url: "https://github.com/mpizenberg/elm-test-rs/releases/download/v2.0.1/elm-test-rs_macos-arm.tar.gz", + fileSize: 2109877, + fileName: "elm-test-rs", + type: "tgz", + }, "darwin-x64": { hash: "fc377b78dfe748417d0aea8619f77e255fd62e980cce387582496c8e0d10d24e", url: "https://github.com/mpizenberg/elm-test-rs/releases/download/v2.0.1/elm-test-rs_macos.tar.gz", @@ -354,6 +538,20 @@ const knownTools = { fileName: "elm-test-rs", type: "tgz", }, + "linux-arm": { + hash: "1c9f3701960d27179fa0a2ecd7eb9ec856e1f300c2c3c3d23814a83e2497d2c3", + url: "https://github.com/mpizenberg/elm-test-rs/releases/download/v2.0.1/elm-test-rs_linux-arm-32.tar.gz", + fileSize: 3466376, + fileName: "elm-test-rs", + type: "tgz", + }, + "linux-arm64": { + hash: "77defc11264bd5392dbdfe0169f812a8ea085b112ae7011b9fd39c3f7e255bda", + url: "https://github.com/mpizenberg/elm-test-rs/releases/download/v2.0.1/elm-test-rs_linux-arm-64.tar.gz", + fileSize: 3408581, + fileName: "elm-test-rs", + type: "tgz", + }, "linux-x64": { hash: "0d69a890819a55b341703369ee9a937720eba752625d41623dfc2d7acfc62d86", url: "https://github.com/mpizenberg/elm-test-rs/releases/download/v2.0.1/elm-test-rs_linux.tar.gz", @@ -370,6 +568,13 @@ const knownTools = { }, }, "3.0.0": { + "darwin-arm64": { + hash: "8701bf104b315446d64ae4d1689aa6a3bad1a85e1b31a9c9907ac911837b5fd1", + url: "https://github.com/mpizenberg/elm-test-rs/releases/download/v3.0/elm-test-rs_macos-arm.tar.gz", + fileSize: 2179607, + fileName: "elm-test-rs", + type: "tgz", + }, "darwin-x64": { hash: "41e2be1d77fb587ac1336f4b8822feb3b914eff7364715f6cac0bc4a90c0948a", url: "https://github.com/mpizenberg/elm-test-rs/releases/download/v3.0/elm-test-rs_macos.tar.gz", @@ -377,6 +582,20 @@ const knownTools = { fileName: "elm-test-rs", type: "tgz", }, + "linux-arm": { + hash: "9dd57a2ff2d869b2aec976841f37e5840b8085dd967294246b9adea2c7e658d5", + url: "https://github.com/mpizenberg/elm-test-rs/releases/download/v3.0/elm-test-rs_linux-arm-32.tar.gz", + fileSize: 3584214, + fileName: "elm-test-rs", + type: "tgz", + }, + "linux-arm64": { + hash: "bf468f39f9a9700f7ca0ed29719f9c9051e4b3796976ae0752a5186fdb8f0449", + url: "https://github.com/mpizenberg/elm-test-rs/releases/download/v3.0/elm-test-rs_linux-arm-64.tar.gz", + fileSize: 3523530, + fileName: "elm-test-rs", + type: "tgz", + }, "linux-x64": { hash: "c72702d32a2a9e051667febeeef486a1794798d0770be1a9da95895e10b6db0f", url: "https://github.com/mpizenberg/elm-test-rs/releases/download/v3.0/elm-test-rs_linux.tar.gz", From b5fe8616b95799af0fa6ee8afce7798ab52c3518 Mon Sep 17 00:00:00 2001 From: Simon Lydell Date: Sat, 7 Jan 2023 14:53:14 +0100 Subject: [PATCH 05/10] istanbul ignore --- src/Parse.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Parse.ts b/src/Parse.ts index 980fa07..05f80f3 100644 --- a/src/Parse.ts +++ b/src/Parse.ts @@ -299,6 +299,7 @@ function parseTools( const asset = platformAssets[platform]; + // istanbul ignore if if (asset === undefined) { return { tag: "Left", @@ -465,6 +466,7 @@ export function getToolThrowing({ const platformAssets = versions[matchingVersion] as PlatformAssets; const asset = platformAssets[platform]; + // istanbul ignore if if (asset === undefined) { throw new Error( `${name} ${matchingVersion} does not support your platform ${platform}\nSupported platforms: ${join( From b7e4f5dd42223478056bec65d8ed5f8aec493786 Mon Sep 17 00:00:00 2001 From: Simon Lydell Date: Sat, 7 Jan 2023 18:12:49 +0100 Subject: [PATCH 06/10] Inform about unsupported tools --- src/Parse.ts | 36 +++++++++++++++++++++++++----------- src/commands/Install.ts | 17 ++++++++++++++--- src/commands/Tools.ts | 18 ++++++++---------- 3 files changed, 47 insertions(+), 24 deletions(-) diff --git a/src/Parse.ts b/src/Parse.ts index 05f80f3..6b496d8 100644 --- a/src/Parse.ts +++ b/src/Parse.ts @@ -85,6 +85,7 @@ export type ParseError = export type Tools = { existing: Array; missing: Array; + unsupported: Array; }; export type Tool = { @@ -94,6 +95,12 @@ export type Tool = { asset: Asset; }; +export type UnsupportedTool = { + name: string; + version: string; + supportedPlatforms: Array; +}; + export function findReadAndParseElmToolingJson( cwd: Cwd, env: Env @@ -253,7 +260,7 @@ function parseTools( const [errors, tools] = partitionMap< [string, unknown], ParseError, - { exists: boolean; tool: Tool } + UnsupportedTool | { exists: boolean; tool: Tool } >(Object.entries(json), ([name, version]) => { if (typeof version !== "string") { return { @@ -302,14 +309,11 @@ function parseTools( // istanbul ignore if if (asset === undefined) { return { - tag: "Left", + tag: "Right", value: { - tag: "WithPath", - path: ["tools", name], - message: `${name} ${version} does not support your platform ${platform}\nSupported platforms: ${join( - Object.keys(platformAssets), - ", " - )}`, + name, + version, + supportedPlatforms: Object.keys(platformAssets), }, }; } @@ -347,15 +351,25 @@ function parseTools( return errors; } + const [supported, unsupported] = partitionMap< + UnsupportedTool | { exists: boolean; tool: Tool }, + { exists: boolean; tool: Tool }, + UnsupportedTool + >(tools, (entry) => + "exists" in entry + ? { tag: "Left", value: entry } + : /* istanbul ignore next */ { tag: "Right", value: entry } + ); + const [existing, missing] = partitionMap< { exists: boolean; tool: Tool }, Tool, Tool - >(tools, ({ exists, tool }) => + >(supported, ({ exists, tool }) => exists ? { tag: "Left", value: tool } : { tag: "Right", value: tool } ); - return { existing, missing }; + return { existing, missing, unsupported }; } export function makeTool( @@ -469,7 +483,7 @@ export function getToolThrowing({ // istanbul ignore if if (asset === undefined) { throw new Error( - `${name} ${matchingVersion} does not support your platform ${platform}\nSupported platforms: ${join( + `${name} ${matchingVersion} does not support your platform, ${platform}\nSupported platforms: ${join( Object.keys(platformAssets), ", " )}` diff --git a/src/commands/Install.ts b/src/commands/Install.ts index dea8481..d372368 100644 --- a/src/commands/Install.ts +++ b/src/commands/Install.ts @@ -179,9 +179,11 @@ async function installTools( updateStatusLine(tool, 0, index); } - const presentNames = tools.missing - .concat(tools.existing) - .map(({ name }) => name); + const presentNames = [ + ...tools.missing, + ...tools.existing, + ...tools.unsupported, + ].map(({ name }) => name); const toolsToRemove = KNOWN_TOOL_NAMES.filter( (name) => !presentNames.includes(name) ); @@ -205,6 +207,15 @@ async function installTools( ...tools.existing.map((tool) => linkTool(cwd, nodeModulesBinPath, tool)), + ...tools.unsupported.map( + (tool) => + `${bold( + `${tool.name} ${tool.version}` + )}: Skipped because not supported on your platform, ${platform}\n${indent( + `Supported platforms: ${join(tool.supportedPlatforms, ", ")}` + )}` + ), + ...removeTools(cwd, env, platform, nodeModulesBinPath, toolsToRemove), ]; diff --git a/src/commands/Tools.ts b/src/commands/Tools.ts index 7e2bfb5..ee18644 100644 --- a/src/commands/Tools.ts +++ b/src/commands/Tools.ts @@ -23,11 +23,7 @@ import { KnownToolNames, } from "../KnownTools"; import type { Logger } from "../Logger"; -import { - findReadAndParseElmToolingJson, - printParseErrors, - Tool, -} from "../Parse"; +import { findReadAndParseElmToolingJson, printParseErrors } from "../Parse"; import type { Cwd, ElmToolingJsonPath } from "../PathHelpers"; export async function toolsCommand( @@ -66,12 +62,14 @@ export async function toolsCommand( ); }; - const allTools = + const allTools: Array = parseResult.tools === undefined ? [] - : sortTools( - parseResult.tools.existing.concat(parseResult.tools.missing) - ); + : sortTools([ + ...parseResult.tools.existing, + ...parseResult.tools.missing, + ...parseResult.tools.unsupported, + ]); logger.log( bold(parseResult.elmToolingJsonPath.theElmToolingJsonPath.absolutePath) @@ -95,7 +93,7 @@ async function start( logger: Logger, stdin: ReadStream, stdout: WriteStream, - tools: Array, + tools: Array, save: (tools: Array) => void ): Promise { return new Promise((resolve) => { From 64e16db3a73311210f878d6c5a25cdb635b858f9 Mon Sep 17 00:00:00 2001 From: Simon Lydell Date: Sat, 7 Jan 2023 19:01:11 +0100 Subject: [PATCH 07/10] Get rid of partitionMap --- src/Helpers.ts | 31 ---------- src/Parse.ts | 131 +++++++++++++++------------------------- src/commands/Install.ts | 17 +++--- 3 files changed, 58 insertions(+), 121 deletions(-) diff --git a/src/Helpers.ts b/src/Helpers.ts index 0c416de..fb8c4f0 100644 --- a/src/Helpers.ts +++ b/src/Helpers.ts @@ -27,37 +27,6 @@ export function isRecord(value: unknown): value is Record { return typeof value === "object" && value !== null && !Array.isArray(value); } -export type Either = - | { tag: "Left"; value: Left } - | { tag: "Right"; value: Right }; - -export function partitionMap( - items: Array, - f: ( - item: T, - index: number, - leftSoFar: Array, - rightSoFar: Array - ) => Either -): [Array, Array] { - const left: Array = []; - const right: Array = []; - - for (const [index, item] of items.entries()) { - const either = f(item, index, left, right); - switch (either.tag) { - case "Left": - left.push(either.value); - break; - case "Right": - right.push(either.value); - break; - } - } - - return [left, right]; -} - export const HIDE_CURSOR = "\x1B[?25l"; export const SHOW_CURSOR = "\x1B[?25h"; export const RESET_COLOR = "\x1B[0m"; diff --git a/src/Parse.ts b/src/Parse.ts index 6b496d8..67fdcf1 100644 --- a/src/Parse.ts +++ b/src/Parse.ts @@ -12,7 +12,6 @@ import { isRecord, join, NonEmptyArray, - partitionMap, printNumErrors, toError, } from "./Helpers"; @@ -257,65 +256,61 @@ function parseTools( ]; } - const [errors, tools] = partitionMap< - [string, unknown], - ParseError, - UnsupportedTool | { exists: boolean; tool: Tool } - >(Object.entries(json), ([name, version]) => { + const errors: Array = []; + + const tools: Tools = { + existing: [], + missing: [], + unsupported: [], + }; + + for (const [name, version] of Object.entries(json)) { if (typeof version !== "string") { - return { - tag: "Left", - value: { - tag: "WithPath", - path: ["tools", name], - message: `Expected a version as a string but got: ${JSON.stringify( - version - )}`, - }, - }; + errors.push({ + tag: "WithPath", + path: ["tools", name], + message: `Expected a version as a string but got: ${JSON.stringify( + version + )}`, + }); + continue; } const versions = getOwn(KNOWN_TOOLS, name); if (versions === undefined) { - return { - tag: "Left", - value: { - tag: "WithPath", - path: ["tools", name], - message: `Unknown tool\nKnown tools: ${join(KNOWN_TOOL_NAMES, ", ")}`, - }, - }; + errors.push({ + tag: "WithPath", + path: ["tools", name], + message: `Unknown tool\nKnown tools: ${join(KNOWN_TOOL_NAMES, ", ")}`, + }); + continue; } const platformAssets = getOwn(versions, version); if (platformAssets === undefined) { - return { - tag: "Left", - value: { - tag: "WithPath", - path: ["tools", name], - message: `Unknown version: ${version}\nKnown versions: ${join( - Object.keys(versions), - ", " - )}`, - }, - }; + errors.push({ + tag: "WithPath", + path: ["tools", name], + message: `Unknown version: ${version}\nKnown versions: ${join( + Object.keys(versions), + ", " + )}`, + }); + continue; } const asset = platformAssets[platform]; // istanbul ignore if if (asset === undefined) { - return { - tag: "Right", - value: { - name, - version, - supportedPlatforms: Object.keys(platformAssets), - }, - }; + tools.unsupported.push({ + name, + version, + supportedPlatforms: Object.keys(platformAssets), + }); + continue; } const tool = makeTool(cwd, env, name, version, asset); @@ -324,52 +319,24 @@ function parseTools( switch (exists.tag) { case "Exists": - return { - tag: "Right", - value: { exists: true, tool }, - }; + tools.existing.push(tool); + break; case "DoesNotExist": - return { - tag: "Right", - value: { exists: false, tool }, - }; + tools.missing.push(tool); + break; case "Error": - return { - tag: "Left", - value: { - tag: "WithPath", - path: ["tools", name], - message: exists.message, - }, - }; + errors.push({ + tag: "WithPath", + path: ["tools", name], + message: exists.message, + }); + break; } - }); - - if (isNonEmptyArray(errors)) { - return errors; } - const [supported, unsupported] = partitionMap< - UnsupportedTool | { exists: boolean; tool: Tool }, - { exists: boolean; tool: Tool }, - UnsupportedTool - >(tools, (entry) => - "exists" in entry - ? { tag: "Left", value: entry } - : /* istanbul ignore next */ { tag: "Right", value: entry } - ); - - const [existing, missing] = partitionMap< - { exists: boolean; tool: Tool }, - Tool, - Tool - >(supported, ({ exists, tool }) => - exists ? { tag: "Left", value: tool } : { tag: "Right", value: tool } - ); - - return { existing, missing, unsupported }; + return isNonEmptyArray(errors) ? errors : tools; } export function makeTool( diff --git a/src/commands/Install.ts b/src/commands/Install.ts index d372368..dc5eb58 100644 --- a/src/commands/Install.ts +++ b/src/commands/Install.ts @@ -14,7 +14,6 @@ import { indent, isNonEmptyArray, join, - partitionMap, printNumErrors, removeColor, toError, @@ -468,13 +467,15 @@ function spawn( // for _all_ spawns, so that we _always_ use Windows’ own `curl` instead of Git // Bash’s `curl`. function adjustPathForWindows(pathString: string): string { - const [system32, rest] = partitionMap( - pathString.split(path.delimiter), - (part) => - part.toLowerCase().includes("system32") - ? { tag: "Left", value: part } - : { tag: "Right", value: part } - ); + const system32 = []; + const rest = []; + for (const part of pathString.split(path.delimiter)) { + if (part.toLowerCase().includes("system32")) { + system32.push(part); + } else { + rest.push(part); + } + } return join([...system32, ...rest], path.delimiter); } From 7817480204c07e431f1c73e4f9d98db3157e66b8 Mon Sep 17 00:00:00 2001 From: Simon Lydell Date: Sat, 7 Jan 2023 19:07:56 +0100 Subject: [PATCH 08/10] Fixes --- src/commands/Install.ts | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/commands/Install.ts b/src/commands/Install.ts index dc5eb58..f85a9d3 100644 --- a/src/commands/Install.ts +++ b/src/commands/Install.ts @@ -86,7 +86,11 @@ export async function install( const { tools } = parseResult; - if (tools.existing.length === 0 && tools.missing.length === 0) { + if ( + tools.existing.length === 0 && + tools.missing.length === 0 && + tools.unsupported.length === 0 + ) { return removeAllTools( cwd, env, @@ -206,6 +210,8 @@ async function installTools( ...tools.existing.map((tool) => linkTool(cwd, nodeModulesBinPath, tool)), + ...removeTools(cwd, env, platform, nodeModulesBinPath, toolsToRemove), + ...tools.unsupported.map( (tool) => `${bold( @@ -214,8 +220,6 @@ async function installTools( `Supported platforms: ${join(tool.supportedPlatforms, ", ")}` )}` ), - - ...removeTools(cwd, env, platform, nodeModulesBinPath, toolsToRemove), ]; return printResults(logger, results); From 804d35f6d3f3e7759cb5b6096ed4255033d394bc Mon Sep 17 00:00:00 2001 From: Simon Lydell Date: Sun, 8 Jan 2023 12:20:57 +0100 Subject: [PATCH 09/10] Suggest supported versions --- src/Parse.ts | 4 ++++ src/commands/Install.ts | 14 +++++++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/Parse.ts b/src/Parse.ts index 67fdcf1..560cb9e 100644 --- a/src/Parse.ts +++ b/src/Parse.ts @@ -98,6 +98,7 @@ export type UnsupportedTool = { name: string; version: string; supportedPlatforms: Array; + supportedVersions: Array; }; export function findReadAndParseElmToolingJson( @@ -309,6 +310,9 @@ function parseTools( name, version, supportedPlatforms: Object.keys(platformAssets), + supportedVersions: Object.entries(versions) + .filter(([, assets]) => Object.hasOwnProperty.call(assets, platform)) + .map(([supportedVersion]) => supportedVersion), }); continue; } diff --git a/src/commands/Install.ts b/src/commands/Install.ts index f85a9d3..a67b945 100644 --- a/src/commands/Install.ts +++ b/src/commands/Install.ts @@ -217,7 +217,19 @@ async function installTools( `${bold( `${tool.name} ${tool.version}` )}: Skipped because not supported on your platform, ${platform}\n${indent( - `Supported platforms: ${join(tool.supportedPlatforms, ", ")}` + `${dim( + `Supported platforms: ${join(tool.supportedPlatforms, ", ")}` + )}${ + isNonEmptyArray(tool.supportedVersions) + ? tool.supportedVersions.length === 1 + ? `\nThis version supports your platform, though: ${bold( + tool.supportedVersions[0] + )}` + : `\nThese versions support your platform, though: ${bold( + join(tool.supportedVersions, ", ") + )}` + : "" + }` )}` ), ]; From f454b4688028720ee7700a0c491e11ede756a465 Mon Sep 17 00:00:00 2001 From: Simon Lydell Date: Sun, 8 Jan 2023 12:26:25 +0100 Subject: [PATCH 10/10] Add more linux-arm binaries --- src/KnownTools.ts | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/src/KnownTools.ts b/src/KnownTools.ts index 59f5186..06e60d8 100644 --- a/src/KnownTools.ts +++ b/src/KnownTools.ts @@ -64,6 +64,13 @@ const knownTools = { fileName: "elm", type: "gz", }, + "linux-arm": { + hash: "bbbb8a2aa723c5dd9d7ed558406e809f0c13da80387edfbec40b823a4ed4a8a8", + url: "https://github.com/dmy/elm-raspberry-pi/releases/download/20200611/elm.tar.gz", + fileSize: 8700664, + fileName: "elm", + type: "tgz", + }, "linux-arm64": { hash: "a9123b40db040fc431ec8c2d275fa04ce260bc8d5eab5050ff5869477253605d", url: "https://github.com/lydell/compiler/releases/download/0.19.1/binary-for-linux-arm-64-bit.gz", @@ -135,6 +142,13 @@ const knownTools = { fileName: "elm-format", type: "tgz", }, + "linux-arm": { + hash: "bbbb8a2aa723c5dd9d7ed558406e809f0c13da80387edfbec40b823a4ed4a8a8", + url: "https://github.com/dmy/elm-raspberry-pi/releases/download/20200611/elm.tar.gz", + fileSize: 8700664, + fileName: "elm-format", + type: "tgz", + }, "linux-x64": { hash: "a69a4d3c49ccb0dffb3067b35464dc492563274e5778c40625220f9f6b3fd06d", url: "https://github.com/avh4/elm-format/releases/download/0.8.2/elm-format-0.8.2-linux-x64.tgz", @@ -261,6 +275,13 @@ const knownTools = { fileName: "elm-json", type: "tgz", }, + "linux-arm": { + hash: "973405b81577889db391b7718d7bf7358e46be5cbecd4a7e72214f6388d2468e", + url: "https://github.com/zwilias/elm-json/releases/download/v0.2.8/elm-json-v0.2.8-armv7-unknown-linux-musleabihf.tar.gz", + fileSize: 2086957, + fileName: "elm-json", + type: "tgz", + }, "linux-arm64": { hash: "973405b81577889db391b7718d7bf7358e46be5cbecd4a7e72214f6388d2468e", url: "https://github.com/zwilias/elm-json/releases/download/v0.2.8/elm-json-v0.2.8-armv7-unknown-linux-musleabihf.tar.gz", @@ -299,6 +320,13 @@ const knownTools = { fileName: "elm-json", type: "tgz", }, + "linux-arm": { + hash: "4075fb5a486760d87615d5d78c1a4022669f673eb306dd9ff467ca3129ae6bec", + url: "https://github.com/zwilias/elm-json/releases/download/v0.2.10/elm-json-v0.2.10-armv7-unknown-linux-musleabihf.tar.gz", + fileSize: 2168765, + fileName: "elm-json", + type: "tgz", + }, "linux-arm64": { hash: "4075fb5a486760d87615d5d78c1a4022669f673eb306dd9ff467ca3129ae6bec", url: "https://github.com/zwilias/elm-json/releases/download/v0.2.10/elm-json-v0.2.10-armv7-unknown-linux-musleabihf.tar.gz", @@ -336,6 +364,13 @@ const knownTools = { fileName: "elm-json", type: "tgz", }, + "linux-arm": { + hash: "acc093b8a5037f141c7870ec6d8bb1140b37031ccf4e99cea0280864d7f4831e", + url: "https://github.com/zwilias/elm-json/releases/download/v0.2.13/elm-json-v0.2.13-armv7-unknown-linux-musleabihf.tar.gz", + fileSize: 1978987, + fileName: "elm-json", + type: "tgz", + }, "linux-arm64": { hash: "acc093b8a5037f141c7870ec6d8bb1140b37031ccf4e99cea0280864d7f4831e", url: "https://github.com/zwilias/elm-json/releases/download/v0.2.13/elm-json-v0.2.13-armv7-unknown-linux-musleabihf.tar.gz",