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.
| Merge branch 'g1t-cli' | 1 | // node --test scripts/cli-release.test.mjs |
| 2 | import assert from "node:assert/strict"; | |
| 3 | import { createPrivateKey } from "node:crypto"; | |
| 4 | import { mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs"; | |
| 5 | import { tmpdir } from "node:os"; | |
| 6 | import { join } from "node:path"; | |
| 7 | import { test } from "node:test"; | |
| 8 | ||
| 9 | import { TARGETS, manifest, sha256, version } from "./cli-release.mjs"; | |
| 10 | import { keygen, signBytes, verifyBytes } from "./runner-release.mjs"; | |
| 11 | ||
| 12 | test("the version is crates/g1t's", () => { | |
| 13 | assert.match(version(), /^\d+\.\d+\.\d+/); | |
| 14 | }); | |
| 15 | ||
| 16 | test("the manifest and SHA256SUMS name each binary that was built", () => { | |
| 17 | const dir = mkdtempSync(join(tmpdir(), "cli-release-")); | |
| 18 | try { | |
| 19 | writeFileSync(join(dir, TARGETS["linux-x64"].file), "linux"); | |
| 20 | writeFileSync(join(dir, TARGETS["windows-x64"].file), "windows"); | |
| 21 | const m = manifest(dir, "0.2.0", new Date("2026-10-12T00:00:00Z")); | |
| 22 | assert.deepEqual(m, { | |
| 23 | version: "0.2.0", | |
| 24 | published_at: "2026-10-12T00:00:00.000Z", | |
| 25 | files: { | |
| 26 | "linux-x64": { name: "g1t-linux-x64", sha256: sha256("linux") }, | |
| 27 | "windows-x64": { name: "g1t-windows-x64.exe", sha256: sha256("windows") }, | |
| 28 | }, | |
| 29 | }); | |
| 30 | // The install scripts read `<sha256> <name>` lines. | |
| 31 | assert.equal( | |
| 32 | readFileSync(join(dir, "SHA256SUMS"), "utf8"), | |
| 33 | `${sha256("linux")} g1t-linux-x64\n${sha256("windows")} g1t-windows-x64.exe\n`, | |
| 34 | ); | |
| 35 | assert.equal(readFileSync(join(dir, "latest.json"), "utf8"), readFileSync(join(dir, "manifest.json"), "utf8")); | |
| 36 | const keys = keygen(); | |
| 37 | const key = createPrivateKey({ key: Buffer.from(keys.private, "base64"), format: "der", type: "pkcs8" }); | |
| 38 | const bytes = readFileSync(join(dir, "latest.json")); | |
| 39 | assert.ok(verifyBytes(bytes, signBytes(bytes, key), keys.public)); | |
| 40 | } finally { | |
| 41 | rmSync(dir, { recursive: true, force: true }); | |
| 42 | } | |
| 43 | }); | |
| 44 | ||
| 45 | test("a manifest of nothing is refused", () => { | |
| 46 | const dir = mkdtempSync(join(tmpdir(), "cli-release-")); | |
| 47 | try { | |
| 48 | assert.throws(() => manifest(dir, "0.2.0"), /no binaries/); | |
| 49 | } finally { | |
| 50 | rmSync(dir, { recursive: true, force: true }); | |
| 51 | } | |
| 52 | }); |
This file's history is long; its oldest lines are credited to the oldest commit read.