From 7c40efbc62bd7bd70bcfdb80cd55aef4bafb39d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miguel=20=C3=81ngel?= Date: Wed, 26 Aug 2026 03:02:24 +0000 Subject: [PATCH] fix(fonts): harden localizer release diagnostics --- packages/cli/src/fontLocalize.test.ts | 33 ++++++++++++++++--- packages/cli/src/fontLocalize.ts | 26 +++++++++++---- packages/cli/src/fontLocalizeCli.ts | 9 +++-- packages/cli/src/version.ts | 3 ++ packages/cli/tsup.config.ts | 4 +++ .../deterministicFonts-failClosed.test.ts | 25 ++++++++++++++ .../deterministicFonts-textSubset.test.ts | 13 ++++++++ .../src/services/deterministicFonts.ts | 6 +++- 8 files changed, 104 insertions(+), 15 deletions(-) diff --git a/packages/cli/src/fontLocalize.test.ts b/packages/cli/src/fontLocalize.test.ts index 9637b2b0e..86a9d2384 100644 --- a/packages/cli/src/fontLocalize.test.ts +++ b/packages/cli/src/fontLocalize.test.ts @@ -1,5 +1,5 @@ import { describe, expect, it, vi } from "vitest"; -import { runFontLocalize, stampFontCompilerVersion, type FontLocalizeIo } from "./fontLocalize.js"; +import { runFontLocalize, stampFontVersions, type FontLocalizeIo } from "./fontLocalize.js"; function makeIo(input: string): { io: FontLocalizeIo; @@ -71,16 +71,39 @@ describe("runFontLocalize", () => { }); }); -describe("stampFontCompilerVersion", () => { - it("records the compiler version inside the document head", () => { - const stamped = stampFontCompilerVersion( +describe("stampFontVersions", () => { + it("records producer and localizer versions inside the document head", () => { + const stamped = stampFontVersions( "x", - "0.8.15", + { producer: "0.8.15", localizer: "0.8.16" }, ); expect(stamped).toContain(''); + expect(stamped).toContain(''); expect(stamped.indexOf("hyperframes-font-compiler-version")).toBeLessThan( stamped.indexOf(""), ); }); + + it("inserts both diagnostic stamps after a doctype when no head close exists", () => { + const stamped = stampFontVersions("
x
", { + producer: "0.8.15", + localizer: "0.8.16", + }); + + expect(stamped).toMatch( + /^/, + ); + }); + + it("inserts both diagnostic stamps at the start when no head or doctype exists", () => { + const stamped = stampFontVersions("
x
", { + producer: "0.8.15