@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/README.md +13 -7
- package/dist/cli.cjs +21 -11
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +165 -145
- package/dist/cli.js.map +1 -1
- package/dist/config.d.ts +4 -3
- package/dist/config.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 +9 -9
- 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 +120 -120
- package/dist/testing.js.map +1 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
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
|
|
6
|
-
import
|
|
7
|
-
import { createProxyMiddleware as
|
|
8
|
-
import
|
|
9
|
-
import { m as
|
|
10
|
-
import { a as
|
|
11
|
-
const
|
|
12
|
-
function
|
|
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
|
|
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
|
|
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
|
|
33
|
-
|
|
32
|
+
function se(e, t) {
|
|
33
|
+
I(j(e), { recursive: !0 }), x(e, JSON.stringify({ port: t }));
|
|
34
34
|
}
|
|
35
|
-
function
|
|
35
|
+
function ne(e, t) {
|
|
36
36
|
return new Promise((r, o) => {
|
|
37
37
|
var y, w;
|
|
38
|
-
const s =
|
|
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
|
|
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),
|
|
51
|
-
const
|
|
52
|
-
for (const c of
|
|
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
|
|
56
|
-
(u ? console.error : console.log)(`[${
|
|
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 =
|
|
59
|
+
const v = p.replace(ee, "").match(te);
|
|
60
60
|
if (v) {
|
|
61
|
-
n = !0, clearTimeout(
|
|
62
|
-
const c = v[1],
|
|
63
|
-
|
|
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) =>
|
|
67
|
-
n || (n = !0, clearTimeout(
|
|
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(
|
|
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
|
|
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 =
|
|
90
|
-
if (t !== void 0 && await
|
|
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}...`),
|
|
99
|
+
return console.log(`[Dev Launcher] Launching Storybook for ${e.name}...`), ne(e, e.timeoutMs ?? 120 * 1e3);
|
|
100
100
|
}
|
|
101
|
-
const N =
|
|
102
|
-
function
|
|
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}`),
|
|
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
|
|
112
|
-
const [o, s] = e.targets, [n,
|
|
113
|
-
if (!(o != null && o.sourceOfTruth) || !s || s.sourceOfTruth || !n || !
|
|
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
|
|
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
|
-
|
|
123
|
+
E(o.name, n)
|
|
124
124
|
),
|
|
125
|
-
A(
|
|
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
|
-
(
|
|
130
|
-
), u =
|
|
131
|
-
u.get("/", (
|
|
132
|
-
if (
|
|
133
|
-
|
|
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
|
|
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
|
-
|
|
146
|
-
}), u.get("/report-header.txt", (
|
|
145
|
+
b.send(q);
|
|
146
|
+
}), u.get("/report-header.txt", (m, b) => {
|
|
147
147
|
if (e.reportHeader !== void 0) {
|
|
148
|
-
|
|
148
|
+
b.type("text/plain").send(e.reportHeader);
|
|
149
149
|
return;
|
|
150
150
|
}
|
|
151
151
|
try {
|
|
152
|
-
|
|
152
|
+
b.type("text/plain").send(S(v, "utf8"));
|
|
153
153
|
} catch {
|
|
154
|
-
|
|
154
|
+
b.status(500).send("Error loading report-header.txt");
|
|
155
155
|
}
|
|
156
156
|
}), u.use(
|
|
157
157
|
"/",
|
|
158
|
-
|
|
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
|
|
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
|
|
171
|
+
for (const m of i) m.kill("SIGINT");
|
|
172
172
|
process.exit(0);
|
|
173
173
|
}
|
|
174
174
|
};
|
|
175
|
-
process.on("SIGINT",
|
|
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:${
|
|
179
|
+
http://localhost:${f}
|
|
180
180
|
====================================================
|
|
181
|
-
`),
|
|
181
|
+
`), ie(`http://localhost:${f}`);
|
|
182
182
|
});
|
|
183
183
|
}
|
|
184
|
-
const
|
|
185
|
-
$schema:
|
|
186
|
-
$id:
|
|
187
|
-
title:
|
|
188
|
-
description:
|
|
189
|
-
type:
|
|
190
|
-
additionalProperties:
|
|
191
|
-
properties:
|
|
192
|
-
},
|
|
193
|
-
|
|
194
|
-
const
|
|
195
|
-
function
|
|
196
|
-
if (
|
|
197
|
-
const r = (
|
|
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
|
|
207
|
-
function
|
|
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 (!
|
|
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
|
|
215
|
+
function ke(e) {
|
|
216
216
|
var s;
|
|
217
|
-
const r = (s =
|
|
218
|
-
return o ? Number(o[1]) :
|
|
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
|
|
221
|
-
const r =
|
|
220
|
+
function Oe(e) {
|
|
221
|
+
const r = V(e).name;
|
|
222
222
|
return r ? r.split("/").pop() : "Adapter";
|
|
223
223
|
}
|
|
224
|
-
function
|
|
225
|
-
const t = a(e,
|
|
226
|
-
if (!
|
|
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
|
|
229
|
+
return ye(r, t), r;
|
|
230
230
|
}
|
|
231
|
-
function
|
|
232
|
-
var
|
|
233
|
-
const r =
|
|
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 ??
|
|
239
|
-
command:
|
|
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:
|
|
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 ??
|
|
247
|
-
sourceOfTruthThresholdPixels: r.sourceOfTruthThresholdPixels ??
|
|
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(
|
|
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,
|
|
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,
|
|
282
|
-
const
|
|
281
|
+
u = i.name ?? C, p = i.port ?? R;
|
|
282
|
+
const T = $(e, i.cwd ?? ".");
|
|
283
283
|
v = {
|
|
284
|
-
command: i.command ??
|
|
285
|
-
port:
|
|
286
|
-
cwd:
|
|
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(
|
|
292
|
+
dir: a(T, "test", "golden")
|
|
293
293
|
};
|
|
294
294
|
} else {
|
|
295
|
-
u = C,
|
|
296
|
-
const
|
|
297
|
-
v =
|
|
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:
|
|
300
|
-
mantineAdapterVersion:
|
|
299
|
+
port: p,
|
|
300
|
+
mantineAdapterVersion: T,
|
|
301
301
|
storybookTemplateVersion: i.storybookTemplateVersion
|
|
302
302
|
}), c = {
|
|
303
303
|
type: "npm",
|
|
304
|
-
packageName:
|
|
305
|
-
versionSpec:
|
|
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:${
|
|
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
|
|
329
|
-
let
|
|
330
|
-
const k =
|
|
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 =
|
|
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
|
-
|
|
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
|
|
340
|
-
mantineAdapterVersion:
|
|
349
|
+
const D = process.cwd(), { engineConfig: g, webServers: P } = Ee(D, {
|
|
350
|
+
mantineAdapterVersion: H
|
|
341
351
|
});
|
|
342
|
-
|
|
343
|
-
if (
|
|
344
|
-
if (
|
|
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
|
-
|
|
349
|
-
} else if (
|
|
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
|
-
|
|
354
|
-
const
|
|
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
|
-
]),
|
|
361
|
-
|
|
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
|
|
365
|
-
if (
|
|
366
|
-
if (
|
|
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
|
|
380
|
+
await ae(g, P);
|
|
371
381
|
} else {
|
|
372
|
-
const e =
|
|
382
|
+
const e = P.at(-1);
|
|
373
383
|
if (!e)
|
|
374
384
|
throw new Error("resolveConfig() returned no webServers to boot.");
|
|
375
|
-
await
|
|
385
|
+
await Ne(e, g);
|
|
376
386
|
}
|
|
377
387
|
}
|
|
378
|
-
async function
|
|
379
|
-
const r = a(
|
|
380
|
-
|
|
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
|
-
|
|
395
|
+
E(o.name, e)
|
|
386
396
|
);
|
|
387
|
-
o.url = s,
|
|
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
|
-
),
|
|
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(
|
|
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
|
|
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
|
|
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
|
-
...
|
|
467
|
+
...je
|
|
448
468
|
],
|
|
449
|
-
{ stdio: "inherit", cwd:
|
|
469
|
+
{ stdio: "inherit", cwd: D, shell: process.platform === "win32" }
|
|
450
470
|
);
|
|
451
|
-
process.exitCode =
|
|
471
|
+
process.exitCode = l.status ?? 1;
|
|
452
472
|
} finally {
|
|
453
473
|
n == null || n.kill("SIGTERM");
|
|
454
474
|
}
|