@recursica/adapter-tester 5.0.1 → 5.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -0
- package/dist/adapter-tester.schema.json.d.ts +4 -0
- package/dist/cli.cjs +8 -8
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +38 -33
- package/dist/cli.js.map +1 -1
- package/dist/config.d.ts +3 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/devServer.d.ts.map +1 -1
- package/dist/fileConfig.d.ts +3 -0
- package/dist/fileConfig.d.ts.map +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/testing/runVisualRegression.d.ts.map +1 -1
- package/dist/testing.cjs +4 -4
- package/dist/testing.cjs.map +1 -1
- package/dist/testing.js +16 -14
- package/dist/testing.js.map +1 -1
- package/package.json +1 -1
- package/report-header.txt +1 -1
- package/src/adapter-tester.schema.json +4 -0
package/dist/cli.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { spawn as
|
|
3
|
-
import { readFileSync as S, mkdirSync as
|
|
4
|
-
import { dirname as
|
|
5
|
-
import { fileURLToPath as M, pathToFileURL as
|
|
2
|
+
import { spawn as F, spawnSync as J } from "node:child_process";
|
|
3
|
+
import { readFileSync as S, mkdirSync as _, writeFileSync as O, existsSync as I } from "node:fs";
|
|
4
|
+
import { dirname as P, join as a, resolve as j } from "node:path";
|
|
5
|
+
import { fileURLToPath as M, pathToFileURL as q } from "node:url";
|
|
6
6
|
import W from "express";
|
|
7
7
|
import { createProxyMiddleware as B } from "http-proxy-middleware";
|
|
8
8
|
import K from "node:net";
|
|
@@ -30,12 +30,12 @@ function te(e) {
|
|
|
30
30
|
}
|
|
31
31
|
}
|
|
32
32
|
function re(e, t) {
|
|
33
|
-
|
|
33
|
+
_(P(e), { recursive: !0 }), O(e, JSON.stringify({ port: t }));
|
|
34
34
|
}
|
|
35
35
|
function oe(e, t) {
|
|
36
36
|
return new Promise((r, o) => {
|
|
37
37
|
var y, w;
|
|
38
|
-
const s =
|
|
38
|
+
const s = F(e.command, {
|
|
39
39
|
cwd: e.cwd,
|
|
40
40
|
stdio: "pipe",
|
|
41
41
|
shell: !0
|
|
@@ -84,7 +84,7 @@ function x(e, t) {
|
|
|
84
84
|
timeoutMs: t.timeout
|
|
85
85
|
};
|
|
86
86
|
}
|
|
87
|
-
async function
|
|
87
|
+
async function A(e) {
|
|
88
88
|
if (e.reuseExistingServer) {
|
|
89
89
|
const t = te(e.cacheFile);
|
|
90
90
|
if (t !== void 0 && await ee(t))
|
|
@@ -98,10 +98,10 @@ async function E(e) {
|
|
|
98
98
|
}
|
|
99
99
|
return console.log(`[Dev Launcher] Launching Storybook for ${e.name}...`), oe(e, e.timeoutMs ?? 120 * 1e3);
|
|
100
100
|
}
|
|
101
|
-
const N =
|
|
101
|
+
const N = P(M(import.meta.url));
|
|
102
102
|
function se(e) {
|
|
103
103
|
const t = process.platform === "darwin" ? "open" : process.platform === "win32" ? "start" : "xdg-open";
|
|
104
|
-
console.log(`[Dev Launcher] Auto-launching browser: ${e}`),
|
|
104
|
+
console.log(`[Dev Launcher] Auto-launching browser: ${e}`), F(t, [e], { shell: process.platform === "win32" }).on(
|
|
105
105
|
"error",
|
|
106
106
|
(r) => {
|
|
107
107
|
console.error("[Dev Launcher] Failed to auto-launch browser:", r);
|
|
@@ -119,10 +119,10 @@ async function ne(e, t, r = {}) {
|
|
|
119
119
|
`[Dev Launcher] Resolving ${o.name} and ${s.name} Storybooks...`
|
|
120
120
|
);
|
|
121
121
|
const [y, w] = await Promise.all([
|
|
122
|
-
|
|
122
|
+
A(
|
|
123
123
|
x(o.name, n)
|
|
124
124
|
),
|
|
125
|
-
|
|
125
|
+
A(x(s.name, d))
|
|
126
126
|
]);
|
|
127
127
|
console.log("[Dev Launcher] Both Storybooks are active and responsive!");
|
|
128
128
|
const i = [y.process, w.process].filter(
|
|
@@ -133,7 +133,7 @@ async function ne(e, t, r = {}) {
|
|
|
133
133
|
b();
|
|
134
134
|
return;
|
|
135
135
|
}
|
|
136
|
-
const
|
|
136
|
+
const H = S(a(l, "index.html"), "utf8").replace(
|
|
137
137
|
"<head>",
|
|
138
138
|
`<head>
|
|
139
139
|
<script>window.__ADAPTER_TESTER__ = ${JSON.stringify({
|
|
@@ -142,8 +142,12 @@ async function ne(e, t, r = {}) {
|
|
|
142
142
|
sourceOfTruthPort: y.port
|
|
143
143
|
})};<\/script>`
|
|
144
144
|
);
|
|
145
|
-
T.send(
|
|
145
|
+
T.send(H);
|
|
146
146
|
}), u.get("/report-header.txt", (f, T) => {
|
|
147
|
+
if (e.reportHeader !== void 0) {
|
|
148
|
+
T.type("text/plain").send(e.reportHeader);
|
|
149
|
+
return;
|
|
150
|
+
}
|
|
147
151
|
try {
|
|
148
152
|
T.type("text/plain").send(S(v, "utf8"));
|
|
149
153
|
} catch {
|
|
@@ -177,7 +181,7 @@ async function ne(e, t, r = {}) {
|
|
|
177
181
|
`), se(`http://localhost:${h}`);
|
|
178
182
|
});
|
|
179
183
|
}
|
|
180
|
-
const ie = "http://json-schema.org/draft-07/schema#", ae = "https://github.com/borderux/recursica/tree/main/packages/adapter-tester/src/adapter-tester.schema.json", ce = "adapter-tester.config.json", ue = "Configuration for @recursica/adapter-tester. All fields are optional — an adapter repo with a normal `storybook` npm script needs no config file at all.", de = "object", le = !1, pe = { $schema: { type: "string", description: 'Optional pointer to this schema for editor autocomplete, e.g. "https://raw.githubusercontent.com/borderux/recursica/main/packages/adapter-tester/src/adapter-tester.schema.json".' }, name: { type: "string", description: `Label for this project's own target. Defaults to the unscoped name in this project's package.json (e.g. "@recursica/some-adapter" -> "some-adapter").` }, storybook: { type: "object", additionalProperties: !1, description: "This project's own Storybook target.", properties: { port: { type: "integer", minimum: 1, maximum: 65535, description: "First-guess port only, not authoritative — the real port is auto-detected from this Storybook's own startup output, since Storybook silently falls back to an OS-assigned port whenever this one is taken. Auto-detected from this project's own `scripts.storybook` (a `-p <port>`/`--port <port>` flag) when omitted, falling back to 6006." }, command: { type: "string", description: "Command that boots the target's Storybook. Defaults to `npm run storybook`." }, cwd: { type: "string", description: 'Directory the command runs in, relative to the config file. Defaults to ".".' } } }, sourceOfTruth: { description: 'The comparison target. Defaults to `{ "type": "mantine-harness" }`.', oneOf: [{ type: "object", additionalProperties: !1, description: "Default mode: boots a throwaway harness that installs the published @recursica/mantine-adapter from npm — no monorepo checkout required.", properties: { type: { const: "mantine-harness" }, port: { type: "integer", minimum: 1, maximum: 65535, description: "First-guess port only, not authoritative — the real port is auto-detected from the throwaway harness's Storybook's own startup output." }, mantineAdapterVersion: { type: "string", description: "npm version/tag of @recursica/mantine-adapter to install in the harness. Defaults to `latest`." }, storybookTemplateVersion: { type: "string", description: "npm version/tag of @recursica/storybook-template to install in the harness. Defaults to `latest`." } } }, { type: "object", additionalProperties: !1, description: "Non-standard mode: points at an already-addressable Storybook — e.g. a sibling workspace package's own Storybook inside this monorepo.", required: ["type"], properties: { type: { const: "url" }, name: { type: "string", description: 'Label for the source-of-truth target. Defaults to "Mantine".' }, port: { type: "integer", minimum: 1, maximum: 65535, description: "First-guess port only, not authoritative — the real port is auto-detected from the source-of-truth Storybook's own startup output. Defaults to 6011." }, command: { type: "string", description: "Command that boots the source-of-truth Storybook. Defaults to `npm run storybook`." }, cwd: { type: "string", description: 'Directory the command runs in, relative to the config file. Defaults to ".".' } } }] }, isSourceOfTruthAdapter: { type: "boolean", description: "True only for the source-of-truth adapter's own config (mantine-adapter). Skips `sourceOfTruth` entirely — there's nothing above it to diverge from — and runs the own-drift golden check standalone, against just this project's own Storybook. Defaults to false." }, goldenThresholdPixels: { type: "number", minimum: 0, description: "Global visual diff threshold for the own-drift check (this project's live render vs. its own committed `test/golden/` image), in mismatched pixels, before a story is considered a failure. Same library/component on both sides, so this should stay tight. Defaults to 10. AI agents must not modify this field — see AGENT.md.", default: 10 }, sourceOfTruthThresholdPixels: { type: "number", minimum: 0, description: "Global visual diff threshold for the source-of-truth divergence check (this project's golden vs. the source-of-truth adapter's golden), in mismatched pixels, before a difference is flagged. Comparing across two different component libraries has legitimate structural variation (native control widgets, font rendering, etc.), so this is expected to be set much higher than `goldenThresholdPixels`. Ignored on the source-of-truth adapter's own config (`isSourceOfTruthAdapter: true`), which has no divergence check. Defaults to 3500. AI agents must not modify this field — see AGENT.md.", default: 3500 }, stories: { type: "object", additionalProperties: { type: "object", additionalProperties: !1, properties: { goldenThreshold: { type: "number", minimum: 0, description: "Diff threshold override for matching stories' own-drift check, in mismatched pixels. Overrides `goldenThresholdPixels`." }, sourceOfTruthThreshold: { type: "number", minimum: 0, description: "Diff threshold override for matching stories' source-of-truth divergence check, in mismatched pixels. Overrides `sourceOfTruthThresholdPixels`." }, exclude: { type: "boolean", description: "Skip matching stories entirely — no own-drift check, no divergence check, no golden captured. For stories that don't have a cross-adapter counterpart; use `excludeTitlePrefixes` to drop a whole title instead." } } }, description: "Per-story overrides, keyed by story id prefix (a story matches if its id equals the key or starts with it). When more than one key matches a story, the longest (most specific) key wins." }, excludeTitlePrefixes: { type: "array", items: { type: "string" }, description: "Storybook title prefixes to exclude from comparison, in addition to the built-in denylist (`Theme/*`, `Tokens/*`, `Introduction`)." } }, he = {
|
|
184
|
+
const ie = "http://json-schema.org/draft-07/schema#", ae = "https://github.com/borderux/recursica/tree/main/packages/adapter-tester/src/adapter-tester.schema.json", ce = "adapter-tester.config.json", ue = "Configuration for @recursica/adapter-tester. All fields are optional — an adapter repo with a normal `storybook` npm script needs no config file at all.", de = "object", le = !1, pe = { $schema: { type: "string", description: 'Optional pointer to this schema for editor autocomplete, e.g. "https://raw.githubusercontent.com/borderux/recursica/main/packages/adapter-tester/src/adapter-tester.schema.json".' }, name: { type: "string", description: `Label for this project's own target. Defaults to the unscoped name in this project's package.json (e.g. "@recursica/some-adapter" -> "some-adapter").` }, storybook: { type: "object", additionalProperties: !1, description: "This project's own Storybook target.", properties: { port: { type: "integer", minimum: 1, maximum: 65535, description: "First-guess port only, not authoritative — the real port is auto-detected from this Storybook's own startup output, since Storybook silently falls back to an OS-assigned port whenever this one is taken. Auto-detected from this project's own `scripts.storybook` (a `-p <port>`/`--port <port>` flag) when omitted, falling back to 6006." }, command: { type: "string", description: "Command that boots the target's Storybook. Defaults to `npm run storybook`." }, cwd: { type: "string", description: 'Directory the command runs in, relative to the config file. Defaults to ".".' } } }, sourceOfTruth: { description: 'The comparison target. Defaults to `{ "type": "mantine-harness" }`.', oneOf: [{ type: "object", additionalProperties: !1, description: "Default mode: boots a throwaway harness that installs the published @recursica/mantine-adapter from npm — no monorepo checkout required.", properties: { type: { const: "mantine-harness" }, port: { type: "integer", minimum: 1, maximum: 65535, description: "First-guess port only, not authoritative — the real port is auto-detected from the throwaway harness's Storybook's own startup output." }, mantineAdapterVersion: { type: "string", description: "npm version/tag of @recursica/mantine-adapter to install in the harness. Defaults to `latest`." }, storybookTemplateVersion: { type: "string", description: "npm version/tag of @recursica/storybook-template to install in the harness. Defaults to `latest`." } } }, { type: "object", additionalProperties: !1, description: "Non-standard mode: points at an already-addressable Storybook — e.g. a sibling workspace package's own Storybook inside this monorepo.", required: ["type"], properties: { type: { const: "url" }, name: { type: "string", description: 'Label for the source-of-truth target. Defaults to "Mantine".' }, port: { type: "integer", minimum: 1, maximum: 65535, description: "First-guess port only, not authoritative — the real port is auto-detected from the source-of-truth Storybook's own startup output. Defaults to 6011." }, command: { type: "string", description: "Command that boots the source-of-truth Storybook. Defaults to `npm run storybook`." }, cwd: { type: "string", description: 'Directory the command runs in, relative to the config file. Defaults to ".".' } } }] }, isSourceOfTruthAdapter: { type: "boolean", description: "True only for the source-of-truth adapter's own config (mantine-adapter). Skips `sourceOfTruth` entirely — there's nothing above it to diverge from — and runs the own-drift golden check standalone, against just this project's own Storybook. Defaults to false." }, goldenThresholdPixels: { type: "number", minimum: 0, description: "Global visual diff threshold for the own-drift check (this project's live render vs. its own committed `test/golden/` image), in mismatched pixels, before a story is considered a failure. Same library/component on both sides, so this should stay tight. Defaults to 10. AI agents must not modify this field — see AGENT.md.", default: 10 }, sourceOfTruthThresholdPixels: { type: "number", minimum: 0, description: "Global visual diff threshold for the source-of-truth divergence check (this project's golden vs. the source-of-truth adapter's golden), in mismatched pixels, before a difference is flagged. Comparing across two different component libraries has legitimate structural variation (native control widgets, font rendering, etc.), so this is expected to be set much higher than `goldenThresholdPixels`. Ignored on the source-of-truth adapter's own config (`isSourceOfTruthAdapter: true`), which has no divergence check. Defaults to 3500. AI agents must not modify this field — see AGENT.md.", default: 3500 }, stories: { type: "object", additionalProperties: { type: "object", additionalProperties: !1, properties: { goldenThreshold: { type: "number", minimum: 0, description: "Diff threshold override for matching stories' own-drift check, in mismatched pixels. Overrides `goldenThresholdPixels`." }, sourceOfTruthThreshold: { type: "number", minimum: 0, description: "Diff threshold override for matching stories' source-of-truth divergence check, in mismatched pixels. Overrides `sourceOfTruthThresholdPixels`." }, exclude: { type: "boolean", description: "Skip matching stories entirely — no own-drift check, no divergence check, no golden captured. For stories that don't have a cross-adapter counterpart; use `excludeTitlePrefixes` to drop a whole title instead." } } }, description: "Per-story overrides, keyed by story id prefix (a story matches if its id equals the key or starts with it). When more than one key matches a story, the longest (most specific) key wins." }, excludeTitlePrefixes: { type: "array", items: { type: "string" }, description: "Storybook title prefixes to exclude from comparison, in addition to the built-in denylist (`Theme/*`, `Tokens/*`, `Introduction`)." }, reportHeader: { type: "string", description: 'Overrides the AI report header text shown in Dev Mode\'s "Full Report" export. Defaults to the contents of `report-header.txt`.' } }, he = {
|
|
181
185
|
$schema: ie,
|
|
182
186
|
$id: ae,
|
|
183
187
|
title: ce,
|
|
@@ -199,7 +203,7 @@ function me(e, t) {
|
|
|
199
203
|
throw new Error(`Invalid ${t}:
|
|
200
204
|
${r}`);
|
|
201
205
|
}
|
|
202
|
-
const ge = "@recursica/mantine-adapter", ye = "adapter-tester.config.json", L = "npm run storybook", we = 6006,
|
|
206
|
+
const ge = "@recursica/mantine-adapter", ye = "adapter-tester.config.json", L = "npm run storybook", we = 6006, R = 6011, C = "Mantine", ve = 10, Te = 3500;
|
|
203
207
|
function G(e) {
|
|
204
208
|
const t = a(e, "package.json");
|
|
205
209
|
if (!I(t))
|
|
@@ -243,6 +247,7 @@ function Oe(e, t = {}) {
|
|
|
243
247
|
sourceOfTruthThresholdPixels: r.sourceOfTruthThresholdPixels ?? Te,
|
|
244
248
|
stories: r.stories,
|
|
245
249
|
excludeTitlePrefixes: r.excludeTitlePrefixes,
|
|
250
|
+
reportHeader: r.reportHeader,
|
|
246
251
|
// Keyed off `ownCwd`, not `cwd` — the project actually being tested, not
|
|
247
252
|
// wherever the config file happens to live. Matters whenever
|
|
248
253
|
// `storybook.cwd` points at a sibling package: its goldens must resolve
|
|
@@ -273,7 +278,7 @@ function Oe(e, t = {}) {
|
|
|
273
278
|
throw new Error(
|
|
274
279
|
`--source-of-truth-version has no effect with sourceOfTruth.type: "url" — that mode reads a sibling package's local checkout directly, not a published version.`
|
|
275
280
|
);
|
|
276
|
-
u = i.name ??
|
|
281
|
+
u = i.name ?? C, l = i.port ?? R;
|
|
277
282
|
const b = j(e, i.cwd ?? ".");
|
|
278
283
|
v = {
|
|
279
284
|
command: i.command ?? L,
|
|
@@ -287,7 +292,7 @@ function Oe(e, t = {}) {
|
|
|
287
292
|
dir: a(b, "test", "golden")
|
|
288
293
|
};
|
|
289
294
|
} else {
|
|
290
|
-
u =
|
|
295
|
+
u = C, l = i.port ?? R;
|
|
291
296
|
const b = t.mantineAdapterVersion ?? i.mantineAdapterVersion;
|
|
292
297
|
v = X({
|
|
293
298
|
dir: a(e, ".adapter-tester/mantine-harness"),
|
|
@@ -320,7 +325,7 @@ function Oe(e, t = {}) {
|
|
|
320
325
|
webServers: [v, y]
|
|
321
326
|
};
|
|
322
327
|
}
|
|
323
|
-
const xe =
|
|
328
|
+
const xe = P(M(import.meta.url)), Ae = q(a(xe, "testing.js")).href, g = process.argv.slice(2);
|
|
324
329
|
let V;
|
|
325
330
|
const k = g.indexOf("--source-of-truth-version");
|
|
326
331
|
if (k !== -1) {
|
|
@@ -331,7 +336,7 @@ if (k !== -1) {
|
|
|
331
336
|
);
|
|
332
337
|
V = e, g.splice(k, 2);
|
|
333
338
|
}
|
|
334
|
-
const
|
|
339
|
+
const E = process.cwd(), { engineConfig: m, webServers: D } = Oe(E, {
|
|
335
340
|
mantineAdapterVersion: V
|
|
336
341
|
});
|
|
337
342
|
g.includes("--update-golden") ? m.goldenMode = "update-golden" : g.includes("--approve-divergence") && (m.goldenMode = "approve-divergence");
|
|
@@ -345,38 +350,38 @@ if (g.includes("--divergence-only")) {
|
|
|
345
350
|
throw new Error(
|
|
346
351
|
"--approve-divergence only makes sense with --divergence-only — there's nothing to approve without the divergence check running."
|
|
347
352
|
);
|
|
348
|
-
g.includes("--dry-run") && (console.log(JSON.stringify({ engineConfig: m, webServers:
|
|
349
|
-
const
|
|
353
|
+
g.includes("--dry-run") && (console.log(JSON.stringify({ engineConfig: m, webServers: D }, null, 2)), process.exit(0));
|
|
354
|
+
const Ee = /* @__PURE__ */ new Set([
|
|
350
355
|
"--dry-run",
|
|
351
356
|
"--serve",
|
|
352
357
|
"--update-golden",
|
|
353
358
|
"--approve-divergence",
|
|
354
359
|
"--divergence-only"
|
|
355
|
-
]),
|
|
356
|
-
|
|
360
|
+
]), De = g.filter((e) => !Ee.has(e));
|
|
361
|
+
Pe().catch((e) => {
|
|
357
362
|
console.error(e), process.exitCode = 1;
|
|
358
363
|
});
|
|
359
|
-
async function
|
|
364
|
+
async function Pe() {
|
|
360
365
|
if (g.includes("--serve")) {
|
|
361
366
|
if (m.isSourceOfTruthAdapter)
|
|
362
367
|
throw new Error(
|
|
363
368
|
"Dev Mode (--serve) has nothing to sync this project's Storybook against — isSourceOfTruthAdapter is true in this project's adapter-tester.config.json."
|
|
364
369
|
);
|
|
365
|
-
await ne(m,
|
|
370
|
+
await ne(m, D);
|
|
366
371
|
} else {
|
|
367
|
-
const e =
|
|
372
|
+
const e = D.at(-1);
|
|
368
373
|
if (!e)
|
|
369
374
|
throw new Error("resolveConfig() returned no webServers to boot.");
|
|
370
375
|
await je(e, m);
|
|
371
376
|
}
|
|
372
377
|
}
|
|
373
378
|
async function je(e, t) {
|
|
374
|
-
const r = a(
|
|
375
|
-
|
|
379
|
+
const r = a(E, ".adapter-tester/run");
|
|
380
|
+
_(r, { recursive: !0 });
|
|
376
381
|
const o = t.targets.at(-1);
|
|
377
382
|
if (!o)
|
|
378
383
|
throw new Error("resolveConfig() returned no targets to check.");
|
|
379
|
-
const { url: s, process: n } = await
|
|
384
|
+
const { url: s, process: n } = await A(
|
|
380
385
|
x(o.name, e)
|
|
381
386
|
);
|
|
382
387
|
o.url = s, O(
|
|
@@ -406,7 +411,7 @@ export default defineConfig({
|
|
|
406
411
|
a(r, "visual-regression.spec.js"),
|
|
407
412
|
`// Generated by \`adapter-tester\` — do not edit, regenerated on every run.
|
|
408
413
|
import { test, expect } from "@playwright/test";
|
|
409
|
-
import { resolveVisualRegressionPlan } from ${JSON.stringify(
|
|
414
|
+
import { resolveVisualRegressionPlan } from ${JSON.stringify(Ae)};
|
|
410
415
|
|
|
411
416
|
// \`test.describe\`/\`test\` are called here, not inside resolveVisualRegressionPlan,
|
|
412
417
|
// so Playwright's HTML report groups the suite under this file instead of a
|
|
@@ -432,16 +437,16 @@ test.describe(\`\${ownTargetName} — \${suiteLabel}\`, () => {
|
|
|
432
437
|
`
|
|
433
438
|
);
|
|
434
439
|
try {
|
|
435
|
-
const d =
|
|
440
|
+
const d = J(
|
|
436
441
|
"npx",
|
|
437
442
|
[
|
|
438
443
|
"playwright",
|
|
439
444
|
"test",
|
|
440
445
|
"--config",
|
|
441
446
|
a(r, "playwright.config.js"),
|
|
442
|
-
...
|
|
447
|
+
...De
|
|
443
448
|
],
|
|
444
|
-
{ stdio: "inherit", cwd:
|
|
449
|
+
{ stdio: "inherit", cwd: E, shell: process.platform === "win32" }
|
|
445
450
|
);
|
|
446
451
|
process.exitCode = d.status ?? 1;
|
|
447
452
|
} finally {
|
package/dist/cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.js","sources":["../src/portDiscovery.ts","../src/devServer.ts","../src/validateFileConfig.ts","../src/fileConfig.ts","../src/cli.ts"],"sourcesContent":["import { spawn, type ChildProcess } from \"node:child_process\";\nimport { mkdirSync, readFileSync, writeFileSync } from \"node:fs\";\nimport { dirname } from \"node:path\";\nimport net from \"node:net\";\nimport type { HarnessWebServerConfig } from \"./harness/mantineSourceOfTruth.js\";\n\n/**\n * Boots a target's Storybook and discovers the real port it ends up on,\n * instead of pinning one via `-p`/`--port`. Storybook silently falls back to\n * an OS-assigned port whenever its default/configured one is taken (this is\n * what caused the flaky `webServer` timeouts noted in mui-adapter), so the\n * only reliable source of truth is the URL it prints in its own startup\n * banner. Used by both the automated/headless run (cli.ts) and Dev Mode\n * (devServer.ts) — neither pins a port anymore.\n */\n\nexport interface LaunchTarget {\n /** Human-readable name used in log lines. */\n name: string;\n command: string;\n cwd: string;\n /** Reuse an already-running instance (detected via the last-known-port\n * cache) instead of spawning a new one. Mirrors the old `reuseExistingServer`\n * behavior, which used to just probe the one fixed configured port. */\n reuseExistingServer: boolean;\n /** File the discovered port is cached in between runs, so a later\n * `reuseExistingServer` run knows where to look. One per target. */\n cacheFile: string;\n timeoutMs?: number;\n}\n\nexport interface DiscoveredServer {\n url: string;\n port: number;\n /** The process we spawned, or `null` if an already-running instance was\n * reused — callers should only kill what they started. */\n process: ChildProcess | null;\n}\n\n// Storybook prints its bound address in its startup banner wrapped in ANSI\n// color codes and box-drawing chars, e.g.:\n// │ │ - Local: http://localhost:57496/ │ │\n// Strip ANSI first, then match the URL itself.\nconst ANSI_PATTERN = /\\x1b\\[[0-9;]*m/g;\nconst LOCAL_URL_PATTERN = /Local:\\s*(https?:\\/\\/localhost:\\d+)/;\n\nfunction isPortActive(port: number): Promise<boolean> {\n return new Promise((resolve) => {\n const socket = new net.Socket();\n socket.setTimeout(200);\n socket.once(\"connect\", () => {\n socket.destroy();\n resolve(true);\n });\n socket.once(\"timeout\", () => {\n socket.destroy();\n resolve(false);\n });\n socket.once(\"error\", () => {\n socket.destroy();\n resolve(false);\n });\n socket.connect(port, \"127.0.0.1\");\n });\n}\n\nfunction readCachedPort(cacheFile: string): number | undefined {\n try {\n const port = JSON.parse(readFileSync(cacheFile, \"utf8\")).port;\n return typeof port === \"number\" ? port : undefined;\n } catch {\n return undefined;\n }\n}\n\nfunction writeCachedPort(cacheFile: string, port: number): void {\n mkdirSync(dirname(cacheFile), { recursive: true });\n writeFileSync(cacheFile, JSON.stringify({ port }));\n}\n\n/** Spawns `target.command`, streaming its output to the console like before,\n * and resolves once it reports the URL it actually bound to. */\nfunction spawnAndDetect(\n target: LaunchTarget,\n timeoutMs: number,\n): Promise<DiscoveredServer> {\n return new Promise((resolve, reject) => {\n const child = spawn(target.command, {\n cwd: target.cwd,\n stdio: \"pipe\",\n shell: true,\n });\n\n let settled = false;\n const timer = setTimeout(() => {\n if (settled) return;\n settled = true;\n child.kill();\n reject(\n new Error(\n `Timed out after ${timeoutMs}ms waiting for ${target.name}'s Storybook to report its URL (no \"Local: http://localhost:<port>\" line seen in its output).`,\n ),\n );\n }, timeoutMs);\n\n const handleOutput = (data: Buffer, isError: boolean) => {\n const text = data.toString();\n for (const line of text.split(\"\\n\")) {\n if (line.trim()) {\n const label = isError\n ? `${target.name} SB ERROR`\n : `${target.name} SB`;\n (isError ? console.error : console.log)(`[${label}] ${line.trim()}`);\n }\n }\n if (settled) return;\n const match = text.replace(ANSI_PATTERN, \"\").match(LOCAL_URL_PATTERN);\n if (match) {\n settled = true;\n clearTimeout(timer);\n // Non-null: LOCAL_URL_PATTERN has exactly one capture group, and a\n // match only happens when it participated.\n const url = match[1]!;\n const port = Number(new URL(url).port);\n writeCachedPort(target.cacheFile, port);\n resolve({ url, port, process: child });\n }\n };\n child.stdout?.on(\"data\", (data: Buffer) => handleOutput(data, false));\n child.stderr?.on(\"data\", (data: Buffer) => handleOutput(data, true));\n child.on(\"error\", (err) => {\n if (settled) return;\n settled = true;\n clearTimeout(timer);\n reject(err);\n });\n child.on(\"exit\", (code) => {\n if (settled) return;\n settled = true;\n clearTimeout(timer);\n reject(\n new Error(\n `${target.name}'s Storybook exited (code ${code}) before reporting its URL.`,\n ),\n );\n });\n });\n}\n\n/** Adapts a resolved `HarnessWebServerConfig` into a `LaunchTarget`. */\nexport function toLaunchTarget(\n name: string,\n server: HarnessWebServerConfig,\n): LaunchTarget {\n return {\n name,\n command: server.command,\n cwd: server.cwd,\n reuseExistingServer: server.reuseExistingServer,\n cacheFile: server.cacheFile,\n timeoutMs: server.timeout,\n };\n}\n\n/** Reuses an already-running Storybook if `reuseExistingServer` is set and\n * the last-known-port cache points at something still listening; otherwise\n * spawns `target.command` fresh and detects the real port from its output. */\nexport async function launchAndDetectStorybook(\n target: LaunchTarget,\n): Promise<DiscoveredServer> {\n if (target.reuseExistingServer) {\n const cachedPort = readCachedPort(target.cacheFile);\n if (cachedPort !== undefined && (await isPortActive(cachedPort))) {\n console.log(\n `[Dev Launcher] ${target.name} is already running on port ${cachedPort} (reused).`,\n );\n return {\n url: `http://localhost:${cachedPort}`,\n port: cachedPort,\n process: null,\n };\n }\n }\n console.log(`[Dev Launcher] Launching Storybook for ${target.name}...`);\n return spawnAndDetect(target, target.timeoutMs ?? 120 * 1000);\n}\n","import { spawn, type ChildProcess } from \"node:child_process\";\nimport { readFileSync } from \"node:fs\";\nimport { dirname, join } from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\nimport express from \"express\";\nimport { createProxyMiddleware } from \"http-proxy-middleware\";\nimport type { AdapterTesterConfig } from \"./config.js\";\nimport type { HarnessWebServerConfig } from \"./harness/mantineSourceOfTruth.js\";\nimport { launchAndDetectStorybook, toLaunchTarget } from \"./portDiscovery.js\";\n\n/**\n * Interactive Dev Mode: a synced, side-by-side browser view of this\n * project's own Storybook and the source of truth, with per-story note\n * taking and an AI-report export. Boots both Storybooks (reusing them if\n * already running) behind a proxy so the own/target pane — which drives\n * the sync and carries Storybook's nav sidebar — loads same-origin on the\n * left, with the source of truth following along as a bare preview on the\n * right.\n *\n * Config-driven — takes the same `{ engineConfig, webServers }` shape\n * `resolveConfig()` produces, in the same [sourceOfTruth, target] order.\n */\n\nconst distDir = dirname(fileURLToPath(import.meta.url));\n\nfunction openBrowser(url: string): void {\n const startCmd =\n process.platform === \"darwin\"\n ? \"open\"\n : process.platform === \"win32\"\n ? \"start\"\n : \"xdg-open\";\n console.log(`[Dev Launcher] Auto-launching browser: ${url}`);\n spawn(startCmd, [url], { shell: process.platform === \"win32\" }).on(\n \"error\",\n (err) => {\n console.error(`[Dev Launcher] Failed to auto-launch browser:`, err);\n },\n );\n}\n\nexport interface DevServerOptions {\n /** Port the dev-mode proxy UI itself listens on. Defaults to 6010. */\n port?: number;\n}\n\nexport async function startDevServer(\n engineConfig: AdapterTesterConfig,\n webServers: HarnessWebServerConfig[],\n options: DevServerOptions = {},\n): Promise<void> {\n const [sourceOfTruth, target] = engineConfig.targets;\n const [sourceOfTruthServer, targetServer] = webServers;\n if (\n !sourceOfTruth?.sourceOfTruth ||\n !target ||\n target.sourceOfTruth ||\n !sourceOfTruthServer ||\n !targetServer\n ) {\n throw new Error(\n \"adapter-tester dev mode requires exactly two targets: [sourceOfTruth, target] — check adapter-tester.config.json.\",\n );\n }\n\n const devPort = options.port ?? 6010;\n\n // Neither Storybook is pinned to a specific port — each one silently\n // falls back to an OS-assigned port whenever its default/configured one is\n // taken, so the real port is only known once it reports it (see\n // portDiscovery.ts). Booted concurrently since neither depends on the other.\n console.log(\n `[Dev Launcher] Resolving ${sourceOfTruth.name} and ${target.name} Storybooks...`,\n );\n const [sourceOfTruthRunning, targetRunning] = await Promise.all([\n launchAndDetectStorybook(\n toLaunchTarget(sourceOfTruth.name, sourceOfTruthServer),\n ),\n launchAndDetectStorybook(toLaunchTarget(target.name, targetServer)),\n ]);\n console.log(`[Dev Launcher] Both Storybooks are active and responsive!`);\n\n const spawned = [sourceOfTruthRunning.process, targetRunning.process].filter(\n (child): child is ChildProcess => child !== null,\n );\n\n const app = express();\n const publicDir = join(distDir, \"../public\");\n const headerPath = join(distDir, \"../report-header.txt\");\n\n // Serve the Dev Mode UI at the root path ONLY if there is no query string.\n // This allows the iframe (which loads with ?path=/story/...) to pass\n // through to the proxy, avoiding an infinite loop of nested wrappers.\n app.get(\"/\", (req, res, next) => {\n if (req.query.path) {\n next();\n return;\n }\n const html = readFileSync(join(publicDir, \"index.html\"), \"utf8\").replace(\n \"<head>\",\n `<head>\\n <script>window.__ADAPTER_TESTER__ = ${JSON.stringify({\n ownName: target.name,\n sourceOfTruthName: sourceOfTruth.name,\n sourceOfTruthPort: sourceOfTruthRunning.port,\n })};</script>`,\n );\n res.send(html);\n });\n\n // Serve the AI prompt header dynamically so it can be edited externally.\n app.get(\"/report-header.txt\", (req, res) => {\n try {\n res.type(\"text/plain\").send(readFileSync(headerPath, \"utf8\"));\n } catch {\n res.status(500).send(\"Error loading report-header.txt\");\n }\n });\n\n // Proxy everything else to this project's own Storybook, preserving\n // absolute paths (e.g. /@vite/client) so HMR keeps working same-origin.\n // This is the pane that drives the sync and shows Storybook's nav sidebar.\n app.use(\n \"/\",\n createProxyMiddleware({\n target: targetRunning.url,\n changeOrigin: true,\n ws: true,\n }),\n );\n\n let cleaningUp = false;\n const cleanup = () => {\n if (cleaningUp) return;\n cleaningUp = true;\n console.log(\n \"\\n[Dev Launcher] Shutting down Dev Mode server and spawned Storybooks...\",\n );\n for (const child of spawned) child.kill(\"SIGINT\");\n process.exit(0);\n };\n process.on(\"SIGINT\", cleanup);\n process.on(\"SIGTERM\", cleanup);\n\n app.listen(devPort, () => {\n console.log(`\n====================================================\n🚀 Adapter Dev Mode proxy running at:\n http://localhost:${devPort}\n====================================================\n`);\n openBrowser(`http://localhost:${devPort}`);\n });\n}\n","import { Ajv } from \"ajv\";\nimport * as ajvFormatsModule from \"ajv-formats\";\nimport type { FormatsPlugin } from \"ajv-formats\";\nimport schema from \"./adapter-tester.schema.json\" with { type: \"json\" };\n\n// ajv-formats ships an ESM-style `export default` on a CJS build with no\n// `\"type\"` field, which under `moduleResolution: NodeNext` TS resolves to\n// the raw module namespace instead of unwrapping the default — a known\n// ajv-formats/TS interop gap, not a version mismatch.\nconst addFormats = (ajvFormatsModule as unknown as { default: FormatsPlugin })\n .default;\n\nconst ajv = new Ajv({ allErrors: true, strict: true });\naddFormats(ajv);\nconst validate = ajv.compile(schema);\n\n/**\n * Validates a parsed `adapter-tester.config.json` against\n * `adapter-tester.schema.json`. Throws with every violation listed — callers\n * must not silently coerce or drop invalid fields.\n */\nexport function validateFileConfig(data: unknown, path: string): void {\n if (validate(data)) return;\n\n const errors = (validate.errors ?? [])\n .map((error) => {\n const extra = error.params?.additionalProperty\n ? ` '${error.params.additionalProperty}'`\n : \"\";\n return ` - ${error.instancePath || \"root\"} ${error.message}${extra}`;\n })\n .join(\"\\n\");\n throw new Error(`Invalid ${path}:\\n${errors}`);\n}\n","import { existsSync, readFileSync } from \"node:fs\";\nimport { join, resolve } from \"node:path\";\nimport type {\n AdapterTesterConfig,\n SourceOfTruthGoldenLocation,\n StoryOverride,\n} from \"./config.js\";\nimport type { HarnessWebServerConfig } from \"./harness/mantineSourceOfTruth.js\";\nimport { mantineSourceOfTruthWebServer } from \"./harness/mantineSourceOfTruth.js\";\nimport { validateFileConfig } from \"./validateFileConfig.js\";\n\nconst MANTINE_ADAPTER_PACKAGE_NAME = \"@recursica/mantine-adapter\";\n\nexport const CONFIG_FILE_NAME = \"adapter-tester.config.json\";\nconst DEFAULT_STORYBOOK_COMMAND = \"npm run storybook\";\nconst DEFAULT_STORYBOOK_PORT = 6006;\nconst DEFAULT_SOURCE_OF_TRUTH_PORT = 6011;\nconst DEFAULT_SOURCE_OF_TRUTH_NAME = \"Mantine\";\nconst DEFAULT_GOLDEN_THRESHOLD_PIXELS = 10;\nconst DEFAULT_SOURCE_OF_TRUTH_THRESHOLD_PIXELS = 3500;\n\ninterface StorybookTargetFileConfig {\n /** First-guess port only, not authoritative — the real port is\n * auto-detected from this Storybook's own startup output, since Storybook\n * silently falls back to an OS-assigned port whenever this one is taken.\n * Auto-detected from this project's own `scripts.storybook` (a `-p\n * <port>`/`--port <port>` flag) when omitted, falling back to 6006. */\n port?: number;\n /** Command that boots the target's Storybook. Defaults to `npm run storybook`. */\n command?: string;\n /** Directory the command runs in, relative to the config file. Defaults to \".\" */\n cwd?: string;\n}\n\ninterface MantineHarnessSourceOfTruthFileConfig {\n /** Default mode: boots a throwaway harness that installs the published\n * `@recursica/mantine-adapter` from npm — no monorepo checkout required. */\n type?: \"mantine-harness\";\n /** First-guess port only, not authoritative — see `HarnessWebServerConfig.port`. */\n port?: number;\n mantineAdapterVersion?: string;\n storybookTemplateVersion?: string;\n}\n\ninterface UrlSourceOfTruthFileConfig {\n /** Non-standard mode: points at an already-addressable Storybook — e.g. a\n * sibling workspace package's own Storybook inside this monorepo. */\n type: \"url\";\n name?: string;\n /** First-guess port only, not authoritative — see `HarnessWebServerConfig.port`.\n * Defaults to 6011. */\n port?: number;\n command?: string;\n cwd?: string;\n}\n\ntype SourceOfTruthFileConfig =\n | MantineHarnessSourceOfTruthFileConfig\n | UrlSourceOfTruthFileConfig;\n\nexport interface AdapterTesterFileConfig {\n /** Label for this project's own target. Defaults to the unscoped name in\n * this project's package.json (e.g. \"@recursica/mui-adapter\" -> \"mui-adapter\"). */\n name?: string;\n storybook?: StorybookTargetFileConfig;\n sourceOfTruth?: SourceOfTruthFileConfig;\n goldenThresholdPixels?: number;\n sourceOfTruthThresholdPixels?: number;\n stories?: Record<string, StoryOverride>;\n excludeTitlePrefixes?: string[];\n /**\n * True only for the source-of-truth adapter's own config (mantine-adapter).\n * Skips `sourceOfTruth` entirely — there's nothing above it to diverge\n * from — and runs the own-drift golden check standalone, against just this\n * project's own Storybook. Defaults to false.\n */\n isSourceOfTruthAdapter?: boolean;\n}\n\nexport interface ResolvedAdapterTesterConfig {\n engineConfig: AdapterTesterConfig;\n webServers: HarnessWebServerConfig[];\n}\n\nexport interface ResolveConfigOverrides {\n /** From `--source-of-truth-version`. Overrides `sourceOfTruth.mantineAdapterVersion`. */\n mantineAdapterVersion?: string;\n}\n\nfunction readOwnPackageJson(cwd: string): any {\n const path = join(cwd, \"package.json\");\n if (!existsSync(path)) {\n throw new Error(\n `No package.json found in ${cwd} — run adapter-tester from the root of the project being tested.`,\n );\n }\n return JSON.parse(readFileSync(path, \"utf8\"));\n}\n\nfunction detectOwnPort(cwd: string): number {\n const pkg = readOwnPackageJson(cwd);\n const storybookScript = pkg.scripts?.storybook as string | undefined;\n const match = storybookScript?.match(/(?:-p|--port)[ =](\\d+)/);\n return match ? Number(match[1]) : DEFAULT_STORYBOOK_PORT;\n}\n\nfunction detectOwnName(cwd: string): string {\n const pkg = readOwnPackageJson(cwd);\n const name = pkg.name as string | undefined;\n return name ? name.split(\"/\").pop()! : \"Adapter\";\n}\n\nfunction loadFileConfig(cwd: string): AdapterTesterFileConfig {\n const path = join(cwd, CONFIG_FILE_NAME);\n if (!existsSync(path)) {\n return {};\n }\n const data = JSON.parse(readFileSync(path, \"utf8\"));\n validateFileConfig(data, path);\n return data;\n}\n\n/**\n * Loads `adapter-tester.config.json` from `cwd` (or falls back to defaults\n * when the file doesn't exist) and resolves it into the engine config\n * `resolveVisualRegressionPlan` consumes plus the Playwright `webServer` entries\n * needed to boot both sides of the comparison.\n *\n * Default mode (no `sourceOfTruth`/`storybook` set): compares this project's\n * own Storybook against a throwaway Mantine harness — no monorepo checkout\n * required. Set `sourceOfTruth.type: \"url\"` for the non-standard mode used\n * to compare sibling workspace packages inside this monorepo.\n *\n * `overrides.mantineAdapterVersion` (from `--source-of-truth-version`) pins\n * the mantine-harness install/golden-fetch version for this run, overriding\n * `sourceOfTruth.mantineAdapterVersion`. Throws if passed together with\n * `isSourceOfTruthAdapter` or `sourceOfTruth.type: \"url\"` — neither has a\n * version to pin.\n */\nexport function resolveConfig(\n cwd: string,\n overrides: ResolveConfigOverrides = {},\n): ResolvedAdapterTesterConfig {\n const file = loadFileConfig(cwd);\n const isSourceOfTruthAdapter = file.isSourceOfTruthAdapter ?? false;\n\n if (overrides.mantineAdapterVersion && isSourceOfTruthAdapter) {\n throw new Error(\n \"--source-of-truth-version has no effect on the source-of-truth adapter's own config (isSourceOfTruthAdapter: true) — there's nothing to pin a version for.\",\n );\n }\n\n const ownName = file.name ?? detectOwnName(cwd);\n const ownPort = file.storybook?.port ?? detectOwnPort(cwd);\n const ownCommand = file.storybook?.command ?? DEFAULT_STORYBOOK_COMMAND;\n const ownCwd = resolve(cwd, file.storybook?.cwd ?? \".\");\n const ownWebServer: HarnessWebServerConfig = {\n command: ownCommand,\n port: ownPort,\n cwd: ownCwd,\n reuseExistingServer: !process.env.CI,\n cacheFile: join(cwd, \".adapter-tester\", \"last-port-own.json\"),\n timeout: 120 * 1000,\n };\n\n const sharedEngineConfig = {\n goldenThresholdPixels:\n file.goldenThresholdPixels ?? DEFAULT_GOLDEN_THRESHOLD_PIXELS,\n sourceOfTruthThresholdPixels:\n file.sourceOfTruthThresholdPixels ??\n DEFAULT_SOURCE_OF_TRUTH_THRESHOLD_PIXELS,\n stories: file.stories,\n excludeTitlePrefixes: file.excludeTitlePrefixes,\n // Keyed off `ownCwd`, not `cwd` — the project actually being tested, not\n // wherever the config file happens to live. Matters whenever\n // `storybook.cwd` points at a sibling package: its goldens must resolve\n // to that package's own `test/golden/` (the same directory used when\n // that package runs adapter-tester directly), not a directory under\n // wherever this config file lives.\n goldenDir: join(ownCwd, \"test\", \"golden\"),\n isSourceOfTruthAdapter,\n // Overwritten by the CLI from --update-golden/--approve-divergence.\n goldenMode: \"check\" as const,\n // Overwritten by the CLI from --divergence-only.\n checkMode: \"own\" as const,\n };\n\n // The source-of-truth adapter's own config has nothing above it to\n // diverge from — no second target, no harness/webServer for it at all.\n if (isSourceOfTruthAdapter) {\n return {\n engineConfig: {\n ...sharedEngineConfig,\n targets: [{ name: ownName, url: `http://localhost:${ownPort}` }],\n },\n webServers: [ownWebServer],\n };\n }\n\n const sourceOfTruth = file.sourceOfTruth ?? {\n type: \"mantine-harness\" as const,\n };\n\n let sourceOfTruthName: string;\n let sourceOfTruthPort: number;\n let sourceOfTruthWebServer: HarnessWebServerConfig;\n let sourceOfTruthGolden: SourceOfTruthGoldenLocation;\n\n if (sourceOfTruth.type === \"url\") {\n if (overrides.mantineAdapterVersion) {\n throw new Error(\n '--source-of-truth-version has no effect with sourceOfTruth.type: \"url\" — that mode reads a sibling package\\'s local checkout directly, not a published version.',\n );\n }\n sourceOfTruthName = sourceOfTruth.name ?? DEFAULT_SOURCE_OF_TRUTH_NAME;\n sourceOfTruthPort = sourceOfTruth.port ?? DEFAULT_SOURCE_OF_TRUTH_PORT;\n const sourceOfTruthCwd = resolve(cwd, sourceOfTruth.cwd ?? \".\");\n sourceOfTruthWebServer = {\n command: sourceOfTruth.command ?? DEFAULT_STORYBOOK_COMMAND,\n port: sourceOfTruthPort,\n cwd: sourceOfTruthCwd,\n reuseExistingServer: !process.env.CI,\n cacheFile: join(cwd, \".adapter-tester\", \"last-port-source-of-truth.json\"),\n timeout: 120 * 1000,\n };\n // Sibling package already checked out locally — read its golden files\n // directly, including any uncommitted local changes. No install, no\n // network call.\n sourceOfTruthGolden = {\n type: \"local\",\n dir: join(sourceOfTruthCwd, \"test\", \"golden\"),\n };\n } else {\n sourceOfTruthName = DEFAULT_SOURCE_OF_TRUTH_NAME;\n sourceOfTruthPort = sourceOfTruth.port ?? DEFAULT_SOURCE_OF_TRUTH_PORT;\n const mantineAdapterVersion =\n overrides.mantineAdapterVersion ?? sourceOfTruth.mantineAdapterVersion;\n sourceOfTruthWebServer = mantineSourceOfTruthWebServer({\n dir: join(cwd, \".adapter-tester/mantine-harness\"),\n port: sourceOfTruthPort,\n mantineAdapterVersion,\n storybookTemplateVersion: sourceOfTruth.storybookTemplateVersion,\n });\n // No local checkout — resolve the installed version against the npm\n // registry and fetch that version's golden files from the public repo.\n // Never needs `sourceOfTruthWebServer` above; the golden check on its\n // own doesn't boot a second Storybook at all (see cli.ts).\n sourceOfTruthGolden = {\n type: \"npm\",\n packageName: MANTINE_ADAPTER_PACKAGE_NAME,\n versionSpec: mantineAdapterVersion ?? \"latest\",\n cacheDir: join(cwd, \".adapter-tester/mantine-golden-cache\"),\n };\n }\n\n return {\n engineConfig: {\n ...sharedEngineConfig,\n targets: [\n {\n name: sourceOfTruthName,\n url: `http://localhost:${sourceOfTruthPort}`,\n sourceOfTruth: true,\n },\n { name: ownName, url: `http://localhost:${ownPort}` },\n ],\n sourceOfTruthGolden,\n },\n // [sourceOfTruth, own] — Dev Mode needs both; the automated golden run\n // (cli.ts) only ever boots the last entry, since its divergence check\n // reads stored golden files, not a live source-of-truth page.\n webServers: [sourceOfTruthWebServer, ownWebServer],\n };\n}\n","import { spawnSync } from \"node:child_process\";\nimport { mkdirSync, writeFileSync } from \"node:fs\";\nimport { dirname, join } from \"node:path\";\nimport { fileURLToPath, pathToFileURL } from \"node:url\";\nimport type { AdapterTesterConfig } from \"./config.js\";\nimport { startDevServer } from \"./devServer.js\";\nimport { resolveConfig } from \"./fileConfig.js\";\nimport type { HarnessWebServerConfig } from \"./harness/mantineSourceOfTruth.js\";\nimport { launchAndDetectStorybook, toLaunchTarget } from \"./portDiscovery.js\";\n\n// `dist/testing.js` is always a sibling of this file — both inside a\n// consumer's node_modules/@recursica/adapter-tester/dist and inside this\n// monorepo's own packages/adapter-tester/dist when self-hosting — so the\n// generated spec below can reach it without depending on how the package\n// itself resolves at import time.\nconst distDir = dirname(fileURLToPath(import.meta.url));\nconst testingEntry = pathToFileURL(join(distDir, \"testing.js\")).href;\n\n// `--source-of-truth-version <value>` takes a value, unlike every other own\n// flag below — pulled out of argv first so the boolean flags/passthrough\n// logic never has to know it exists.\nconst args = process.argv.slice(2);\nlet sourceOfTruthVersion: string | undefined;\nconst sourceOfTruthVersionFlagIndex = args.indexOf(\"--source-of-truth-version\");\nif (sourceOfTruthVersionFlagIndex !== -1) {\n const value = args[sourceOfTruthVersionFlagIndex + 1];\n if (value === undefined || value.startsWith(\"--\")) {\n throw new Error(\n \"--source-of-truth-version requires a value, e.g. --source-of-truth-version 0.53.0\",\n );\n }\n sourceOfTruthVersion = value;\n args.splice(sourceOfTruthVersionFlagIndex, 2);\n}\n\nconst cwd = process.cwd();\nconst { engineConfig, webServers } = resolveConfig(cwd, {\n mantineAdapterVersion: sourceOfTruthVersion,\n});\n\nif (args.includes(\"--update-golden\")) {\n engineConfig.goldenMode = \"update-golden\";\n} else if (args.includes(\"--approve-divergence\")) {\n engineConfig.goldenMode = \"approve-divergence\";\n}\n\nif (args.includes(\"--divergence-only\")) {\n if (engineConfig.isSourceOfTruthAdapter) {\n throw new Error(\n \"--divergence-only has nothing to diverge from — isSourceOfTruthAdapter is true in this project's adapter-tester.config.json.\",\n );\n }\n engineConfig.checkMode = \"divergence\";\n} else if (engineConfig.goldenMode === \"approve-divergence\") {\n throw new Error(\n \"--approve-divergence only makes sense with --divergence-only — there's nothing to approve without the divergence check running.\",\n );\n}\n\nif (args.includes(\"--dry-run\")) {\n console.log(JSON.stringify({ engineConfig, webServers }, null, 2));\n process.exit(0);\n}\n\n// Any arg besides our own flags is passed straight through to `playwright\n// test` — e.g. `npm run adapter-tester:automated -- --grep \"Toast\"` to scope\n// a run to matching stories, instead of every invocation running the full\n// suite. Our own flags are consumed above, not forwarded — Playwright itself\n// doesn't know about them.\nconst OWN_FLAGS = new Set([\n \"--dry-run\",\n \"--serve\",\n \"--update-golden\",\n \"--approve-divergence\",\n \"--divergence-only\",\n]);\nconst passthroughArgs = args.filter((arg) => !OWN_FLAGS.has(arg));\n\n// The bundled build target doesn't support top-level await, so the async\n// work (launching Storybook and detecting its real port) lives in main().\nmain().catch((err) => {\n console.error(err);\n process.exitCode = 1;\n});\n\nasync function main(): Promise<void> {\n if (args.includes(\"--serve\")) {\n if (engineConfig.isSourceOfTruthAdapter) {\n throw new Error(\n \"Dev Mode (--serve) has nothing to sync this project's Storybook against — isSourceOfTruthAdapter is true in this project's adapter-tester.config.json.\",\n );\n }\n // Dual-Storybook interactive Dev Mode — no Playwright, no screenshots.\n // Used by the `adapter-tester` npm script.\n await startDevServer(engineConfig, webServers);\n } else {\n // The golden-image checks never need the source-of-truth adapter's own\n // Storybook running — the divergence check reads its stored golden files,\n // not a live page — so only the last (own) webServer is booted here. Dev\n // Mode above is the one thing that still needs both.\n const ownWebServer = webServers.at(-1);\n if (!ownWebServer) {\n throw new Error(\"resolveConfig() returned no webServers to boot.\");\n }\n await runAutomated(ownWebServer, engineConfig);\n }\n}\n\n/**\n * Boots this project's own Storybook (auto-detecting the port it actually\n * lands on — see portDiscovery.ts), generates a throwaway Playwright config\n * + spec under `.adapter-tester/run/`, and runs the automated pixel-diff\n * suite against it. Used by the `adapter-tester:automated` npm script.\n *\n * Playwright's own `webServer` option can't be used here — it only knows how\n * to poll a port/URL decided *before* the command it spawns runs, but\n * Storybook silently falls back to a different, OS-assigned port whenever\n * its configured one is taken. So this boots and waits for Storybook itself,\n * then points the generated config straight at whatever URL it actually\n * reports.\n */\nasync function runAutomated(\n server: HarnessWebServerConfig,\n config: AdapterTesterConfig,\n): Promise<void> {\n const runDir = join(cwd, \".adapter-tester/run\");\n mkdirSync(runDir, { recursive: true });\n\n const ownTarget = config.targets.at(-1);\n if (!ownTarget) {\n throw new Error(\"resolveConfig() returned no targets to check.\");\n }\n const { url, process: spawned } = await launchAndDetectStorybook(\n toLaunchTarget(ownTarget.name, server),\n );\n ownTarget.url = url;\n\n writeFileSync(\n join(runDir, \"playwright.config.js\"),\n `// Generated by \\`adapter-tester\\` — do not edit, regenerated on every run.\nimport { defineConfig, devices } from \"@playwright/test\";\n\nexport default defineConfig({\n testDir: ${JSON.stringify(runDir)},\n // Each golden check only reads/writes its own story's manifest.json entry,\n // under a lock, so concurrent workers never race each other (see\n // \\`updateManifestEntry\\`). Defaults to 1 worker (1 Chromium instance) to\n // avoid exhausting memory running the full suite; override with\n // \\`--workers <n>\\` (forwarded straight through to Playwright) to parallelize.\n workers: 1,\n fullyParallel: true,\n forbidOnly: !!process.env.CI,\n retries: process.env.CI ? 2 : 0,\n reporter: [[\"html\", { open: \"never\" }], [\"list\"]],\n use: { trace: \"on-first-retry\" },\n projects: [{ name: \"chromium\", use: { ...devices[\"Desktop Chrome\"] } }],\n // No webServer entry — this project's own Storybook is already running by\n // the time this config is used (see runAutomated() in cli.ts).\n});\n`,\n );\n\n writeFileSync(\n join(runDir, \"visual-regression.spec.js\"),\n `// Generated by \\`adapter-tester\\` — do not edit, regenerated on every run.\nimport { test, expect } from \"@playwright/test\";\nimport { resolveVisualRegressionPlan } from ${JSON.stringify(testingEntry)};\n\n// \\`test.describe\\`/\\`test\\` are called here, not inside resolveVisualRegressionPlan,\n// so Playwright's HTML report groups the suite under this file instead of a\n// sourcemapped path into adapter-tester's own library code.\nconst { ownTargetName, suiteLabel, stories, missingFromSourceOfTruth, checkStory } =\n await resolveVisualRegressionPlan(${JSON.stringify(config, null, 2)});\n\ntest.describe(\\`\\${ownTargetName} — \\${suiteLabel}\\`, () => {\n if (missingFromSourceOfTruth.length > 0) {\n test(\"story parity with source of truth\", () => {\n expect(\n missingFromSourceOfTruth,\n \\`\\${missingFromSourceOfTruth.length} stor(y/ies) exist in the source of truth but are missing here. Add the missing story, or mark it \\\\\\`exclude: true\\\\\\` under \\\\\\`stories\\\\\\` in adapter-tester.config.json if intentional.\\`,\n ).toEqual([]);\n });\n }\n for (const story of stories) {\n test(story.id, async ({ browser }, testInfo) => {\n await checkStory(story, browser, testInfo);\n });\n }\n});\n`,\n );\n\n try {\n const result = spawnSync(\n \"npx\",\n [\n \"playwright\",\n \"test\",\n \"--config\",\n join(runDir, \"playwright.config.js\"),\n ...passthroughArgs,\n ],\n { stdio: \"inherit\", cwd, shell: process.platform === \"win32\" },\n );\n process.exitCode = result.status ?? 1;\n } finally {\n // Only tear down the Storybook we spawned — an instance we reused via\n // the last-known-port cache was already running before we got here, and\n // should stay running after.\n spawned?.kill(\"SIGTERM\");\n }\n}\n"],"names":["ANSI_PATTERN","LOCAL_URL_PATTERN","isPortActive","port","resolve","socket","net","readCachedPort","cacheFile","readFileSync","writeCachedPort","mkdirSync","dirname","writeFileSync","spawnAndDetect","target","timeoutMs","reject","child","spawn","settled","timer","handleOutput","data","isError","text","line","label","match","url","_a","_b","err","code","toLaunchTarget","name","server","launchAndDetectStorybook","cachedPort","distDir","fileURLToPath","openBrowser","startCmd","startDevServer","engineConfig","webServers","options","sourceOfTruth","sourceOfTruthServer","targetServer","devPort","sourceOfTruthRunning","targetRunning","spawned","app","express","publicDir","join","headerPath","req","res","next","html","createProxyMiddleware","cleaningUp","cleanup","addFormats","ajvFormatsModule.default","ajv","Ajv","validate","schema","validateFileConfig","path","errors","error","extra","MANTINE_ADAPTER_PACKAGE_NAME","CONFIG_FILE_NAME","DEFAULT_STORYBOOK_COMMAND","DEFAULT_STORYBOOK_PORT","DEFAULT_SOURCE_OF_TRUTH_PORT","DEFAULT_SOURCE_OF_TRUTH_NAME","DEFAULT_GOLDEN_THRESHOLD_PIXELS","DEFAULT_SOURCE_OF_TRUTH_THRESHOLD_PIXELS","readOwnPackageJson","cwd","existsSync","detectOwnPort","storybookScript","detectOwnName","loadFileConfig","resolveConfig","overrides","file","isSourceOfTruthAdapter","ownName","ownPort","ownCommand","ownCwd","_c","ownWebServer","sharedEngineConfig","sourceOfTruthName","sourceOfTruthPort","sourceOfTruthWebServer","sourceOfTruthGolden","sourceOfTruthCwd","mantineAdapterVersion","mantineSourceOfTruthWebServer","testingEntry","pathToFileURL","args","sourceOfTruthVersion","sourceOfTruthVersionFlagIndex","value","OWN_FLAGS","passthroughArgs","arg","main","runAutomated","config","runDir","ownTarget","result","spawnSync"],"mappings":";;;;;;;;;;AA2CA,MAAMA,IAAe,mBACfC,IAAoB;AAE1B,SAASC,GAAaC,GAAgC;AACpD,SAAO,IAAI,QAAQ,CAACC,M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src/validateFileConfig.ts","../src/fileConfig.ts","../src/cli.ts"],"sourcesContent":["import { spawn, type ChildProcess } from \"node:child_process\";\nimport { mkdirSync, readFileSync, writeFileSync } from \"node:fs\";\nimport { dirname } from \"node:path\";\nimport net from \"node:net\";\nimport type { HarnessWebServerConfig } from \"./harness/mantineSourceOfTruth.js\";\n\n/**\n * Boots a target's Storybook and discovers the real port it ends up on,\n * instead of pinning one via `-p`/`--port`. Storybook silently falls back to\n * an OS-assigned port whenever its default/configured one is taken (this is\n * what caused the flaky `webServer` timeouts noted in mui-adapter), so the\n * only reliable source of truth is the URL it prints in its own startup\n * banner. Used by both the automated/headless run (cli.ts) and Dev Mode\n * (devServer.ts) — neither pins a port anymore.\n */\n\nexport interface LaunchTarget {\n /** Human-readable name used in log lines. */\n name: string;\n command: string;\n cwd: string;\n /** Reuse an already-running instance (detected via the last-known-port\n * cache) instead of spawning a new one. Mirrors the old `reuseExistingServer`\n * behavior, which used to just probe the one fixed configured port. */\n reuseExistingServer: boolean;\n /** File the discovered port is cached in between runs, so a later\n * `reuseExistingServer` run knows where to look. One per target. */\n cacheFile: string;\n timeoutMs?: number;\n}\n\nexport interface DiscoveredServer {\n url: string;\n port: number;\n /** The process we spawned, or `null` if an already-running instance was\n * reused — callers should only kill what they started. */\n process: ChildProcess | null;\n}\n\n// Storybook prints its bound address in its startup banner wrapped in ANSI\n// color codes and box-drawing chars, e.g.:\n// │ │ - Local: http://localhost:57496/ │ │\n// Strip ANSI first, then match the URL itself.\nconst ANSI_PATTERN = /\\x1b\\[[0-9;]*m/g;\nconst LOCAL_URL_PATTERN = /Local:\\s*(https?:\\/\\/localhost:\\d+)/;\n\nfunction isPortActive(port: number): Promise<boolean> {\n return new Promise((resolve) => {\n const socket = new net.Socket();\n socket.setTimeout(200);\n socket.once(\"connect\", () => {\n socket.destroy();\n resolve(true);\n });\n socket.once(\"timeout\", () => {\n socket.destroy();\n resolve(false);\n });\n socket.once(\"error\", () => {\n socket.destroy();\n resolve(false);\n });\n socket.connect(port, \"127.0.0.1\");\n });\n}\n\nfunction readCachedPort(cacheFile: string): number | undefined {\n try {\n const port = JSON.parse(readFileSync(cacheFile, \"utf8\")).port;\n return typeof port === \"number\" ? port : undefined;\n } catch {\n return undefined;\n }\n}\n\nfunction writeCachedPort(cacheFile: string, port: number): void {\n mkdirSync(dirname(cacheFile), { recursive: true });\n writeFileSync(cacheFile, JSON.stringify({ port }));\n}\n\n/** Spawns `target.command`, streaming its output to the console like before,\n * and resolves once it reports the URL it actually bound to. */\nfunction spawnAndDetect(\n target: LaunchTarget,\n timeoutMs: number,\n): Promise<DiscoveredServer> {\n return new Promise((resolve, reject) => {\n const child = spawn(target.command, {\n cwd: target.cwd,\n stdio: \"pipe\",\n shell: true,\n });\n\n let settled = false;\n const timer = setTimeout(() => {\n if (settled) return;\n settled = true;\n child.kill();\n reject(\n new Error(\n `Timed out after ${timeoutMs}ms waiting for ${target.name}'s Storybook to report its URL (no \"Local: http://localhost:<port>\" line seen in its output).`,\n ),\n );\n }, timeoutMs);\n\n const handleOutput = (data: Buffer, isError: boolean) => {\n const text = data.toString();\n for (const line of text.split(\"\\n\")) {\n if (line.trim()) {\n const label = isError\n ? `${target.name} SB ERROR`\n : `${target.name} SB`;\n (isError ? console.error : console.log)(`[${label}] ${line.trim()}`);\n }\n }\n if (settled) return;\n const match = text.replace(ANSI_PATTERN, \"\").match(LOCAL_URL_PATTERN);\n if (match) {\n settled = true;\n clearTimeout(timer);\n // Non-null: LOCAL_URL_PATTERN has exactly one capture group, and a\n // match only happens when it participated.\n const url = match[1]!;\n const port = Number(new URL(url).port);\n writeCachedPort(target.cacheFile, port);\n resolve({ url, port, process: child });\n }\n };\n child.stdout?.on(\"data\", (data: Buffer) => handleOutput(data, false));\n child.stderr?.on(\"data\", (data: Buffer) => handleOutput(data, true));\n child.on(\"error\", (err) => {\n if (settled) return;\n settled = true;\n clearTimeout(timer);\n reject(err);\n });\n child.on(\"exit\", (code) => {\n if (settled) return;\n settled = true;\n clearTimeout(timer);\n reject(\n new Error(\n `${target.name}'s Storybook exited (code ${code}) before reporting its URL.`,\n ),\n );\n });\n });\n}\n\n/** Adapts a resolved `HarnessWebServerConfig` into a `LaunchTarget`. */\nexport function toLaunchTarget(\n name: string,\n server: HarnessWebServerConfig,\n): LaunchTarget {\n return {\n name,\n command: server.command,\n cwd: server.cwd,\n reuseExistingServer: server.reuseExistingServer,\n cacheFile: server.cacheFile,\n timeoutMs: server.timeout,\n };\n}\n\n/** Reuses an already-running Storybook if `reuseExistingServer` is set and\n * the last-known-port cache points at something still listening; otherwise\n * spawns `target.command` fresh and detects the real port from its output. */\nexport async function launchAndDetectStorybook(\n target: LaunchTarget,\n): Promise<DiscoveredServer> {\n if (target.reuseExistingServer) {\n const cachedPort = readCachedPort(target.cacheFile);\n if (cachedPort !== undefined && (await isPortActive(cachedPort))) {\n console.log(\n `[Dev Launcher] ${target.name} is already running on port ${cachedPort} (reused).`,\n );\n return {\n url: `http://localhost:${cachedPort}`,\n port: cachedPort,\n process: null,\n };\n }\n }\n console.log(`[Dev Launcher] Launching Storybook for ${target.name}...`);\n return spawnAndDetect(target, target.timeoutMs ?? 120 * 1000);\n}\n","import { spawn, type ChildProcess } from \"node:child_process\";\nimport { readFileSync } from \"node:fs\";\nimport { dirname, join } from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\nimport express from \"express\";\nimport { createProxyMiddleware } from \"http-proxy-middleware\";\nimport type { AdapterTesterConfig } from \"./config.js\";\nimport type { HarnessWebServerConfig } from \"./harness/mantineSourceOfTruth.js\";\nimport { launchAndDetectStorybook, toLaunchTarget } from \"./portDiscovery.js\";\n\n/**\n * Interactive Dev Mode: a synced, side-by-side browser view of this\n * project's own Storybook and the source of truth, with per-story note\n * taking and an AI-report export. Boots both Storybooks (reusing them if\n * already running) behind a proxy so the own/target pane — which drives\n * the sync and carries Storybook's nav sidebar — loads same-origin on the\n * left, with the source of truth following along as a bare preview on the\n * right.\n *\n * Config-driven — takes the same `{ engineConfig, webServers }` shape\n * `resolveConfig()` produces, in the same [sourceOfTruth, target] order.\n */\n\nconst distDir = dirname(fileURLToPath(import.meta.url));\n\nfunction openBrowser(url: string): void {\n const startCmd =\n process.platform === \"darwin\"\n ? \"open\"\n : process.platform === \"win32\"\n ? \"start\"\n : \"xdg-open\";\n console.log(`[Dev Launcher] Auto-launching browser: ${url}`);\n spawn(startCmd, [url], { shell: process.platform === \"win32\" }).on(\n \"error\",\n (err) => {\n console.error(`[Dev Launcher] Failed to auto-launch browser:`, err);\n },\n );\n}\n\nexport interface DevServerOptions {\n /** Port the dev-mode proxy UI itself listens on. Defaults to 6010. */\n port?: number;\n}\n\nexport async function startDevServer(\n engineConfig: AdapterTesterConfig,\n webServers: HarnessWebServerConfig[],\n options: DevServerOptions = {},\n): Promise<void> {\n const [sourceOfTruth, target] = engineConfig.targets;\n const [sourceOfTruthServer, targetServer] = webServers;\n if (\n !sourceOfTruth?.sourceOfTruth ||\n !target ||\n target.sourceOfTruth ||\n !sourceOfTruthServer ||\n !targetServer\n ) {\n throw new Error(\n \"adapter-tester dev mode requires exactly two targets: [sourceOfTruth, target] — check adapter-tester.config.json.\",\n );\n }\n\n const devPort = options.port ?? 6010;\n\n // Neither Storybook is pinned to a specific port — each one silently\n // falls back to an OS-assigned port whenever its default/configured one is\n // taken, so the real port is only known once it reports it (see\n // portDiscovery.ts). Booted concurrently since neither depends on the other.\n console.log(\n `[Dev Launcher] Resolving ${sourceOfTruth.name} and ${target.name} Storybooks...`,\n );\n const [sourceOfTruthRunning, targetRunning] = await Promise.all([\n launchAndDetectStorybook(\n toLaunchTarget(sourceOfTruth.name, sourceOfTruthServer),\n ),\n launchAndDetectStorybook(toLaunchTarget(target.name, targetServer)),\n ]);\n console.log(`[Dev Launcher] Both Storybooks are active and responsive!`);\n\n const spawned = [sourceOfTruthRunning.process, targetRunning.process].filter(\n (child): child is ChildProcess => child !== null,\n );\n\n const app = express();\n const publicDir = join(distDir, \"../public\");\n const headerPath = join(distDir, \"../report-header.txt\");\n\n // Serve the Dev Mode UI at the root path ONLY if there is no query string.\n // This allows the iframe (which loads with ?path=/story/...) to pass\n // through to the proxy, avoiding an infinite loop of nested wrappers.\n app.get(\"/\", (req, res, next) => {\n if (req.query.path) {\n next();\n return;\n }\n const html = readFileSync(join(publicDir, \"index.html\"), \"utf8\").replace(\n \"<head>\",\n `<head>\\n <script>window.__ADAPTER_TESTER__ = ${JSON.stringify({\n ownName: target.name,\n sourceOfTruthName: sourceOfTruth.name,\n sourceOfTruthPort: sourceOfTruthRunning.port,\n })};</script>`,\n );\n res.send(html);\n });\n\n // Serve the AI prompt header dynamically so it can be edited externally.\n // `reportHeader` in adapter-tester.config.json overrides the file entirely.\n app.get(\"/report-header.txt\", (req, res) => {\n if (engineConfig.reportHeader !== undefined) {\n res.type(\"text/plain\").send(engineConfig.reportHeader);\n return;\n }\n try {\n res.type(\"text/plain\").send(readFileSync(headerPath, \"utf8\"));\n } catch {\n res.status(500).send(\"Error loading report-header.txt\");\n }\n });\n\n // Proxy everything else to this project's own Storybook, preserving\n // absolute paths (e.g. /@vite/client) so HMR keeps working same-origin.\n // This is the pane that drives the sync and shows Storybook's nav sidebar.\n app.use(\n \"/\",\n createProxyMiddleware({\n target: targetRunning.url,\n changeOrigin: true,\n ws: true,\n }),\n );\n\n let cleaningUp = false;\n const cleanup = () => {\n if (cleaningUp) return;\n cleaningUp = true;\n console.log(\n \"\\n[Dev Launcher] Shutting down Dev Mode server and spawned Storybooks...\",\n );\n for (const child of spawned) child.kill(\"SIGINT\");\n process.exit(0);\n };\n process.on(\"SIGINT\", cleanup);\n process.on(\"SIGTERM\", cleanup);\n\n app.listen(devPort, () => {\n console.log(`\n====================================================\n🚀 Adapter Dev Mode proxy running at:\n http://localhost:${devPort}\n====================================================\n`);\n openBrowser(`http://localhost:${devPort}`);\n });\n}\n","import { Ajv } from \"ajv\";\nimport * as ajvFormatsModule from \"ajv-formats\";\nimport type { FormatsPlugin } from \"ajv-formats\";\nimport schema from \"./adapter-tester.schema.json\" with { type: \"json\" };\n\n// ajv-formats ships an ESM-style `export default` on a CJS build with no\n// `\"type\"` field, which under `moduleResolution: NodeNext` TS resolves to\n// the raw module namespace instead of unwrapping the default — a known\n// ajv-formats/TS interop gap, not a version mismatch.\nconst addFormats = (ajvFormatsModule as unknown as { default: FormatsPlugin })\n .default;\n\nconst ajv = new Ajv({ allErrors: true, strict: true });\naddFormats(ajv);\nconst validate = ajv.compile(schema);\n\n/**\n * Validates a parsed `adapter-tester.config.json` against\n * `adapter-tester.schema.json`. Throws with every violation listed — callers\n * must not silently coerce or drop invalid fields.\n */\nexport function validateFileConfig(data: unknown, path: string): void {\n if (validate(data)) return;\n\n const errors = (validate.errors ?? [])\n .map((error) => {\n const extra = error.params?.additionalProperty\n ? ` '${error.params.additionalProperty}'`\n : \"\";\n return ` - ${error.instancePath || \"root\"} ${error.message}${extra}`;\n })\n .join(\"\\n\");\n throw new Error(`Invalid ${path}:\\n${errors}`);\n}\n","import { existsSync, readFileSync } from \"node:fs\";\nimport { join, resolve } from \"node:path\";\nimport type {\n AdapterTesterConfig,\n SourceOfTruthGoldenLocation,\n StoryOverride,\n} from \"./config.js\";\nimport type { HarnessWebServerConfig } from \"./harness/mantineSourceOfTruth.js\";\nimport { mantineSourceOfTruthWebServer } from \"./harness/mantineSourceOfTruth.js\";\nimport { validateFileConfig } from \"./validateFileConfig.js\";\n\nconst MANTINE_ADAPTER_PACKAGE_NAME = \"@recursica/mantine-adapter\";\n\nexport const CONFIG_FILE_NAME = \"adapter-tester.config.json\";\nconst DEFAULT_STORYBOOK_COMMAND = \"npm run storybook\";\nconst DEFAULT_STORYBOOK_PORT = 6006;\nconst DEFAULT_SOURCE_OF_TRUTH_PORT = 6011;\nconst DEFAULT_SOURCE_OF_TRUTH_NAME = \"Mantine\";\nconst DEFAULT_GOLDEN_THRESHOLD_PIXELS = 10;\nconst DEFAULT_SOURCE_OF_TRUTH_THRESHOLD_PIXELS = 3500;\n\ninterface StorybookTargetFileConfig {\n /** First-guess port only, not authoritative — the real port is\n * auto-detected from this Storybook's own startup output, since Storybook\n * silently falls back to an OS-assigned port whenever this one is taken.\n * Auto-detected from this project's own `scripts.storybook` (a `-p\n * <port>`/`--port <port>` flag) when omitted, falling back to 6006. */\n port?: number;\n /** Command that boots the target's Storybook. Defaults to `npm run storybook`. */\n command?: string;\n /** Directory the command runs in, relative to the config file. Defaults to \".\" */\n cwd?: string;\n}\n\ninterface MantineHarnessSourceOfTruthFileConfig {\n /** Default mode: boots a throwaway harness that installs the published\n * `@recursica/mantine-adapter` from npm — no monorepo checkout required. */\n type?: \"mantine-harness\";\n /** First-guess port only, not authoritative — see `HarnessWebServerConfig.port`. */\n port?: number;\n mantineAdapterVersion?: string;\n storybookTemplateVersion?: string;\n}\n\ninterface UrlSourceOfTruthFileConfig {\n /** Non-standard mode: points at an already-addressable Storybook — e.g. a\n * sibling workspace package's own Storybook inside this monorepo. */\n type: \"url\";\n name?: string;\n /** First-guess port only, not authoritative — see `HarnessWebServerConfig.port`.\n * Defaults to 6011. */\n port?: number;\n command?: string;\n cwd?: string;\n}\n\ntype SourceOfTruthFileConfig =\n | MantineHarnessSourceOfTruthFileConfig\n | UrlSourceOfTruthFileConfig;\n\nexport interface AdapterTesterFileConfig {\n /** Label for this project's own target. Defaults to the unscoped name in\n * this project's package.json (e.g. \"@recursica/mui-adapter\" -> \"mui-adapter\"). */\n name?: string;\n storybook?: StorybookTargetFileConfig;\n sourceOfTruth?: SourceOfTruthFileConfig;\n goldenThresholdPixels?: number;\n sourceOfTruthThresholdPixels?: number;\n stories?: Record<string, StoryOverride>;\n excludeTitlePrefixes?: string[];\n /** Overrides the AI report header text shown in Dev Mode's \"Full Report\"\n * export. Defaults to the contents of `report-header.txt`. */\n reportHeader?: string;\n /**\n * True only for the source-of-truth adapter's own config (mantine-adapter).\n * Skips `sourceOfTruth` entirely — there's nothing above it to diverge\n * from — and runs the own-drift golden check standalone, against just this\n * project's own Storybook. Defaults to false.\n */\n isSourceOfTruthAdapter?: boolean;\n}\n\nexport interface ResolvedAdapterTesterConfig {\n engineConfig: AdapterTesterConfig;\n webServers: HarnessWebServerConfig[];\n}\n\nexport interface ResolveConfigOverrides {\n /** From `--source-of-truth-version`. Overrides `sourceOfTruth.mantineAdapterVersion`. */\n mantineAdapterVersion?: string;\n}\n\nfunction readOwnPackageJson(cwd: string): any {\n const path = join(cwd, \"package.json\");\n if (!existsSync(path)) {\n throw new Error(\n `No package.json found in ${cwd} — run adapter-tester from the root of the project being tested.`,\n );\n }\n return JSON.parse(readFileSync(path, \"utf8\"));\n}\n\nfunction detectOwnPort(cwd: string): number {\n const pkg = readOwnPackageJson(cwd);\n const storybookScript = pkg.scripts?.storybook as string | undefined;\n const match = storybookScript?.match(/(?:-p|--port)[ =](\\d+)/);\n return match ? Number(match[1]) : DEFAULT_STORYBOOK_PORT;\n}\n\nfunction detectOwnName(cwd: string): string {\n const pkg = readOwnPackageJson(cwd);\n const name = pkg.name as string | undefined;\n return name ? name.split(\"/\").pop()! : \"Adapter\";\n}\n\nfunction loadFileConfig(cwd: string): AdapterTesterFileConfig {\n const path = join(cwd, CONFIG_FILE_NAME);\n if (!existsSync(path)) {\n return {};\n }\n const data = JSON.parse(readFileSync(path, \"utf8\"));\n validateFileConfig(data, path);\n return data;\n}\n\n/**\n * Loads `adapter-tester.config.json` from `cwd` (or falls back to defaults\n * when the file doesn't exist) and resolves it into the engine config\n * `resolveVisualRegressionPlan` consumes plus the Playwright `webServer` entries\n * needed to boot both sides of the comparison.\n *\n * Default mode (no `sourceOfTruth`/`storybook` set): compares this project's\n * own Storybook against a throwaway Mantine harness — no monorepo checkout\n * required. Set `sourceOfTruth.type: \"url\"` for the non-standard mode used\n * to compare sibling workspace packages inside this monorepo.\n *\n * `overrides.mantineAdapterVersion` (from `--source-of-truth-version`) pins\n * the mantine-harness install/golden-fetch version for this run, overriding\n * `sourceOfTruth.mantineAdapterVersion`. Throws if passed together with\n * `isSourceOfTruthAdapter` or `sourceOfTruth.type: \"url\"` — neither has a\n * version to pin.\n */\nexport function resolveConfig(\n cwd: string,\n overrides: ResolveConfigOverrides = {},\n): ResolvedAdapterTesterConfig {\n const file = loadFileConfig(cwd);\n const isSourceOfTruthAdapter = file.isSourceOfTruthAdapter ?? false;\n\n if (overrides.mantineAdapterVersion && isSourceOfTruthAdapter) {\n throw new Error(\n \"--source-of-truth-version has no effect on the source-of-truth adapter's own config (isSourceOfTruthAdapter: true) — there's nothing to pin a version for.\",\n );\n }\n\n const ownName = file.name ?? detectOwnName(cwd);\n const ownPort = file.storybook?.port ?? detectOwnPort(cwd);\n const ownCommand = file.storybook?.command ?? DEFAULT_STORYBOOK_COMMAND;\n const ownCwd = resolve(cwd, file.storybook?.cwd ?? \".\");\n const ownWebServer: HarnessWebServerConfig = {\n command: ownCommand,\n port: ownPort,\n cwd: ownCwd,\n reuseExistingServer: !process.env.CI,\n cacheFile: join(cwd, \".adapter-tester\", \"last-port-own.json\"),\n timeout: 120 * 1000,\n };\n\n const sharedEngineConfig = {\n goldenThresholdPixels:\n file.goldenThresholdPixels ?? DEFAULT_GOLDEN_THRESHOLD_PIXELS,\n sourceOfTruthThresholdPixels:\n file.sourceOfTruthThresholdPixels ??\n DEFAULT_SOURCE_OF_TRUTH_THRESHOLD_PIXELS,\n stories: file.stories,\n excludeTitlePrefixes: file.excludeTitlePrefixes,\n reportHeader: file.reportHeader,\n // Keyed off `ownCwd`, not `cwd` — the project actually being tested, not\n // wherever the config file happens to live. Matters whenever\n // `storybook.cwd` points at a sibling package: its goldens must resolve\n // to that package's own `test/golden/` (the same directory used when\n // that package runs adapter-tester directly), not a directory under\n // wherever this config file lives.\n goldenDir: join(ownCwd, \"test\", \"golden\"),\n isSourceOfTruthAdapter,\n // Overwritten by the CLI from --update-golden/--approve-divergence.\n goldenMode: \"check\" as const,\n // Overwritten by the CLI from --divergence-only.\n checkMode: \"own\" as const,\n };\n\n // The source-of-truth adapter's own config has nothing above it to\n // diverge from — no second target, no harness/webServer for it at all.\n if (isSourceOfTruthAdapter) {\n return {\n engineConfig: {\n ...sharedEngineConfig,\n targets: [{ name: ownName, url: `http://localhost:${ownPort}` }],\n },\n webServers: [ownWebServer],\n };\n }\n\n const sourceOfTruth = file.sourceOfTruth ?? {\n type: \"mantine-harness\" as const,\n };\n\n let sourceOfTruthName: string;\n let sourceOfTruthPort: number;\n let sourceOfTruthWebServer: HarnessWebServerConfig;\n let sourceOfTruthGolden: SourceOfTruthGoldenLocation;\n\n if (sourceOfTruth.type === \"url\") {\n if (overrides.mantineAdapterVersion) {\n throw new Error(\n '--source-of-truth-version has no effect with sourceOfTruth.type: \"url\" — that mode reads a sibling package\\'s local checkout directly, not a published version.',\n );\n }\n sourceOfTruthName = sourceOfTruth.name ?? DEFAULT_SOURCE_OF_TRUTH_NAME;\n sourceOfTruthPort = sourceOfTruth.port ?? DEFAULT_SOURCE_OF_TRUTH_PORT;\n const sourceOfTruthCwd = resolve(cwd, sourceOfTruth.cwd ?? \".\");\n sourceOfTruthWebServer = {\n command: sourceOfTruth.command ?? DEFAULT_STORYBOOK_COMMAND,\n port: sourceOfTruthPort,\n cwd: sourceOfTruthCwd,\n reuseExistingServer: !process.env.CI,\n cacheFile: join(cwd, \".adapter-tester\", \"last-port-source-of-truth.json\"),\n timeout: 120 * 1000,\n };\n // Sibling package already checked out locally — read its golden files\n // directly, including any uncommitted local changes. No install, no\n // network call.\n sourceOfTruthGolden = {\n type: \"local\",\n dir: join(sourceOfTruthCwd, \"test\", \"golden\"),\n };\n } else {\n sourceOfTruthName = DEFAULT_SOURCE_OF_TRUTH_NAME;\n sourceOfTruthPort = sourceOfTruth.port ?? DEFAULT_SOURCE_OF_TRUTH_PORT;\n const mantineAdapterVersion =\n overrides.mantineAdapterVersion ?? sourceOfTruth.mantineAdapterVersion;\n sourceOfTruthWebServer = mantineSourceOfTruthWebServer({\n dir: join(cwd, \".adapter-tester/mantine-harness\"),\n port: sourceOfTruthPort,\n mantineAdapterVersion,\n storybookTemplateVersion: sourceOfTruth.storybookTemplateVersion,\n });\n // No local checkout — resolve the installed version against the npm\n // registry and fetch that version's golden files from the public repo.\n // Never needs `sourceOfTruthWebServer` above; the golden check on its\n // own doesn't boot a second Storybook at all (see cli.ts).\n sourceOfTruthGolden = {\n type: \"npm\",\n packageName: MANTINE_ADAPTER_PACKAGE_NAME,\n versionSpec: mantineAdapterVersion ?? \"latest\",\n cacheDir: join(cwd, \".adapter-tester/mantine-golden-cache\"),\n };\n }\n\n return {\n engineConfig: {\n ...sharedEngineConfig,\n targets: [\n {\n name: sourceOfTruthName,\n url: `http://localhost:${sourceOfTruthPort}`,\n sourceOfTruth: true,\n },\n { name: ownName, url: `http://localhost:${ownPort}` },\n ],\n sourceOfTruthGolden,\n },\n // [sourceOfTruth, own] — Dev Mode needs both; the automated golden run\n // (cli.ts) only ever boots the last entry, since its divergence check\n // reads stored golden files, not a live source-of-truth page.\n webServers: [sourceOfTruthWebServer, ownWebServer],\n };\n}\n","import { spawnSync } from \"node:child_process\";\nimport { mkdirSync, writeFileSync } from \"node:fs\";\nimport { dirname, join } from \"node:path\";\nimport { fileURLToPath, pathToFileURL } from \"node:url\";\nimport type { AdapterTesterConfig } from \"./config.js\";\nimport { startDevServer } from \"./devServer.js\";\nimport { resolveConfig } from \"./fileConfig.js\";\nimport type { HarnessWebServerConfig } from \"./harness/mantineSourceOfTruth.js\";\nimport { launchAndDetectStorybook, toLaunchTarget } from \"./portDiscovery.js\";\n\n// `dist/testing.js` is always a sibling of this file — both inside a\n// consumer's node_modules/@recursica/adapter-tester/dist and inside this\n// monorepo's own packages/adapter-tester/dist when self-hosting — so the\n// generated spec below can reach it without depending on how the package\n// itself resolves at import time.\nconst distDir = dirname(fileURLToPath(import.meta.url));\nconst testingEntry = pathToFileURL(join(distDir, \"testing.js\")).href;\n\n// `--source-of-truth-version <value>` takes a value, unlike every other own\n// flag below — pulled out of argv first so the boolean flags/passthrough\n// logic never has to know it exists.\nconst args = process.argv.slice(2);\nlet sourceOfTruthVersion: string | undefined;\nconst sourceOfTruthVersionFlagIndex = args.indexOf(\"--source-of-truth-version\");\nif (sourceOfTruthVersionFlagIndex !== -1) {\n const value = args[sourceOfTruthVersionFlagIndex + 1];\n if (value === undefined || value.startsWith(\"--\")) {\n throw new Error(\n \"--source-of-truth-version requires a value, e.g. --source-of-truth-version 0.53.0\",\n );\n }\n sourceOfTruthVersion = value;\n args.splice(sourceOfTruthVersionFlagIndex, 2);\n}\n\nconst cwd = process.cwd();\nconst { engineConfig, webServers } = resolveConfig(cwd, {\n mantineAdapterVersion: sourceOfTruthVersion,\n});\n\nif (args.includes(\"--update-golden\")) {\n engineConfig.goldenMode = \"update-golden\";\n} else if (args.includes(\"--approve-divergence\")) {\n engineConfig.goldenMode = \"approve-divergence\";\n}\n\nif (args.includes(\"--divergence-only\")) {\n if (engineConfig.isSourceOfTruthAdapter) {\n throw new Error(\n \"--divergence-only has nothing to diverge from — isSourceOfTruthAdapter is true in this project's adapter-tester.config.json.\",\n );\n }\n engineConfig.checkMode = \"divergence\";\n} else if (engineConfig.goldenMode === \"approve-divergence\") {\n throw new Error(\n \"--approve-divergence only makes sense with --divergence-only — there's nothing to approve without the divergence check running.\",\n );\n}\n\nif (args.includes(\"--dry-run\")) {\n console.log(JSON.stringify({ engineConfig, webServers }, null, 2));\n process.exit(0);\n}\n\n// Any arg besides our own flags is passed straight through to `playwright\n// test` — e.g. `npm run adapter-tester:automated -- --grep \"Toast\"` to scope\n// a run to matching stories, instead of every invocation running the full\n// suite. Our own flags are consumed above, not forwarded — Playwright itself\n// doesn't know about them.\nconst OWN_FLAGS = new Set([\n \"--dry-run\",\n \"--serve\",\n \"--update-golden\",\n \"--approve-divergence\",\n \"--divergence-only\",\n]);\nconst passthroughArgs = args.filter((arg) => !OWN_FLAGS.has(arg));\n\n// The bundled build target doesn't support top-level await, so the async\n// work (launching Storybook and detecting its real port) lives in main().\nmain().catch((err) => {\n console.error(err);\n process.exitCode = 1;\n});\n\nasync function main(): Promise<void> {\n if (args.includes(\"--serve\")) {\n if (engineConfig.isSourceOfTruthAdapter) {\n throw new Error(\n \"Dev Mode (--serve) has nothing to sync this project's Storybook against — isSourceOfTruthAdapter is true in this project's adapter-tester.config.json.\",\n );\n }\n // Dual-Storybook interactive Dev Mode — no Playwright, no screenshots.\n // Used by the `adapter-tester` npm script.\n await startDevServer(engineConfig, webServers);\n } else {\n // The golden-image checks never need the source-of-truth adapter's own\n // Storybook running — the divergence check reads its stored golden files,\n // not a live page — so only the last (own) webServer is booted here. Dev\n // Mode above is the one thing that still needs both.\n const ownWebServer = webServers.at(-1);\n if (!ownWebServer) {\n throw new Error(\"resolveConfig() returned no webServers to boot.\");\n }\n await runAutomated(ownWebServer, engineConfig);\n }\n}\n\n/**\n * Boots this project's own Storybook (auto-detecting the port it actually\n * lands on — see portDiscovery.ts), generates a throwaway Playwright config\n * + spec under `.adapter-tester/run/`, and runs the automated pixel-diff\n * suite against it. Used by the `adapter-tester:automated` npm script.\n *\n * Playwright's own `webServer` option can't be used here — it only knows how\n * to poll a port/URL decided *before* the command it spawns runs, but\n * Storybook silently falls back to a different, OS-assigned port whenever\n * its configured one is taken. So this boots and waits for Storybook itself,\n * then points the generated config straight at whatever URL it actually\n * reports.\n */\nasync function runAutomated(\n server: HarnessWebServerConfig,\n config: AdapterTesterConfig,\n): Promise<void> {\n const runDir = join(cwd, \".adapter-tester/run\");\n mkdirSync(runDir, { recursive: true });\n\n const ownTarget = config.targets.at(-1);\n if (!ownTarget) {\n throw new Error(\"resolveConfig() returned no targets to check.\");\n }\n const { url, process: spawned } = await launchAndDetectStorybook(\n toLaunchTarget(ownTarget.name, server),\n );\n ownTarget.url = url;\n\n writeFileSync(\n join(runDir, \"playwright.config.js\"),\n `// Generated by \\`adapter-tester\\` — do not edit, regenerated on every run.\nimport { defineConfig, devices } from \"@playwright/test\";\n\nexport default defineConfig({\n testDir: ${JSON.stringify(runDir)},\n // Each golden check only reads/writes its own story's manifest.json entry,\n // under a lock, so concurrent workers never race each other (see\n // \\`updateManifestEntry\\`). Defaults to 1 worker (1 Chromium instance) to\n // avoid exhausting memory running the full suite; override with\n // \\`--workers <n>\\` (forwarded straight through to Playwright) to parallelize.\n workers: 1,\n fullyParallel: true,\n forbidOnly: !!process.env.CI,\n retries: process.env.CI ? 2 : 0,\n reporter: [[\"html\", { open: \"never\" }], [\"list\"]],\n use: { trace: \"on-first-retry\" },\n projects: [{ name: \"chromium\", use: { ...devices[\"Desktop Chrome\"] } }],\n // No webServer entry — this project's own Storybook is already running by\n // the time this config is used (see runAutomated() in cli.ts).\n});\n`,\n );\n\n writeFileSync(\n join(runDir, \"visual-regression.spec.js\"),\n `// Generated by \\`adapter-tester\\` — do not edit, regenerated on every run.\nimport { test, expect } from \"@playwright/test\";\nimport { resolveVisualRegressionPlan } from ${JSON.stringify(testingEntry)};\n\n// \\`test.describe\\`/\\`test\\` are called here, not inside resolveVisualRegressionPlan,\n// so Playwright's HTML report groups the suite under this file instead of a\n// sourcemapped path into adapter-tester's own library code.\nconst { ownTargetName, suiteLabel, stories, missingFromSourceOfTruth, checkStory } =\n await resolveVisualRegressionPlan(${JSON.stringify(config, null, 2)});\n\ntest.describe(\\`\\${ownTargetName} — \\${suiteLabel}\\`, () => {\n if (missingFromSourceOfTruth.length > 0) {\n test(\"story parity with source of truth\", () => {\n expect(\n missingFromSourceOfTruth,\n \\`\\${missingFromSourceOfTruth.length} stor(y/ies) exist in the source of truth but are missing here. Add the missing story, or mark it \\\\\\`exclude: true\\\\\\` under \\\\\\`stories\\\\\\` in adapter-tester.config.json if intentional.\\`,\n ).toEqual([]);\n });\n }\n for (const story of stories) {\n test(story.id, async ({ browser }, testInfo) => {\n await checkStory(story, browser, testInfo);\n });\n }\n});\n`,\n );\n\n try {\n const result = spawnSync(\n \"npx\",\n [\n \"playwright\",\n \"test\",\n \"--config\",\n join(runDir, \"playwright.config.js\"),\n ...passthroughArgs,\n ],\n { stdio: \"inherit\", cwd, shell: process.platform === \"win32\" },\n );\n process.exitCode = result.status ?? 1;\n } finally {\n // Only tear down the Storybook we spawned — an instance we reused via\n // the last-known-port cache was already running before we got here, and\n // should stay running after.\n spawned?.kill(\"SIGTERM\");\n }\n}\n"],"names":["ANSI_PATTERN","LOCAL_URL_PATTERN","isPortActive","port","resolve","socket","net","readCachedPort","cacheFile","readFileSync","writeCachedPort","mkdirSync","dirname","writeFileSync","spawnAndDetect","target","timeoutMs","reject","child","spawn","settled","timer","handleOutput","data","isError","text","line","label","match","url","_a","_b","err","code","toLaunchTarget","name","server","launchAndDetectStorybook","cachedPort","distDir","fileURLToPath","openBrowser","startCmd","startDevServer","engineConfig","webServers","options","sourceOfTruth","sourceOfTruthServer","targetServer","devPort","sourceOfTruthRunning","targetRunning","spawned","app","express","publicDir","join","headerPath","req","res","next","html","createProxyMiddleware","cleaningUp","cleanup","addFormats","ajvFormatsModule.default","ajv","Ajv","validate","schema","validateFileConfig","path","errors","error","extra","MANTINE_ADAPTER_PACKAGE_NAME","CONFIG_FILE_NAME","DEFAULT_STORYBOOK_COMMAND","DEFAULT_STORYBOOK_PORT","DEFAULT_SOURCE_OF_TRUTH_PORT","DEFAULT_SOURCE_OF_TRUTH_NAME","DEFAULT_GOLDEN_THRESHOLD_PIXELS","DEFAULT_SOURCE_OF_TRUTH_THRESHOLD_PIXELS","readOwnPackageJson","cwd","existsSync","detectOwnPort","storybookScript","detectOwnName","loadFileConfig","resolveConfig","overrides","file","isSourceOfTruthAdapter","ownName","ownPort","ownCommand","ownCwd","_c","ownWebServer","sharedEngineConfig","sourceOfTruthName","sourceOfTruthPort","sourceOfTruthWebServer","sourceOfTruthGolden","sourceOfTruthCwd","mantineAdapterVersion","mantineSourceOfTruthWebServer","testingEntry","pathToFileURL","args","sourceOfTruthVersion","sourceOfTruthVersionFlagIndex","value","OWN_FLAGS","passthroughArgs","arg","main","runAutomated","config","runDir","ownTarget","result","spawnSync"],"mappings":";;;;;;;;;;AA2CA,MAAMA,IAAe,mBACfC,IAAoB;AA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,QAAA;AAAA,IAAQ;AAE/D,YAAQ,WAAWsC,EAAO,UAAU;AAAA,EACtC,UAAA;AAIE,IAAAvE,KAAA,QAAAA,EAAS,KAAK;AAAA,EAChB;AACF;"}
|
package/dist/config.d.ts
CHANGED
|
@@ -95,6 +95,9 @@ export interface AdapterTesterConfig {
|
|
|
95
95
|
goldenMode: GoldenMode;
|
|
96
96
|
/** Set by the CLI from `--divergence-only`. Defaults to `"own"`. */
|
|
97
97
|
checkMode: CheckMode;
|
|
98
|
+
/** Overrides the AI report header text (normally read from
|
|
99
|
+
* `report-header.txt`) shown in Dev Mode's "Full Report" export. */
|
|
100
|
+
reportHeader?: string;
|
|
98
101
|
}
|
|
99
102
|
export declare function defineAdapterTesterConfig(config: AdapterTesterConfig): AdapterTesterConfig;
|
|
100
103
|
export declare function getSourceOfTruth(config: AdapterTesterConfig): AdapterTarget;
|
package/dist/config.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,aAAa;IAC5B,sFAAsF;IACtF,IAAI,EAAE,MAAM,CAAC;IACb,+DAA+D;IAC/D,GAAG,EAAE,MAAM,CAAC;IACZ;;;OAGG;IACH,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB;AAED;;mEAEmE;AACnE,MAAM,MAAM,2BAA2B,GACnC;IACE;+EAC2E;IAC3E,IAAI,EAAE,OAAO,CAAC;IACd,+EAA+E;IAC/E,GAAG,EAAE,MAAM,CAAC;CACb,GACD;IACE;;gFAE4E;IAC5E,IAAI,EAAE,KAAK,CAAC;IACZ,WAAW,EAAE,MAAM,CAAC;IACpB,0EAA0E;IAC1E,WAAW,EAAE,MAAM,CAAC;IACpB,uEAAuE;IACvE,QAAQ,EAAE,MAAM,CAAC;CAClB,CAAC;AAEN,MAAM,MAAM,UAAU,GAAG,OAAO,GAAG,eAAe,GAAG,oBAAoB,CAAC;AAE1E;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+1 @@
|
|
|
1
|
-
{"version":3,"file":"devServer.d.ts","sourceRoot":"","sources":["../src/devServer.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AACvD,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,mCAAmC,CAAC;AAkChF,MAAM,WAAW,gBAAgB;IAC/B,sEAAsE;IACtE,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,wBAAsB,cAAc,CAClC,YAAY,EAAE,mBAAmB,EACjC,UAAU,EAAE,sBAAsB,EAAE,EACpC,OAAO,GAAE,gBAAqB,GAC7B,OAAO,CAAC,IAAI,CAAC,
|
|
1
|
+
{"version":3,"file":"devServer.d.ts","sourceRoot":"","sources":["../src/devServer.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AACvD,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,mCAAmC,CAAC;AAkChF,MAAM,WAAW,gBAAgB;IAC/B,sEAAsE;IACtE,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,wBAAsB,cAAc,CAClC,YAAY,EAAE,mBAAmB,EACjC,UAAU,EAAE,sBAAsB,EAAE,EACpC,OAAO,GAAE,gBAAqB,GAC7B,OAAO,CAAC,IAAI,CAAC,CA2Gf"}
|
package/dist/fileConfig.d.ts
CHANGED
|
@@ -44,6 +44,9 @@ export interface AdapterTesterFileConfig {
|
|
|
44
44
|
sourceOfTruthThresholdPixels?: number;
|
|
45
45
|
stories?: Record<string, StoryOverride>;
|
|
46
46
|
excludeTitlePrefixes?: string[];
|
|
47
|
+
/** Overrides the AI report header text shown in Dev Mode's "Full Report"
|
|
48
|
+
* export. Defaults to the contents of `report-header.txt`. */
|
|
49
|
+
reportHeader?: string;
|
|
47
50
|
/**
|
|
48
51
|
* True only for the source-of-truth adapter's own config (mantine-adapter).
|
|
49
52
|
* Skips `sourceOfTruth` entirely — there's nothing above it to diverge
|
package/dist/fileConfig.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fileConfig.d.ts","sourceRoot":"","sources":["../src/fileConfig.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,mBAAmB,EAEnB,aAAa,EACd,MAAM,aAAa,CAAC;AACrB,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,mCAAmC,CAAC;AAMhF,eAAO,MAAM,gBAAgB,+BAA+B,CAAC;AAQ7D,UAAU,yBAAyB;IACjC;;;;2EAIuE;IACvE,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,kFAAkF;IAClF,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,kFAAkF;IAClF,GAAG,CAAC,EAAE,MAAM,CAAC;CACd;AAED,UAAU,qCAAqC;IAC7C;gFAC4E;IAC5E,IAAI,CAAC,EAAE,iBAAiB,CAAC;IACzB,oFAAoF;IACpF,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,qBAAqB,CAAC,EAAE,MAAM,CAAC;IAC/B,wBAAwB,CAAC,EAAE,MAAM,CAAC;CACnC;AAED,UAAU,0BAA0B;IAClC;yEACqE;IACrE,IAAI,EAAE,KAAK,CAAC;IACZ,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;2BACuB;IACvB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,GAAG,CAAC,EAAE,MAAM,CAAC;CACd;AAED,KAAK,uBAAuB,GACxB,qCAAqC,GACrC,0BAA0B,CAAC;AAE/B,MAAM,WAAW,uBAAuB;IACtC;uFACmF;IACnF,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,yBAAyB,CAAC;IACtC,aAAa,CAAC,EAAE,uBAAuB,CAAC;IACxC,qBAAqB,CAAC,EAAE,MAAM,CAAC;IAC/B,4BAA4B,CAAC,EAAE,MAAM,CAAC;IACtC,OAAO,CAAC,EAAE,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,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,GAAG,CAAC,EAAE,MAAM,CAAC;CACd;AAED,KAAK,uBAAuB,GACxB,qCAAqC,GACrC,0BAA0B,CAAC;AAE/B,MAAM,WAAW,uBAAuB;IACtC;uFACmF;IACnF,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,yBAAyB,CAAC;IACtC,aAAa,CAAC,EAAE,uBAAuB,CAAC;IACxC,qBAAqB,CAAC,EAAE,MAAM,CAAC;IAC/B,4BAA4B,CAAC,EAAE,MAAM,CAAC;IACtC,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC;IACxC,oBAAoB,CAAC,EAAE,MAAM,EAAE,CAAC;IAChC;kEAC8D;IAC9D,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB;;;;;OAKG;IACH,sBAAsB,CAAC,EAAE,OAAO,CAAC;CAClC;AAED,MAAM,WAAW,2BAA2B;IAC1C,YAAY,EAAE,mBAAmB,CAAC;IAClC,UAAU,EAAE,sBAAsB,EAAE,CAAC;CACtC;AAED,MAAM,WAAW,sBAAsB;IACrC,yFAAyF;IACzF,qBAAqB,CAAC,EAAE,MAAM,CAAC;CAChC;AAmCD;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,aAAa,CAC3B,GAAG,EAAE,MAAM,EACX,SAAS,GAAE,sBAA2B,GACrC,2BAA2B,CAoI7B"}
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":["../src/config.ts"],"sourcesContent":["export interface AdapterTarget {\n /** Human-readable name used in test titles, report labels, and artifact filenames. */\n name: string;\n /** Base URL the target's Storybook instance is served from. */\n url: string;\n /**\n * Marks this target as the visual/token source of truth every other target\n * is compared against. Exactly one target in a config must set this true.\n */\n sourceOfTruth?: boolean;\n}\n\n/** How `resolveVisualRegressionPlan` reaches the source-of-truth adapter's (mantine)\n * own golden images, for the divergence check. Never involves booting a\n * Storybook — both `readImage` targets are plain files on disk. */\nexport type SourceOfTruthGoldenLocation =\n | {\n /** Sibling package already checked out locally (this monorepo's own\n * `sourceOfTruth.type: \"url\"` mode) — read its `test/golden/` directly. */\n type: \"local\";\n /** Absolute path to the source-of-truth adapter's `test/golden/` directory. */\n dir: string;\n }\n | {\n /** No local checkout (the default, standalone-repo mode) — resolve the\n * installed version against the npm registry, then fetch that git tag's\n * `test/golden/` from the public GitHub repo, caching what's downloaded. */\n type: \"npm\";\n packageName: string;\n /** npm version/dist-tag to resolve, e.g. \"latest\" or a pinned version. */\n versionSpec: string;\n /** Directory downloaded manifest/images are cached in between runs. */\n cacheDir: string;\n };\n\nexport type GoldenMode = \"check\" | \"update-golden\" | \"approve-divergence\";\n\n/**\n * Which check(s) a run performs. `\"own\"` (the default) is what a normal,\n * fast, no-network run does: this project's own live render vs. its own\n * committed golden images. `\"divergence\"` is the separate, opt-in check\n * against the source-of-truth adapter's published golden images.\n */\nexport type CheckMode = \"own\" | \"divergence\";\n\nexport interface StoryOverride {\n /** Diff threshold override for this story's own-drift check. Overrides\n * `goldenThresholdPixels`. */\n goldenThreshold?: number;\n /** Diff threshold override for this story's source-of-truth divergence\n * check. Overrides `sourceOfTruthThresholdPixels` for components with\n * acceptable cross-library structural variation (e.g. native control\n * widgets). */\n sourceOfTruthThreshold?: number;\n /** Skip this story entirely — no own-drift check, no divergence check, no\n * golden captured. For stories with no meaningful cross-adapter counterpart. */\n exclude?: boolean;\n}\n\nexport interface AdapterTesterConfig {\n targets: AdapterTarget[];\n /** Global pixel-diff threshold for the own-drift check (this project's live\n * render vs. its own committed golden). Same library on both sides, so this\n * should stay tight. */\n goldenThresholdPixels: number;\n /** Global pixel-diff threshold for the source-of-truth divergence check\n * (this project's golden vs. the source-of-truth adapter's golden).\n * Comparing across two different component libraries has legitimate\n * structural variation, so this is expected to be much higher than\n * `goldenThresholdPixels`. Unused on the source-of-truth adapter's own\n * config (`isSourceOfTruthAdapter: true`). */\n sourceOfTruthThresholdPixels: number;\n /**\n * Per-story overrides, keyed by story id prefix (a story matches if its id\n * equals the key or starts with it). When more than one key matches, the\n * longest (most specific) key wins.\n */\n stories?: Record<string, StoryOverride>;\n /**\n * Storybook entry title categories excluded from the comparison — an\n * entry is excluded if its title equals one of these or starts with\n * `\"<value>/\"`. Defaults to [\"Theme\", \"Tokens\", \"Introduction\"]:\n * `@recursica/storybook-template`'s own default token/theme demo stories\n * (which every adapter's Storybook inherits automatically) plus each\n * adapter's own onboarding \"Introduction\" stories — neither has a\n * cross-adapter counterpart to diff against.\n */\n excludeTitlePrefixes?: string[];\n /** Absolute path to this project's own `test/golden/` directory — where\n * golden PNGs and `manifest.json` are stored, committed to git. */\n goldenDir: string;\n /**\n * True only for the source-of-truth adapter's own config (mantine). It has\n * nothing above it to diverge from, so the divergence check is skipped\n * entirely and `sourceOfTruthGolden` is ignored.\n */\n isSourceOfTruthAdapter: boolean;\n /** How to reach the source-of-truth's golden images. Required unless\n * `isSourceOfTruthAdapter` is true. */\n sourceOfTruthGolden?: SourceOfTruthGoldenLocation;\n /** Set by the CLI from `--update-golden`/`--approve-divergence`. Defaults to `\"check\"`. */\n goldenMode: GoldenMode;\n /** Set by the CLI from `--divergence-only`. Defaults to `\"own\"`. */\n checkMode: CheckMode;\n}\n\nexport function defineAdapterTesterConfig(\n config: AdapterTesterConfig,\n): AdapterTesterConfig {\n const sourceOfTruthCount = config.targets.filter(\n (target) => target.sourceOfTruth,\n ).length;\n if (sourceOfTruthCount !== 1) {\n throw new Error(\n `adapter-tester config must mark exactly one target as sourceOfTruth (found ${sourceOfTruthCount})`,\n );\n }\n return config;\n}\n\nexport function getSourceOfTruth(config: AdapterTesterConfig): AdapterTarget {\n const sourceOfTruth = config.targets.find((target) => target.sourceOfTruth);\n if (!sourceOfTruth) {\n throw new Error(\"adapter-tester config has no target marked sourceOfTruth\");\n }\n return sourceOfTruth;\n}\n"],"names":["defineAdapterTesterConfig","config","sourceOfTruthCount","target","getSourceOfTruth","sourceOfTruth"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../src/config.ts"],"sourcesContent":["export interface AdapterTarget {\n /** Human-readable name used in test titles, report labels, and artifact filenames. */\n name: string;\n /** Base URL the target's Storybook instance is served from. */\n url: string;\n /**\n * Marks this target as the visual/token source of truth every other target\n * is compared against. Exactly one target in a config must set this true.\n */\n sourceOfTruth?: boolean;\n}\n\n/** How `resolveVisualRegressionPlan` reaches the source-of-truth adapter's (mantine)\n * own golden images, for the divergence check. Never involves booting a\n * Storybook — both `readImage` targets are plain files on disk. */\nexport type SourceOfTruthGoldenLocation =\n | {\n /** Sibling package already checked out locally (this monorepo's own\n * `sourceOfTruth.type: \"url\"` mode) — read its `test/golden/` directly. */\n type: \"local\";\n /** Absolute path to the source-of-truth adapter's `test/golden/` directory. */\n dir: string;\n }\n | {\n /** No local checkout (the default, standalone-repo mode) — resolve the\n * installed version against the npm registry, then fetch that git tag's\n * `test/golden/` from the public GitHub repo, caching what's downloaded. */\n type: \"npm\";\n packageName: string;\n /** npm version/dist-tag to resolve, e.g. \"latest\" or a pinned version. */\n versionSpec: string;\n /** Directory downloaded manifest/images are cached in between runs. */\n cacheDir: string;\n };\n\nexport type GoldenMode = \"check\" | \"update-golden\" | \"approve-divergence\";\n\n/**\n * Which check(s) a run performs. `\"own\"` (the default) is what a normal,\n * fast, no-network run does: this project's own live render vs. its own\n * committed golden images. `\"divergence\"` is the separate, opt-in check\n * against the source-of-truth adapter's published golden images.\n */\nexport type CheckMode = \"own\" | \"divergence\";\n\nexport interface StoryOverride {\n /** Diff threshold override for this story's own-drift check. Overrides\n * `goldenThresholdPixels`. */\n goldenThreshold?: number;\n /** Diff threshold override for this story's source-of-truth divergence\n * check. Overrides `sourceOfTruthThresholdPixels` for components with\n * acceptable cross-library structural variation (e.g. native control\n * widgets). */\n sourceOfTruthThreshold?: number;\n /** Skip this story entirely — no own-drift check, no divergence check, no\n * golden captured. For stories with no meaningful cross-adapter counterpart. */\n exclude?: boolean;\n}\n\nexport interface AdapterTesterConfig {\n targets: AdapterTarget[];\n /** Global pixel-diff threshold for the own-drift check (this project's live\n * render vs. its own committed golden). Same library on both sides, so this\n * should stay tight. */\n goldenThresholdPixels: number;\n /** Global pixel-diff threshold for the source-of-truth divergence check\n * (this project's golden vs. the source-of-truth adapter's golden).\n * Comparing across two different component libraries has legitimate\n * structural variation, so this is expected to be much higher than\n * `goldenThresholdPixels`. Unused on the source-of-truth adapter's own\n * config (`isSourceOfTruthAdapter: true`). */\n sourceOfTruthThresholdPixels: number;\n /**\n * Per-story overrides, keyed by story id prefix (a story matches if its id\n * equals the key or starts with it). When more than one key matches, the\n * longest (most specific) key wins.\n */\n stories?: Record<string, StoryOverride>;\n /**\n * Storybook entry title categories excluded from the comparison — an\n * entry is excluded if its title equals one of these or starts with\n * `\"<value>/\"`. Defaults to [\"Theme\", \"Tokens\", \"Introduction\"]:\n * `@recursica/storybook-template`'s own default token/theme demo stories\n * (which every adapter's Storybook inherits automatically) plus each\n * adapter's own onboarding \"Introduction\" stories — neither has a\n * cross-adapter counterpart to diff against.\n */\n excludeTitlePrefixes?: string[];\n /** Absolute path to this project's own `test/golden/` directory — where\n * golden PNGs and `manifest.json` are stored, committed to git. */\n goldenDir: string;\n /**\n * True only for the source-of-truth adapter's own config (mantine). It has\n * nothing above it to diverge from, so the divergence check is skipped\n * entirely and `sourceOfTruthGolden` is ignored.\n */\n isSourceOfTruthAdapter: boolean;\n /** How to reach the source-of-truth's golden images. Required unless\n * `isSourceOfTruthAdapter` is true. */\n sourceOfTruthGolden?: SourceOfTruthGoldenLocation;\n /** Set by the CLI from `--update-golden`/`--approve-divergence`. Defaults to `\"check\"`. */\n goldenMode: GoldenMode;\n /** Set by the CLI from `--divergence-only`. Defaults to `\"own\"`. */\n checkMode: CheckMode;\n /** Overrides the AI report header text (normally read from\n * `report-header.txt`) shown in Dev Mode's \"Full Report\" export. */\n reportHeader?: string;\n}\n\nexport function defineAdapterTesterConfig(\n config: AdapterTesterConfig,\n): AdapterTesterConfig {\n const sourceOfTruthCount = config.targets.filter(\n (target) => target.sourceOfTruth,\n ).length;\n if (sourceOfTruthCount !== 1) {\n throw new Error(\n `adapter-tester config must mark exactly one target as sourceOfTruth (found ${sourceOfTruthCount})`,\n );\n }\n return config;\n}\n\nexport function getSourceOfTruth(config: AdapterTesterConfig): AdapterTarget {\n const sourceOfTruth = config.targets.find((target) => target.sourceOfTruth);\n if (!sourceOfTruth) {\n throw new Error(\"adapter-tester config has no target marked sourceOfTruth\");\n }\n return sourceOfTruth;\n}\n"],"names":["defineAdapterTesterConfig","config","sourceOfTruthCount","target","getSourceOfTruth","sourceOfTruth"],"mappings":"uIA6GO,SAASA,EACdC,EACqB,CACrB,MAAMC,EAAqBD,EAAO,QAAQ,OACvCE,GAAWA,EAAO,aAAA,EACnB,OACF,GAAID,IAAuB,EACzB,MAAM,IAAI,MACR,8EAA8EA,CAAkB,GAAA,EAGpG,OAAOD,CACT,CAEO,SAASG,EAAiBH,EAA4C,CAC3E,MAAMI,EAAgBJ,EAAO,QAAQ,KAAME,GAAWA,EAAO,aAAa,EAC1E,GAAI,CAACE,EACH,MAAM,IAAI,MAAM,0DAA0D,EAE5E,OAAOA,CACT"}
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../src/config.ts"],"sourcesContent":["export interface AdapterTarget {\n /** Human-readable name used in test titles, report labels, and artifact filenames. */\n name: string;\n /** Base URL the target's Storybook instance is served from. */\n url: string;\n /**\n * Marks this target as the visual/token source of truth every other target\n * is compared against. Exactly one target in a config must set this true.\n */\n sourceOfTruth?: boolean;\n}\n\n/** How `resolveVisualRegressionPlan` reaches the source-of-truth adapter's (mantine)\n * own golden images, for the divergence check. Never involves booting a\n * Storybook — both `readImage` targets are plain files on disk. */\nexport type SourceOfTruthGoldenLocation =\n | {\n /** Sibling package already checked out locally (this monorepo's own\n * `sourceOfTruth.type: \"url\"` mode) — read its `test/golden/` directly. */\n type: \"local\";\n /** Absolute path to the source-of-truth adapter's `test/golden/` directory. */\n dir: string;\n }\n | {\n /** No local checkout (the default, standalone-repo mode) — resolve the\n * installed version against the npm registry, then fetch that git tag's\n * `test/golden/` from the public GitHub repo, caching what's downloaded. */\n type: \"npm\";\n packageName: string;\n /** npm version/dist-tag to resolve, e.g. \"latest\" or a pinned version. */\n versionSpec: string;\n /** Directory downloaded manifest/images are cached in between runs. */\n cacheDir: string;\n };\n\nexport type GoldenMode = \"check\" | \"update-golden\" | \"approve-divergence\";\n\n/**\n * Which check(s) a run performs. `\"own\"` (the default) is what a normal,\n * fast, no-network run does: this project's own live render vs. its own\n * committed golden images. `\"divergence\"` is the separate, opt-in check\n * against the source-of-truth adapter's published golden images.\n */\nexport type CheckMode = \"own\" | \"divergence\";\n\nexport interface StoryOverride {\n /** Diff threshold override for this story's own-drift check. Overrides\n * `goldenThresholdPixels`. */\n goldenThreshold?: number;\n /** Diff threshold override for this story's source-of-truth divergence\n * check. Overrides `sourceOfTruthThresholdPixels` for components with\n * acceptable cross-library structural variation (e.g. native control\n * widgets). */\n sourceOfTruthThreshold?: number;\n /** Skip this story entirely — no own-drift check, no divergence check, no\n * golden captured. For stories with no meaningful cross-adapter counterpart. */\n exclude?: boolean;\n}\n\nexport interface AdapterTesterConfig {\n targets: AdapterTarget[];\n /** Global pixel-diff threshold for the own-drift check (this project's live\n * render vs. its own committed golden). Same library on both sides, so this\n * should stay tight. */\n goldenThresholdPixels: number;\n /** Global pixel-diff threshold for the source-of-truth divergence check\n * (this project's golden vs. the source-of-truth adapter's golden).\n * Comparing across two different component libraries has legitimate\n * structural variation, so this is expected to be much higher than\n * `goldenThresholdPixels`. Unused on the source-of-truth adapter's own\n * config (`isSourceOfTruthAdapter: true`). */\n sourceOfTruthThresholdPixels: number;\n /**\n * Per-story overrides, keyed by story id prefix (a story matches if its id\n * equals the key or starts with it). When more than one key matches, the\n * longest (most specific) key wins.\n */\n stories?: Record<string, StoryOverride>;\n /**\n * Storybook entry title categories excluded from the comparison — an\n * entry is excluded if its title equals one of these or starts with\n * `\"<value>/\"`. Defaults to [\"Theme\", \"Tokens\", \"Introduction\"]:\n * `@recursica/storybook-template`'s own default token/theme demo stories\n * (which every adapter's Storybook inherits automatically) plus each\n * adapter's own onboarding \"Introduction\" stories — neither has a\n * cross-adapter counterpart to diff against.\n */\n excludeTitlePrefixes?: string[];\n /** Absolute path to this project's own `test/golden/` directory — where\n * golden PNGs and `manifest.json` are stored, committed to git. */\n goldenDir: string;\n /**\n * True only for the source-of-truth adapter's own config (mantine). It has\n * nothing above it to diverge from, so the divergence check is skipped\n * entirely and `sourceOfTruthGolden` is ignored.\n */\n isSourceOfTruthAdapter: boolean;\n /** How to reach the source-of-truth's golden images. Required unless\n * `isSourceOfTruthAdapter` is true. */\n sourceOfTruthGolden?: SourceOfTruthGoldenLocation;\n /** Set by the CLI from `--update-golden`/`--approve-divergence`. Defaults to `\"check\"`. */\n goldenMode: GoldenMode;\n /** Set by the CLI from `--divergence-only`. Defaults to `\"own\"`. */\n checkMode: CheckMode;\n}\n\nexport function defineAdapterTesterConfig(\n config: AdapterTesterConfig,\n): AdapterTesterConfig {\n const sourceOfTruthCount = config.targets.filter(\n (target) => target.sourceOfTruth,\n ).length;\n if (sourceOfTruthCount !== 1) {\n throw new Error(\n `adapter-tester config must mark exactly one target as sourceOfTruth (found ${sourceOfTruthCount})`,\n );\n }\n return config;\n}\n\nexport function getSourceOfTruth(config: AdapterTesterConfig): AdapterTarget {\n const sourceOfTruth = config.targets.find((target) => target.sourceOfTruth);\n if (!sourceOfTruth) {\n throw new Error(\"adapter-tester config has no target marked sourceOfTruth\");\n }\n return sourceOfTruth;\n}\n"],"names":["defineAdapterTesterConfig","config","sourceOfTruthCount","target","getSourceOfTruth","sourceOfTruth"],"mappings":";
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../src/config.ts"],"sourcesContent":["export interface AdapterTarget {\n /** Human-readable name used in test titles, report labels, and artifact filenames. */\n name: string;\n /** Base URL the target's Storybook instance is served from. */\n url: string;\n /**\n * Marks this target as the visual/token source of truth every other target\n * is compared against. Exactly one target in a config must set this true.\n */\n sourceOfTruth?: boolean;\n}\n\n/** How `resolveVisualRegressionPlan` reaches the source-of-truth adapter's (mantine)\n * own golden images, for the divergence check. Never involves booting a\n * Storybook — both `readImage` targets are plain files on disk. */\nexport type SourceOfTruthGoldenLocation =\n | {\n /** Sibling package already checked out locally (this monorepo's own\n * `sourceOfTruth.type: \"url\"` mode) — read its `test/golden/` directly. */\n type: \"local\";\n /** Absolute path to the source-of-truth adapter's `test/golden/` directory. */\n dir: string;\n }\n | {\n /** No local checkout (the default, standalone-repo mode) — resolve the\n * installed version against the npm registry, then fetch that git tag's\n * `test/golden/` from the public GitHub repo, caching what's downloaded. */\n type: \"npm\";\n packageName: string;\n /** npm version/dist-tag to resolve, e.g. \"latest\" or a pinned version. */\n versionSpec: string;\n /** Directory downloaded manifest/images are cached in between runs. */\n cacheDir: string;\n };\n\nexport type GoldenMode = \"check\" | \"update-golden\" | \"approve-divergence\";\n\n/**\n * Which check(s) a run performs. `\"own\"` (the default) is what a normal,\n * fast, no-network run does: this project's own live render vs. its own\n * committed golden images. `\"divergence\"` is the separate, opt-in check\n * against the source-of-truth adapter's published golden images.\n */\nexport type CheckMode = \"own\" | \"divergence\";\n\nexport interface StoryOverride {\n /** Diff threshold override for this story's own-drift check. Overrides\n * `goldenThresholdPixels`. */\n goldenThreshold?: number;\n /** Diff threshold override for this story's source-of-truth divergence\n * check. Overrides `sourceOfTruthThresholdPixels` for components with\n * acceptable cross-library structural variation (e.g. native control\n * widgets). */\n sourceOfTruthThreshold?: number;\n /** Skip this story entirely — no own-drift check, no divergence check, no\n * golden captured. For stories with no meaningful cross-adapter counterpart. */\n exclude?: boolean;\n}\n\nexport interface AdapterTesterConfig {\n targets: AdapterTarget[];\n /** Global pixel-diff threshold for the own-drift check (this project's live\n * render vs. its own committed golden). Same library on both sides, so this\n * should stay tight. */\n goldenThresholdPixels: number;\n /** Global pixel-diff threshold for the source-of-truth divergence check\n * (this project's golden vs. the source-of-truth adapter's golden).\n * Comparing across two different component libraries has legitimate\n * structural variation, so this is expected to be much higher than\n * `goldenThresholdPixels`. Unused on the source-of-truth adapter's own\n * config (`isSourceOfTruthAdapter: true`). */\n sourceOfTruthThresholdPixels: number;\n /**\n * Per-story overrides, keyed by story id prefix (a story matches if its id\n * equals the key or starts with it). When more than one key matches, the\n * longest (most specific) key wins.\n */\n stories?: Record<string, StoryOverride>;\n /**\n * Storybook entry title categories excluded from the comparison — an\n * entry is excluded if its title equals one of these or starts with\n * `\"<value>/\"`. Defaults to [\"Theme\", \"Tokens\", \"Introduction\"]:\n * `@recursica/storybook-template`'s own default token/theme demo stories\n * (which every adapter's Storybook inherits automatically) plus each\n * adapter's own onboarding \"Introduction\" stories — neither has a\n * cross-adapter counterpart to diff against.\n */\n excludeTitlePrefixes?: string[];\n /** Absolute path to this project's own `test/golden/` directory — where\n * golden PNGs and `manifest.json` are stored, committed to git. */\n goldenDir: string;\n /**\n * True only for the source-of-truth adapter's own config (mantine). It has\n * nothing above it to diverge from, so the divergence check is skipped\n * entirely and `sourceOfTruthGolden` is ignored.\n */\n isSourceOfTruthAdapter: boolean;\n /** How to reach the source-of-truth's golden images. Required unless\n * `isSourceOfTruthAdapter` is true. */\n sourceOfTruthGolden?: SourceOfTruthGoldenLocation;\n /** Set by the CLI from `--update-golden`/`--approve-divergence`. Defaults to `\"check\"`. */\n goldenMode: GoldenMode;\n /** Set by the CLI from `--divergence-only`. Defaults to `\"own\"`. */\n checkMode: CheckMode;\n /** Overrides the AI report header text (normally read from\n * `report-header.txt`) shown in Dev Mode's \"Full Report\" export. */\n reportHeader?: string;\n}\n\nexport function defineAdapterTesterConfig(\n config: AdapterTesterConfig,\n): AdapterTesterConfig {\n const sourceOfTruthCount = config.targets.filter(\n (target) => target.sourceOfTruth,\n ).length;\n if (sourceOfTruthCount !== 1) {\n throw new Error(\n `adapter-tester config must mark exactly one target as sourceOfTruth (found ${sourceOfTruthCount})`,\n );\n }\n return config;\n}\n\nexport function getSourceOfTruth(config: AdapterTesterConfig): AdapterTarget {\n const sourceOfTruth = config.targets.find((target) => target.sourceOfTruth);\n if (!sourceOfTruth) {\n throw new Error(\"adapter-tester config has no target marked sourceOfTruth\");\n }\n return sourceOfTruth;\n}\n"],"names":["defineAdapterTesterConfig","config","sourceOfTruthCount","target","getSourceOfTruth","sourceOfTruth"],"mappings":";AA6GO,SAASA,EACdC,GACqB;AACrB,QAAMC,IAAqBD,EAAO,QAAQ;AAAA,IACxC,CAACE,MAAWA,EAAO;AAAA,EAAA,EACnB;AACF,MAAID,MAAuB;AACzB,UAAM,IAAI;AAAA,MACR,8EAA8EA,CAAkB;AAAA,IAAA;AAGpG,SAAOD;AACT;AAEO,SAASG,EAAiBH,GAA4C;AAC3E,QAAMI,IAAgBJ,EAAO,QAAQ,KAAK,CAACE,MAAWA,EAAO,aAAa;AAC1E,MAAI,CAACE;AACH,UAAM,IAAI,MAAM,0DAA0D;AAE5E,SAAOA;AACT;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runVisualRegression.d.ts","sourceRoot":"","sources":["../../src/testing/runVisualRegression.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAE1D,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAcxD,UAAU,cAAc;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;CACf;AAmED;;;;wEAIwE;AACxE,MAAM,WAAW,oBAAoB;IACnC,6EAA6E;IAC7E,aAAa,EAAE,MAAM,CAAC;IACtB,iEAAiE;IACjE,UAAU,EAAE,MAAM,CAAC;IACnB,2DAA2D;IAC3D,OAAO,EAAE,cAAc,EAAE,CAAC;IAC1B;;;+EAG2E;IAC3E,wBAAwB,EAAE,MAAM,EAAE,CAAC;IACnC;;;;uDAImD;IACnD,UAAU,EAAE,CACV,KAAK,EAAE,cAAc,EACrB,OAAO,EAAE,OAAO,EAChB,QAAQ,EAAE,QAAQ,KACf,OAAO,CAAC,IAAI,CAAC,CAAC;CACpB;AAED;;;;wEAIwE;AACxE,MAAM,WAAW,oBAAoB;IACnC,6EAA6E;IAC7E,aAAa,EAAE,MAAM,CAAC;IACtB,iEAAiE;IACjE,UAAU,EAAE,MAAM,CAAC;IACnB,2DAA2D;IAC3D,OAAO,EAAE,cAAc,EAAE,CAAC;IAC1B;;;;uDAImD;IACnD,UAAU,EAAE,CACV,KAAK,EAAE,cAAc,EACrB,OAAO,EAAE,OAAO,EAChB,QAAQ,EAAE,QAAQ,KACf,OAAO,CAAC,IAAI,CAAC,CAAC;CACpB;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAsB,2BAA2B,CAC/C,MAAM,EAAE,mBAAmB,GAC1B,OAAO,CAAC,oBAAoB,CAAC,
|
|
1
|
+
{"version":3,"file":"runVisualRegression.d.ts","sourceRoot":"","sources":["../../src/testing/runVisualRegression.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAE1D,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAcxD,UAAU,cAAc;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;CACf;AAmED;;;;wEAIwE;AACxE,MAAM,WAAW,oBAAoB;IACnC,6EAA6E;IAC7E,aAAa,EAAE,MAAM,CAAC;IACtB,iEAAiE;IACjE,UAAU,EAAE,MAAM,CAAC;IACnB,2DAA2D;IAC3D,OAAO,EAAE,cAAc,EAAE,CAAC;IAC1B;;;+EAG2E;IAC3E,wBAAwB,EAAE,MAAM,EAAE,CAAC;IACnC;;;;uDAImD;IACnD,UAAU,EAAE,CACV,KAAK,EAAE,cAAc,EACrB,OAAO,EAAE,OAAO,EAChB,QAAQ,EAAE,QAAQ,KACf,OAAO,CAAC,IAAI,CAAC,CAAC;CACpB;AAED;;;;wEAIwE;AACxE,MAAM,WAAW,oBAAoB;IACnC,6EAA6E;IAC7E,aAAa,EAAE,MAAM,CAAC;IACtB,iEAAiE;IACjE,UAAU,EAAE,MAAM,CAAC;IACnB,2DAA2D;IAC3D,OAAO,EAAE,cAAc,EAAE,CAAC;IAC1B;;;;uDAImD;IACnD,UAAU,EAAE,CACV,KAAK,EAAE,cAAc,EACrB,OAAO,EAAE,OAAO,EAChB,QAAQ,EAAE,QAAQ,KACf,OAAO,CAAC,IAAI,CAAC,CAAC;CACpB;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAsB,2BAA2B,CAC/C,MAAM,EAAE,mBAAmB,GAC1B,OAAO,CAAC,oBAAoB,CAAC,CA8P/B"}
|