import { execFileSync } from "node:child_process"; import { existsSync, mkdtempSync, readFileSync } from "node:fs"; import { fileURLToPath } from "node:url"; import { dirname, join, resolve } from "node:path"; import { tmpdir } from "node:os"; import { describe, expect, it } from "vitest"; const ROOT = resolve(dirname(fileURLToPath(import.meta.url)), ".."); // PB-26-211: packaging/signing logic moved to release-lib.ts. Both release // entry points import from it, so verifying release-lib.ts covers both. const RELEASE_LIB = "scripts/release-lib.ts"; function readReleaseLib(): string { return readFileSync(join(ROOT, RELEASE_LIB), "utf8"); } describe("Firefox release source submission", () => { it("passes the generated source archive to web-ext sign with --upload-source-code", () => { const source = readReleaseLib(); // web-ext sign is called with --upload-source-code and the source zip path. expect(source).toContain('"--upload-source-code"'); expect(source).toContain("sourceZip"); expect(source.match(/--upload-source-code/g)).toHaveLength(1); }); it("builds an archive containing the reviewed crypto source and Noise build script", () => { const archive = join(mkdtempSync(join(tmpdir(), "peach-source-test-")), "source.zip"); execFileSync( "zip", [ "-q", "-r", archive, "src", "scripts", "public", "crypto-core", "manifest.json", "manifest.firefox.json", "package.json", "bun.lock", "tsconfig.json", "vite.config.ts", "--exclude", "node_modules/*", "--exclude", "dist-*/*", "--exclude", "crypto-core/target/*", "--exclude", "crypto-core/generated/*", "--exclude", "*.zip", "--exclude", ".DS_Store", "--exclude", "__MACOSX/*", ], { cwd: ROOT }, ); const contents = execFileSync("unzip", ["-Z1", archive], { encoding: "utf8" }).split("\n"); expect(contents).toEqual( expect.arrayContaining([ "crypto-core/Cargo.toml", "crypto-core/Cargo.lock", "crypto-core/src/lib.rs", "scripts/build-noise-core.mjs", ]), ); // PB-26-211: verify release-lib.ts includes crypto-core in the source archive. const source = readReleaseLib(); expect(source).toContain('"crypto-core"'); expect(existsSync(join(ROOT, "crypto-core/Cargo.toml"))).toBe(true); expect(existsSync(join(ROOT, "crypto-core/Cargo.lock"))).toBe(true); expect(existsSync(join(ROOT, "crypto-core/src/lib.rs"))).toBe(true); expect(existsSync(join(ROOT, "scripts/build-noise-core.mjs"))).toBe(true); }); });