Pick any line to see why it is the way it is: the commit, the pull request and issue it came from, and what the agent was thinking.
| preparing for cloud work | 1 | import assert from "node:assert/strict"; |
| 2 | import { test } from "node:test"; | |
| 3 | ||
| 4 | import { classify, hostPlatform, manifest, platformOfTriple } from "./desktop-release.mjs"; | |
| 5 | ||
| 6 | test("a bundle's place in a release", () => { | |
| 7 | assert.deepEqual(classify("g1t_0.1.0_x64-setup.exe", "windows-x64", "0.1.0"), { | |
| 8 | platform: "windows", | |
| 9 | arch: "x64", | |
| 10 | kind: "installer", | |
| 11 | name: "g1t-0.1.0-windows-x64-setup.exe", | |
| 12 | updater: true, | |
| 13 | }); | |
| 14 | assert.deepEqual(classify("g1t.app.tar.gz", "macos-arm64", "0.1.0"), { | |
| 15 | platform: "macos", | |
| 16 | arch: "arm64", | |
| 17 | kind: "update", | |
| 18 | name: "g1t-0.1.0-macos-arm64.app.tar.gz", | |
| 19 | updater: true, | |
| 20 | }); | |
| 21 | assert.equal(classify("g1t_0.1.0_aarch64.dmg", "macos-arm64", "0.1.0").kind, "dmg"); | |
| 22 | assert.equal(classify("g1t_0.1.0_amd64.AppImage", "linux-x64", "0.1.0").name, "g1t-0.1.0-linux-x64.AppImage"); | |
| 23 | assert.equal(classify("g1t_0.1.0_amd64.deb", "linux-x64", "0.1.0").updater, false); | |
| 24 | assert.equal(classify("g1t-0.1.0-1.x86_64.rpm", "linux-x64", "0.1.0").kind, "rpm"); | |
| 25 | // Signatures ride with their file; an MSI is not published. | |
| 26 | assert.equal(classify("g1t_0.1.0_x64-setup.exe.sig", "windows-x64", "0.1.0"), null); | |
| 27 | assert.equal(classify("g1t_0.1.0_x64_en-US.msi", "windows-x64", "0.1.0"), null); | |
| 28 | }); | |
| 29 | ||
| 30 | test("platforms, from a machine and from a target", () => { | |
| 31 | assert.equal(hostPlatform("win32", "x64"), "windows-x64"); | |
| 32 | assert.equal(hostPlatform("darwin", "arm64"), "macos-arm64"); | |
| 33 | assert.equal(hostPlatform("linux", "x64"), "linux-x64"); | |
| 34 | assert.equal(platformOfTriple("x86_64-pc-windows-msvc"), "windows-x64"); | |
| 35 | assert.equal(platformOfTriple("aarch64-apple-darwin"), "macos-arm64"); | |
| 36 | assert.equal(platformOfTriple("debug"), null); | |
| 37 | }); | |
| 38 | ||
| 39 | test("the manifest serves the updater and the download page", () => { | |
| 40 | const entries = [ | |
| 41 | { platform: "windows", arch: "x64", kind: "installer", name: "g1t-0.1.0-windows-x64-setup.exe", updater: true, size: 10, sha256: "a", signature: "sig-win" }, | |
| 42 | { platform: "macos", arch: "arm64", kind: "update", name: "g1t-0.1.0-macos-arm64.app.tar.gz", updater: true, size: 20, sha256: "b", signature: "sig-mac" }, | |
| 43 | { platform: "macos", arch: "arm64", kind: "dmg", name: "g1t-0.1.0-macos-arm64.dmg", updater: false, size: 30, sha256: "c", signature: null }, | |
| 44 | { platform: "linux", arch: "x64", kind: "deb", name: "g1t-0.1.0-linux-x64.deb", updater: false, size: 40, sha256: "d", signature: null }, | |
| 45 | ]; | |
| 46 | const m = manifest(entries, "0.1.0", { date: "2026-10-11T00:00:00.000Z", notes: "First." }); | |
| 47 | assert.equal(m.version, "0.1.0"); | |
| 48 | assert.equal(m.notes, "First."); | |
| 49 | assert.deepEqual(m.platforms, { | |
| 50 | "windows-x86_64": { url: "https://g1t.sh/downloads/desktop/0.1.0/g1t-0.1.0-windows-x64-setup.exe", signature: "sig-win" }, | |
| 51 | "darwin-aarch64": { url: "https://g1t.sh/downloads/desktop/0.1.0/g1t-0.1.0-macos-arm64.app.tar.gz", signature: "sig-mac" }, | |
| 52 | }); | |
| 53 | // The update archive is the updater's alone; people download the disk image. | |
| 54 | assert.deepEqual( | |
| 55 | m.downloads.map((d) => d.name), | |
| 56 | ["g1t-0.1.0-linux-x64.deb", "g1t-0.1.0-macos-arm64.dmg", "g1t-0.1.0-windows-x64-setup.exe"], | |
| 57 | ); | |
| 58 | assert.deepEqual(m.downloads[1], { platform: "macos", arch: "arm64", kind: "dmg", name: "g1t-0.1.0-macos-arm64.dmg", size: 30, sha256: "c" }); | |
| 59 | }); |