@recursica/adapter-tester 5.0.1 → 5.1.0

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/dist/cli.js CHANGED
@@ -1,17 +1,17 @@
1
1
  #!/usr/bin/env node
2
- import { spawn as _, spawnSync as q } from "node:child_process";
3
- import { readFileSync as S, mkdirSync as F, writeFileSync as O, existsSync as I } from "node:fs";
4
- import { dirname as D, join as a, resolve as j } from "node:path";
5
- import { fileURLToPath as M, pathToFileURL as H } from "node:url";
6
- import W from "express";
7
- import { createProxyMiddleware as B } from "http-proxy-middleware";
8
- import K from "node:net";
9
- import { m as X } from "./mantineSourceOfTruth-DE7XOgea.js";
10
- import { a as Y, i as z } from "./index-DqQzFSAH.js";
11
- const Q = /\x1b\[[0-9;]*m/g, Z = /Local:\s*(https?:\/\/localhost:\d+)/;
12
- function ee(e) {
2
+ import { spawn as _, spawnSync as W } from "node:child_process";
3
+ import { readFileSync as S, mkdirSync as I, writeFileSync as x, existsSync as M } from "node:fs";
4
+ import { dirname as j, join as a, resolve as $ } from "node:path";
5
+ import { fileURLToPath as U, pathToFileURL as B } from "node:url";
6
+ import K from "express";
7
+ import { createProxyMiddleware as X } from "http-proxy-middleware";
8
+ import Y from "node:net";
9
+ import { m as z } from "./mantineSourceOfTruth-DE7XOgea.js";
10
+ import { a as Q, i as Z } from "./index-DqQzFSAH.js";
11
+ const ee = /\x1b\[[0-9;]*m/g, te = /Local:\s*(https?:\/\/localhost:\d+)/;
12
+ function re(e) {
13
13
  return new Promise((t) => {
14
- const r = new K.Socket();
14
+ const r = new Y.Socket();
15
15
  r.setTimeout(200), r.once("connect", () => {
16
16
  r.destroy(), t(!0);
17
17
  }), r.once("timeout", () => {
@@ -21,7 +21,7 @@ function ee(e) {
21
21
  }), r.connect(e, "127.0.0.1");
22
22
  });
23
23
  }
24
- function te(e) {
24
+ function oe(e) {
25
25
  try {
26
26
  const t = JSON.parse(S(e, "utf8")).port;
27
27
  return typeof t == "number" ? t : void 0;
@@ -29,10 +29,10 @@ function te(e) {
29
29
  return;
30
30
  }
31
31
  }
32
- function re(e, t) {
33
- F(D(e), { recursive: !0 }), O(e, JSON.stringify({ port: t }));
32
+ function se(e, t) {
33
+ I(j(e), { recursive: !0 }), x(e, JSON.stringify({ port: t }));
34
34
  }
35
- function oe(e, t) {
35
+ function ne(e, t) {
36
36
  return new Promise((r, o) => {
37
37
  var y, w;
38
38
  const s = _(e.command, {
@@ -41,32 +41,32 @@ function oe(e, t) {
41
41
  shell: !0
42
42
  });
43
43
  let n = !1;
44
- const d = setTimeout(() => {
44
+ const l = setTimeout(() => {
45
45
  n || (n = !0, s.kill(), o(
46
46
  new Error(
47
47
  `Timed out after ${t}ms waiting for ${e.name}'s Storybook to report its URL (no "Local: http://localhost:<port>" line seen in its output).`
48
48
  )
49
49
  ));
50
- }, t), h = (i, u) => {
51
- const l = i.toString();
52
- for (const c of l.split(`
50
+ }, t), f = (i, u) => {
51
+ const p = i.toString();
52
+ for (const c of p.split(`
53
53
  `))
54
54
  if (c.trim()) {
55
- const p = u ? `${e.name} SB ERROR` : `${e.name} SB`;
56
- (u ? console.error : console.log)(`[${p}] ${c.trim()}`);
55
+ const h = u ? `${e.name} SB ERROR` : `${e.name} SB`;
56
+ (u ? console.error : console.log)(`[${h}] ${c.trim()}`);
57
57
  }
58
58
  if (n) return;
59
- const v = l.replace(Q, "").match(Z);
59
+ const v = p.replace(ee, "").match(te);
60
60
  if (v) {
61
- n = !0, clearTimeout(d);
62
- const c = v[1], p = Number(new URL(c).port);
63
- re(e.cacheFile, p), r({ url: c, port: p, process: s });
61
+ n = !0, clearTimeout(l);
62
+ const c = v[1], h = Number(new URL(c).port);
63
+ se(e.cacheFile, h), r({ url: c, port: h, process: s });
64
64
  }
65
65
  };
66
- (y = s.stdout) == null || y.on("data", (i) => h(i, !1)), (w = s.stderr) == null || w.on("data", (i) => h(i, !0)), s.on("error", (i) => {
67
- n || (n = !0, clearTimeout(d), o(i));
66
+ (y = s.stdout) == null || y.on("data", (i) => f(i, !1)), (w = s.stderr) == null || w.on("data", (i) => f(i, !0)), s.on("error", (i) => {
67
+ n || (n = !0, clearTimeout(l), o(i));
68
68
  }), s.on("exit", (i) => {
69
- n || (n = !0, clearTimeout(d), o(
69
+ n || (n = !0, clearTimeout(l), o(
70
70
  new Error(
71
71
  `${e.name}'s Storybook exited (code ${i}) before reporting its URL.`
72
72
  )
@@ -74,7 +74,7 @@ function oe(e, t) {
74
74
  });
75
75
  });
76
76
  }
77
- function x(e, t) {
77
+ function E(e, t) {
78
78
  return {
79
79
  name: e,
80
80
  command: t.command,
@@ -84,10 +84,10 @@ function x(e, t) {
84
84
  timeoutMs: t.timeout
85
85
  };
86
86
  }
87
- async function E(e) {
87
+ async function A(e) {
88
88
  if (e.reuseExistingServer) {
89
- const t = te(e.cacheFile);
90
- if (t !== void 0 && await ee(t))
89
+ const t = oe(e.cacheFile);
90
+ if (t !== void 0 && await re(t))
91
91
  return console.log(
92
92
  `[Dev Launcher] ${e.name} is already running on port ${t} (reused).`
93
93
  ), {
@@ -96,10 +96,10 @@ async function E(e) {
96
96
  process: null
97
97
  };
98
98
  }
99
- return console.log(`[Dev Launcher] Launching Storybook for ${e.name}...`), oe(e, e.timeoutMs ?? 120 * 1e3);
99
+ return console.log(`[Dev Launcher] Launching Storybook for ${e.name}...`), ne(e, e.timeoutMs ?? 120 * 1e3);
100
100
  }
101
- const N = D(M(import.meta.url));
102
- function se(e) {
101
+ const N = j(U(import.meta.url));
102
+ function ie(e) {
103
103
  const t = process.platform === "darwin" ? "open" : process.platform === "win32" ? "start" : "xdg-open";
104
104
  console.log(`[Dev Launcher] Auto-launching browser: ${e}`), _(t, [e], { shell: process.platform === "win32" }).on(
105
105
  "error",
@@ -108,32 +108,32 @@ function se(e) {
108
108
  }
109
109
  );
110
110
  }
111
- async function ne(e, t, r = {}) {
112
- const [o, s] = e.targets, [n, d] = t;
113
- if (!(o != null && o.sourceOfTruth) || !s || s.sourceOfTruth || !n || !d)
111
+ async function ae(e, t, r = {}) {
112
+ const [o, s] = e.targets, [n, l] = t;
113
+ if (!(o != null && o.sourceOfTruth) || !s || s.sourceOfTruth || !n || !l)
114
114
  throw new Error(
115
115
  "adapter-tester dev mode requires exactly two targets: [sourceOfTruth, target] — check adapter-tester.config.json."
116
116
  );
117
- const h = r.port ?? 6010;
117
+ const f = r.port ?? 6010;
118
118
  console.log(
119
119
  `[Dev Launcher] Resolving ${o.name} and ${s.name} Storybooks...`
120
120
  );
121
121
  const [y, w] = await Promise.all([
122
- E(
123
- x(o.name, n)
122
+ A(
123
+ E(o.name, n)
124
124
  ),
125
- E(x(s.name, d))
125
+ A(E(s.name, l))
126
126
  ]);
127
127
  console.log("[Dev Launcher] Both Storybooks are active and responsive!");
128
128
  const i = [y.process, w.process].filter(
129
- (f) => f !== null
130
- ), u = W(), l = a(N, "../public"), v = a(N, "../report-header.txt");
131
- u.get("/", (f, T, b) => {
132
- if (f.query.path) {
133
- b();
129
+ (m) => m !== null
130
+ ), u = K(), p = a(N, "../public"), v = a(N, "../report-header.txt");
131
+ u.get("/", (m, b, T) => {
132
+ if (m.query.path) {
133
+ T();
134
134
  return;
135
135
  }
136
- const J = S(a(l, "index.html"), "utf8").replace(
136
+ const q = S(a(p, "index.html"), "utf8").replace(
137
137
  "<head>",
138
138
  `<head>
139
139
  <script>window.__ADAPTER_TESTER__ = ${JSON.stringify({
@@ -142,55 +142,59 @@ async function ne(e, t, r = {}) {
142
142
  sourceOfTruthPort: y.port
143
143
  })};<\/script>`
144
144
  );
145
- T.send(J);
146
- }), u.get("/report-header.txt", (f, T) => {
145
+ b.send(q);
146
+ }), u.get("/report-header.txt", (m, b) => {
147
+ if (e.reportHeader !== void 0) {
148
+ b.type("text/plain").send(e.reportHeader);
149
+ return;
150
+ }
147
151
  try {
148
- T.type("text/plain").send(S(v, "utf8"));
152
+ b.type("text/plain").send(S(v, "utf8"));
149
153
  } catch {
150
- T.status(500).send("Error loading report-header.txt");
154
+ b.status(500).send("Error loading report-header.txt");
151
155
  }
152
156
  }), u.use(
153
157
  "/",
154
- B({
158
+ X({
155
159
  target: w.url,
156
160
  changeOrigin: !0,
157
161
  ws: !0
158
162
  })
159
163
  );
160
164
  let c = !1;
161
- const p = () => {
165
+ const h = () => {
162
166
  if (!c) {
163
167
  c = !0, console.log(
164
168
  `
165
169
  [Dev Launcher] Shutting down Dev Mode server and spawned Storybooks...`
166
170
  );
167
- for (const f of i) f.kill("SIGINT");
171
+ for (const m of i) m.kill("SIGINT");
168
172
  process.exit(0);
169
173
  }
170
174
  };
171
- process.on("SIGINT", p), process.on("SIGTERM", p), u.listen(h, () => {
175
+ process.on("SIGINT", h), process.on("SIGTERM", h), u.listen(f, () => {
172
176
  console.log(`
173
177
  ====================================================
174
178
  🚀 Adapter Dev Mode proxy running at:
175
- http://localhost:${h}
179
+ http://localhost:${f}
176
180
  ====================================================
177
- `), se(`http://localhost:${h}`);
181
+ `), ie(`http://localhost:${f}`);
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 = {
181
- $schema: ie,
182
- $id: ae,
183
- title: ce,
184
- description: ue,
185
- type: de,
186
- additionalProperties: le,
187
- properties: pe
188
- }, fe = z, U = new Y.Ajv({ allErrors: !0, strict: !0 });
189
- fe(U);
190
- const $ = U.compile(he);
191
- function me(e, t) {
192
- if ($(e)) return;
193
- const r = ($.errors ?? []).map((o) => {
184
+ const ce = "http://json-schema.org/draft-07/schema#", de = "https://github.com/borderux/recursica/tree/main/packages/adapter-tester/src/adapter-tester.schema.json", ue = "adapter-tester.config.json", le = "Configuration for @recursica/adapter-tester. All fields are optional — an adapter repo with a normal `storybook` npm script needs no config file at all.", pe = "object", he = !1, fe = { $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`.' } }, me = {
185
+ $schema: ce,
186
+ $id: de,
187
+ title: ue,
188
+ description: le,
189
+ type: pe,
190
+ additionalProperties: he,
191
+ properties: fe
192
+ }, ge = Z, G = new Q.Ajv({ allErrors: !0, strict: !0 });
193
+ ge(G);
194
+ const L = G.compile(me);
195
+ function ye(e, t) {
196
+ if (L(e)) return;
197
+ const r = (L.errors ?? []).map((o) => {
194
198
  var n;
195
199
  const s = (n = o.params) != null && n.additionalProperty ? ` '${o.params.additionalProperty}'` : "";
196
200
  return ` - ${o.instancePath || "root"} ${o.message}${s}`;
@@ -199,57 +203,58 @@ 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, C = 6011, R = "Mantine", ve = 10, Te = 3500;
203
- function G(e) {
206
+ const we = "@recursica/mantine-adapter", ve = "adapter-tester.config.json", F = "npm run storybook", be = 6006, R = 6011, C = "Mantine", Te = 10, Se = 3500;
207
+ function V(e) {
204
208
  const t = a(e, "package.json");
205
- if (!I(t))
209
+ if (!M(t))
206
210
  throw new Error(
207
211
  `No package.json found in ${e} — run adapter-tester from the root of the project being tested.`
208
212
  );
209
213
  return JSON.parse(S(t, "utf8"));
210
214
  }
211
- function be(e) {
215
+ function ke(e) {
212
216
  var s;
213
- const r = (s = G(e).scripts) == null ? void 0 : s.storybook, o = r == null ? void 0 : r.match(/(?:-p|--port)[ =](\d+)/);
214
- return o ? Number(o[1]) : we;
217
+ const r = (s = V(e).scripts) == null ? void 0 : s.storybook, o = r == null ? void 0 : r.match(/(?:-p|--port)[ =](\d+)/);
218
+ return o ? Number(o[1]) : be;
215
219
  }
216
- function Se(e) {
217
- const r = G(e).name;
220
+ function Oe(e) {
221
+ const r = V(e).name;
218
222
  return r ? r.split("/").pop() : "Adapter";
219
223
  }
220
- function ke(e) {
221
- const t = a(e, ye);
222
- if (!I(t))
224
+ function xe(e) {
225
+ const t = a(e, ve);
226
+ if (!M(t))
223
227
  return {};
224
228
  const r = JSON.parse(S(t, "utf8"));
225
- return me(r, t), r;
229
+ return ye(r, t), r;
226
230
  }
227
- function Oe(e, t = {}) {
228
- var p, f, T;
229
- const r = ke(e), o = r.isSourceOfTruthAdapter ?? !1;
231
+ function Ee(e, t = {}) {
232
+ var h, m, b;
233
+ const r = xe(e), o = r.isSourceOfTruthAdapter ?? !1;
230
234
  if (t.mantineAdapterVersion && o)
231
235
  throw new Error(
232
236
  "--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."
233
237
  );
234
- const s = r.name ?? Se(e), n = ((p = r.storybook) == null ? void 0 : p.port) ?? be(e), d = ((f = r.storybook) == null ? void 0 : f.command) ?? L, h = j(e, ((T = r.storybook) == null ? void 0 : T.cwd) ?? "."), y = {
235
- command: d,
238
+ const s = r.name ?? Oe(e), n = ((h = r.storybook) == null ? void 0 : h.port) ?? ke(e), l = ((m = r.storybook) == null ? void 0 : m.command) ?? F, f = $(e, ((b = r.storybook) == null ? void 0 : b.cwd) ?? "."), y = {
239
+ command: l,
236
240
  port: n,
237
- cwd: h,
241
+ cwd: f,
238
242
  reuseExistingServer: !process.env.CI,
239
243
  cacheFile: a(e, ".adapter-tester", "last-port-own.json"),
240
244
  timeout: 120 * 1e3
241
245
  }, w = {
242
- goldenThresholdPixels: r.goldenThresholdPixels ?? ve,
243
- sourceOfTruthThresholdPixels: r.sourceOfTruthThresholdPixels ?? Te,
246
+ goldenThresholdPixels: r.goldenThresholdPixels ?? Te,
247
+ sourceOfTruthThresholdPixels: r.sourceOfTruthThresholdPixels ?? Se,
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
249
254
  // to that package's own `test/golden/` (the same directory used when
250
255
  // that package runs adapter-tester directly), not a directory under
251
256
  // wherever this config file lives.
252
- goldenDir: a(h, "test", "golden"),
257
+ goldenDir: a(f, "test", "golden"),
253
258
  isSourceOfTruthAdapter: o,
254
259
  // Overwritten by the CLI from --update-golden/--approve-divergence.
255
260
  goldenMode: "check",
@@ -267,37 +272,37 @@ function Oe(e, t = {}) {
267
272
  const i = r.sourceOfTruth ?? {
268
273
  type: "mantine-harness"
269
274
  };
270
- let u, l, v, c;
275
+ let u, p, v, c;
271
276
  if (i.type === "url") {
272
277
  if (t.mantineAdapterVersion)
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 ?? R, l = i.port ?? C;
277
- const b = j(e, i.cwd ?? ".");
281
+ u = i.name ?? C, p = i.port ?? R;
282
+ const T = $(e, i.cwd ?? ".");
278
283
  v = {
279
- command: i.command ?? L,
280
- port: l,
281
- cwd: b,
284
+ command: i.command ?? F,
285
+ port: p,
286
+ cwd: T,
282
287
  reuseExistingServer: !process.env.CI,
283
288
  cacheFile: a(e, ".adapter-tester", "last-port-source-of-truth.json"),
284
289
  timeout: 120 * 1e3
285
290
  }, c = {
286
291
  type: "local",
287
- dir: a(b, "test", "golden")
292
+ dir: a(T, "test", "golden")
288
293
  };
289
294
  } else {
290
- u = R, l = i.port ?? C;
291
- const b = t.mantineAdapterVersion ?? i.mantineAdapterVersion;
292
- v = X({
295
+ u = C, p = i.port ?? R;
296
+ const T = t.mantineAdapterVersion ?? i.mantineAdapterVersion;
297
+ v = z({
293
298
  dir: a(e, ".adapter-tester/mantine-harness"),
294
- port: l,
295
- mantineAdapterVersion: b,
299
+ port: p,
300
+ mantineAdapterVersion: T,
296
301
  storybookTemplateVersion: i.storybookTemplateVersion
297
302
  }), c = {
298
303
  type: "npm",
299
- packageName: ge,
300
- versionSpec: b ?? "latest",
304
+ packageName: we,
305
+ versionSpec: T ?? "latest",
301
306
  cacheDir: a(e, ".adapter-tester/mantine-golden-cache")
302
307
  };
303
308
  }
@@ -307,7 +312,7 @@ function Oe(e, t = {}) {
307
312
  targets: [
308
313
  {
309
314
  name: u,
310
- url: `http://localhost:${l}`,
315
+ url: `http://localhost:${p}`,
311
316
  sourceOfTruth: !0
312
317
  },
313
318
  { name: s, url: `http://localhost:${n}` }
@@ -320,66 +325,76 @@ function Oe(e, t = {}) {
320
325
  webServers: [v, y]
321
326
  };
322
327
  }
323
- const xe = D(M(import.meta.url)), Ee = H(a(xe, "testing.js")).href, g = process.argv.slice(2);
324
- let V;
325
- const k = g.indexOf("--source-of-truth-version");
328
+ const Ae = j(U(import.meta.url)), De = B(a(Ae, "testing.js")).href, d = process.argv.slice(2);
329
+ let H;
330
+ const k = d.indexOf("--source-of-truth-version");
326
331
  if (k !== -1) {
327
- const e = g[k + 1];
332
+ const e = d[k + 1];
328
333
  if (e === void 0 || e.startsWith("--"))
329
334
  throw new Error(
330
335
  "--source-of-truth-version requires a value, e.g. --source-of-truth-version 0.53.0"
331
336
  );
332
- V = e, g.splice(k, 2);
337
+ H = e, d.splice(k, 2);
338
+ }
339
+ let J;
340
+ const O = d.indexOf("--story");
341
+ if (O !== -1) {
342
+ const e = d[O + 1];
343
+ if (e === void 0 || e.startsWith("--"))
344
+ throw new Error(
345
+ "--story requires a story id, e.g. --story ui-kit-button--loading"
346
+ );
347
+ J = e, d.splice(O, 2);
333
348
  }
334
- const A = process.cwd(), { engineConfig: m, webServers: P } = Oe(A, {
335
- mantineAdapterVersion: V
349
+ const D = process.cwd(), { engineConfig: g, webServers: P } = Ee(D, {
350
+ mantineAdapterVersion: H
336
351
  });
337
- g.includes("--update-golden") ? m.goldenMode = "update-golden" : g.includes("--approve-divergence") && (m.goldenMode = "approve-divergence");
338
- if (g.includes("--divergence-only")) {
339
- if (m.isSourceOfTruthAdapter)
352
+ d.includes("--update-golden") ? g.goldenMode = "update-golden" : d.includes("--approve-divergence") && (g.goldenMode = "approve-divergence");
353
+ if (d.includes("--divergence-only")) {
354
+ if (g.isSourceOfTruthAdapter)
340
355
  throw new Error(
341
356
  "--divergence-only has nothing to diverge from — isSourceOfTruthAdapter is true in this project's adapter-tester.config.json."
342
357
  );
343
- m.checkMode = "divergence";
344
- } else if (m.goldenMode === "approve-divergence")
358
+ g.checkMode = "divergence";
359
+ } else if (g.goldenMode === "approve-divergence")
345
360
  throw new Error(
346
361
  "--approve-divergence only makes sense with --divergence-only — there's nothing to approve without the divergence check running."
347
362
  );
348
- g.includes("--dry-run") && (console.log(JSON.stringify({ engineConfig: m, webServers: P }, null, 2)), process.exit(0));
349
- const Ae = /* @__PURE__ */ new Set([
363
+ d.includes("--dry-run") && (console.log(JSON.stringify({ engineConfig: g, webServers: P }, null, 2)), process.exit(0));
364
+ const Pe = /* @__PURE__ */ new Set([
350
365
  "--dry-run",
351
366
  "--serve",
352
367
  "--update-golden",
353
368
  "--approve-divergence",
354
369
  "--divergence-only"
355
- ]), Pe = g.filter((e) => !Ae.has(e));
356
- De().catch((e) => {
370
+ ]), je = d.filter((e) => !Pe.has(e));
371
+ $e().catch((e) => {
357
372
  console.error(e), process.exitCode = 1;
358
373
  });
359
- async function De() {
360
- if (g.includes("--serve")) {
361
- if (m.isSourceOfTruthAdapter)
374
+ async function $e() {
375
+ if (d.includes("--serve")) {
376
+ if (g.isSourceOfTruthAdapter)
362
377
  throw new Error(
363
378
  "Dev Mode (--serve) has nothing to sync this project's Storybook against — isSourceOfTruthAdapter is true in this project's adapter-tester.config.json."
364
379
  );
365
- await ne(m, P);
380
+ await ae(g, P);
366
381
  } else {
367
382
  const e = P.at(-1);
368
383
  if (!e)
369
384
  throw new Error("resolveConfig() returned no webServers to boot.");
370
- await je(e, m);
385
+ await Ne(e, g);
371
386
  }
372
387
  }
373
- async function je(e, t) {
374
- const r = a(A, ".adapter-tester/run");
375
- F(r, { recursive: !0 });
388
+ async function Ne(e, t) {
389
+ const r = a(D, ".adapter-tester/run");
390
+ I(r, { recursive: !0 });
376
391
  const o = t.targets.at(-1);
377
392
  if (!o)
378
393
  throw new Error("resolveConfig() returned no targets to check.");
379
- const { url: s, process: n } = await E(
380
- x(o.name, e)
394
+ const { url: s, process: n } = await A(
395
+ E(o.name, e)
381
396
  );
382
- o.url = s, O(
397
+ o.url = s, x(
383
398
  a(r, "playwright.config.js"),
384
399
  `// Generated by \`adapter-tester\` — do not edit, regenerated on every run.
385
400
  import { defineConfig, devices } from "@playwright/test";
@@ -402,11 +417,11 @@ export default defineConfig({
402
417
  // the time this config is used (see runAutomated() in cli.ts).
403
418
  });
404
419
  `
405
- ), O(
420
+ ), x(
406
421
  a(r, "visual-regression.spec.js"),
407
422
  `// Generated by \`adapter-tester\` — do not edit, regenerated on every run.
408
423
  import { test, expect } from "@playwright/test";
409
- import { resolveVisualRegressionPlan } from ${JSON.stringify(Ee)};
424
+ import { resolveVisualRegressionPlan } from ${JSON.stringify(De)};
410
425
 
411
426
  // \`test.describe\`/\`test\` are called here, not inside resolveVisualRegressionPlan,
412
427
  // so Playwright's HTML report groups the suite under this file instead of a
@@ -414,8 +429,18 @@ import { resolveVisualRegressionPlan } from ${JSON.stringify(Ee)};
414
429
  const { ownTargetName, suiteLabel, stories, missingFromSourceOfTruth, checkStory } =
415
430
  await resolveVisualRegressionPlan(${JSON.stringify(t, null, 2)});
416
431
 
432
+ // Set from \`--story <story-id>\` — scopes this run to exactly one story and
433
+ // skips the (suite-wide) parity check, which has nothing to do with it.
434
+ const storyId = ${JSON.stringify(J ?? null)};
435
+ const scopedStories = storyId
436
+ ? stories.filter((story) => story.id === storyId)
437
+ : stories;
438
+ if (storyId && scopedStories.length === 0) {
439
+ throw new Error(\`--story "\${storyId}" matched no story in this Storybook.\`);
440
+ }
441
+
417
442
  test.describe(\`\${ownTargetName} — \${suiteLabel}\`, () => {
418
- if (missingFromSourceOfTruth.length > 0) {
443
+ if (!storyId && missingFromSourceOfTruth.length > 0) {
419
444
  test("story parity with source of truth", () => {
420
445
  expect(
421
446
  missingFromSourceOfTruth,
@@ -423,7 +448,7 @@ test.describe(\`\${ownTargetName} — \${suiteLabel}\`, () => {
423
448
  ).toEqual([]);
424
449
  });
425
450
  }
426
- for (const story of stories) {
451
+ for (const story of scopedStories) {
427
452
  test(story.id, async ({ browser }, testInfo) => {
428
453
  await checkStory(story, browser, testInfo);
429
454
  });
@@ -432,18 +457,18 @@ test.describe(\`\${ownTargetName} — \${suiteLabel}\`, () => {
432
457
  `
433
458
  );
434
459
  try {
435
- const d = q(
460
+ const l = W(
436
461
  "npx",
437
462
  [
438
463
  "playwright",
439
464
  "test",
440
465
  "--config",
441
466
  a(r, "playwright.config.js"),
442
- ...Pe
467
+ ...je
443
468
  ],
444
- { stdio: "inherit", cwd: A, shell: process.platform === "win32" }
469
+ { stdio: "inherit", cwd: D, shell: process.platform === "win32" }
445
470
  );
446
- process.exitCode = d.status ?? 1;
471
+ process.exitCode = l.status ?? 1;
447
472
  } finally {
448
473
  n == null || n.kill("SIGTERM");
449
474
  }