@recursica/adapter-tester 5.0.2 → 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 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
- 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,44 +29,44 @@ function te(e) {
29
29
  return;
30
30
  }
31
31
  }
32
- function re(e, t) {
33
- _(P(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
- const s = F(e.command, {
38
+ const s = _(e.command, {
39
39
  cwd: e.cwd,
40
40
  stdio: "pipe",
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,
@@ -86,8 +86,8 @@ function x(e, t) {
86
86
  }
87
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,44 +96,44 @@ async function A(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 = P(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
- console.log(`[Dev Launcher] Auto-launching browser: ${e}`), F(t, [e], { shell: process.platform === "win32" }).on(
104
+ console.log(`[Dev Launcher] Auto-launching browser: ${e}`), _(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);
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
122
  A(
123
- x(o.name, n)
123
+ E(o.name, n)
124
124
  ),
125
- A(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 H = 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,59 +142,59 @@ async function ne(e, t, r = {}) {
142
142
  sourceOfTruthPort: y.port
143
143
  })};<\/script>`
144
144
  );
145
- T.send(H);
146
- }), u.get("/report-header.txt", (f, T) => {
145
+ b.send(q);
146
+ }), u.get("/report-header.txt", (m, b) => {
147
147
  if (e.reportHeader !== void 0) {
148
- T.type("text/plain").send(e.reportHeader);
148
+ b.type("text/plain").send(e.reportHeader);
149
149
  return;
150
150
  }
151
151
  try {
152
- T.type("text/plain").send(S(v, "utf8"));
152
+ b.type("text/plain").send(S(v, "utf8"));
153
153
  } catch {
154
- T.status(500).send("Error loading report-header.txt");
154
+ b.status(500).send("Error loading report-header.txt");
155
155
  }
156
156
  }), u.use(
157
157
  "/",
158
- B({
158
+ X({
159
159
  target: w.url,
160
160
  changeOrigin: !0,
161
161
  ws: !0
162
162
  })
163
163
  );
164
164
  let c = !1;
165
- const p = () => {
165
+ const h = () => {
166
166
  if (!c) {
167
167
  c = !0, console.log(
168
168
  `
169
169
  [Dev Launcher] Shutting down Dev Mode server and spawned Storybooks...`
170
170
  );
171
- for (const f of i) f.kill("SIGINT");
171
+ for (const m of i) m.kill("SIGINT");
172
172
  process.exit(0);
173
173
  }
174
174
  };
175
- process.on("SIGINT", p), process.on("SIGTERM", p), u.listen(h, () => {
175
+ process.on("SIGINT", h), process.on("SIGTERM", h), u.listen(f, () => {
176
176
  console.log(`
177
177
  ====================================================
178
178
  🚀 Adapter Dev Mode proxy running at:
179
- http://localhost:${h}
179
+ http://localhost:${f}
180
180
  ====================================================
181
- `), se(`http://localhost:${h}`);
181
+ `), ie(`http://localhost:${f}`);
182
182
  });
183
183
  }
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 = {
185
- $schema: ie,
186
- $id: ae,
187
- title: ce,
188
- description: ue,
189
- type: de,
190
- additionalProperties: le,
191
- properties: pe
192
- }, fe = z, U = new Y.Ajv({ allErrors: !0, strict: !0 });
193
- fe(U);
194
- const $ = U.compile(he);
195
- function me(e, t) {
196
- if ($(e)) return;
197
- 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) => {
198
198
  var n;
199
199
  const s = (n = o.params) != null && n.additionalProperty ? ` '${o.params.additionalProperty}'` : "";
200
200
  return ` - ${o.instancePath || "root"} ${o.message}${s}`;
@@ -203,48 +203,48 @@ function me(e, t) {
203
203
  throw new Error(`Invalid ${t}:
204
204
  ${r}`);
205
205
  }
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;
207
- 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) {
208
208
  const t = a(e, "package.json");
209
- if (!I(t))
209
+ if (!M(t))
210
210
  throw new Error(
211
211
  `No package.json found in ${e} — run adapter-tester from the root of the project being tested.`
212
212
  );
213
213
  return JSON.parse(S(t, "utf8"));
214
214
  }
215
- function be(e) {
215
+ function ke(e) {
216
216
  var s;
217
- const r = (s = G(e).scripts) == null ? void 0 : s.storybook, o = r == null ? void 0 : r.match(/(?:-p|--port)[ =](\d+)/);
218
- 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;
219
219
  }
220
- function Se(e) {
221
- const r = G(e).name;
220
+ function Oe(e) {
221
+ const r = V(e).name;
222
222
  return r ? r.split("/").pop() : "Adapter";
223
223
  }
224
- function ke(e) {
225
- const t = a(e, ye);
226
- if (!I(t))
224
+ function xe(e) {
225
+ const t = a(e, ve);
226
+ if (!M(t))
227
227
  return {};
228
228
  const r = JSON.parse(S(t, "utf8"));
229
- return me(r, t), r;
229
+ return ye(r, t), r;
230
230
  }
231
- function Oe(e, t = {}) {
232
- var p, f, T;
233
- 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;
234
234
  if (t.mantineAdapterVersion && o)
235
235
  throw new Error(
236
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."
237
237
  );
238
- 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 = {
239
- 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,
240
240
  port: n,
241
- cwd: h,
241
+ cwd: f,
242
242
  reuseExistingServer: !process.env.CI,
243
243
  cacheFile: a(e, ".adapter-tester", "last-port-own.json"),
244
244
  timeout: 120 * 1e3
245
245
  }, w = {
246
- goldenThresholdPixels: r.goldenThresholdPixels ?? ve,
247
- sourceOfTruthThresholdPixels: r.sourceOfTruthThresholdPixels ?? Te,
246
+ goldenThresholdPixels: r.goldenThresholdPixels ?? Te,
247
+ sourceOfTruthThresholdPixels: r.sourceOfTruthThresholdPixels ?? Se,
248
248
  stories: r.stories,
249
249
  excludeTitlePrefixes: r.excludeTitlePrefixes,
250
250
  reportHeader: r.reportHeader,
@@ -254,7 +254,7 @@ function Oe(e, t = {}) {
254
254
  // to that package's own `test/golden/` (the same directory used when
255
255
  // that package runs adapter-tester directly), not a directory under
256
256
  // wherever this config file lives.
257
- goldenDir: a(h, "test", "golden"),
257
+ goldenDir: a(f, "test", "golden"),
258
258
  isSourceOfTruthAdapter: o,
259
259
  // Overwritten by the CLI from --update-golden/--approve-divergence.
260
260
  goldenMode: "check",
@@ -272,37 +272,37 @@ function Oe(e, t = {}) {
272
272
  const i = r.sourceOfTruth ?? {
273
273
  type: "mantine-harness"
274
274
  };
275
- let u, l, v, c;
275
+ let u, p, v, c;
276
276
  if (i.type === "url") {
277
277
  if (t.mantineAdapterVersion)
278
278
  throw new Error(
279
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.`
280
280
  );
281
- u = i.name ?? C, l = i.port ?? R;
282
- const b = j(e, i.cwd ?? ".");
281
+ u = i.name ?? C, p = i.port ?? R;
282
+ const T = $(e, i.cwd ?? ".");
283
283
  v = {
284
- command: i.command ?? L,
285
- port: l,
286
- cwd: b,
284
+ command: i.command ?? F,
285
+ port: p,
286
+ cwd: T,
287
287
  reuseExistingServer: !process.env.CI,
288
288
  cacheFile: a(e, ".adapter-tester", "last-port-source-of-truth.json"),
289
289
  timeout: 120 * 1e3
290
290
  }, c = {
291
291
  type: "local",
292
- dir: a(b, "test", "golden")
292
+ dir: a(T, "test", "golden")
293
293
  };
294
294
  } else {
295
- u = C, l = i.port ?? R;
296
- const b = t.mantineAdapterVersion ?? i.mantineAdapterVersion;
297
- v = X({
295
+ u = C, p = i.port ?? R;
296
+ const T = t.mantineAdapterVersion ?? i.mantineAdapterVersion;
297
+ v = z({
298
298
  dir: a(e, ".adapter-tester/mantine-harness"),
299
- port: l,
300
- mantineAdapterVersion: b,
299
+ port: p,
300
+ mantineAdapterVersion: T,
301
301
  storybookTemplateVersion: i.storybookTemplateVersion
302
302
  }), c = {
303
303
  type: "npm",
304
- packageName: ge,
305
- versionSpec: b ?? "latest",
304
+ packageName: we,
305
+ versionSpec: T ?? "latest",
306
306
  cacheDir: a(e, ".adapter-tester/mantine-golden-cache")
307
307
  };
308
308
  }
@@ -312,7 +312,7 @@ function Oe(e, t = {}) {
312
312
  targets: [
313
313
  {
314
314
  name: u,
315
- url: `http://localhost:${l}`,
315
+ url: `http://localhost:${p}`,
316
316
  sourceOfTruth: !0
317
317
  },
318
318
  { name: s, url: `http://localhost:${n}` }
@@ -325,66 +325,76 @@ function Oe(e, t = {}) {
325
325
  webServers: [v, y]
326
326
  };
327
327
  }
328
- const xe = P(M(import.meta.url)), Ae = q(a(xe, "testing.js")).href, g = process.argv.slice(2);
329
- let V;
330
- 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");
331
331
  if (k !== -1) {
332
- const e = g[k + 1];
332
+ const e = d[k + 1];
333
333
  if (e === void 0 || e.startsWith("--"))
334
334
  throw new Error(
335
335
  "--source-of-truth-version requires a value, e.g. --source-of-truth-version 0.53.0"
336
336
  );
337
- 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);
338
348
  }
339
- const E = process.cwd(), { engineConfig: m, webServers: D } = Oe(E, {
340
- mantineAdapterVersion: V
349
+ const D = process.cwd(), { engineConfig: g, webServers: P } = Ee(D, {
350
+ mantineAdapterVersion: H
341
351
  });
342
- g.includes("--update-golden") ? m.goldenMode = "update-golden" : g.includes("--approve-divergence") && (m.goldenMode = "approve-divergence");
343
- if (g.includes("--divergence-only")) {
344
- 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)
345
355
  throw new Error(
346
356
  "--divergence-only has nothing to diverge from — isSourceOfTruthAdapter is true in this project's adapter-tester.config.json."
347
357
  );
348
- m.checkMode = "divergence";
349
- } else if (m.goldenMode === "approve-divergence")
358
+ g.checkMode = "divergence";
359
+ } else if (g.goldenMode === "approve-divergence")
350
360
  throw new Error(
351
361
  "--approve-divergence only makes sense with --divergence-only — there's nothing to approve without the divergence check running."
352
362
  );
353
- g.includes("--dry-run") && (console.log(JSON.stringify({ engineConfig: m, webServers: D }, null, 2)), process.exit(0));
354
- const Ee = /* @__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([
355
365
  "--dry-run",
356
366
  "--serve",
357
367
  "--update-golden",
358
368
  "--approve-divergence",
359
369
  "--divergence-only"
360
- ]), De = g.filter((e) => !Ee.has(e));
361
- Pe().catch((e) => {
370
+ ]), je = d.filter((e) => !Pe.has(e));
371
+ $e().catch((e) => {
362
372
  console.error(e), process.exitCode = 1;
363
373
  });
364
- async function Pe() {
365
- if (g.includes("--serve")) {
366
- if (m.isSourceOfTruthAdapter)
374
+ async function $e() {
375
+ if (d.includes("--serve")) {
376
+ if (g.isSourceOfTruthAdapter)
367
377
  throw new Error(
368
378
  "Dev Mode (--serve) has nothing to sync this project's Storybook against — isSourceOfTruthAdapter is true in this project's adapter-tester.config.json."
369
379
  );
370
- await ne(m, D);
380
+ await ae(g, P);
371
381
  } else {
372
- const e = D.at(-1);
382
+ const e = P.at(-1);
373
383
  if (!e)
374
384
  throw new Error("resolveConfig() returned no webServers to boot.");
375
- await je(e, m);
385
+ await Ne(e, g);
376
386
  }
377
387
  }
378
- async function je(e, t) {
379
- const r = a(E, ".adapter-tester/run");
380
- _(r, { recursive: !0 });
388
+ async function Ne(e, t) {
389
+ const r = a(D, ".adapter-tester/run");
390
+ I(r, { recursive: !0 });
381
391
  const o = t.targets.at(-1);
382
392
  if (!o)
383
393
  throw new Error("resolveConfig() returned no targets to check.");
384
394
  const { url: s, process: n } = await A(
385
- x(o.name, e)
395
+ E(o.name, e)
386
396
  );
387
- o.url = s, O(
397
+ o.url = s, x(
388
398
  a(r, "playwright.config.js"),
389
399
  `// Generated by \`adapter-tester\` — do not edit, regenerated on every run.
390
400
  import { defineConfig, devices } from "@playwright/test";
@@ -407,11 +417,11 @@ export default defineConfig({
407
417
  // the time this config is used (see runAutomated() in cli.ts).
408
418
  });
409
419
  `
410
- ), O(
420
+ ), x(
411
421
  a(r, "visual-regression.spec.js"),
412
422
  `// Generated by \`adapter-tester\` — do not edit, regenerated on every run.
413
423
  import { test, expect } from "@playwright/test";
414
- import { resolveVisualRegressionPlan } from ${JSON.stringify(Ae)};
424
+ import { resolveVisualRegressionPlan } from ${JSON.stringify(De)};
415
425
 
416
426
  // \`test.describe\`/\`test\` are called here, not inside resolveVisualRegressionPlan,
417
427
  // so Playwright's HTML report groups the suite under this file instead of a
@@ -419,8 +429,18 @@ import { resolveVisualRegressionPlan } from ${JSON.stringify(Ae)};
419
429
  const { ownTargetName, suiteLabel, stories, missingFromSourceOfTruth, checkStory } =
420
430
  await resolveVisualRegressionPlan(${JSON.stringify(t, null, 2)});
421
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
+
422
442
  test.describe(\`\${ownTargetName} — \${suiteLabel}\`, () => {
423
- if (missingFromSourceOfTruth.length > 0) {
443
+ if (!storyId && missingFromSourceOfTruth.length > 0) {
424
444
  test("story parity with source of truth", () => {
425
445
  expect(
426
446
  missingFromSourceOfTruth,
@@ -428,7 +448,7 @@ test.describe(\`\${ownTargetName} — \${suiteLabel}\`, () => {
428
448
  ).toEqual([]);
429
449
  });
430
450
  }
431
- for (const story of stories) {
451
+ for (const story of scopedStories) {
432
452
  test(story.id, async ({ browser }, testInfo) => {
433
453
  await checkStory(story, browser, testInfo);
434
454
  });
@@ -437,18 +457,18 @@ test.describe(\`\${ownTargetName} — \${suiteLabel}\`, () => {
437
457
  `
438
458
  );
439
459
  try {
440
- const d = J(
460
+ const l = W(
441
461
  "npx",
442
462
  [
443
463
  "playwright",
444
464
  "test",
445
465
  "--config",
446
466
  a(r, "playwright.config.js"),
447
- ...De
467
+ ...je
448
468
  ],
449
- { stdio: "inherit", cwd: E, shell: process.platform === "win32" }
469
+ { stdio: "inherit", cwd: D, shell: process.platform === "win32" }
450
470
  );
451
- process.exitCode = d.status ?? 1;
471
+ process.exitCode = l.status ?? 1;
452
472
  } finally {
453
473
  n == null || n.kill("SIGTERM");
454
474
  }