@recursica/adapter-tester 3.0.0 → 4.0.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 +36 -21
- package/dist/adapter-tester.schema.json.d.ts +18 -9
- package/dist/cli.cjs +31 -18
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +231 -181
- package/dist/cli.js.map +1 -1
- package/dist/config.d.ts +23 -12
- package/dist/config.d.ts.map +1 -1
- package/dist/fileConfig.d.ts +14 -5
- package/dist/fileConfig.d.ts.map +1 -1
- package/dist/golden/diffPng.d.ts +12 -7
- package/dist/golden/diffPng.d.ts.map +1 -1
- package/dist/golden/manifestStore.d.ts +19 -1
- package/dist/golden/manifestStore.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 +46 -21
- package/dist/testing/runVisualRegression.d.ts.map +1 -1
- package/dist/testing.cjs +3 -3
- package/dist/testing.cjs.map +1 -1
- package/dist/testing.d.ts +1 -1
- package/dist/testing.d.ts.map +1 -1
- package/dist/testing.js +251 -165
- package/dist/testing.js.map +1 -1
- package/package.json +2 -6
- package/src/adapter-tester.schema.json +18 -9
package/README.md
CHANGED
|
@@ -12,9 +12,9 @@ This package provides three primary utilities:
|
|
|
12
12
|
2. **Interactive Dev Mode:** A side-by-side synchronized browser environment with built-in note taking for auditing components and feeding fixes directly to an AI agent.
|
|
13
13
|
3. **An installable devDependency**, wired into `@recursica/mantine-adapter` — the source-of-truth adapter, run in `isSourceOfTruthAdapter` mode (own-drift check only, since it has nothing above it to diverge from). Any other adapter repo — including one that never checked out this monorepo — can install it the same way. See [Using this package in another adapter repo](#using-this-package-in-another-adapter-repo).
|
|
14
14
|
|
|
15
|
-
**Default mode** (used by any adapter repo installing this package): checks this project's own Storybook — the one already defined by its `storybook` npm script — against its own committed golden images,
|
|
15
|
+
**Default mode** (used by any adapter repo installing this package): checks this project's own Storybook — the one already defined by its `storybook` npm script — against its own committed golden images. No monorepo checkout, no manual config, in most cases no config file at all. Divergence from the source-of-truth adapter's (`@recursica/mantine-adapter`) own golden images is a separate, opt-in check — see [`--divergence-only`](#automated-visual-tests).
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
`@recursica/adapter-tester` itself has no default mode and no `adapter-tester.config.json` of its own — it's purely a tool other adapters install and configure. `mantine-adapter` and `mui-adapter` are the ones that run it, each with their own config.
|
|
18
18
|
|
|
19
19
|
---
|
|
20
20
|
|
|
@@ -26,13 +26,15 @@ Installing `@recursica/adapter-tester` as a devDependency (see [below](#using-th
|
|
|
26
26
|
{
|
|
27
27
|
"scripts": {
|
|
28
28
|
"adapter-tester": "adapter-tester --serve",
|
|
29
|
-
"adapter-tester:automated": "adapter-tester"
|
|
29
|
+
"adapter-tester:automated": "adapter-tester",
|
|
30
|
+
"adapter-tester:source-of-truth": "adapter-tester --divergence-only"
|
|
30
31
|
}
|
|
31
32
|
}
|
|
32
33
|
```
|
|
33
34
|
|
|
34
35
|
- `npm run adapter-tester` — Interactive Dev Mode: boots both Storybooks (reusing them if already running) and opens the synced side-by-side comparison browser.
|
|
35
|
-
- `npm run adapter-tester:automated` — the headless
|
|
36
|
+
- `npm run adapter-tester:automated` — the headless own-drift check against this project's own committed goldens; see [Automated Visual Tests](#automated-visual-tests) below. This is the one to run normally — fast, no network calls.
|
|
37
|
+
- `npm run adapter-tester:source-of-truth` — the separate, opt-in divergence check against the source-of-truth adapter's published goldens. Not wired up for `@recursica/mantine-adapter` itself — it _is_ the source of truth, so it has nothing to diverge from.
|
|
36
38
|
|
|
37
39
|
Both boot Storybooks themselves — nothing needs to be running beforehand.
|
|
38
40
|
|
|
@@ -76,10 +78,11 @@ The Dev Mode server fetches this file dynamically, so any changes you make to `r
|
|
|
76
78
|
|
|
77
79
|
## Automated Visual Tests
|
|
78
80
|
|
|
79
|
-
|
|
81
|
+
Two independent checks, gated by `--divergence-only` — the normal, everyday one and a separate opt-in one:
|
|
80
82
|
|
|
81
83
|
```bash
|
|
82
|
-
npm run adapter-tester:automated
|
|
84
|
+
npm run adapter-tester:automated # own-drift check only — the normal one to run
|
|
85
|
+
npm run adapter-tester:source-of-truth # divergence check only — opt-in, against Mantine
|
|
83
86
|
```
|
|
84
87
|
|
|
85
88
|
`adapter-tester` reads `adapter-tester.config.json` from the current directory (or falls back to defaults if the file doesn't exist), generates a throwaway Playwright config + spec under `.adapter-tester/run/` (git-ignore this directory), and runs it. There's no Playwright config or spec file to hand-author.
|
|
@@ -92,13 +95,21 @@ Any other args are forwarded to `playwright test`, so you can scope a run to spe
|
|
|
92
95
|
npm run adapter-tester:automated -- --grep "Toast"
|
|
93
96
|
```
|
|
94
97
|
|
|
98
|
+
Pin the source-of-truth adapter's version for the divergence check (instead of resolving `@recursica/mantine-adapter`'s `latest` on npm) with `--source-of-truth-version`:
|
|
99
|
+
|
|
100
|
+
```bash
|
|
101
|
+
npm run adapter-tester:source-of-truth -- --source-of-truth-version 0.53.0
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
Only meaningful with the default `sourceOfTruth.type: "mantine-harness"` mode — throws if combined with `sourceOfTruth.type: "url"` (that mode reads a sibling package's local checkout directly, there's no version to pin) or with `isSourceOfTruthAdapter: true` (nothing to pin a version for).
|
|
105
|
+
|
|
95
106
|
### What happens during execution?
|
|
96
107
|
|
|
97
108
|
1. **Automatic Storybook Bootup**: `adapter-tester` boots only this project's own Storybook — the divergence check reads the source-of-truth adapter's stored golden files, never a live Storybook, so nothing else needs to boot.
|
|
98
109
|
2. **Story Discovery**: The test suite fetches this project's own Storybook index (`/index.json`) to dynamically discover and parameterize tests for every component story, excluding `@recursica/storybook-template`'s own default token/theme demo stories (`Theme/*`, `Tokens/*`) and each adapter's own onboarding stories (`Introduction/*`).
|
|
99
|
-
3. **Headless Snapshot**: It launches headless Chrome, navigates to the isolated iframe view, and takes a screenshot.
|
|
100
|
-
4. **Own-Drift Check
|
|
101
|
-
5. **Divergence Check
|
|
110
|
+
3. **Headless Snapshot**: It launches headless Chrome, navigates to the isolated iframe view, and takes a screenshot. A missing golden is captured from this screenshot regardless of which check is running.
|
|
111
|
+
4. **Own-Drift Check** (`adapter-tester:automated`): Diffs the screenshot against this project's own `test/golden/<story-id>.png` using `pixelmatch`, against the configured mismatch threshold. No golden yet for a story is not a failure — one is captured from this run.
|
|
112
|
+
5. **Divergence Check** (`adapter-tester:source-of-truth`): Diffs this project's own golden against the source-of-truth adapter's golden (skipped for the source-of-truth adapter's own config). Different and not yet reviewed via `--approve-divergence`? Flagged as a report annotation — never a failure on its own.
|
|
102
113
|
6. **Native Report Generation**: Screenshots, diff overlays, and divergence flags are embedded directly as test attachments/annotations.
|
|
103
114
|
|
|
104
115
|
### Output & Reports
|
|
@@ -129,8 +140,9 @@ These are explicit, developer-run workflows — not run in CI, and not scoped do
|
|
|
129
140
|
npm run adapter-tester:automated -- --grep "Toast" --update-golden
|
|
130
141
|
|
|
131
142
|
# Review a flagged divergence from the source of truth, and accept it as
|
|
132
|
-
# intentional.
|
|
133
|
-
|
|
143
|
+
# intentional. Only valid alongside --divergence-only — there's nothing to
|
|
144
|
+
# approve without the divergence check running.
|
|
145
|
+
npm run adapter-tester:source-of-truth -- --grep "Toast" --approve-divergence
|
|
134
146
|
```
|
|
135
147
|
|
|
136
148
|
`--approve-divergence` records the source-of-truth adapter's own `manifest.json` `createdAt` for that story at review time. If the source of truth's golden is recaptured later, the divergence flags again for re-review — approval isn't a permanent exemption.
|
|
@@ -151,24 +163,26 @@ Every `adapter-tester.config.json` is validated against [`src/adapter-tester.sch
|
|
|
151
163
|
|
|
152
164
|
```json
|
|
153
165
|
{
|
|
154
|
-
"$schema": "
|
|
166
|
+
"$schema": "https://raw.githubusercontent.com/borderux/recursica/main/packages/adapter-tester/src/adapter-tester.schema.json",
|
|
155
167
|
"name": "MyAdapter",
|
|
156
168
|
"storybook": { "port": 6006, "command": "npm run storybook" },
|
|
157
169
|
"sourceOfTruth": { "type": "mantine-harness" },
|
|
158
170
|
"diffThresholdPixels": 3500,
|
|
159
|
-
"
|
|
160
|
-
|
|
161
|
-
|
|
171
|
+
"stories": {
|
|
172
|
+
"ui-kit-slider": { "threshold": 15000 },
|
|
173
|
+
"ui-kit-slider--range-mode-with-icons-and-inputs": { "exclude": true }
|
|
174
|
+
},
|
|
175
|
+
"excludeTitlePrefixes": ["Theme", "Tokens", "Introduction"]
|
|
162
176
|
}
|
|
163
177
|
```
|
|
164
178
|
|
|
165
179
|
- `name` — label for this project's own target. Defaults to the unscoped `package.json` name.
|
|
166
180
|
- `storybook.port` — defaults to whatever `-p`/`--port` is set on this project's own `storybook` script; falls back to Storybook's default of `6006`.
|
|
167
181
|
- `storybook.command`/`storybook.cwd` — default to `npm run storybook` in the current directory.
|
|
168
|
-
- `sourceOfTruth` — defaults to `{ "type": "mantine-harness" }`: a throwaway harness that installs the _published_ `@recursica/mantine-adapter` from npm, so you never need this monorepo checked out. This is the standard mode every external adapter repo uses.
|
|
169
|
-
- `sourceOfTruth.type: "url"` — the **non-standard** mode: points at an already-addressable Storybook via `command`/`port`/`cwd` instead of the harness, and reads that sibling package's `test/golden/` directly from disk for the divergence check (including uncommitted local changes) instead of resolving a published npm version.
|
|
182
|
+
- `sourceOfTruth` — defaults to `{ "type": "mantine-harness" }`: a throwaway harness that installs the _published_ `@recursica/mantine-adapter` from npm, so you never need this monorepo checked out. This is the standard mode every external adapter repo uses. `sourceOfTruth.mantineAdapterVersion` pins the version installed/fetched (defaults to `latest`) — or override it per-run with `--source-of-truth-version` instead of hardcoding it in the config.
|
|
183
|
+
- `sourceOfTruth.type: "url"` — the **non-standard** mode: points at an already-addressable Storybook via `command`/`port`/`cwd` instead of the harness, and reads that sibling package's `test/golden/` directly from disk for the divergence check (including uncommitted local changes) instead of resolving a published npm version. For comparing two locally checked-out sibling adapters instead of a published one.
|
|
170
184
|
- `isSourceOfTruthAdapter` — set `true` only in the source-of-truth adapter's own config (`@recursica/mantine-adapter`). Skips `sourceOfTruth`/the divergence check entirely; runs the own-drift check standalone. Also disables Dev Mode (`--serve`) — there's nothing to sync against.
|
|
171
|
-
- `diffThresholdPixels`/`
|
|
185
|
+
- `diffThresholdPixels`/`stories`/`excludeTitlePrefixes` — same meaning as before; see `src/adapter-tester.schema.json` for full docs.
|
|
172
186
|
|
|
173
187
|
---
|
|
174
188
|
|
|
@@ -181,11 +195,12 @@ npm install --save-dev @recursica/adapter-tester @playwright/test
|
|
|
181
195
|
npx playwright install chromium
|
|
182
196
|
```
|
|
183
197
|
|
|
184
|
-
If your repo already has a `storybook` npm script with a port set (`storybook dev -p 6006`), no config file is required. Add the
|
|
198
|
+
If your repo already has a `storybook` npm script with a port set (`storybook dev -p 6006`), no config file is required. Add the scripts from [npm scripts](#npm-scripts) above to your `package.json`, then:
|
|
185
199
|
|
|
186
200
|
```bash
|
|
187
|
-
npm run adapter-tester
|
|
188
|
-
npm run adapter-tester:automated
|
|
201
|
+
npm run adapter-tester # Interactive Dev Mode
|
|
202
|
+
npm run adapter-tester:automated # own-drift check — run this normally
|
|
203
|
+
npm run adapter-tester:source-of-truth # divergence check — opt-in, against Mantine
|
|
189
204
|
```
|
|
190
205
|
|
|
191
206
|
Any extra args after `adapter-tester:automated` are passed straight through to `playwright test`, so you can scope a run instead of executing the full suite:
|
|
@@ -8,7 +8,7 @@ declare const _default: {
|
|
|
8
8
|
"properties": {
|
|
9
9
|
"$schema": {
|
|
10
10
|
"type": "string",
|
|
11
|
-
"description": "Optional pointer to this schema for editor autocomplete, e.g. \"
|
|
11
|
+
"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\"."
|
|
12
12
|
},
|
|
13
13
|
"name": {
|
|
14
14
|
"type": "string",
|
|
@@ -98,20 +98,29 @@ declare const _default: {
|
|
|
98
98
|
"minimum": 0,
|
|
99
99
|
"description": "Global visual diff threshold, in mismatched pixels, before a story is considered a failure. Defaults to 3500. AI agents must not modify this field — see AGENT.md."
|
|
100
100
|
},
|
|
101
|
-
"
|
|
101
|
+
"stories": {
|
|
102
102
|
"type": "object",
|
|
103
|
-
"additionalProperties": {
|
|
104
|
-
|
|
103
|
+
"additionalProperties": {
|
|
104
|
+
"type": "object",
|
|
105
|
+
"additionalProperties": false,
|
|
106
|
+
"properties": {
|
|
107
|
+
"threshold": {
|
|
108
|
+
"type": "number",
|
|
109
|
+
"minimum": 0,
|
|
110
|
+
"description": "Diff threshold override for matching stories, in mismatched pixels. Overrides `diffThresholdPixels`."
|
|
111
|
+
},
|
|
112
|
+
"exclude": {
|
|
113
|
+
"type": "boolean",
|
|
114
|
+
"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."
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
},
|
|
118
|
+
"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."
|
|
105
119
|
},
|
|
106
120
|
"excludeTitlePrefixes": {
|
|
107
121
|
"type": "array",
|
|
108
122
|
"items": { "type": "string" },
|
|
109
123
|
"description": "Storybook title prefixes to exclude from comparison, in addition to the built-in denylist (`Theme/*`, `Tokens/*`, `Introduction`)."
|
|
110
|
-
},
|
|
111
|
-
"excludeStoryIds": {
|
|
112
|
-
"type": "array",
|
|
113
|
-
"items": { "type": "string" },
|
|
114
|
-
"description": "Story id prefixes to skip entirely — no own-drift check, no divergence check, no golden captured. For excluding individual stories that don't have a cross-adapter counterpart; use `excludeTitlePrefixes` to drop a whole title instead."
|
|
115
124
|
}
|
|
116
125
|
}
|
|
117
126
|
}
|
package/dist/cli.cjs
CHANGED
|
@@ -1,35 +1,48 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
"use strict";const x=require("node:child_process"),
|
|
3
|
-
`))
|
|
4
|
-
`))
|
|
5
|
-
<script>window.__ADAPTER_TESTER__ = ${JSON.stringify({ownName:
|
|
6
|
-
[Dev Launcher] Shutting down Dev Mode server and spawned Storybooks...`);for(const
|
|
2
|
+
"use strict";const x=require("node:child_process"),u=require("node:fs"),n=require("node:path"),A=require("node:url"),V=require("node:net"),G=require("express"),J=require("http-proxy-middleware"),B=require("./mantineSourceOfTruth-BUb5MZy0.cjs"),I=require("./index-C6uYPRmx.cjs");var S=typeof document<"u"?document.currentScript:null;const R=n.dirname(A.fileURLToPath(typeof document>"u"?require("url").pathToFileURL(__filename).href:S&&S.tagName.toUpperCase()==="SCRIPT"&&S.src||new URL("cli.cjs",document.baseURI).href));function P(t){return new Promise(r=>{const e=new V.Socket;e.setTimeout(200),e.once("connect",()=>{e.destroy(),r(!0)}),e.once("timeout",()=>{e.destroy(),r(!1)}),e.once("error",()=>{e.destroy(),r(!1)}),e.connect(t,"127.0.0.1")})}async function _(t,r=6e4){const e=Date.now();for(;Date.now()-e<r;){if(await P(t))return!0;await new Promise(o=>setTimeout(o,500))}return!1}function $(t){return Number(new URL(t).port)}function L(t,r){var o,s;console.log(`[Dev Launcher] Port ${r.port} is inactive. Launching Storybook for ${t}...`);const e=x.spawn(r.command,{cwd:r.cwd,stdio:"pipe",shell:!0});return(o=e.stdout)==null||o.on("data",i=>{for(const d of i.toString().split(`
|
|
3
|
+
`))d.trim()&&console.log(`[${t} SB] ${d.trim()}`)}),(s=e.stderr)==null||s.on("data",i=>{for(const d of i.toString().split(`
|
|
4
|
+
`))d.trim()&&console.error(`[${t} SB ERROR] ${d.trim()}`)}),e.on("error",i=>{console.error(`[${t} SB ERROR] Failed to start process:`,i)}),e}function W(t){const r=process.platform==="darwin"?"open":process.platform==="win32"?"start":"xdg-open";console.log(`[Dev Launcher] Auto-launching browser: ${t}`),x.spawn(r,[t],{shell:process.platform==="win32"}).on("error",e=>{console.error("[Dev Launcher] Failed to auto-launch browser:",e)})}function H(t,r,e={}){const[o,s]=t.targets,[i,d]=r;if(!(o!=null&&o.sourceOfTruth)||!s||s.sourceOfTruth||!i||!d)throw new Error("adapter-tester dev mode requires exactly two targets: [sourceOfTruth, target] — check adapter-tester.config.json.");const w=e.port??6010,m=$(o.url),g=$(s.url),a=G(),T=n.join(R,"../public"),v=n.join(R,"../report-header.txt");a.get("/",(p,l,c)=>{if(p.query.path){c();return}const E=u.readFileSync(n.join(T,"index.html"),"utf8").replace("<head>",`<head>
|
|
5
|
+
<script>window.__ADAPTER_TESTER__ = ${JSON.stringify({ownName:s.name,sourceOfTruthName:o.name,sourceOfTruthPort:m})};<\/script>`);l.send(E)}),a.get("/report-header.txt",(p,l)=>{try{l.type("text/plain").send(u.readFileSync(v,"utf8"))}catch{l.status(500).send("Error loading report-header.txt")}}),a.use("/",J.createProxyMiddleware({target:`http://localhost:${g}`,changeOrigin:!0,ws:!0}));const y=[];let b=!1;const k=()=>{if(!b){b=!0,console.log(`
|
|
6
|
+
[Dev Launcher] Shutting down Dev Mode server and spawned Storybooks...`);for(const p of y)p.kill("SIGINT");process.exit(0)}};process.on("SIGINT",k),process.on("SIGTERM",k),a.listen(w,async()=>{console.log(`
|
|
7
7
|
====================================================
|
|
8
8
|
🚀 Adapter Dev Mode proxy running at:
|
|
9
|
-
http://localhost:${
|
|
9
|
+
http://localhost:${w}
|
|
10
10
|
====================================================
|
|
11
|
-
`);const[
|
|
12
|
-
`);throw new Error(`Invalid ${
|
|
13
|
-
${e}`)}const
|
|
11
|
+
`);const[p,l]=await Promise.all([P(m),P(g)]);p?console.log(`[Dev Launcher] ${o.name} is already running on port ${m}.`):y.push(L(o.name,i)),l?console.log(`[Dev Launcher] ${s.name} is already running on port ${g}.`):y.push(L(s.name,d));const c=[];p||c.push(_(m)),l||c.push(_(g)),c.length>0?(console.log("[Dev Launcher] Waiting for Storybooks to be responsive..."),(await Promise.all(c)).every(Boolean)?console.log("[Dev Launcher] All Storybooks are active and responsive!"):console.warn("[Dev Launcher] Warning: some Storybooks timed out during startup, but proceeding...")):console.log("[Dev Launcher] Both Storybooks already active."),W(`http://localhost:${w}`)})}const K="http://json-schema.org/draft-07/schema#",Y="https://github.com/borderux/recursica/tree/main/packages/adapter-tester/src/adapter-tester.schema.json",X="adapter-tester.config.json",z="Configuration for @recursica/adapter-tester. All fields are optional — an adapter repo with a normal `storybook` npm script needs no config file at all.",Q="object",Z=!1,ee={$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:"Port the target's Storybook is served on. Auto-detected from this project's own `scripts.storybook` (a `-p <port>`/`--port <port>` flag) when omitted, falling back to Storybook's own default of 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:"Port the throwaway harness's Storybook is served on. Defaults to 6011."},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","port"],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:"Port the source-of-truth Storybook is served on."},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."},diffThresholdPixels:{type:"number",minimum:0,description:"Global visual diff threshold, in mismatched pixels, before a story is considered a failure. Defaults to 3500. AI agents must not modify this field — see AGENT.md."},stories:{type:"object",additionalProperties:{type:"object",additionalProperties:!1,properties:{threshold:{type:"number",minimum:0,description:"Diff threshold override for matching stories, in mismatched pixels. Overrides `diffThresholdPixels`."},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`)."}},te={$schema:K,$id:Y,title:X,description:z,type:Q,additionalProperties:Z,properties:ee},re=I.index,M=new I.ajvExports.Ajv({allErrors:!0,strict:!0});re(M);const N=M.compile(te);function oe(t,r){if(N(t))return;const e=(N.errors??[]).map(o=>{var i;const s=(i=o.params)!=null&&i.additionalProperty?` '${o.params.additionalProperty}'`:"";return` - ${o.instancePath||"root"} ${o.message}${s}`}).join(`
|
|
12
|
+
`);throw new Error(`Invalid ${r}:
|
|
13
|
+
${e}`)}const ne="@recursica/mantine-adapter",se="adapter-tester.config.json",C="npm run storybook",ie=6006,ae=6011,F="Mantine",ce=3500;function U(t){const r=n.join(t,"package.json");if(!u.existsSync(r))throw new Error(`No package.json found in ${t} — run adapter-tester from the root of the project being tested.`);return JSON.parse(u.readFileSync(r,"utf8"))}function de(t){var s;const e=(s=U(t).scripts)==null?void 0:s.storybook,o=e==null?void 0:e.match(/(?:-p|--port)[ =](\d+)/);return o?Number(o[1]):ie}function pe(t){const e=U(t).name;return e?e.split("/").pop():"Adapter"}function le(t){const r=n.join(t,se);if(!u.existsSync(r))return{};const e=JSON.parse(u.readFileSync(r,"utf8"));return oe(e,r),e}function ue(t,r={}){var k,p,l;const e=le(t),o=e.isSourceOfTruthAdapter??!1;if(r.mantineAdapterVersion&&o)throw new Error("--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.");const s=e.name??pe(t),i=((k=e.storybook)==null?void 0:k.port)??de(t),d=((p=e.storybook)==null?void 0:p.command)??C,w=n.resolve(t,((l=e.storybook)==null?void 0:l.cwd)??"."),m={command:d,port:i,cwd:w,reuseExistingServer:!process.env.CI,timeout:120*1e3},g={diffThresholdPixels:e.diffThresholdPixels??ce,stories:e.stories,excludeTitlePrefixes:e.excludeTitlePrefixes,goldenDir:n.join(w,"test","golden"),isSourceOfTruthAdapter:o,goldenMode:"check",checkMode:"own"};if(o)return{engineConfig:{...g,targets:[{name:s,url:`http://localhost:${i}`}]},webServers:[m]};const a=e.sourceOfTruth??{type:"mantine-harness"};let T,v,y,b;if(a.type==="url"){if(r.mantineAdapterVersion)throw new Error(`--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.`);T=a.name??F,v=a.port;const c=n.resolve(t,a.cwd??".");y={command:a.command??C,port:a.port,cwd:c,reuseExistingServer:!process.env.CI,timeout:120*1e3},b={type:"local",dir:n.join(c,"test","golden")}}else{T=F,v=a.port??ae;const c=r.mantineAdapterVersion??a.mantineAdapterVersion;y=B.mantineSourceOfTruthWebServer({dir:n.join(t,".adapter-tester/mantine-harness"),port:v,mantineAdapterVersion:c,storybookTemplateVersion:a.storybookTemplateVersion}),b={type:"npm",packageName:ne,versionSpec:c??"latest",cacheDir:n.join(t,".adapter-tester/mantine-golden-cache")}}return{engineConfig:{...g,targets:[{name:T,url:`http://localhost:${v}`,sourceOfTruth:!0},{name:s,url:`http://localhost:${i}`}],sourceOfTruthGolden:b},webServers:[y,m]}}const he=n.dirname(A.fileURLToPath(typeof document>"u"?require("url").pathToFileURL(__filename).href:S&&S.tagName.toUpperCase()==="SCRIPT"&&S.src||new URL("cli.cjs",document.baseURI).href)),fe=A.pathToFileURL(n.join(he,"testing.js")).href,f=process.argv.slice(2);let q;const O=f.indexOf("--source-of-truth-version");if(O!==-1){const t=f[O+1];if(t===void 0||t.startsWith("--"))throw new Error("--source-of-truth-version requires a value, e.g. --source-of-truth-version 0.53.0");q=t,f.splice(O,2)}const j=process.cwd(),{engineConfig:h,webServers:D}=ue(j,{mantineAdapterVersion:q});f.includes("--update-golden")?h.goldenMode="update-golden":f.includes("--approve-divergence")&&(h.goldenMode="approve-divergence");if(f.includes("--divergence-only")){if(h.isSourceOfTruthAdapter)throw new Error("--divergence-only has nothing to diverge from — isSourceOfTruthAdapter is true in this project's adapter-tester.config.json.");h.checkMode="divergence"}else if(h.goldenMode==="approve-divergence")throw new Error("--approve-divergence only makes sense with --divergence-only — there's nothing to approve without the divergence check running.");f.includes("--dry-run")&&(console.log(JSON.stringify({engineConfig:h,webServers:D},null,2)),process.exit(0));const me=new Set(["--dry-run","--serve","--update-golden","--approve-divergence","--divergence-only"]),ge=f.filter(t=>!me.has(t));if(f.includes("--serve")){if(h.isSourceOfTruthAdapter)throw new Error("Dev Mode (--serve) has nothing to sync this project's Storybook against — isSourceOfTruthAdapter is true in this project's adapter-tester.config.json.");H(h,D)}else ye(D.slice(-1),h);function ye(t,r){const e=n.join(j,".adapter-tester/run");u.mkdirSync(e,{recursive:!0}),u.writeFileSync(n.join(e,"playwright.config.js"),`// Generated by \`adapter-tester\` — do not edit, regenerated on every run.
|
|
14
14
|
import { defineConfig, devices } from "@playwright/test";
|
|
15
15
|
|
|
16
16
|
export default defineConfig({
|
|
17
17
|
testDir: ${JSON.stringify(e)},
|
|
18
|
-
//
|
|
19
|
-
// story's
|
|
20
|
-
//
|
|
21
|
-
|
|
18
|
+
// Stories run across Playwright's default worker pool — each golden check
|
|
19
|
+
// only reads/writes its own story's manifest.json entry, under a lock, so
|
|
20
|
+
// concurrent workers never race each other (see \`updateManifestEntry\`).
|
|
21
|
+
// Override with \`--workers <n>\` (forwarded straight through to Playwright).
|
|
22
|
+
fullyParallel: true,
|
|
22
23
|
forbidOnly: !!process.env.CI,
|
|
23
24
|
retries: process.env.CI ? 2 : 0,
|
|
24
|
-
workers: 1,
|
|
25
25
|
reporter: [["html", { open: "never" }], ["list"]],
|
|
26
26
|
use: { trace: "on-first-retry" },
|
|
27
27
|
projects: [{ name: "chromium", use: { ...devices["Desktop Chrome"] } }],
|
|
28
28
|
webServer: ${JSON.stringify(t,null,2)},
|
|
29
29
|
});
|
|
30
|
-
`),
|
|
31
|
-
import {
|
|
30
|
+
`),u.writeFileSync(n.join(e,"visual-regression.spec.js"),`// Generated by \`adapter-tester\` — do not edit, regenerated on every run.
|
|
31
|
+
import { test } from "@playwright/test";
|
|
32
|
+
import { resolveVisualRegressionPlan } from ${JSON.stringify(fe)};
|
|
32
33
|
|
|
33
|
-
|
|
34
|
-
|
|
34
|
+
// \`test.describe\`/\`test\` are called here, not inside resolveVisualRegressionPlan,
|
|
35
|
+
// so Playwright's HTML report groups the suite under this file instead of a
|
|
36
|
+
// sourcemapped path into adapter-tester's own library code.
|
|
37
|
+
const { ownTargetName, suiteLabel, stories, checkStory } =
|
|
38
|
+
await resolveVisualRegressionPlan(${JSON.stringify(r,null,2)});
|
|
39
|
+
|
|
40
|
+
test.describe(\`\${ownTargetName} — \${suiteLabel}\`, () => {
|
|
41
|
+
for (const story of stories) {
|
|
42
|
+
test(story.id, async ({ browser }, testInfo) => {
|
|
43
|
+
await checkStory(story, browser, testInfo);
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
`);const o=x.spawnSync("npx",["playwright","test","--config",n.join(e,"playwright.config.js"),...ge],{stdio:"inherit",cwd:j,shell:process.platform==="win32"});process.exit(o.status??1)}
|
|
35
48
|
//# sourceMappingURL=cli.cjs.map
|
package/dist/cli.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.cjs","sources":["../src/devServer.ts","../src/validateFileConfig.ts","../src/fileConfig.ts","../src/cli.ts"],"sourcesContent":["import { spawn, type ChildProcess } from \"node:child_process\";\nimport { readFileSync } from \"node:fs\";\nimport net from \"node:net\";\nimport { dirname, join } from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\nimport express from \"express\";\nimport { createProxyMiddleware } from \"http-proxy-middleware\";\nimport type { AdapterTesterConfig } from \"./config.js\";\nimport type { HarnessWebServerConfig } from \"./harness/mantineSourceOfTruth.js\";\n\n/**\n * Interactive Dev Mode: a synced, side-by-side browser view of this\n * project's own Storybook and the source of truth, with per-story note\n * taking and an AI-report export. Boots both Storybooks (reusing them if\n * already running) behind a proxy so the own/target pane — which drives\n * the sync and carries Storybook's nav sidebar — loads same-origin on the\n * left, with the source of truth following along as a bare preview on the\n * right.\n *\n * Config-driven — takes the same `{ engineConfig, webServers }` shape\n * `resolveConfig()` produces, in the same [sourceOfTruth, target] order.\n */\n\nconst distDir = dirname(fileURLToPath(import.meta.url));\n\nfunction isPortActive(port: number): Promise<boolean> {\n return new Promise((resolve) => {\n const socket = new net.Socket();\n socket.setTimeout(200);\n socket.once(\"connect\", () => {\n socket.destroy();\n resolve(true);\n });\n socket.once(\"timeout\", () => {\n socket.destroy();\n resolve(false);\n });\n socket.once(\"error\", () => {\n socket.destroy();\n resolve(false);\n });\n socket.connect(port, \"127.0.0.1\");\n });\n}\n\nasync function waitForPort(port: number, timeoutMs = 60000): Promise<boolean> {\n const start = Date.now();\n while (Date.now() - start < timeoutMs) {\n if (await isPortActive(port)) return true;\n await new Promise((resolve) => setTimeout(resolve, 500));\n }\n return false;\n}\n\nfunction portOf(url: string): number {\n return Number(new URL(url).port);\n}\n\nfunction launchStorybook(\n name: string,\n server: HarnessWebServerConfig,\n): ChildProcess {\n console.log(\n `[Dev Launcher] Port ${server.port} is inactive. Launching Storybook for ${name}...`,\n );\n const child = spawn(server.command, {\n cwd: server.cwd,\n stdio: \"pipe\",\n shell: true,\n });\n\n child.stdout?.on(\"data\", (data: Buffer) => {\n for (const line of data.toString().split(\"\\n\")) {\n if (line.trim()) console.log(`[${name} SB] ${line.trim()}`);\n }\n });\n child.stderr?.on(\"data\", (data: Buffer) => {\n for (const line of data.toString().split(\"\\n\")) {\n if (line.trim()) console.error(`[${name} SB ERROR] ${line.trim()}`);\n }\n });\n child.on(\"error\", (err) => {\n console.error(`[${name} SB ERROR] Failed to start process:`, err);\n });\n\n return child;\n}\n\nfunction openBrowser(url: string): void {\n const startCmd =\n process.platform === \"darwin\"\n ? \"open\"\n : process.platform === \"win32\"\n ? \"start\"\n : \"xdg-open\";\n console.log(`[Dev Launcher] Auto-launching browser: ${url}`);\n spawn(startCmd, [url], { shell: process.platform === \"win32\" }).on(\n \"error\",\n (err) => {\n console.error(`[Dev Launcher] Failed to auto-launch browser:`, err);\n },\n );\n}\n\nexport interface DevServerOptions {\n /** Port the dev-mode proxy UI itself listens on. Defaults to 6010. */\n port?: number;\n}\n\nexport function startDevServer(\n engineConfig: AdapterTesterConfig,\n webServers: HarnessWebServerConfig[],\n options: DevServerOptions = {},\n): void {\n const [sourceOfTruth, target] = engineConfig.targets;\n const [sourceOfTruthServer, targetServer] = webServers;\n if (\n !sourceOfTruth?.sourceOfTruth ||\n !target ||\n target.sourceOfTruth ||\n !sourceOfTruthServer ||\n !targetServer\n ) {\n throw new Error(\n \"adapter-tester dev mode requires exactly two targets: [sourceOfTruth, target] — check adapter-tester.config.json.\",\n );\n }\n\n const devPort = options.port ?? 6010;\n const sourceOfTruthPort = portOf(sourceOfTruth.url);\n const targetPort = portOf(target.url);\n\n const app = express();\n const publicDir = join(distDir, \"../public\");\n const headerPath = join(distDir, \"../report-header.txt\");\n\n // Serve the Dev Mode UI at the root path ONLY if there is no query string.\n // This allows the iframe (which loads with ?path=/story/...) to pass\n // through to the proxy, avoiding an infinite loop of nested wrappers.\n app.get(\"/\", (req, res, next) => {\n if (req.query.path) {\n next();\n return;\n }\n const html = readFileSync(join(publicDir, \"index.html\"), \"utf8\").replace(\n \"<head>\",\n `<head>\\n <script>window.__ADAPTER_TESTER__ = ${JSON.stringify({\n ownName: target.name,\n sourceOfTruthName: sourceOfTruth.name,\n sourceOfTruthPort,\n })};</script>`,\n );\n res.send(html);\n });\n\n // Serve the AI prompt header dynamically so it can be edited externally.\n app.get(\"/report-header.txt\", (req, res) => {\n try {\n res.type(\"text/plain\").send(readFileSync(headerPath, \"utf8\"));\n } catch {\n res.status(500).send(\"Error loading report-header.txt\");\n }\n });\n\n // Proxy everything else to this project's own Storybook, preserving\n // absolute paths (e.g. /@vite/client) so HMR keeps working same-origin.\n // This is the pane that drives the sync and shows Storybook's nav sidebar.\n app.use(\n \"/\",\n createProxyMiddleware({\n target: `http://localhost:${targetPort}`,\n changeOrigin: true,\n ws: true,\n }),\n );\n\n const spawned: ChildProcess[] = [];\n let cleaningUp = false;\n const cleanup = () => {\n if (cleaningUp) return;\n cleaningUp = true;\n console.log(\n \"\\n[Dev Launcher] Shutting down Dev Mode server and spawned Storybooks...\",\n );\n for (const child of spawned) child.kill(\"SIGINT\");\n process.exit(0);\n };\n process.on(\"SIGINT\", cleanup);\n process.on(\"SIGTERM\", cleanup);\n\n app.listen(devPort, async () => {\n console.log(`\n====================================================\n🚀 Adapter Dev Mode proxy running at:\n http://localhost:${devPort}\n====================================================\n`);\n\n const [sourceOfTruthRunning, targetRunning] = await Promise.all([\n isPortActive(sourceOfTruthPort),\n isPortActive(targetPort),\n ]);\n\n if (sourceOfTruthRunning) {\n console.log(\n `[Dev Launcher] ${sourceOfTruth.name} is already running on port ${sourceOfTruthPort}.`,\n );\n } else {\n spawned.push(launchStorybook(sourceOfTruth.name, sourceOfTruthServer));\n }\n if (targetRunning) {\n console.log(\n `[Dev Launcher] ${target.name} is already running on port ${targetPort}.`,\n );\n } else {\n spawned.push(launchStorybook(target.name, targetServer));\n }\n\n const waits: Promise<boolean>[] = [];\n if (!sourceOfTruthRunning) waits.push(waitForPort(sourceOfTruthPort));\n if (!targetRunning) waits.push(waitForPort(targetPort));\n\n if (waits.length > 0) {\n console.log(`[Dev Launcher] Waiting for Storybooks to be responsive...`);\n const results = await Promise.all(waits);\n if (results.every(Boolean)) {\n console.log(`[Dev Launcher] All Storybooks are active and responsive!`);\n } else {\n console.warn(\n `[Dev Launcher] Warning: some Storybooks timed out during startup, but proceeding...`,\n );\n }\n } else {\n console.log(`[Dev Launcher] Both Storybooks already active.`);\n }\n\n openBrowser(`http://localhost:${devPort}`);\n });\n}\n","import { Ajv } from \"ajv\";\nimport * as ajvFormatsModule from \"ajv-formats\";\nimport type { FormatsPlugin } from \"ajv-formats\";\nimport schema from \"./adapter-tester.schema.json\" with { type: \"json\" };\n\n// ajv-formats ships an ESM-style `export default` on a CJS build with no\n// `\"type\"` field, which under `moduleResolution: NodeNext` TS resolves to\n// the raw module namespace instead of unwrapping the default — a known\n// ajv-formats/TS interop gap, not a version mismatch.\nconst addFormats = (ajvFormatsModule as unknown as { default: FormatsPlugin })\n .default;\n\nconst ajv = new Ajv({ allErrors: true, strict: true });\naddFormats(ajv);\nconst validate = ajv.compile(schema);\n\n/**\n * Validates a parsed `adapter-tester.config.json` against\n * `adapter-tester.schema.json`. Throws with every violation listed — callers\n * must not silently coerce or drop invalid fields.\n */\nexport function validateFileConfig(data: unknown, path: string): void {\n if (validate(data)) return;\n\n const errors = (validate.errors ?? [])\n .map((error) => {\n const extra = error.params?.additionalProperty\n ? ` '${error.params.additionalProperty}'`\n : \"\";\n return ` - ${error.instancePath || \"root\"} ${error.message}${extra}`;\n })\n .join(\"\\n\");\n throw new Error(`Invalid ${path}:\\n${errors}`);\n}\n","import { existsSync, readFileSync } from \"node:fs\";\nimport { join, resolve } from \"node:path\";\nimport type {\n AdapterTesterConfig,\n SourceOfTruthGoldenLocation,\n} from \"./config.js\";\nimport type { HarnessWebServerConfig } from \"./harness/mantineSourceOfTruth.js\";\nimport { mantineSourceOfTruthWebServer } from \"./harness/mantineSourceOfTruth.js\";\nimport { validateFileConfig } from \"./validateFileConfig.js\";\n\nconst MANTINE_ADAPTER_PACKAGE_NAME = \"@recursica/mantine-adapter\";\n\nexport const CONFIG_FILE_NAME = \"adapter-tester.config.json\";\nconst DEFAULT_STORYBOOK_COMMAND = \"npm run storybook\";\nconst DEFAULT_STORYBOOK_PORT = 6006;\nconst DEFAULT_SOURCE_OF_TRUTH_PORT = 6011;\nconst DEFAULT_SOURCE_OF_TRUTH_NAME = \"Mantine\";\nconst DEFAULT_DIFF_THRESHOLD_PIXELS = 3500;\n\ninterface StorybookTargetFileConfig {\n /** Port the target's Storybook is served on. Auto-detected from this\n * project's own `scripts.storybook` (a `-p <port>`/`--port <port>` flag)\n * when omitted, falling back to Storybook's own default of 6006. */\n port?: number;\n /** Command that boots the target's Storybook. Defaults to `npm run storybook`. */\n command?: string;\n /** Directory the command runs in, relative to the config file. Defaults to \".\" */\n cwd?: string;\n}\n\ninterface MantineHarnessSourceOfTruthFileConfig {\n /** Default mode: boots a throwaway harness that installs the published\n * `@recursica/mantine-adapter` from npm — no monorepo checkout required. */\n type?: \"mantine-harness\";\n port?: number;\n mantineAdapterVersion?: string;\n storybookTemplateVersion?: string;\n}\n\ninterface UrlSourceOfTruthFileConfig {\n /** Non-standard mode: points at an already-addressable Storybook — e.g. a\n * sibling workspace package's own Storybook inside this monorepo. */\n type: \"url\";\n name?: string;\n port: number;\n command?: string;\n cwd?: string;\n}\n\ntype SourceOfTruthFileConfig =\n | MantineHarnessSourceOfTruthFileConfig\n | UrlSourceOfTruthFileConfig;\n\nexport interface AdapterTesterFileConfig {\n /** Label for this project's own target. Defaults to the unscoped name in\n * this project's package.json (e.g. \"@recursica/mui-adapter\" -> \"mui-adapter\"). */\n name?: string;\n storybook?: StorybookTargetFileConfig;\n sourceOfTruth?: SourceOfTruthFileConfig;\n diffThresholdPixels?: number;\n storyThresholds?: Record<string, number>;\n excludeTitlePrefixes?: string[];\n excludeStoryIds?: string[];\n /**\n * True only for the source-of-truth adapter's own config (mantine-adapter).\n * Skips `sourceOfTruth` entirely — there's nothing above it to diverge\n * from — and runs the own-drift golden check standalone, against just this\n * project's own Storybook. Defaults to false.\n */\n isSourceOfTruthAdapter?: boolean;\n}\n\nexport interface ResolvedAdapterTesterConfig {\n engineConfig: AdapterTesterConfig;\n webServers: HarnessWebServerConfig[];\n}\n\nfunction readOwnPackageJson(cwd: string): any {\n const path = join(cwd, \"package.json\");\n if (!existsSync(path)) {\n throw new Error(\n `No package.json found in ${cwd} — run adapter-tester from the root of the project being tested.`,\n );\n }\n return JSON.parse(readFileSync(path, \"utf8\"));\n}\n\nfunction detectOwnPort(cwd: string): number {\n const pkg = readOwnPackageJson(cwd);\n const storybookScript = pkg.scripts?.storybook as string | undefined;\n const match = storybookScript?.match(/(?:-p|--port)[ =](\\d+)/);\n return match ? Number(match[1]) : DEFAULT_STORYBOOK_PORT;\n}\n\nfunction detectOwnName(cwd: string): string {\n const pkg = readOwnPackageJson(cwd);\n const name = pkg.name as string | undefined;\n return name ? name.split(\"/\").pop()! : \"Adapter\";\n}\n\nfunction loadFileConfig(cwd: string): AdapterTesterFileConfig {\n const path = join(cwd, CONFIG_FILE_NAME);\n if (!existsSync(path)) {\n return {};\n }\n const data = JSON.parse(readFileSync(path, \"utf8\"));\n validateFileConfig(data, path);\n return data;\n}\n\n/**\n * Loads `adapter-tester.config.json` from `cwd` (or falls back to defaults\n * when the file doesn't exist) and resolves it into the engine config\n * `runVisualRegression` consumes plus the Playwright `webServer` entries\n * needed to boot both sides of the comparison.\n *\n * Default mode (no `sourceOfTruth`/`storybook` set): compares this project's\n * own Storybook against a throwaway Mantine harness — no monorepo checkout\n * required. Set `sourceOfTruth.type: \"url\"` for the non-standard mode used\n * to compare sibling workspace packages inside this monorepo.\n */\nexport function resolveConfig(cwd: string): ResolvedAdapterTesterConfig {\n const file = loadFileConfig(cwd);\n const isSourceOfTruthAdapter = file.isSourceOfTruthAdapter ?? false;\n\n const ownName = file.name ?? detectOwnName(cwd);\n const ownPort = file.storybook?.port ?? detectOwnPort(cwd);\n const ownCommand = file.storybook?.command ?? DEFAULT_STORYBOOK_COMMAND;\n const ownCwd = resolve(cwd, file.storybook?.cwd ?? \".\");\n const ownWebServer: HarnessWebServerConfig = {\n command: ownCommand,\n port: ownPort,\n cwd: ownCwd,\n reuseExistingServer: !process.env.CI,\n timeout: 120 * 1000,\n };\n\n const sharedEngineConfig = {\n diffThresholdPixels:\n file.diffThresholdPixels ?? DEFAULT_DIFF_THRESHOLD_PIXELS,\n storyThresholds: file.storyThresholds,\n excludeTitlePrefixes: file.excludeTitlePrefixes,\n excludeStoryIds: file.excludeStoryIds,\n // Keyed off `ownCwd`, not `cwd` — the project actually being tested, not\n // wherever the config file happens to live. Matters for this monorepo's\n // own non-standard config, whose `storybook.cwd` points at a sibling\n // package: its goldens must resolve to that package's own `test/golden/`\n // (the same directory used when that package runs adapter-tester\n // directly), not a directory under `packages/adapter-tester/`.\n goldenDir: join(ownCwd, \"test\", \"golden\"),\n isSourceOfTruthAdapter,\n // Overwritten by the CLI from --update-golden/--approve-divergence.\n goldenMode: \"check\" as const,\n };\n\n // The source-of-truth adapter's own config has nothing above it to\n // diverge from — no second target, no harness/webServer for it at all.\n if (isSourceOfTruthAdapter) {\n return {\n engineConfig: {\n ...sharedEngineConfig,\n targets: [{ name: ownName, url: `http://localhost:${ownPort}` }],\n },\n webServers: [ownWebServer],\n };\n }\n\n const sourceOfTruth = file.sourceOfTruth ?? {\n type: \"mantine-harness\" as const,\n };\n\n let sourceOfTruthName: string;\n let sourceOfTruthPort: number;\n let sourceOfTruthWebServer: HarnessWebServerConfig;\n let sourceOfTruthGolden: SourceOfTruthGoldenLocation;\n\n if (sourceOfTruth.type === \"url\") {\n sourceOfTruthName = sourceOfTruth.name ?? DEFAULT_SOURCE_OF_TRUTH_NAME;\n sourceOfTruthPort = sourceOfTruth.port;\n const sourceOfTruthCwd = resolve(cwd, sourceOfTruth.cwd ?? \".\");\n sourceOfTruthWebServer = {\n command: sourceOfTruth.command ?? DEFAULT_STORYBOOK_COMMAND,\n port: sourceOfTruth.port,\n cwd: sourceOfTruthCwd,\n reuseExistingServer: !process.env.CI,\n timeout: 120 * 1000,\n };\n // Sibling package already checked out locally — read its golden files\n // directly, including any uncommitted local changes. No install, no\n // network call.\n sourceOfTruthGolden = {\n type: \"local\",\n dir: join(sourceOfTruthCwd, \"test\", \"golden\"),\n };\n } else {\n sourceOfTruthName = DEFAULT_SOURCE_OF_TRUTH_NAME;\n sourceOfTruthPort = sourceOfTruth.port ?? DEFAULT_SOURCE_OF_TRUTH_PORT;\n sourceOfTruthWebServer = mantineSourceOfTruthWebServer({\n dir: join(cwd, \".adapter-tester/mantine-harness\"),\n port: sourceOfTruthPort,\n mantineAdapterVersion: sourceOfTruth.mantineAdapterVersion,\n storybookTemplateVersion: sourceOfTruth.storybookTemplateVersion,\n });\n // No local checkout — resolve the installed version against the npm\n // registry and fetch that version's golden files from the public repo.\n // Never needs `sourceOfTruthWebServer` above; the golden check on its\n // own doesn't boot a second Storybook at all (see cli.ts).\n sourceOfTruthGolden = {\n type: \"npm\",\n packageName: MANTINE_ADAPTER_PACKAGE_NAME,\n versionSpec: sourceOfTruth.mantineAdapterVersion ?? \"latest\",\n cacheDir: join(cwd, \".adapter-tester/mantine-golden-cache\"),\n };\n }\n\n return {\n engineConfig: {\n ...sharedEngineConfig,\n targets: [\n {\n name: sourceOfTruthName,\n url: `http://localhost:${sourceOfTruthPort}`,\n sourceOfTruth: true,\n },\n { name: ownName, url: `http://localhost:${ownPort}` },\n ],\n sourceOfTruthGolden,\n },\n // [sourceOfTruth, own] — Dev Mode needs both; the automated golden run\n // (cli.ts) only ever boots the last entry, since its divergence check\n // reads stored golden files, not a live source-of-truth page.\n webServers: [sourceOfTruthWebServer, ownWebServer],\n };\n}\n","import { spawnSync } from \"node:child_process\";\nimport { mkdirSync, writeFileSync } from \"node:fs\";\nimport { dirname, join } from \"node:path\";\nimport { fileURLToPath, pathToFileURL } from \"node:url\";\nimport type { AdapterTesterConfig } from \"./config.js\";\nimport { startDevServer } from \"./devServer.js\";\nimport { resolveConfig } from \"./fileConfig.js\";\nimport type { HarnessWebServerConfig } from \"./harness/mantineSourceOfTruth.js\";\n\n// `dist/testing.js` is always a sibling of this file — both inside a\n// consumer's node_modules/@recursica/adapter-tester/dist and inside this\n// monorepo's own packages/adapter-tester/dist when self-hosting — so the\n// generated spec below can reach it without depending on how the package\n// itself resolves at import time.\nconst distDir = dirname(fileURLToPath(import.meta.url));\nconst testingEntry = pathToFileURL(join(distDir, \"testing.js\")).href;\n\nconst cwd = process.cwd();\nconst { engineConfig, webServers } = resolveConfig(cwd);\n\nif (process.argv.includes(\"--update-golden\")) {\n engineConfig.goldenMode = \"update-golden\";\n} else if (process.argv.includes(\"--approve-divergence\")) {\n engineConfig.goldenMode = \"approve-divergence\";\n}\n\nif (process.argv.includes(\"--dry-run\")) {\n console.log(JSON.stringify({ engineConfig, webServers }, null, 2));\n process.exit(0);\n}\n\n// Any arg besides our own flags is passed straight through to `playwright\n// test` — e.g. `npm run adapter-tester:automated -- --grep \"Toast\"` to scope\n// a run to matching stories, instead of every invocation running the full\n// suite. `--update-golden`/`--approve-divergence` are consumed above, not\n// forwarded — Playwright itself doesn't know about them.\nconst OWN_FLAGS = new Set([\n \"--dry-run\",\n \"--serve\",\n \"--update-golden\",\n \"--approve-divergence\",\n]);\nconst passthroughArgs = process.argv\n .slice(2)\n .filter((arg) => !OWN_FLAGS.has(arg));\n\nif (process.argv.includes(\"--serve\")) {\n if (engineConfig.isSourceOfTruthAdapter) {\n throw new Error(\n \"Dev Mode (--serve) has nothing to sync this project's Storybook against — isSourceOfTruthAdapter is true in this project's adapter-tester.config.json.\",\n );\n }\n // Dual-Storybook interactive Dev Mode — no Playwright, no screenshots.\n // Used by the `adapter-tester` npm script.\n startDevServer(engineConfig, webServers);\n} else {\n // The golden-image checks never need the source-of-truth adapter's own\n // Storybook running — the divergence check reads its stored golden files,\n // not a live page — so only the last (own) webServer is booted here. Dev\n // Mode above is the one thing that still needs both.\n runAutomated(webServers.slice(-1), engineConfig);\n}\n\n/**\n * Generates a throwaway Playwright config + spec under `.adapter-tester/run/`\n * and runs the automated pixel-diff suite. Used by the\n * `adapter-tester:automated` npm script.\n */\nfunction runAutomated(\n servers: HarnessWebServerConfig[],\n config: AdapterTesterConfig,\n): void {\n const runDir = join(cwd, \".adapter-tester/run\");\n mkdirSync(runDir, { recursive: true });\n\n writeFileSync(\n join(runDir, \"playwright.config.js\"),\n `// Generated by \\`adapter-tester\\` — do not edit, regenerated on every run.\nimport { defineConfig, devices } from \"@playwright/test\";\n\nexport default defineConfig({\n testDir: ${JSON.stringify(runDir)},\n // Golden checks read-modify-write the same manifest.json across every\n // story's test body — forced sequential (no worker parallelism) so those\n // writes never race each other.\n fullyParallel: false,\n forbidOnly: !!process.env.CI,\n retries: process.env.CI ? 2 : 0,\n workers: 1,\n reporter: [[\"html\", { open: \"never\" }], [\"list\"]],\n use: { trace: \"on-first-retry\" },\n projects: [{ name: \"chromium\", use: { ...devices[\"Desktop Chrome\"] } }],\n webServer: ${JSON.stringify(servers, null, 2)},\n});\n`,\n );\n\n writeFileSync(\n join(runDir, \"visual-regression.spec.js\"),\n `// Generated by \\`adapter-tester\\` — do not edit, regenerated on every run.\nimport { runVisualRegression } from ${JSON.stringify(testingEntry)};\n\nawait runVisualRegression(${JSON.stringify(config, null, 2)});\n`,\n );\n\n const result = spawnSync(\n \"npx\",\n [\n \"playwright\",\n \"test\",\n \"--config\",\n join(runDir, \"playwright.config.js\"),\n ...passthroughArgs,\n ],\n { stdio: \"inherit\", cwd, shell: process.platform === \"win32\" },\n );\n\n process.exit(result.status ?? 1);\n}\n"],"names":["distDir","dirname","fileURLToPath","_documentCurrentScript","isPortActive","port","resolve","socket","net","waitForPort","timeoutMs","start","portOf","url","launchStorybook","name","server","child","spawn","_a","data","line","_b","err","openBrowser","startCmd","startDevServer","engineConfig","webServers","options","sourceOfTruth","target","sourceOfTruthServer","targetServer","devPort","sourceOfTruthPort","targetPort","app","express","publicDir","join","headerPath","req","res","next","html","readFileSync","createProxyMiddleware","spawned","cleaningUp","cleanup","sourceOfTruthRunning","targetRunning","waits","addFormats","ajvFormatsModule.default","ajv","Ajv","validate","schema","validateFileConfig","path","errors","error","extra","MANTINE_ADAPTER_PACKAGE_NAME","CONFIG_FILE_NAME","DEFAULT_STORYBOOK_COMMAND","DEFAULT_STORYBOOK_PORT","DEFAULT_SOURCE_OF_TRUTH_PORT","DEFAULT_SOURCE_OF_TRUTH_NAME","DEFAULT_DIFF_THRESHOLD_PIXELS","readOwnPackageJson","cwd","existsSync","detectOwnPort","storybookScript","match","detectOwnName","loadFileConfig","resolveConfig","file","isSourceOfTruthAdapter","ownName","ownPort","ownCommand","ownCwd","_c","ownWebServer","sharedEngineConfig","sourceOfTruthName","sourceOfTruthWebServer","sourceOfTruthGolden","sourceOfTruthCwd","mantineSourceOfTruthWebServer","testingEntry","pathToFileURL","OWN_FLAGS","passthroughArgs","arg","runAutomated","servers","config","runDir","mkdirSync","writeFileSync","result","spawnSync"],"mappings":";4UAuBA,MAAMA,EAAUC,EAAAA,QAAQC,gBAAc,OAAA,SAAA,IAAA,QAAA,KAAA,EAAA,cAAA,UAAA,EAAA,KAAAC,GAAAA,EAAA,QAAA,YAAA,IAAA,UAAAA,EAAA,KAAA,IAAA,IAAA,UAAA,SAAA,OAAA,EAAA,IAAe,CAAC,EAEtD,SAASC,EAAaC,EAAgC,CACpD,OAAO,IAAI,QAASC,GAAY,CAC9B,MAAMC,EAAS,IAAIC,EAAI,OACvBD,EAAO,WAAW,GAAG,EACrBA,EAAO,KAAK,UAAW,IAAM,CAC3BA,EAAO,QAAA,EACPD,EAAQ,EAAI,CACd,CAAC,EACDC,EAAO,KAAK,UAAW,IAAM,C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,WACAnE,EAAAA,KAAK+D,EAAQ,sBAAsB,EACnC,GAAGL,EAAA,EAEL,CAAE,MAAO,UAAW,IAAAzB,EAAK,MAAO,QAAQ,WAAa,OAAA,CAAQ,EAG/D,QAAQ,KAAKiC,EAAO,QAAU,CAAC,CACjC"}
|
|
1
|
+
{"version":3,"file":"cli.cjs","sources":["../src/devServer.ts","../src/validateFileConfig.ts","../src/fileConfig.ts","../src/cli.ts"],"sourcesContent":["import { spawn, type ChildProcess } from \"node:child_process\";\nimport { readFileSync } from \"node:fs\";\nimport net from \"node:net\";\nimport { dirname, join } from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\nimport express from \"express\";\nimport { createProxyMiddleware } from \"http-proxy-middleware\";\nimport type { AdapterTesterConfig } from \"./config.js\";\nimport type { HarnessWebServerConfig } from \"./harness/mantineSourceOfTruth.js\";\n\n/**\n * Interactive Dev Mode: a synced, side-by-side browser view of this\n * project's own Storybook and the source of truth, with per-story note\n * taking and an AI-report export. Boots both Storybooks (reusing them if\n * already running) behind a proxy so the own/target pane — which drives\n * the sync and carries Storybook's nav sidebar — loads same-origin on the\n * left, with the source of truth following along as a bare preview on the\n * right.\n *\n * Config-driven — takes the same `{ engineConfig, webServers }` shape\n * `resolveConfig()` produces, in the same [sourceOfTruth, target] order.\n */\n\nconst distDir = dirname(fileURLToPath(import.meta.url));\n\nfunction isPortActive(port: number): Promise<boolean> {\n return new Promise((resolve) => {\n const socket = new net.Socket();\n socket.setTimeout(200);\n socket.once(\"connect\", () => {\n socket.destroy();\n resolve(true);\n });\n socket.once(\"timeout\", () => {\n socket.destroy();\n resolve(false);\n });\n socket.once(\"error\", () => {\n socket.destroy();\n resolve(false);\n });\n socket.connect(port, \"127.0.0.1\");\n });\n}\n\nasync function waitForPort(port: number, timeoutMs = 60000): Promise<boolean> {\n const start = Date.now();\n while (Date.now() - start < timeoutMs) {\n if (await isPortActive(port)) return true;\n await new Promise((resolve) => setTimeout(resolve, 500));\n }\n return false;\n}\n\nfunction portOf(url: string): number {\n return Number(new URL(url).port);\n}\n\nfunction launchStorybook(\n name: string,\n server: HarnessWebServerConfig,\n): ChildProcess {\n console.log(\n `[Dev Launcher] Port ${server.port} is inactive. Launching Storybook for ${name}...`,\n );\n const child = spawn(server.command, {\n cwd: server.cwd,\n stdio: \"pipe\",\n shell: true,\n });\n\n child.stdout?.on(\"data\", (data: Buffer) => {\n for (const line of data.toString().split(\"\\n\")) {\n if (line.trim()) console.log(`[${name} SB] ${line.trim()}`);\n }\n });\n child.stderr?.on(\"data\", (data: Buffer) => {\n for (const line of data.toString().split(\"\\n\")) {\n if (line.trim()) console.error(`[${name} SB ERROR] ${line.trim()}`);\n }\n });\n child.on(\"error\", (err) => {\n console.error(`[${name} SB ERROR] Failed to start process:`, err);\n });\n\n return child;\n}\n\nfunction openBrowser(url: string): void {\n const startCmd =\n process.platform === \"darwin\"\n ? \"open\"\n : process.platform === \"win32\"\n ? \"start\"\n : \"xdg-open\";\n console.log(`[Dev Launcher] Auto-launching browser: ${url}`);\n spawn(startCmd, [url], { shell: process.platform === \"win32\" }).on(\n \"error\",\n (err) => {\n console.error(`[Dev Launcher] Failed to auto-launch browser:`, err);\n },\n );\n}\n\nexport interface DevServerOptions {\n /** Port the dev-mode proxy UI itself listens on. Defaults to 6010. */\n port?: number;\n}\n\nexport function startDevServer(\n engineConfig: AdapterTesterConfig,\n webServers: HarnessWebServerConfig[],\n options: DevServerOptions = {},\n): void {\n const [sourceOfTruth, target] = engineConfig.targets;\n const [sourceOfTruthServer, targetServer] = webServers;\n if (\n !sourceOfTruth?.sourceOfTruth ||\n !target ||\n target.sourceOfTruth ||\n !sourceOfTruthServer ||\n !targetServer\n ) {\n throw new Error(\n \"adapter-tester dev mode requires exactly two targets: [sourceOfTruth, target] — check adapter-tester.config.json.\",\n );\n }\n\n const devPort = options.port ?? 6010;\n const sourceOfTruthPort = portOf(sourceOfTruth.url);\n const targetPort = portOf(target.url);\n\n const app = express();\n const publicDir = join(distDir, \"../public\");\n const headerPath = join(distDir, \"../report-header.txt\");\n\n // Serve the Dev Mode UI at the root path ONLY if there is no query string.\n // This allows the iframe (which loads with ?path=/story/...) to pass\n // through to the proxy, avoiding an infinite loop of nested wrappers.\n app.get(\"/\", (req, res, next) => {\n if (req.query.path) {\n next();\n return;\n }\n const html = readFileSync(join(publicDir, \"index.html\"), \"utf8\").replace(\n \"<head>\",\n `<head>\\n <script>window.__ADAPTER_TESTER__ = ${JSON.stringify({\n ownName: target.name,\n sourceOfTruthName: sourceOfTruth.name,\n sourceOfTruthPort,\n })};</script>`,\n );\n res.send(html);\n });\n\n // Serve the AI prompt header dynamically so it can be edited externally.\n app.get(\"/report-header.txt\", (req, res) => {\n try {\n res.type(\"text/plain\").send(readFileSync(headerPath, \"utf8\"));\n } catch {\n res.status(500).send(\"Error loading report-header.txt\");\n }\n });\n\n // Proxy everything else to this project's own Storybook, preserving\n // absolute paths (e.g. /@vite/client) so HMR keeps working same-origin.\n // This is the pane that drives the sync and shows Storybook's nav sidebar.\n app.use(\n \"/\",\n createProxyMiddleware({\n target: `http://localhost:${targetPort}`,\n changeOrigin: true,\n ws: true,\n }),\n );\n\n const spawned: ChildProcess[] = [];\n let cleaningUp = false;\n const cleanup = () => {\n if (cleaningUp) return;\n cleaningUp = true;\n console.log(\n \"\\n[Dev Launcher] Shutting down Dev Mode server and spawned Storybooks...\",\n );\n for (const child of spawned) child.kill(\"SIGINT\");\n process.exit(0);\n };\n process.on(\"SIGINT\", cleanup);\n process.on(\"SIGTERM\", cleanup);\n\n app.listen(devPort, async () => {\n console.log(`\n====================================================\n🚀 Adapter Dev Mode proxy running at:\n http://localhost:${devPort}\n====================================================\n`);\n\n const [sourceOfTruthRunning, targetRunning] = await Promise.all([\n isPortActive(sourceOfTruthPort),\n isPortActive(targetPort),\n ]);\n\n if (sourceOfTruthRunning) {\n console.log(\n `[Dev Launcher] ${sourceOfTruth.name} is already running on port ${sourceOfTruthPort}.`,\n );\n } else {\n spawned.push(launchStorybook(sourceOfTruth.name, sourceOfTruthServer));\n }\n if (targetRunning) {\n console.log(\n `[Dev Launcher] ${target.name} is already running on port ${targetPort}.`,\n );\n } else {\n spawned.push(launchStorybook(target.name, targetServer));\n }\n\n const waits: Promise<boolean>[] = [];\n if (!sourceOfTruthRunning) waits.push(waitForPort(sourceOfTruthPort));\n if (!targetRunning) waits.push(waitForPort(targetPort));\n\n if (waits.length > 0) {\n console.log(`[Dev Launcher] Waiting for Storybooks to be responsive...`);\n const results = await Promise.all(waits);\n if (results.every(Boolean)) {\n console.log(`[Dev Launcher] All Storybooks are active and responsive!`);\n } else {\n console.warn(\n `[Dev Launcher] Warning: some Storybooks timed out during startup, but proceeding...`,\n );\n }\n } else {\n console.log(`[Dev Launcher] Both Storybooks already active.`);\n }\n\n openBrowser(`http://localhost:${devPort}`);\n });\n}\n","import { Ajv } from \"ajv\";\nimport * as ajvFormatsModule from \"ajv-formats\";\nimport type { FormatsPlugin } from \"ajv-formats\";\nimport schema from \"./adapter-tester.schema.json\" with { type: \"json\" };\n\n// ajv-formats ships an ESM-style `export default` on a CJS build with no\n// `\"type\"` field, which under `moduleResolution: NodeNext` TS resolves to\n// the raw module namespace instead of unwrapping the default — a known\n// ajv-formats/TS interop gap, not a version mismatch.\nconst addFormats = (ajvFormatsModule as unknown as { default: FormatsPlugin })\n .default;\n\nconst ajv = new Ajv({ allErrors: true, strict: true });\naddFormats(ajv);\nconst validate = ajv.compile(schema);\n\n/**\n * Validates a parsed `adapter-tester.config.json` against\n * `adapter-tester.schema.json`. Throws with every violation listed — callers\n * must not silently coerce or drop invalid fields.\n */\nexport function validateFileConfig(data: unknown, path: string): void {\n if (validate(data)) return;\n\n const errors = (validate.errors ?? [])\n .map((error) => {\n const extra = error.params?.additionalProperty\n ? ` '${error.params.additionalProperty}'`\n : \"\";\n return ` - ${error.instancePath || \"root\"} ${error.message}${extra}`;\n })\n .join(\"\\n\");\n throw new Error(`Invalid ${path}:\\n${errors}`);\n}\n","import { existsSync, readFileSync } from \"node:fs\";\nimport { join, resolve } from \"node:path\";\nimport type {\n AdapterTesterConfig,\n SourceOfTruthGoldenLocation,\n StoryOverride,\n} from \"./config.js\";\nimport type { HarnessWebServerConfig } from \"./harness/mantineSourceOfTruth.js\";\nimport { mantineSourceOfTruthWebServer } from \"./harness/mantineSourceOfTruth.js\";\nimport { validateFileConfig } from \"./validateFileConfig.js\";\n\nconst MANTINE_ADAPTER_PACKAGE_NAME = \"@recursica/mantine-adapter\";\n\nexport const CONFIG_FILE_NAME = \"adapter-tester.config.json\";\nconst DEFAULT_STORYBOOK_COMMAND = \"npm run storybook\";\nconst DEFAULT_STORYBOOK_PORT = 6006;\nconst DEFAULT_SOURCE_OF_TRUTH_PORT = 6011;\nconst DEFAULT_SOURCE_OF_TRUTH_NAME = \"Mantine\";\nconst DEFAULT_DIFF_THRESHOLD_PIXELS = 3500;\n\ninterface StorybookTargetFileConfig {\n /** Port the target's Storybook is served on. Auto-detected from this\n * project's own `scripts.storybook` (a `-p <port>`/`--port <port>` flag)\n * when omitted, falling back to Storybook's own default of 6006. */\n port?: number;\n /** Command that boots the target's Storybook. Defaults to `npm run storybook`. */\n command?: string;\n /** Directory the command runs in, relative to the config file. Defaults to \".\" */\n cwd?: string;\n}\n\ninterface MantineHarnessSourceOfTruthFileConfig {\n /** Default mode: boots a throwaway harness that installs the published\n * `@recursica/mantine-adapter` from npm — no monorepo checkout required. */\n type?: \"mantine-harness\";\n port?: number;\n mantineAdapterVersion?: string;\n storybookTemplateVersion?: string;\n}\n\ninterface UrlSourceOfTruthFileConfig {\n /** Non-standard mode: points at an already-addressable Storybook — e.g. a\n * sibling workspace package's own Storybook inside this monorepo. */\n type: \"url\";\n name?: string;\n port: number;\n command?: string;\n cwd?: string;\n}\n\ntype SourceOfTruthFileConfig =\n | MantineHarnessSourceOfTruthFileConfig\n | UrlSourceOfTruthFileConfig;\n\nexport interface AdapterTesterFileConfig {\n /** Label for this project's own target. Defaults to the unscoped name in\n * this project's package.json (e.g. \"@recursica/mui-adapter\" -> \"mui-adapter\"). */\n name?: string;\n storybook?: StorybookTargetFileConfig;\n sourceOfTruth?: SourceOfTruthFileConfig;\n diffThresholdPixels?: number;\n stories?: Record<string, StoryOverride>;\n excludeTitlePrefixes?: string[];\n /**\n * True only for the source-of-truth adapter's own config (mantine-adapter).\n * Skips `sourceOfTruth` entirely — there's nothing above it to diverge\n * from — and runs the own-drift golden check standalone, against just this\n * project's own Storybook. Defaults to false.\n */\n isSourceOfTruthAdapter?: boolean;\n}\n\nexport interface ResolvedAdapterTesterConfig {\n engineConfig: AdapterTesterConfig;\n webServers: HarnessWebServerConfig[];\n}\n\nexport interface ResolveConfigOverrides {\n /** From `--source-of-truth-version`. Overrides `sourceOfTruth.mantineAdapterVersion`. */\n mantineAdapterVersion?: string;\n}\n\nfunction readOwnPackageJson(cwd: string): any {\n const path = join(cwd, \"package.json\");\n if (!existsSync(path)) {\n throw new Error(\n `No package.json found in ${cwd} — run adapter-tester from the root of the project being tested.`,\n );\n }\n return JSON.parse(readFileSync(path, \"utf8\"));\n}\n\nfunction detectOwnPort(cwd: string): number {\n const pkg = readOwnPackageJson(cwd);\n const storybookScript = pkg.scripts?.storybook as string | undefined;\n const match = storybookScript?.match(/(?:-p|--port)[ =](\\d+)/);\n return match ? Number(match[1]) : DEFAULT_STORYBOOK_PORT;\n}\n\nfunction detectOwnName(cwd: string): string {\n const pkg = readOwnPackageJson(cwd);\n const name = pkg.name as string | undefined;\n return name ? name.split(\"/\").pop()! : \"Adapter\";\n}\n\nfunction loadFileConfig(cwd: string): AdapterTesterFileConfig {\n const path = join(cwd, CONFIG_FILE_NAME);\n if (!existsSync(path)) {\n return {};\n }\n const data = JSON.parse(readFileSync(path, \"utf8\"));\n validateFileConfig(data, path);\n return data;\n}\n\n/**\n * Loads `adapter-tester.config.json` from `cwd` (or falls back to defaults\n * when the file doesn't exist) and resolves it into the engine config\n * `resolveVisualRegressionPlan` consumes plus the Playwright `webServer` entries\n * needed to boot both sides of the comparison.\n *\n * Default mode (no `sourceOfTruth`/`storybook` set): compares this project's\n * own Storybook against a throwaway Mantine harness — no monorepo checkout\n * required. Set `sourceOfTruth.type: \"url\"` for the non-standard mode used\n * to compare sibling workspace packages inside this monorepo.\n *\n * `overrides.mantineAdapterVersion` (from `--source-of-truth-version`) pins\n * the mantine-harness install/golden-fetch version for this run, overriding\n * `sourceOfTruth.mantineAdapterVersion`. Throws if passed together with\n * `isSourceOfTruthAdapter` or `sourceOfTruth.type: \"url\"` — neither has a\n * version to pin.\n */\nexport function resolveConfig(\n cwd: string,\n overrides: ResolveConfigOverrides = {},\n): ResolvedAdapterTesterConfig {\n const file = loadFileConfig(cwd);\n const isSourceOfTruthAdapter = file.isSourceOfTruthAdapter ?? false;\n\n if (overrides.mantineAdapterVersion && isSourceOfTruthAdapter) {\n throw new Error(\n \"--source-of-truth-version has no effect on the source-of-truth adapter's own config (isSourceOfTruthAdapter: true) — there's nothing to pin a version for.\",\n );\n }\n\n const ownName = file.name ?? detectOwnName(cwd);\n const ownPort = file.storybook?.port ?? detectOwnPort(cwd);\n const ownCommand = file.storybook?.command ?? DEFAULT_STORYBOOK_COMMAND;\n const ownCwd = resolve(cwd, file.storybook?.cwd ?? \".\");\n const ownWebServer: HarnessWebServerConfig = {\n command: ownCommand,\n port: ownPort,\n cwd: ownCwd,\n reuseExistingServer: !process.env.CI,\n timeout: 120 * 1000,\n };\n\n const sharedEngineConfig = {\n diffThresholdPixels:\n file.diffThresholdPixels ?? DEFAULT_DIFF_THRESHOLD_PIXELS,\n stories: file.stories,\n excludeTitlePrefixes: file.excludeTitlePrefixes,\n // Keyed off `ownCwd`, not `cwd` — the project actually being tested, not\n // wherever the config file happens to live. Matters whenever\n // `storybook.cwd` points at a sibling package: its goldens must resolve\n // to that package's own `test/golden/` (the same directory used when\n // that package runs adapter-tester directly), not a directory under\n // wherever this config file lives.\n goldenDir: join(ownCwd, \"test\", \"golden\"),\n isSourceOfTruthAdapter,\n // Overwritten by the CLI from --update-golden/--approve-divergence.\n goldenMode: \"check\" as const,\n // Overwritten by the CLI from --divergence-only.\n checkMode: \"own\" as const,\n };\n\n // The source-of-truth adapter's own config has nothing above it to\n // diverge from — no second target, no harness/webServer for it at all.\n if (isSourceOfTruthAdapter) {\n return {\n engineConfig: {\n ...sharedEngineConfig,\n targets: [{ name: ownName, url: `http://localhost:${ownPort}` }],\n },\n webServers: [ownWebServer],\n };\n }\n\n const sourceOfTruth = file.sourceOfTruth ?? {\n type: \"mantine-harness\" as const,\n };\n\n let sourceOfTruthName: string;\n let sourceOfTruthPort: number;\n let sourceOfTruthWebServer: HarnessWebServerConfig;\n let sourceOfTruthGolden: SourceOfTruthGoldenLocation;\n\n if (sourceOfTruth.type === \"url\") {\n if (overrides.mantineAdapterVersion) {\n throw new Error(\n '--source-of-truth-version has no effect with sourceOfTruth.type: \"url\" — that mode reads a sibling package\\'s local checkout directly, not a published version.',\n );\n }\n sourceOfTruthName = sourceOfTruth.name ?? DEFAULT_SOURCE_OF_TRUTH_NAME;\n sourceOfTruthPort = sourceOfTruth.port;\n const sourceOfTruthCwd = resolve(cwd, sourceOfTruth.cwd ?? \".\");\n sourceOfTruthWebServer = {\n command: sourceOfTruth.command ?? DEFAULT_STORYBOOK_COMMAND,\n port: sourceOfTruth.port,\n cwd: sourceOfTruthCwd,\n reuseExistingServer: !process.env.CI,\n timeout: 120 * 1000,\n };\n // Sibling package already checked out locally — read its golden files\n // directly, including any uncommitted local changes. No install, no\n // network call.\n sourceOfTruthGolden = {\n type: \"local\",\n dir: join(sourceOfTruthCwd, \"test\", \"golden\"),\n };\n } else {\n sourceOfTruthName = DEFAULT_SOURCE_OF_TRUTH_NAME;\n sourceOfTruthPort = sourceOfTruth.port ?? DEFAULT_SOURCE_OF_TRUTH_PORT;\n const mantineAdapterVersion =\n overrides.mantineAdapterVersion ?? sourceOfTruth.mantineAdapterVersion;\n sourceOfTruthWebServer = mantineSourceOfTruthWebServer({\n dir: join(cwd, \".adapter-tester/mantine-harness\"),\n port: sourceOfTruthPort,\n mantineAdapterVersion,\n storybookTemplateVersion: sourceOfTruth.storybookTemplateVersion,\n });\n // No local checkout — resolve the installed version against the npm\n // registry and fetch that version's golden files from the public repo.\n // Never needs `sourceOfTruthWebServer` above; the golden check on its\n // own doesn't boot a second Storybook at all (see cli.ts).\n sourceOfTruthGolden = {\n type: \"npm\",\n packageName: MANTINE_ADAPTER_PACKAGE_NAME,\n versionSpec: mantineAdapterVersion ?? \"latest\",\n cacheDir: join(cwd, \".adapter-tester/mantine-golden-cache\"),\n };\n }\n\n return {\n engineConfig: {\n ...sharedEngineConfig,\n targets: [\n {\n name: sourceOfTruthName,\n url: `http://localhost:${sourceOfTruthPort}`,\n sourceOfTruth: true,\n },\n { name: ownName, url: `http://localhost:${ownPort}` },\n ],\n sourceOfTruthGolden,\n },\n // [sourceOfTruth, own] — Dev Mode needs both; the automated golden run\n // (cli.ts) only ever boots the last entry, since its divergence check\n // reads stored golden files, not a live source-of-truth page.\n webServers: [sourceOfTruthWebServer, ownWebServer],\n };\n}\n","import { spawnSync } from \"node:child_process\";\nimport { mkdirSync, writeFileSync } from \"node:fs\";\nimport { dirname, join } from \"node:path\";\nimport { fileURLToPath, pathToFileURL } from \"node:url\";\nimport type { AdapterTesterConfig } from \"./config.js\";\nimport { startDevServer } from \"./devServer.js\";\nimport { resolveConfig } from \"./fileConfig.js\";\nimport type { HarnessWebServerConfig } from \"./harness/mantineSourceOfTruth.js\";\n\n// `dist/testing.js` is always a sibling of this file — both inside a\n// consumer's node_modules/@recursica/adapter-tester/dist and inside this\n// monorepo's own packages/adapter-tester/dist when self-hosting — so the\n// generated spec below can reach it without depending on how the package\n// itself resolves at import time.\nconst distDir = dirname(fileURLToPath(import.meta.url));\nconst testingEntry = pathToFileURL(join(distDir, \"testing.js\")).href;\n\n// `--source-of-truth-version <value>` takes a value, unlike every other own\n// flag below — pulled out of argv first so the boolean flags/passthrough\n// logic never has to know it exists.\nconst args = process.argv.slice(2);\nlet sourceOfTruthVersion: string | undefined;\nconst sourceOfTruthVersionFlagIndex = args.indexOf(\"--source-of-truth-version\");\nif (sourceOfTruthVersionFlagIndex !== -1) {\n const value = args[sourceOfTruthVersionFlagIndex + 1];\n if (value === undefined || value.startsWith(\"--\")) {\n throw new Error(\n \"--source-of-truth-version requires a value, e.g. --source-of-truth-version 0.53.0\",\n );\n }\n sourceOfTruthVersion = value;\n args.splice(sourceOfTruthVersionFlagIndex, 2);\n}\n\nconst cwd = process.cwd();\nconst { engineConfig, webServers } = resolveConfig(cwd, {\n mantineAdapterVersion: sourceOfTruthVersion,\n});\n\nif (args.includes(\"--update-golden\")) {\n engineConfig.goldenMode = \"update-golden\";\n} else if (args.includes(\"--approve-divergence\")) {\n engineConfig.goldenMode = \"approve-divergence\";\n}\n\nif (args.includes(\"--divergence-only\")) {\n if (engineConfig.isSourceOfTruthAdapter) {\n throw new Error(\n \"--divergence-only has nothing to diverge from — isSourceOfTruthAdapter is true in this project's adapter-tester.config.json.\",\n );\n }\n engineConfig.checkMode = \"divergence\";\n} else if (engineConfig.goldenMode === \"approve-divergence\") {\n throw new Error(\n \"--approve-divergence only makes sense with --divergence-only — there's nothing to approve without the divergence check running.\",\n );\n}\n\nif (args.includes(\"--dry-run\")) {\n console.log(JSON.stringify({ engineConfig, webServers }, null, 2));\n process.exit(0);\n}\n\n// Any arg besides our own flags is passed straight through to `playwright\n// test` — e.g. `npm run adapter-tester:automated -- --grep \"Toast\"` to scope\n// a run to matching stories, instead of every invocation running the full\n// suite. Our own flags are consumed above, not forwarded — Playwright itself\n// doesn't know about them.\nconst OWN_FLAGS = new Set([\n \"--dry-run\",\n \"--serve\",\n \"--update-golden\",\n \"--approve-divergence\",\n \"--divergence-only\",\n]);\nconst passthroughArgs = args.filter((arg) => !OWN_FLAGS.has(arg));\n\nif (args.includes(\"--serve\")) {\n if (engineConfig.isSourceOfTruthAdapter) {\n throw new Error(\n \"Dev Mode (--serve) has nothing to sync this project's Storybook against — isSourceOfTruthAdapter is true in this project's adapter-tester.config.json.\",\n );\n }\n // Dual-Storybook interactive Dev Mode — no Playwright, no screenshots.\n // Used by the `adapter-tester` npm script.\n startDevServer(engineConfig, webServers);\n} else {\n // The golden-image checks never need the source-of-truth adapter's own\n // Storybook running — the divergence check reads its stored golden files,\n // not a live page — so only the last (own) webServer is booted here. Dev\n // Mode above is the one thing that still needs both.\n runAutomated(webServers.slice(-1), engineConfig);\n}\n\n/**\n * Generates a throwaway Playwright config + spec under `.adapter-tester/run/`\n * and runs the automated pixel-diff suite. Used by the\n * `adapter-tester:automated` npm script.\n */\nfunction runAutomated(\n servers: HarnessWebServerConfig[],\n config: AdapterTesterConfig,\n): void {\n const runDir = join(cwd, \".adapter-tester/run\");\n mkdirSync(runDir, { recursive: true });\n\n writeFileSync(\n join(runDir, \"playwright.config.js\"),\n `// Generated by \\`adapter-tester\\` — do not edit, regenerated on every run.\nimport { defineConfig, devices } from \"@playwright/test\";\n\nexport default defineConfig({\n testDir: ${JSON.stringify(runDir)},\n // Stories run across Playwright's default worker pool — each golden check\n // only reads/writes its own story's manifest.json entry, under a lock, so\n // concurrent workers never race each other (see \\`updateManifestEntry\\`).\n // Override with \\`--workers <n>\\` (forwarded straight through to Playwright).\n fullyParallel: true,\n forbidOnly: !!process.env.CI,\n retries: process.env.CI ? 2 : 0,\n reporter: [[\"html\", { open: \"never\" }], [\"list\"]],\n use: { trace: \"on-first-retry\" },\n projects: [{ name: \"chromium\", use: { ...devices[\"Desktop Chrome\"] } }],\n webServer: ${JSON.stringify(servers, null, 2)},\n});\n`,\n );\n\n writeFileSync(\n join(runDir, \"visual-regression.spec.js\"),\n `// Generated by \\`adapter-tester\\` — do not edit, regenerated on every run.\nimport { test } from \"@playwright/test\";\nimport { resolveVisualRegressionPlan } from ${JSON.stringify(testingEntry)};\n\n// \\`test.describe\\`/\\`test\\` are called here, not inside resolveVisualRegressionPlan,\n// so Playwright's HTML report groups the suite under this file instead of a\n// sourcemapped path into adapter-tester's own library code.\nconst { ownTargetName, suiteLabel, stories, checkStory } =\n await resolveVisualRegressionPlan(${JSON.stringify(config, null, 2)});\n\ntest.describe(\\`\\${ownTargetName} — \\${suiteLabel}\\`, () => {\n for (const story of stories) {\n test(story.id, async ({ browser }, testInfo) => {\n await checkStory(story, browser, testInfo);\n });\n }\n});\n`,\n );\n\n const result = spawnSync(\n \"npx\",\n [\n \"playwright\",\n \"test\",\n \"--config\",\n join(runDir, \"playwright.config.js\"),\n ...passthroughArgs,\n ],\n { stdio: \"inherit\", cwd, shell: process.platform === \"win32\" },\n );\n\n process.exit(result.status ?? 1);\n}\n"],"names":["distDir","dirname","fileURLToPath","_documentCurrentScript","isPortActive","port","resolve","socket","net","waitForPort","timeoutMs","start","portOf","url","launchStorybook","name","server","child","spawn","_a","data","line","_b","err","openBrowser","startCmd","startDevServer","engineConfig","webServers","options","sourceOfTruth","target","sourceOfTruthServer","targetServer","devPort","sourceOfTruthPort","targetPort","app","express","publicDir","join","headerPath","req","res","next","html","readFileSync","createProxyMiddleware","spawned","cleaningUp","cleanup","sourceOfTruthRunning","targetRunning","waits","addFormats","ajvFormatsModule.default","ajv","Ajv","validate","schema","validateFileConfig","path","errors","error","extra","MANTINE_ADAPTER_PACKAGE_NAME","CONFIG_FILE_NAME","DEFAULT_STORYBOOK_COMMAND","DEFAULT_STORYBOOK_PORT","DEFAULT_SOURCE_OF_TRUTH_PORT","DEFAULT_SOURCE_OF_TRUTH_NAME","DEFAULT_DIFF_THRESHOLD_PIXELS","readOwnPackageJson","cwd","existsSync","detectOwnPort","storybookScript","match","detectOwnName","loadFileConfig","resolveConfig","overrides","file","isSourceOfTruthAdapter","ownName","ownPort","ownCommand","ownCwd","_c","ownWebServer","sharedEngineConfig","sourceOfTruthName","sourceOfTruthWebServer","sourceOfTruthGolden","sourceOfTruthCwd","mantineAdapterVersion","mantineSourceOfTruthWebServer","testingEntry","pathToFileURL","args","sourceOfTruthVersion","sourceOfTruthVersionFlagIndex","value","OWN_FLAGS","passthroughArgs","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