@recursica/adapter-tester 5.0.0 → 5.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -74,6 +74,8 @@ You can modify this instructional header at any time by editing:
74
74
 
75
75
  The Dev Mode server fetches this file dynamically, so any changes you make to `report-header.txt` will instantly appear the next time you click **Full Report**—no restart required!
76
76
 
77
+ Alternatively, set `reportHeader` in `adapter-tester.config.json` to override the text directly, without editing `report-header.txt`. When set, it takes precedence over the file.
78
+
77
79
  ---
78
80
 
79
81
  ## Automated Visual Tests
@@ -133,6 +133,10 @@ declare const _default: {
133
133
  "type": "array",
134
134
  "items": { "type": "string" },
135
135
  "description": "Storybook title prefixes to exclude from comparison, in addition to the built-in denylist (`Theme/*`, `Tokens/*`, `Introduction`)."
136
+ },
137
+ "reportHeader": {
138
+ "type": "string",
139
+ "description": "Overrides the AI report header text shown in Dev Mode's \"Full Report\" export. Defaults to the contents of `report-header.txt`."
136
140
  }
137
141
  }
138
142
  }
package/dist/cli.cjs CHANGED
@@ -1,23 +1,25 @@
1
1
  #!/usr/bin/env node
2
- "use strict";const E=require("node:child_process"),u=require("node:fs"),i=require("node:path"),D=require("node:url"),q=require("express"),G=require("http-proxy-middleware"),V=require("node:net"),J=require("./mantineSourceOfTruth-Dpe4mlmF.cjs"),N=require("./index-C6uYPRmx.cjs");var k=typeof document<"u"?document.currentScript:null;const H=/\x1b\[[0-9;]*m/g,W=/Local:\s*(https?:\/\/localhost:\d+)/;function B(e){return new Promise(t=>{const r=new V.Socket;r.setTimeout(200),r.once("connect",()=>{r.destroy(),t(!0)}),r.once("timeout",()=>{r.destroy(),t(!1)}),r.once("error",()=>{r.destroy(),t(!1)}),r.connect(e,"127.0.0.1")})}function K(e){try{const t=JSON.parse(u.readFileSync(e,"utf8")).port;return typeof t=="number"?t:void 0}catch{return}}function X(e,t){u.mkdirSync(i.dirname(e),{recursive:!0}),u.writeFileSync(e,JSON.stringify({port:t}))}function Y(e,t){return new Promise((r,o)=>{var w,v;const n=E.spawn(e.command,{cwd:e.cwd,stdio:"pipe",shell:!0});let s=!1;const l=setTimeout(()=>{s||(s=!0,n.kill(),o(new Error(`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).`)))},t),f=(a,d)=>{const p=a.toString();for(const c of p.split(`
3
- `))if(c.trim()){const h=d?`${e.name} SB ERROR`:`${e.name} SB`;(d?console.error:console.log)(`[${h}] ${c.trim()}`)}if(s)return;const T=p.replace(H,"").match(W);if(T){s=!0,clearTimeout(l);const c=T[1],h=Number(new URL(c).port);X(e.cacheFile,h),r({url:c,port:h,process:n})}};(w=n.stdout)==null||w.on("data",a=>f(a,!1)),(v=n.stderr)==null||v.on("data",a=>f(a,!0)),n.on("error",a=>{s||(s=!0,clearTimeout(l),o(a))}),n.on("exit",a=>{s||(s=!0,clearTimeout(l),o(new Error(`${e.name}'s Storybook exited (code ${a}) before reporting its URL.`)))})})}function x(e,t){return{name:e,command:t.command,cwd:t.cwd,reuseExistingServer:t.reuseExistingServer,cacheFile:t.cacheFile,timeoutMs:t.timeout}}async function j(e){if(e.reuseExistingServer){const t=K(e.cacheFile);if(t!==void 0&&await B(t))return console.log(`[Dev Launcher] ${e.name} is already running on port ${t} (reused).`),{url:`http://localhost:${t}`,port:t,process:null}}return console.log(`[Dev Launcher] Launching Storybook for ${e.name}...`),Y(e,e.timeoutMs??120*1e3)}const _=i.dirname(D.fileURLToPath(typeof document>"u"?require("url").pathToFileURL(__filename).href:k&&k.tagName.toUpperCase()==="SCRIPT"&&k.src||new URL("cli.cjs",document.baseURI).href));function z(e){const t=process.platform==="darwin"?"open":process.platform==="win32"?"start":"xdg-open";console.log(`[Dev Launcher] Auto-launching browser: ${e}`),E.spawn(t,[e],{shell:process.platform==="win32"}).on("error",r=>{console.error("[Dev Launcher] Failed to auto-launch browser:",r)})}async function Q(e,t,r={}){const[o,n]=e.targets,[s,l]=t;if(!(o!=null&&o.sourceOfTruth)||!n||n.sourceOfTruth||!s||!l)throw new Error("adapter-tester dev mode requires exactly two targets: [sourceOfTruth, target] — check adapter-tester.config.json.");const f=r.port??6010;console.log(`[Dev Launcher] Resolving ${o.name} and ${n.name} Storybooks...`);const[w,v]=await Promise.all([j(x(o.name,s)),j(x(n.name,l))]);console.log("[Dev Launcher] Both Storybooks are active and responsive!");const a=[w.process,v.process].filter(m=>m!==null),d=q(),p=i.join(_,"../public"),T=i.join(_,"../report-header.txt");d.get("/",(m,b,S)=>{if(m.query.path){S();return}const M=u.readFileSync(i.join(p,"index.html"),"utf8").replace("<head>",`<head>
4
- <script>window.__ADAPTER_TESTER__ = ${JSON.stringify({ownName:n.name,sourceOfTruthName:o.name,sourceOfTruthPort:w.port})};<\/script>`);b.send(M)}),d.get("/report-header.txt",(m,b)=>{try{b.type("text/plain").send(u.readFileSync(T,"utf8"))}catch{b.status(500).send("Error loading report-header.txt")}}),d.use("/",G.createProxyMiddleware({target:v.url,changeOrigin:!0,ws:!0}));let c=!1;const h=()=>{if(!c){c=!0,console.log(`
5
- [Dev Launcher] Shutting down Dev Mode server and spawned Storybooks...`);for(const m of a)m.kill("SIGINT");process.exit(0)}};process.on("SIGINT",h),process.on("SIGTERM",h),d.listen(f,()=>{console.log(`
2
+ "use strict";const E=require("node:child_process"),d=require("node:fs"),i=require("node:path"),D=require("node:url"),q=require("express"),G=require("http-proxy-middleware"),V=require("node:net"),H=require("./mantineSourceOfTruth-Dpe4mlmF.cjs"),C=require("./index-C6uYPRmx.cjs");var k=typeof document<"u"?document.currentScript:null;const J=/\x1b\[[0-9;]*m/g,W=/Local:\s*(https?:\/\/localhost:\d+)/;function B(e){return new Promise(t=>{const r=new V.Socket;r.setTimeout(200),r.once("connect",()=>{r.destroy(),t(!0)}),r.once("timeout",()=>{r.destroy(),t(!1)}),r.once("error",()=>{r.destroy(),t(!1)}),r.connect(e,"127.0.0.1")})}function K(e){try{const t=JSON.parse(d.readFileSync(e,"utf8")).port;return typeof t=="number"?t:void 0}catch{return}}function X(e,t){d.mkdirSync(i.dirname(e),{recursive:!0}),d.writeFileSync(e,JSON.stringify({port:t}))}function Y(e,t){return new Promise((r,o)=>{var w,v;const n=E.spawn(e.command,{cwd:e.cwd,stdio:"pipe",shell:!0});let s=!1;const l=setTimeout(()=>{s||(s=!0,n.kill(),o(new Error(`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).`)))},t),f=(a,u)=>{const p=a.toString();for(const c of p.split(`
3
+ `))if(c.trim()){const h=u?`${e.name} SB ERROR`:`${e.name} SB`;(u?console.error:console.log)(`[${h}] ${c.trim()}`)}if(s)return;const T=p.replace(J,"").match(W);if(T){s=!0,clearTimeout(l);const c=T[1],h=Number(new URL(c).port);X(e.cacheFile,h),r({url:c,port:h,process:n})}};(w=n.stdout)==null||w.on("data",a=>f(a,!1)),(v=n.stderr)==null||v.on("data",a=>f(a,!0)),n.on("error",a=>{s||(s=!0,clearTimeout(l),o(a))}),n.on("exit",a=>{s||(s=!0,clearTimeout(l),o(new Error(`${e.name}'s Storybook exited (code ${a}) before reporting its URL.`)))})})}function x(e,t){return{name:e,command:t.command,cwd:t.cwd,reuseExistingServer:t.reuseExistingServer,cacheFile:t.cacheFile,timeoutMs:t.timeout}}async function j(e){if(e.reuseExistingServer){const t=K(e.cacheFile);if(t!==void 0&&await B(t))return console.log(`[Dev Launcher] ${e.name} is already running on port ${t} (reused).`),{url:`http://localhost:${t}`,port:t,process:null}}return console.log(`[Dev Launcher] Launching Storybook for ${e.name}...`),Y(e,e.timeoutMs??120*1e3)}const R=i.dirname(D.fileURLToPath(typeof document>"u"?require("url").pathToFileURL(__filename).href:k&&k.tagName.toUpperCase()==="SCRIPT"&&k.src||new URL("cli.cjs",document.baseURI).href));function z(e){const t=process.platform==="darwin"?"open":process.platform==="win32"?"start":"xdg-open";console.log(`[Dev Launcher] Auto-launching browser: ${e}`),E.spawn(t,[e],{shell:process.platform==="win32"}).on("error",r=>{console.error("[Dev Launcher] Failed to auto-launch browser:",r)})}async function Q(e,t,r={}){const[o,n]=e.targets,[s,l]=t;if(!(o!=null&&o.sourceOfTruth)||!n||n.sourceOfTruth||!s||!l)throw new Error("adapter-tester dev mode requires exactly two targets: [sourceOfTruth, target] — check adapter-tester.config.json.");const f=r.port??6010;console.log(`[Dev Launcher] Resolving ${o.name} and ${n.name} Storybooks...`);const[w,v]=await Promise.all([j(x(o.name,s)),j(x(n.name,l))]);console.log("[Dev Launcher] Both Storybooks are active and responsive!");const a=[w.process,v.process].filter(m=>m!==null),u=q(),p=i.join(R,"../public"),T=i.join(R,"../report-header.txt");u.get("/",(m,b,S)=>{if(m.query.path){S();return}const M=d.readFileSync(i.join(p,"index.html"),"utf8").replace("<head>",`<head>
4
+ <script>window.__ADAPTER_TESTER__ = ${JSON.stringify({ownName:n.name,sourceOfTruthName:o.name,sourceOfTruthPort:w.port})};<\/script>`);b.send(M)}),u.get("/report-header.txt",(m,b)=>{if(e.reportHeader!==void 0){b.type("text/plain").send(e.reportHeader);return}try{b.type("text/plain").send(d.readFileSync(T,"utf8"))}catch{b.status(500).send("Error loading report-header.txt")}}),u.use("/",G.createProxyMiddleware({target:v.url,changeOrigin:!0,ws:!0}));let c=!1;const h=()=>{if(!c){c=!0,console.log(`
5
+ [Dev Launcher] Shutting down Dev Mode server and spawned Storybooks...`);for(const m of a)m.kill("SIGINT");process.exit(0)}};process.on("SIGINT",h),process.on("SIGTERM",h),u.listen(f,()=>{console.log(`
6
6
  ====================================================
7
7
  🚀 Adapter Dev Mode proxy running at:
8
8
  http://localhost:${f}
9
9
  ====================================================
10
- `),z(`http://localhost:${f}`)})}const Z="http://json-schema.org/draft-07/schema#",ee="https://github.com/borderux/recursica/tree/main/packages/adapter-tester/src/adapter-tester.schema.json",te="adapter-tester.config.json",re="Configuration for @recursica/adapter-tester. All fields are optional — an adapter repo with a normal `storybook` npm script needs no config file at all.",oe="object",ne=!1,se={$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`)."}},ie={$schema:Z,$id:ee,title:te,description:re,type:oe,additionalProperties:ne,properties:se},ae=N.index,$=new N.ajvExports.Ajv({allErrors:!0,strict:!0});ae($);const R=$.compile(ie);function ce(e,t){if(R(e))return;const r=(R.errors??[]).map(o=>{var s;const n=(s=o.params)!=null&&s.additionalProperty?` '${o.params.additionalProperty}'`:"";return` - ${o.instancePath||"root"} ${o.message}${n}`}).join(`
10
+ `),z(`http://localhost:${f}`)})}const Z="http://json-schema.org/draft-07/schema#",ee="https://github.com/borderux/recursica/tree/main/packages/adapter-tester/src/adapter-tester.schema.json",te="adapter-tester.config.json",re="Configuration for @recursica/adapter-tester. All fields are optional — an adapter repo with a normal `storybook` npm script needs no config file at all.",oe="object",ne=!1,se={$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`.'}},ie={$schema:Z,$id:ee,title:te,description:re,type:oe,additionalProperties:ne,properties:se},ae=C.index,$=new C.ajvExports.Ajv({allErrors:!0,strict:!0});ae($);const _=$.compile(ie);function ce(e,t){if(_(e))return;const r=(_.errors??[]).map(o=>{var s;const n=(s=o.params)!=null&&s.additionalProperty?` '${o.params.additionalProperty}'`:"";return` - ${o.instancePath||"root"} ${o.message}${n}`}).join(`
11
11
  `);throw new Error(`Invalid ${t}:
12
- ${r}`)}const ue="@recursica/mantine-adapter",de="adapter-tester.config.json",L="npm run storybook",le=6006,F=6011,C="Mantine",pe=10,he=3500;function I(e){const t=i.join(e,"package.json");if(!u.existsSync(t))throw new Error(`No package.json found in ${e} — run adapter-tester from the root of the project being tested.`);return JSON.parse(u.readFileSync(t,"utf8"))}function fe(e){var n;const r=(n=I(e).scripts)==null?void 0:n.storybook,o=r==null?void 0:r.match(/(?:-p|--port)[ =](\d+)/);return o?Number(o[1]):le}function me(e){const r=I(e).name;return r?r.split("/").pop():"Adapter"}function ge(e){const t=i.join(e,de);if(!u.existsSync(t))return{};const r=JSON.parse(u.readFileSync(t,"utf8"));return ce(r,t),r}function ye(e,t={}){var h,m,b;const r=ge(e),o=r.isSourceOfTruthAdapter??!1;if(t.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 n=r.name??me(e),s=((h=r.storybook)==null?void 0:h.port)??fe(e),l=((m=r.storybook)==null?void 0:m.command)??L,f=i.resolve(e,((b=r.storybook)==null?void 0:b.cwd)??"."),w={command:l,port:s,cwd:f,reuseExistingServer:!process.env.CI,cacheFile:i.join(e,".adapter-tester","last-port-own.json"),timeout:120*1e3},v={goldenThresholdPixels:r.goldenThresholdPixels??pe,sourceOfTruthThresholdPixels:r.sourceOfTruthThresholdPixels??he,stories:r.stories,excludeTitlePrefixes:r.excludeTitlePrefixes,goldenDir:i.join(f,"test","golden"),isSourceOfTruthAdapter:o,goldenMode:"check",checkMode:"own"};if(o)return{engineConfig:{...v,targets:[{name:n,url:`http://localhost:${s}`}]},webServers:[w]};const a=r.sourceOfTruth??{type:"mantine-harness"};let d,p,T,c;if(a.type==="url"){if(t.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.`);d=a.name??C,p=a.port??F;const S=i.resolve(e,a.cwd??".");T={command:a.command??L,port:p,cwd:S,reuseExistingServer:!process.env.CI,cacheFile:i.join(e,".adapter-tester","last-port-source-of-truth.json"),timeout:120*1e3},c={type:"local",dir:i.join(S,"test","golden")}}else{d=C,p=a.port??F;const S=t.mantineAdapterVersion??a.mantineAdapterVersion;T=J.mantineSourceOfTruthWebServer({dir:i.join(e,".adapter-tester/mantine-harness"),port:p,mantineAdapterVersion:S,storybookTemplateVersion:a.storybookTemplateVersion}),c={type:"npm",packageName:ue,versionSpec:S??"latest",cacheDir:i.join(e,".adapter-tester/mantine-golden-cache")}}return{engineConfig:{...v,targets:[{name:d,url:`http://localhost:${p}`,sourceOfTruth:!0},{name:n,url:`http://localhost:${s}`}],sourceOfTruthGolden:c},webServers:[T,w]}}const we=i.dirname(D.fileURLToPath(typeof document>"u"?require("url").pathToFileURL(__filename).href:k&&k.tagName.toUpperCase()==="SCRIPT"&&k.src||new URL("cli.cjs",document.baseURI).href)),ve=D.pathToFileURL(i.join(we,"testing.js")).href,y=process.argv.slice(2);let U;const O=y.indexOf("--source-of-truth-version");if(O!==-1){const e=y[O+1];if(e===void 0||e.startsWith("--"))throw new Error("--source-of-truth-version requires a value, e.g. --source-of-truth-version 0.53.0");U=e,y.splice(O,2)}const P=process.cwd(),{engineConfig:g,webServers:A}=ye(P,{mantineAdapterVersion:U});y.includes("--update-golden")?g.goldenMode="update-golden":y.includes("--approve-divergence")&&(g.goldenMode="approve-divergence");if(y.includes("--divergence-only")){if(g.isSourceOfTruthAdapter)throw new Error("--divergence-only has nothing to diverge from — isSourceOfTruthAdapter is true in this project's adapter-tester.config.json.");g.checkMode="divergence"}else if(g.goldenMode==="approve-divergence")throw new Error("--approve-divergence only makes sense with --divergence-only — there's nothing to approve without the divergence check running.");y.includes("--dry-run")&&(console.log(JSON.stringify({engineConfig:g,webServers:A},null,2)),process.exit(0));const Te=new Set(["--dry-run","--serve","--update-golden","--approve-divergence","--divergence-only"]),be=y.filter(e=>!Te.has(e));Se().catch(e=>{console.error(e),process.exitCode=1});async function Se(){if(y.includes("--serve")){if(g.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.");await Q(g,A)}else{const e=A.at(-1);if(!e)throw new Error("resolveConfig() returned no webServers to boot.");await ke(e,g)}}async function ke(e,t){const r=i.join(P,".adapter-tester/run");u.mkdirSync(r,{recursive:!0});const o=t.targets.at(-1);if(!o)throw new Error("resolveConfig() returned no targets to check.");const{url:n,process:s}=await j(x(o.name,e));o.url=n,u.writeFileSync(i.join(r,"playwright.config.js"),`// Generated by \`adapter-tester\` — do not edit, regenerated on every run.
12
+ ${r}`)}const de="@recursica/mantine-adapter",ue="adapter-tester.config.json",F="npm run storybook",le=6006,L=6011,N="Mantine",pe=10,he=3500;function I(e){const t=i.join(e,"package.json");if(!d.existsSync(t))throw new Error(`No package.json found in ${e} — run adapter-tester from the root of the project being tested.`);return JSON.parse(d.readFileSync(t,"utf8"))}function fe(e){var n;const r=(n=I(e).scripts)==null?void 0:n.storybook,o=r==null?void 0:r.match(/(?:-p|--port)[ =](\d+)/);return o?Number(o[1]):le}function me(e){const r=I(e).name;return r?r.split("/").pop():"Adapter"}function ge(e){const t=i.join(e,ue);if(!d.existsSync(t))return{};const r=JSON.parse(d.readFileSync(t,"utf8"));return ce(r,t),r}function ye(e,t={}){var h,m,b;const r=ge(e),o=r.isSourceOfTruthAdapter??!1;if(t.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 n=r.name??me(e),s=((h=r.storybook)==null?void 0:h.port)??fe(e),l=((m=r.storybook)==null?void 0:m.command)??F,f=i.resolve(e,((b=r.storybook)==null?void 0:b.cwd)??"."),w={command:l,port:s,cwd:f,reuseExistingServer:!process.env.CI,cacheFile:i.join(e,".adapter-tester","last-port-own.json"),timeout:120*1e3},v={goldenThresholdPixels:r.goldenThresholdPixels??pe,sourceOfTruthThresholdPixels:r.sourceOfTruthThresholdPixels??he,stories:r.stories,excludeTitlePrefixes:r.excludeTitlePrefixes,reportHeader:r.reportHeader,goldenDir:i.join(f,"test","golden"),isSourceOfTruthAdapter:o,goldenMode:"check",checkMode:"own"};if(o)return{engineConfig:{...v,targets:[{name:n,url:`http://localhost:${s}`}]},webServers:[w]};const a=r.sourceOfTruth??{type:"mantine-harness"};let u,p,T,c;if(a.type==="url"){if(t.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.`);u=a.name??N,p=a.port??L;const S=i.resolve(e,a.cwd??".");T={command:a.command??F,port:p,cwd:S,reuseExistingServer:!process.env.CI,cacheFile:i.join(e,".adapter-tester","last-port-source-of-truth.json"),timeout:120*1e3},c={type:"local",dir:i.join(S,"test","golden")}}else{u=N,p=a.port??L;const S=t.mantineAdapterVersion??a.mantineAdapterVersion;T=H.mantineSourceOfTruthWebServer({dir:i.join(e,".adapter-tester/mantine-harness"),port:p,mantineAdapterVersion:S,storybookTemplateVersion:a.storybookTemplateVersion}),c={type:"npm",packageName:de,versionSpec:S??"latest",cacheDir:i.join(e,".adapter-tester/mantine-golden-cache")}}return{engineConfig:{...v,targets:[{name:u,url:`http://localhost:${p}`,sourceOfTruth:!0},{name:n,url:`http://localhost:${s}`}],sourceOfTruthGolden:c},webServers:[T,w]}}const we=i.dirname(D.fileURLToPath(typeof document>"u"?require("url").pathToFileURL(__filename).href:k&&k.tagName.toUpperCase()==="SCRIPT"&&k.src||new URL("cli.cjs",document.baseURI).href)),ve=D.pathToFileURL(i.join(we,"testing.js")).href,y=process.argv.slice(2);let U;const O=y.indexOf("--source-of-truth-version");if(O!==-1){const e=y[O+1];if(e===void 0||e.startsWith("--"))throw new Error("--source-of-truth-version requires a value, e.g. --source-of-truth-version 0.53.0");U=e,y.splice(O,2)}const P=process.cwd(),{engineConfig:g,webServers:A}=ye(P,{mantineAdapterVersion:U});y.includes("--update-golden")?g.goldenMode="update-golden":y.includes("--approve-divergence")&&(g.goldenMode="approve-divergence");if(y.includes("--divergence-only")){if(g.isSourceOfTruthAdapter)throw new Error("--divergence-only has nothing to diverge from — isSourceOfTruthAdapter is true in this project's adapter-tester.config.json.");g.checkMode="divergence"}else if(g.goldenMode==="approve-divergence")throw new Error("--approve-divergence only makes sense with --divergence-only — there's nothing to approve without the divergence check running.");y.includes("--dry-run")&&(console.log(JSON.stringify({engineConfig:g,webServers:A},null,2)),process.exit(0));const Te=new Set(["--dry-run","--serve","--update-golden","--approve-divergence","--divergence-only"]),be=y.filter(e=>!Te.has(e));Se().catch(e=>{console.error(e),process.exitCode=1});async function Se(){if(y.includes("--serve")){if(g.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.");await Q(g,A)}else{const e=A.at(-1);if(!e)throw new Error("resolveConfig() returned no webServers to boot.");await ke(e,g)}}async function ke(e,t){const r=i.join(P,".adapter-tester/run");d.mkdirSync(r,{recursive:!0});const o=t.targets.at(-1);if(!o)throw new Error("resolveConfig() returned no targets to check.");const{url:n,process:s}=await j(x(o.name,e));o.url=n,d.writeFileSync(i.join(r,"playwright.config.js"),`// Generated by \`adapter-tester\` — do not edit, regenerated on every run.
13
13
  import { defineConfig, devices } from "@playwright/test";
14
14
 
15
15
  export default defineConfig({
16
16
  testDir: ${JSON.stringify(r)},
17
- // Stories run across Playwright's default worker pool each golden check
18
- // only reads/writes its own story's manifest.json entry, under a lock, so
19
- // concurrent workers never race each other (see \`updateManifestEntry\`).
20
- // Override with \`--workers <n>\` (forwarded straight through to Playwright).
17
+ // Each golden check only reads/writes its own story's manifest.json entry,
18
+ // under a lock, so concurrent workers never race each other (see
19
+ // \`updateManifestEntry\`). Defaults to 1 worker (1 Chromium instance) to
20
+ // avoid exhausting memory running the full suite; override with
21
+ // \`--workers <n>\` (forwarded straight through to Playwright) to parallelize.
22
+ workers: 1,
21
23
  fullyParallel: true,
22
24
  forbidOnly: !!process.env.CI,
23
25
  retries: process.env.CI ? 2 : 0,
@@ -27,7 +29,7 @@ export default defineConfig({
27
29
  // No webServer entry — this project's own Storybook is already running by
28
30
  // the time this config is used (see runAutomated() in cli.ts).
29
31
  });
30
- `),u.writeFileSync(i.join(r,"visual-regression.spec.js"),`// Generated by \`adapter-tester\` — do not edit, regenerated on every run.
32
+ `),d.writeFileSync(i.join(r,"visual-regression.spec.js"),`// Generated by \`adapter-tester\` — do not edit, regenerated on every run.
31
33
  import { test, expect } from "@playwright/test";
32
34
  import { resolveVisualRegressionPlan } from ${JSON.stringify(ve)};
33
35
 
package/dist/cli.cjs.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"cli.cjs","sources":["../src/portDiscovery.ts","../src/devServer.ts","../src/validateFileConfig.ts","../src/fileConfig.ts","../src/cli.ts"],"sourcesContent":["import { spawn, type ChildProcess } from \"node:child_process\";\nimport { mkdirSync, readFileSync, writeFileSync } from \"node:fs\";\nimport { dirname } from \"node:path\";\nimport net from \"node:net\";\nimport type { HarnessWebServerConfig } from \"./harness/mantineSourceOfTruth.js\";\n\n/**\n * Boots a target's Storybook and discovers the real port it ends up on,\n * instead of pinning one via `-p`/`--port`. Storybook silently falls back to\n * an OS-assigned port whenever its default/configured one is taken (this is\n * what caused the flaky `webServer` timeouts noted in mui-adapter), so the\n * only reliable source of truth is the URL it prints in its own startup\n * banner. Used by both the automated/headless run (cli.ts) and Dev Mode\n * (devServer.ts) — neither pins a port anymore.\n */\n\nexport interface LaunchTarget {\n /** Human-readable name used in log lines. */\n name: string;\n command: string;\n cwd: string;\n /** Reuse an already-running instance (detected via the last-known-port\n * cache) instead of spawning a new one. Mirrors the old `reuseExistingServer`\n * behavior, which used to just probe the one fixed configured port. */\n reuseExistingServer: boolean;\n /** File the discovered port is cached in between runs, so a later\n * `reuseExistingServer` run knows where to look. One per target. */\n cacheFile: string;\n timeoutMs?: number;\n}\n\nexport interface DiscoveredServer {\n url: string;\n port: number;\n /** The process we spawned, or `null` if an already-running instance was\n * reused — callers should only kill what they started. */\n process: ChildProcess | null;\n}\n\n// Storybook prints its bound address in its startup banner wrapped in ANSI\n// color codes and box-drawing chars, e.g.:\n// │ │ - Local: http://localhost:57496/ │ │\n// Strip ANSI first, then match the URL itself.\nconst ANSI_PATTERN = /\\x1b\\[[0-9;]*m/g;\nconst LOCAL_URL_PATTERN = /Local:\\s*(https?:\\/\\/localhost:\\d+)/;\n\nfunction isPortActive(port: number): Promise<boolean> {\n return new Promise((resolve) => {\n const socket = new net.Socket();\n socket.setTimeout(200);\n socket.once(\"connect\", () => {\n socket.destroy();\n resolve(true);\n });\n socket.once(\"timeout\", () => {\n socket.destroy();\n resolve(false);\n });\n socket.once(\"error\", () => {\n socket.destroy();\n resolve(false);\n });\n socket.connect(port, \"127.0.0.1\");\n });\n}\n\nfunction readCachedPort(cacheFile: string): number | undefined {\n try {\n const port = JSON.parse(readFileSync(cacheFile, \"utf8\")).port;\n return typeof port === \"number\" ? port : undefined;\n } catch {\n return undefined;\n }\n}\n\nfunction writeCachedPort(cacheFile: string, port: number): void {\n mkdirSync(dirname(cacheFile), { recursive: true });\n writeFileSync(cacheFile, JSON.stringify({ port }));\n}\n\n/** Spawns `target.command`, streaming its output to the console like before,\n * and resolves once it reports the URL it actually bound to. */\nfunction spawnAndDetect(\n target: LaunchTarget,\n timeoutMs: number,\n): Promise<DiscoveredServer> {\n return new Promise((resolve, reject) => {\n const child = spawn(target.command, {\n cwd: target.cwd,\n stdio: \"pipe\",\n shell: true,\n });\n\n let settled = false;\n const timer = setTimeout(() => {\n if (settled) return;\n settled = true;\n child.kill();\n reject(\n new Error(\n `Timed out after ${timeoutMs}ms waiting for ${target.name}'s Storybook to report its URL (no \"Local: http://localhost:<port>\" line seen in its output).`,\n ),\n );\n }, timeoutMs);\n\n const handleOutput = (data: Buffer, isError: boolean) => {\n const text = data.toString();\n for (const line of text.split(\"\\n\")) {\n if (line.trim()) {\n const label = isError\n ? `${target.name} SB ERROR`\n : `${target.name} SB`;\n (isError ? console.error : console.log)(`[${label}] ${line.trim()}`);\n }\n }\n if (settled) return;\n const match = text.replace(ANSI_PATTERN, \"\").match(LOCAL_URL_PATTERN);\n if (match) {\n settled = true;\n clearTimeout(timer);\n // Non-null: LOCAL_URL_PATTERN has exactly one capture group, and a\n // match only happens when it participated.\n const url = match[1]!;\n const port = Number(new URL(url).port);\n writeCachedPort(target.cacheFile, port);\n resolve({ url, port, process: child });\n }\n };\n child.stdout?.on(\"data\", (data: Buffer) => handleOutput(data, false));\n child.stderr?.on(\"data\", (data: Buffer) => handleOutput(data, true));\n child.on(\"error\", (err) => {\n if (settled) return;\n settled = true;\n clearTimeout(timer);\n reject(err);\n });\n child.on(\"exit\", (code) => {\n if (settled) return;\n settled = true;\n clearTimeout(timer);\n reject(\n new Error(\n `${target.name}'s Storybook exited (code ${code}) before reporting its URL.`,\n ),\n );\n });\n });\n}\n\n/** Adapts a resolved `HarnessWebServerConfig` into a `LaunchTarget`. */\nexport function toLaunchTarget(\n name: string,\n server: HarnessWebServerConfig,\n): LaunchTarget {\n return {\n name,\n command: server.command,\n cwd: server.cwd,\n reuseExistingServer: server.reuseExistingServer,\n cacheFile: server.cacheFile,\n timeoutMs: server.timeout,\n };\n}\n\n/** Reuses an already-running Storybook if `reuseExistingServer` is set and\n * the last-known-port cache points at something still listening; otherwise\n * spawns `target.command` fresh and detects the real port from its output. */\nexport async function launchAndDetectStorybook(\n target: LaunchTarget,\n): Promise<DiscoveredServer> {\n if (target.reuseExistingServer) {\n const cachedPort = readCachedPort(target.cacheFile);\n if (cachedPort !== undefined && (await isPortActive(cachedPort))) {\n console.log(\n `[Dev Launcher] ${target.name} is already running on port ${cachedPort} (reused).`,\n );\n return {\n url: `http://localhost:${cachedPort}`,\n port: cachedPort,\n process: null,\n };\n }\n }\n console.log(`[Dev Launcher] Launching Storybook for ${target.name}...`);\n return spawnAndDetect(target, target.timeoutMs ?? 120 * 1000);\n}\n","import { spawn, type ChildProcess } from \"node:child_process\";\nimport { readFileSync } from \"node:fs\";\nimport { dirname, join } from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\nimport express from \"express\";\nimport { createProxyMiddleware } from \"http-proxy-middleware\";\nimport type { AdapterTesterConfig } from \"./config.js\";\nimport type { HarnessWebServerConfig } from \"./harness/mantineSourceOfTruth.js\";\nimport { launchAndDetectStorybook, toLaunchTarget } from \"./portDiscovery.js\";\n\n/**\n * Interactive Dev Mode: a synced, side-by-side browser view of this\n * project's own Storybook and the source of truth, with per-story note\n * taking and an AI-report export. Boots both Storybooks (reusing them if\n * already running) behind a proxy so the own/target pane — which drives\n * the sync and carries Storybook's nav sidebar — loads same-origin on the\n * left, with the source of truth following along as a bare preview on the\n * right.\n *\n * Config-driven — takes the same `{ engineConfig, webServers }` shape\n * `resolveConfig()` produces, in the same [sourceOfTruth, target] order.\n */\n\nconst distDir = dirname(fileURLToPath(import.meta.url));\n\nfunction openBrowser(url: string): void {\n const startCmd =\n process.platform === \"darwin\"\n ? \"open\"\n : process.platform === \"win32\"\n ? \"start\"\n : \"xdg-open\";\n console.log(`[Dev Launcher] Auto-launching browser: ${url}`);\n spawn(startCmd, [url], { shell: process.platform === \"win32\" }).on(\n \"error\",\n (err) => {\n console.error(`[Dev Launcher] Failed to auto-launch browser:`, err);\n },\n );\n}\n\nexport interface DevServerOptions {\n /** Port the dev-mode proxy UI itself listens on. Defaults to 6010. */\n port?: number;\n}\n\nexport async function startDevServer(\n engineConfig: AdapterTesterConfig,\n webServers: HarnessWebServerConfig[],\n options: DevServerOptions = {},\n): Promise<void> {\n const [sourceOfTruth, target] = engineConfig.targets;\n const [sourceOfTruthServer, targetServer] = webServers;\n if (\n !sourceOfTruth?.sourceOfTruth ||\n !target ||\n target.sourceOfTruth ||\n !sourceOfTruthServer ||\n !targetServer\n ) {\n throw new Error(\n \"adapter-tester dev mode requires exactly two targets: [sourceOfTruth, target] — check adapter-tester.config.json.\",\n );\n }\n\n const devPort = options.port ?? 6010;\n\n // Neither Storybook is pinned to a specific port — each one silently\n // falls back to an OS-assigned port whenever its default/configured one is\n // taken, so the real port is only known once it reports it (see\n // portDiscovery.ts). Booted concurrently since neither depends on the other.\n console.log(\n `[Dev Launcher] Resolving ${sourceOfTruth.name} and ${target.name} Storybooks...`,\n );\n const [sourceOfTruthRunning, targetRunning] = await Promise.all([\n launchAndDetectStorybook(\n toLaunchTarget(sourceOfTruth.name, sourceOfTruthServer),\n ),\n launchAndDetectStorybook(toLaunchTarget(target.name, targetServer)),\n ]);\n console.log(`[Dev Launcher] Both Storybooks are active and responsive!`);\n\n const spawned = [sourceOfTruthRunning.process, targetRunning.process].filter(\n (child): child is ChildProcess => child !== null,\n );\n\n const app = express();\n const publicDir = join(distDir, \"../public\");\n const headerPath = join(distDir, \"../report-header.txt\");\n\n // Serve the Dev Mode UI at the root path ONLY if there is no query string.\n // This allows the iframe (which loads with ?path=/story/...) to pass\n // through to the proxy, avoiding an infinite loop of nested wrappers.\n app.get(\"/\", (req, res, next) => {\n if (req.query.path) {\n next();\n return;\n }\n const html = readFileSync(join(publicDir, \"index.html\"), \"utf8\").replace(\n \"<head>\",\n `<head>\\n <script>window.__ADAPTER_TESTER__ = ${JSON.stringify({\n ownName: target.name,\n sourceOfTruthName: sourceOfTruth.name,\n sourceOfTruthPort: sourceOfTruthRunning.port,\n })};</script>`,\n );\n res.send(html);\n });\n\n // Serve the AI prompt header dynamically so it can be edited externally.\n app.get(\"/report-header.txt\", (req, res) => {\n try {\n res.type(\"text/plain\").send(readFileSync(headerPath, \"utf8\"));\n } catch {\n res.status(500).send(\"Error loading report-header.txt\");\n }\n });\n\n // Proxy everything else to this project's own Storybook, preserving\n // absolute paths (e.g. /@vite/client) so HMR keeps working same-origin.\n // This is the pane that drives the sync and shows Storybook's nav sidebar.\n app.use(\n \"/\",\n createProxyMiddleware({\n target: targetRunning.url,\n changeOrigin: true,\n ws: true,\n }),\n );\n\n let cleaningUp = false;\n const cleanup = () => {\n if (cleaningUp) return;\n cleaningUp = true;\n console.log(\n \"\\n[Dev Launcher] Shutting down Dev Mode server and spawned Storybooks...\",\n );\n for (const child of spawned) child.kill(\"SIGINT\");\n process.exit(0);\n };\n process.on(\"SIGINT\", cleanup);\n process.on(\"SIGTERM\", cleanup);\n\n app.listen(devPort, () => {\n console.log(`\n====================================================\n🚀 Adapter Dev Mode proxy running at:\n http://localhost:${devPort}\n====================================================\n`);\n openBrowser(`http://localhost:${devPort}`);\n });\n}\n","import { Ajv } from \"ajv\";\nimport * as ajvFormatsModule from \"ajv-formats\";\nimport type { FormatsPlugin } from \"ajv-formats\";\nimport schema from \"./adapter-tester.schema.json\" with { type: \"json\" };\n\n// ajv-formats ships an ESM-style `export default` on a CJS build with no\n// `\"type\"` field, which under `moduleResolution: NodeNext` TS resolves to\n// the raw module namespace instead of unwrapping the default — a known\n// ajv-formats/TS interop gap, not a version mismatch.\nconst addFormats = (ajvFormatsModule as unknown as { default: FormatsPlugin })\n .default;\n\nconst ajv = new Ajv({ allErrors: true, strict: true });\naddFormats(ajv);\nconst validate = ajv.compile(schema);\n\n/**\n * Validates a parsed `adapter-tester.config.json` against\n * `adapter-tester.schema.json`. Throws with every violation listed — callers\n * must not silently coerce or drop invalid fields.\n */\nexport function validateFileConfig(data: unknown, path: string): void {\n if (validate(data)) return;\n\n const errors = (validate.errors ?? [])\n .map((error) => {\n const extra = error.params?.additionalProperty\n ? ` '${error.params.additionalProperty}'`\n : \"\";\n return ` - ${error.instancePath || \"root\"} ${error.message}${extra}`;\n })\n .join(\"\\n\");\n throw new Error(`Invalid ${path}:\\n${errors}`);\n}\n","import { existsSync, readFileSync } from \"node:fs\";\nimport { join, resolve } from \"node:path\";\nimport type {\n AdapterTesterConfig,\n SourceOfTruthGoldenLocation,\n StoryOverride,\n} from \"./config.js\";\nimport type { HarnessWebServerConfig } from \"./harness/mantineSourceOfTruth.js\";\nimport { mantineSourceOfTruthWebServer } from \"./harness/mantineSourceOfTruth.js\";\nimport { validateFileConfig } from \"./validateFileConfig.js\";\n\nconst MANTINE_ADAPTER_PACKAGE_NAME = \"@recursica/mantine-adapter\";\n\nexport const CONFIG_FILE_NAME = \"adapter-tester.config.json\";\nconst DEFAULT_STORYBOOK_COMMAND = \"npm run storybook\";\nconst DEFAULT_STORYBOOK_PORT = 6006;\nconst DEFAULT_SOURCE_OF_TRUTH_PORT = 6011;\nconst DEFAULT_SOURCE_OF_TRUTH_NAME = \"Mantine\";\nconst DEFAULT_GOLDEN_THRESHOLD_PIXELS = 10;\nconst DEFAULT_SOURCE_OF_TRUTH_THRESHOLD_PIXELS = 3500;\n\ninterface StorybookTargetFileConfig {\n /** First-guess port only, not authoritative — the real port is\n * auto-detected from this Storybook's own startup output, since Storybook\n * silently falls back to an OS-assigned port whenever this one is taken.\n * Auto-detected from this project's own `scripts.storybook` (a `-p\n * <port>`/`--port <port>` flag) when omitted, falling back to 6006. */\n port?: number;\n /** Command that boots the target's Storybook. Defaults to `npm run storybook`. */\n command?: string;\n /** Directory the command runs in, relative to the config file. Defaults to \".\" */\n cwd?: string;\n}\n\ninterface MantineHarnessSourceOfTruthFileConfig {\n /** Default mode: boots a throwaway harness that installs the published\n * `@recursica/mantine-adapter` from npm — no monorepo checkout required. */\n type?: \"mantine-harness\";\n /** First-guess port only, not authoritative — see `HarnessWebServerConfig.port`. */\n port?: number;\n mantineAdapterVersion?: string;\n storybookTemplateVersion?: string;\n}\n\ninterface UrlSourceOfTruthFileConfig {\n /** Non-standard mode: points at an already-addressable Storybook — e.g. a\n * sibling workspace package's own Storybook inside this monorepo. */\n type: \"url\";\n name?: string;\n /** First-guess port only, not authoritative — see `HarnessWebServerConfig.port`.\n * Defaults to 6011. */\n port?: number;\n command?: string;\n cwd?: string;\n}\n\ntype SourceOfTruthFileConfig =\n | MantineHarnessSourceOfTruthFileConfig\n | UrlSourceOfTruthFileConfig;\n\nexport interface AdapterTesterFileConfig {\n /** Label for this project's own target. Defaults to the unscoped name in\n * this project's package.json (e.g. \"@recursica/mui-adapter\" -> \"mui-adapter\"). */\n name?: string;\n storybook?: StorybookTargetFileConfig;\n sourceOfTruth?: SourceOfTruthFileConfig;\n goldenThresholdPixels?: number;\n sourceOfTruthThresholdPixels?: number;\n stories?: Record<string, StoryOverride>;\n excludeTitlePrefixes?: string[];\n /**\n * True only for the source-of-truth adapter's own config (mantine-adapter).\n * Skips `sourceOfTruth` entirely — there's nothing above it to diverge\n * from — and runs the own-drift golden check standalone, against just this\n * project's own Storybook. Defaults to false.\n */\n isSourceOfTruthAdapter?: boolean;\n}\n\nexport interface ResolvedAdapterTesterConfig {\n engineConfig: AdapterTesterConfig;\n webServers: HarnessWebServerConfig[];\n}\n\nexport interface ResolveConfigOverrides {\n /** From `--source-of-truth-version`. Overrides `sourceOfTruth.mantineAdapterVersion`. */\n mantineAdapterVersion?: string;\n}\n\nfunction readOwnPackageJson(cwd: string): any {\n const path = join(cwd, \"package.json\");\n if (!existsSync(path)) {\n throw new Error(\n `No package.json found in ${cwd} — run adapter-tester from the root of the project being tested.`,\n );\n }\n return JSON.parse(readFileSync(path, \"utf8\"));\n}\n\nfunction detectOwnPort(cwd: string): number {\n const pkg = readOwnPackageJson(cwd);\n const storybookScript = pkg.scripts?.storybook as string | undefined;\n const match = storybookScript?.match(/(?:-p|--port)[ =](\\d+)/);\n return match ? Number(match[1]) : DEFAULT_STORYBOOK_PORT;\n}\n\nfunction detectOwnName(cwd: string): string {\n const pkg = readOwnPackageJson(cwd);\n const name = pkg.name as string | undefined;\n return name ? name.split(\"/\").pop()! : \"Adapter\";\n}\n\nfunction loadFileConfig(cwd: string): AdapterTesterFileConfig {\n const path = join(cwd, CONFIG_FILE_NAME);\n if (!existsSync(path)) {\n return {};\n }\n const data = JSON.parse(readFileSync(path, \"utf8\"));\n validateFileConfig(data, path);\n return data;\n}\n\n/**\n * Loads `adapter-tester.config.json` from `cwd` (or falls back to defaults\n * when the file doesn't exist) and resolves it into the engine config\n * `resolveVisualRegressionPlan` consumes plus the Playwright `webServer` entries\n * needed to boot both sides of the comparison.\n *\n * Default mode (no `sourceOfTruth`/`storybook` set): compares this project's\n * own Storybook against a throwaway Mantine harness — no monorepo checkout\n * required. Set `sourceOfTruth.type: \"url\"` for the non-standard mode used\n * to compare sibling workspace packages inside this monorepo.\n *\n * `overrides.mantineAdapterVersion` (from `--source-of-truth-version`) pins\n * the mantine-harness install/golden-fetch version for this run, overriding\n * `sourceOfTruth.mantineAdapterVersion`. Throws if passed together with\n * `isSourceOfTruthAdapter` or `sourceOfTruth.type: \"url\"` — neither has a\n * version to pin.\n */\nexport function resolveConfig(\n cwd: string,\n overrides: ResolveConfigOverrides = {},\n): ResolvedAdapterTesterConfig {\n const file = loadFileConfig(cwd);\n const isSourceOfTruthAdapter = file.isSourceOfTruthAdapter ?? false;\n\n if (overrides.mantineAdapterVersion && isSourceOfTruthAdapter) {\n throw new Error(\n \"--source-of-truth-version has no effect on the source-of-truth adapter's own config (isSourceOfTruthAdapter: true) — there's nothing to pin a version for.\",\n );\n }\n\n const ownName = file.name ?? detectOwnName(cwd);\n const ownPort = file.storybook?.port ?? detectOwnPort(cwd);\n const ownCommand = file.storybook?.command ?? DEFAULT_STORYBOOK_COMMAND;\n const ownCwd = resolve(cwd, file.storybook?.cwd ?? \".\");\n const ownWebServer: HarnessWebServerConfig = {\n command: ownCommand,\n port: ownPort,\n cwd: ownCwd,\n reuseExistingServer: !process.env.CI,\n cacheFile: join(cwd, \".adapter-tester\", \"last-port-own.json\"),\n timeout: 120 * 1000,\n };\n\n const sharedEngineConfig = {\n goldenThresholdPixels:\n file.goldenThresholdPixels ?? DEFAULT_GOLDEN_THRESHOLD_PIXELS,\n sourceOfTruthThresholdPixels:\n file.sourceOfTruthThresholdPixels ??\n DEFAULT_SOURCE_OF_TRUTH_THRESHOLD_PIXELS,\n stories: file.stories,\n excludeTitlePrefixes: file.excludeTitlePrefixes,\n // Keyed off `ownCwd`, not `cwd` — the project actually being tested, not\n // wherever the config file happens to live. Matters whenever\n // `storybook.cwd` points at a sibling package: its goldens must resolve\n // to that package's own `test/golden/` (the same directory used when\n // that package runs adapter-tester directly), not a directory under\n // wherever this config file lives.\n goldenDir: join(ownCwd, \"test\", \"golden\"),\n isSourceOfTruthAdapter,\n // Overwritten by the CLI from --update-golden/--approve-divergence.\n goldenMode: \"check\" as const,\n // Overwritten by the CLI from --divergence-only.\n checkMode: \"own\" as const,\n };\n\n // The source-of-truth adapter's own config has nothing above it to\n // diverge from — no second target, no harness/webServer for it at all.\n if (isSourceOfTruthAdapter) {\n return {\n engineConfig: {\n ...sharedEngineConfig,\n targets: [{ name: ownName, url: `http://localhost:${ownPort}` }],\n },\n webServers: [ownWebServer],\n };\n }\n\n const sourceOfTruth = file.sourceOfTruth ?? {\n type: \"mantine-harness\" as const,\n };\n\n let sourceOfTruthName: string;\n let sourceOfTruthPort: number;\n let sourceOfTruthWebServer: HarnessWebServerConfig;\n let sourceOfTruthGolden: SourceOfTruthGoldenLocation;\n\n if (sourceOfTruth.type === \"url\") {\n if (overrides.mantineAdapterVersion) {\n throw new Error(\n '--source-of-truth-version has no effect with sourceOfTruth.type: \"url\" — that mode reads a sibling package\\'s local checkout directly, not a published version.',\n );\n }\n sourceOfTruthName = sourceOfTruth.name ?? DEFAULT_SOURCE_OF_TRUTH_NAME;\n sourceOfTruthPort = sourceOfTruth.port ?? DEFAULT_SOURCE_OF_TRUTH_PORT;\n const sourceOfTruthCwd = resolve(cwd, sourceOfTruth.cwd ?? \".\");\n sourceOfTruthWebServer = {\n command: sourceOfTruth.command ?? DEFAULT_STORYBOOK_COMMAND,\n port: sourceOfTruthPort,\n cwd: sourceOfTruthCwd,\n reuseExistingServer: !process.env.CI,\n cacheFile: join(cwd, \".adapter-tester\", \"last-port-source-of-truth.json\"),\n timeout: 120 * 1000,\n };\n // Sibling package already checked out locally — read its golden files\n // directly, including any uncommitted local changes. No install, no\n // network call.\n sourceOfTruthGolden = {\n type: \"local\",\n dir: join(sourceOfTruthCwd, \"test\", \"golden\"),\n };\n } else {\n sourceOfTruthName = DEFAULT_SOURCE_OF_TRUTH_NAME;\n sourceOfTruthPort = sourceOfTruth.port ?? DEFAULT_SOURCE_OF_TRUTH_PORT;\n const mantineAdapterVersion =\n overrides.mantineAdapterVersion ?? sourceOfTruth.mantineAdapterVersion;\n sourceOfTruthWebServer = mantineSourceOfTruthWebServer({\n dir: join(cwd, \".adapter-tester/mantine-harness\"),\n port: sourceOfTruthPort,\n mantineAdapterVersion,\n storybookTemplateVersion: sourceOfTruth.storybookTemplateVersion,\n });\n // No local checkout — resolve the installed version against the npm\n // registry and fetch that version's golden files from the public repo.\n // Never needs `sourceOfTruthWebServer` above; the golden check on its\n // own doesn't boot a second Storybook at all (see cli.ts).\n sourceOfTruthGolden = {\n type: \"npm\",\n packageName: MANTINE_ADAPTER_PACKAGE_NAME,\n versionSpec: mantineAdapterVersion ?? \"latest\",\n cacheDir: join(cwd, \".adapter-tester/mantine-golden-cache\"),\n };\n }\n\n return {\n engineConfig: {\n ...sharedEngineConfig,\n targets: [\n {\n name: sourceOfTruthName,\n url: `http://localhost:${sourceOfTruthPort}`,\n sourceOfTruth: true,\n },\n { name: ownName, url: `http://localhost:${ownPort}` },\n ],\n sourceOfTruthGolden,\n },\n // [sourceOfTruth, own] — Dev Mode needs both; the automated golden run\n // (cli.ts) only ever boots the last entry, since its divergence check\n // reads stored golden files, not a live source-of-truth page.\n webServers: [sourceOfTruthWebServer, ownWebServer],\n };\n}\n","import { spawnSync } from \"node:child_process\";\nimport { mkdirSync, writeFileSync } from \"node:fs\";\nimport { dirname, join } from \"node:path\";\nimport { fileURLToPath, pathToFileURL } from \"node:url\";\nimport type { AdapterTesterConfig } from \"./config.js\";\nimport { startDevServer } from \"./devServer.js\";\nimport { resolveConfig } from \"./fileConfig.js\";\nimport type { HarnessWebServerConfig } from \"./harness/mantineSourceOfTruth.js\";\nimport { launchAndDetectStorybook, toLaunchTarget } from \"./portDiscovery.js\";\n\n// `dist/testing.js` is always a sibling of this file — both inside a\n// consumer's node_modules/@recursica/adapter-tester/dist and inside this\n// monorepo's own packages/adapter-tester/dist when self-hosting — so the\n// generated spec below can reach it without depending on how the package\n// itself resolves at import time.\nconst distDir = dirname(fileURLToPath(import.meta.url));\nconst testingEntry = pathToFileURL(join(distDir, \"testing.js\")).href;\n\n// `--source-of-truth-version <value>` takes a value, unlike every other own\n// flag below — pulled out of argv first so the boolean flags/passthrough\n// logic never has to know it exists.\nconst args = process.argv.slice(2);\nlet sourceOfTruthVersion: string | undefined;\nconst sourceOfTruthVersionFlagIndex = args.indexOf(\"--source-of-truth-version\");\nif (sourceOfTruthVersionFlagIndex !== -1) {\n const value = args[sourceOfTruthVersionFlagIndex + 1];\n if (value === undefined || value.startsWith(\"--\")) {\n throw new Error(\n \"--source-of-truth-version requires a value, e.g. --source-of-truth-version 0.53.0\",\n );\n }\n sourceOfTruthVersion = value;\n args.splice(sourceOfTruthVersionFlagIndex, 2);\n}\n\nconst cwd = process.cwd();\nconst { engineConfig, webServers } = resolveConfig(cwd, {\n mantineAdapterVersion: sourceOfTruthVersion,\n});\n\nif (args.includes(\"--update-golden\")) {\n engineConfig.goldenMode = \"update-golden\";\n} else if (args.includes(\"--approve-divergence\")) {\n engineConfig.goldenMode = \"approve-divergence\";\n}\n\nif (args.includes(\"--divergence-only\")) {\n if (engineConfig.isSourceOfTruthAdapter) {\n throw new Error(\n \"--divergence-only has nothing to diverge from — isSourceOfTruthAdapter is true in this project's adapter-tester.config.json.\",\n );\n }\n engineConfig.checkMode = \"divergence\";\n} else if (engineConfig.goldenMode === \"approve-divergence\") {\n throw new Error(\n \"--approve-divergence only makes sense with --divergence-only — there's nothing to approve without the divergence check running.\",\n );\n}\n\nif (args.includes(\"--dry-run\")) {\n console.log(JSON.stringify({ engineConfig, webServers }, null, 2));\n process.exit(0);\n}\n\n// Any arg besides our own flags is passed straight through to `playwright\n// test` — e.g. `npm run adapter-tester:automated -- --grep \"Toast\"` to scope\n// a run to matching stories, instead of every invocation running the full\n// suite. Our own flags are consumed above, not forwarded — Playwright itself\n// doesn't know about them.\nconst OWN_FLAGS = new Set([\n \"--dry-run\",\n \"--serve\",\n \"--update-golden\",\n \"--approve-divergence\",\n \"--divergence-only\",\n]);\nconst passthroughArgs = args.filter((arg) => !OWN_FLAGS.has(arg));\n\n// The bundled build target doesn't support top-level await, so the async\n// work (launching Storybook and detecting its real port) lives in main().\nmain().catch((err) => {\n console.error(err);\n process.exitCode = 1;\n});\n\nasync function main(): Promise<void> {\n if (args.includes(\"--serve\")) {\n if (engineConfig.isSourceOfTruthAdapter) {\n throw new Error(\n \"Dev Mode (--serve) has nothing to sync this project's Storybook against — isSourceOfTruthAdapter is true in this project's adapter-tester.config.json.\",\n );\n }\n // Dual-Storybook interactive Dev Mode — no Playwright, no screenshots.\n // Used by the `adapter-tester` npm script.\n await startDevServer(engineConfig, webServers);\n } else {\n // The golden-image checks never need the source-of-truth adapter's own\n // Storybook running — the divergence check reads its stored golden files,\n // not a live page — so only the last (own) webServer is booted here. Dev\n // Mode above is the one thing that still needs both.\n const ownWebServer = webServers.at(-1);\n if (!ownWebServer) {\n throw new Error(\"resolveConfig() returned no webServers to boot.\");\n }\n await runAutomated(ownWebServer, engineConfig);\n }\n}\n\n/**\n * Boots this project's own Storybook (auto-detecting the port it actually\n * lands on — see portDiscovery.ts), generates a throwaway Playwright config\n * + spec under `.adapter-tester/run/`, and runs the automated pixel-diff\n * suite against it. Used by the `adapter-tester:automated` npm script.\n *\n * Playwright's own `webServer` option can't be used here — it only knows how\n * to poll a port/URL decided *before* the command it spawns runs, but\n * Storybook silently falls back to a different, OS-assigned port whenever\n * its configured one is taken. So this boots and waits for Storybook itself,\n * then points the generated config straight at whatever URL it actually\n * reports.\n */\nasync function runAutomated(\n server: HarnessWebServerConfig,\n config: AdapterTesterConfig,\n): Promise<void> {\n const runDir = join(cwd, \".adapter-tester/run\");\n mkdirSync(runDir, { recursive: true });\n\n const ownTarget = config.targets.at(-1);\n if (!ownTarget) {\n throw new Error(\"resolveConfig() returned no targets to check.\");\n }\n const { url, process: spawned } = await launchAndDetectStorybook(\n toLaunchTarget(ownTarget.name, server),\n );\n ownTarget.url = url;\n\n writeFileSync(\n join(runDir, \"playwright.config.js\"),\n `// Generated by \\`adapter-tester\\` — do not edit, regenerated on every run.\nimport { defineConfig, devices } from \"@playwright/test\";\n\nexport default defineConfig({\n testDir: ${JSON.stringify(runDir)},\n // 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 // No webServer entry — this project's own Storybook is already running by\n // the time this config is used (see runAutomated() in cli.ts).\n});\n`,\n );\n\n writeFileSync(\n join(runDir, \"visual-regression.spec.js\"),\n `// Generated by \\`adapter-tester\\` — do not edit, regenerated on every run.\nimport { test, expect } from \"@playwright/test\";\nimport { resolveVisualRegressionPlan } from ${JSON.stringify(testingEntry)};\n\n// \\`test.describe\\`/\\`test\\` are called here, not inside resolveVisualRegressionPlan,\n// so Playwright's HTML report groups the suite under this file instead of a\n// sourcemapped path into adapter-tester's own library code.\nconst { ownTargetName, suiteLabel, stories, missingFromSourceOfTruth, checkStory } =\n await resolveVisualRegressionPlan(${JSON.stringify(config, null, 2)});\n\ntest.describe(\\`\\${ownTargetName} — \\${suiteLabel}\\`, () => {\n if (missingFromSourceOfTruth.length > 0) {\n test(\"story parity with source of truth\", () => {\n expect(\n missingFromSourceOfTruth,\n \\`\\${missingFromSourceOfTruth.length} stor(y/ies) exist in the source of truth but are missing here. Add the missing story, or mark it \\\\\\`exclude: true\\\\\\` under \\\\\\`stories\\\\\\` in adapter-tester.config.json if intentional.\\`,\n ).toEqual([]);\n });\n }\n for (const story of stories) {\n test(story.id, async ({ browser }, testInfo) => {\n await checkStory(story, browser, testInfo);\n });\n }\n});\n`,\n );\n\n try {\n const result = spawnSync(\n \"npx\",\n [\n \"playwright\",\n \"test\",\n \"--config\",\n join(runDir, \"playwright.config.js\"),\n ...passthroughArgs,\n ],\n { stdio: \"inherit\", cwd, shell: process.platform === \"win32\" },\n );\n process.exitCode = result.status ?? 1;\n } finally {\n // Only tear down the Storybook we spawned — an instance we reused via\n // the last-known-port cache was already running before we got here, and\n // should stay running after.\n spawned?.kill(\"SIGTERM\");\n }\n}\n"],"names":["ANSI_PATTERN","LOCAL_URL_PATTERN","isPortActive","port","resolve","socket","net","readCachedPort","cacheFile","readFileSync","writeCachedPort","mkdirSync","dirname","writeFileSync","spawnAndDetect","target","timeoutMs","reject","child","spawn","settled","timer","handleOutput","data","isError","text","line","label","match","url","_a","_b","err","code","toLaunchTarget","name","server","launchAndDetectStorybook","cachedPort","distDir","fileURLToPath","_documentCurrentScript","openBrowser","startCmd","startDevServer","engineConfig","webServers","options","sourceOfTruth","sourceOfTruthServer","targetServer","devPort","sourceOfTruthRunning","targetRunning","spawned","app","express","publicDir","join","headerPath","req","res","next","html","createProxyMiddleware","cleaningUp","cleanup","addFormats","ajvFormatsModule.default","ajv","Ajv","validate","schema","validateFileConfig","path","errors","error","extra","MANTINE_ADAPTER_PACKAGE_NAME","CONFIG_FILE_NAME","DEFAULT_STORYBOOK_COMMAND","DEFAULT_STORYBOOK_PORT","DEFAULT_SOURCE_OF_TRUTH_PORT","DEFAULT_SOURCE_OF_TRUTH_NAME","DEFAULT_GOLDEN_THRESHOLD_PIXELS","DEFAULT_SOURCE_OF_TRUTH_THRESHOLD_PIXELS","readOwnPackageJson","cwd","existsSync","detectOwnPort","storybookScript","detectOwnName","loadFileConfig","resolveConfig","overrides","file","isSourceOfTruthAdapter","ownName","ownPort","ownCommand","ownCwd","_c","ownWebServer","sharedEngineConfig","sourceOfTruthName","sourceOfTruthPort","sourceOfTruthWebServer","sourceOfTruthGolden","sourceOfTruthCwd","mantineAdapterVersion","mantineSourceOfTruthWebServer","testingEntry","pathToFileURL","args","sourceOfTruthVersion","sourceOfTruthVersionFlagIndex","value","OWN_FLAGS","passthroughArgs","arg","main","runAutomated","config","runDir","ownTarget","result","spawnSync"],"mappings":";4UA2CA,MAAMA,EAAe,kBACfC,EAAoB,sCAE1B,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,CAC3BA,EAAO,QAAA,EACPD,EAAQ,EAAK,CACf,CAAC,EACDC,EAAO,KAAK,QAAS,IAAM,CACzBA,EAAO,QAAA,EACPD,EAAQ,EAAK,CACf,CAAC,EACDC,EAAO,QAAQF,EAAM,WAAW,CAClC,CAAC,CACH,CAEA,SAASI,EAAeC,EAAuC,CAC7D,GAAI,CACF,MAAML,EAAO,KAAK,MAAMM,EAAAA,aAAaD,EAAW,MA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,CACf,MAAMC,EAASjE,EAAAA,KAAK6B,EAAK,qBAAqB,EAC9C5E,EAAAA,UAAUgH,EAAQ,CAAE,UAAW,EAAA,CAAM,EAErC,MAAMC,EAAYF,EAAO,QAAQ,GAAG,EAAE,EACtC,GAAI,CAACE,EACH,MAAM,IAAI,MAAM,+CAA+C,EAEjE,KAAM,CAAE,IAAA/F,EAAK,QAASyB,CAAA,EAAY,MAAMjB,EACtCH,EAAe0F,EAAU,KAAMxF,CAAM,CAAA,EAEvCwF,EAAU,IAAM/F,EAEhBhB,EAAAA,cACE6C,EAAAA,KAAKiE,EAAQ,sBAAsB,EACnC;AAAA;AAAA;AAAA;AAAA,aAIS,KAAK,UAAUA,CAAM,CAAC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,CAAA,EAiBjC9G,EAAAA,cACE6C,EAAAA,KAAKiE,EAAQ,2BAA2B,EACxC;AAAA;AAAA,8CAE0C,KAAK,UAAUZ,EAAY,CAAC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,sCAMpC,KAAK,UAAUW,EAAQ,KAAM,CAAC,CAAC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,CAAA,EAoBnE,GAAI,CACF,MAAMG,EAASC,EAAAA,UACb,MACA,CACE,aACA,OACA,WACApE,EAAAA,KAAKiE,EAAQ,sBAAsB,EACnC,GAAGL,EAAA,EAEL,CAAE,MAAO,UAAW,IAAA/B,EAAK,MAAO,QAAQ,WAAa,OAAA,CAAQ,EAE/D,QAAQ,SAAWsC,EAAO,QAAU,CACtC,QAAA,CAIEvE,GAAA,MAAAA,EAAS,KAAK,UAChB,CACF"}
1
+ {"version":3,"file":"cli.cjs","sources":["../src/portDiscovery.ts","../src/devServer.ts","../src/validateFileConfig.ts","../src/fileConfig.ts","../src/cli.ts"],"sourcesContent":["import { spawn, type ChildProcess } from \"node:child_process\";\nimport { mkdirSync, readFileSync, writeFileSync } from \"node:fs\";\nimport { dirname } from \"node:path\";\nimport net from \"node:net\";\nimport type { HarnessWebServerConfig } from \"./harness/mantineSourceOfTruth.js\";\n\n/**\n * Boots a target's Storybook and discovers the real port it ends up on,\n * instead of pinning one via `-p`/`--port`. Storybook silently falls back to\n * an OS-assigned port whenever its default/configured one is taken (this is\n * what caused the flaky `webServer` timeouts noted in mui-adapter), so the\n * only reliable source of truth is the URL it prints in its own startup\n * banner. Used by both the automated/headless run (cli.ts) and Dev Mode\n * (devServer.ts) — neither pins a port anymore.\n */\n\nexport interface LaunchTarget {\n /** Human-readable name used in log lines. */\n name: string;\n command: string;\n cwd: string;\n /** Reuse an already-running instance (detected via the last-known-port\n * cache) instead of spawning a new one. Mirrors the old `reuseExistingServer`\n * behavior, which used to just probe the one fixed configured port. */\n reuseExistingServer: boolean;\n /** File the discovered port is cached in between runs, so a later\n * `reuseExistingServer` run knows where to look. One per target. */\n cacheFile: string;\n timeoutMs?: number;\n}\n\nexport interface DiscoveredServer {\n url: string;\n port: number;\n /** The process we spawned, or `null` if an already-running instance was\n * reused — callers should only kill what they started. */\n process: ChildProcess | null;\n}\n\n// Storybook prints its bound address in its startup banner wrapped in ANSI\n// color codes and box-drawing chars, e.g.:\n// │ │ - Local: http://localhost:57496/ │ │\n// Strip ANSI first, then match the URL itself.\nconst ANSI_PATTERN = /\\x1b\\[[0-9;]*m/g;\nconst LOCAL_URL_PATTERN = /Local:\\s*(https?:\\/\\/localhost:\\d+)/;\n\nfunction isPortActive(port: number): Promise<boolean> {\n return new Promise((resolve) => {\n const socket = new net.Socket();\n socket.setTimeout(200);\n socket.once(\"connect\", () => {\n socket.destroy();\n resolve(true);\n });\n socket.once(\"timeout\", () => {\n socket.destroy();\n resolve(false);\n });\n socket.once(\"error\", () => {\n socket.destroy();\n resolve(false);\n });\n socket.connect(port, \"127.0.0.1\");\n });\n}\n\nfunction readCachedPort(cacheFile: string): number | undefined {\n try {\n const port = JSON.parse(readFileSync(cacheFile, \"utf8\")).port;\n return typeof port === \"number\" ? port : undefined;\n } catch {\n return undefined;\n }\n}\n\nfunction writeCachedPort(cacheFile: string, port: number): void {\n mkdirSync(dirname(cacheFile), { recursive: true });\n writeFileSync(cacheFile, JSON.stringify({ port }));\n}\n\n/** Spawns `target.command`, streaming its output to the console like before,\n * and resolves once it reports the URL it actually bound to. */\nfunction spawnAndDetect(\n target: LaunchTarget,\n timeoutMs: number,\n): Promise<DiscoveredServer> {\n return new Promise((resolve, reject) => {\n const child = spawn(target.command, {\n cwd: target.cwd,\n stdio: \"pipe\",\n shell: true,\n });\n\n let settled = false;\n const timer = setTimeout(() => {\n if (settled) return;\n settled = true;\n child.kill();\n reject(\n new Error(\n `Timed out after ${timeoutMs}ms waiting for ${target.name}'s Storybook to report its URL (no \"Local: http://localhost:<port>\" line seen in its output).`,\n ),\n );\n }, timeoutMs);\n\n const handleOutput = (data: Buffer, isError: boolean) => {\n const text = data.toString();\n for (const line of text.split(\"\\n\")) {\n if (line.trim()) {\n const label = isError\n ? `${target.name} SB ERROR`\n : `${target.name} SB`;\n (isError ? console.error : console.log)(`[${label}] ${line.trim()}`);\n }\n }\n if (settled) return;\n const match = text.replace(ANSI_PATTERN, \"\").match(LOCAL_URL_PATTERN);\n if (match) {\n settled = true;\n clearTimeout(timer);\n // Non-null: LOCAL_URL_PATTERN has exactly one capture group, and a\n // match only happens when it participated.\n const url = match[1]!;\n const port = Number(new URL(url).port);\n writeCachedPort(target.cacheFile, port);\n resolve({ url, port, process: child });\n }\n };\n child.stdout?.on(\"data\", (data: Buffer) => handleOutput(data, false));\n child.stderr?.on(\"data\", (data: Buffer) => handleOutput(data, true));\n child.on(\"error\", (err) => {\n if (settled) return;\n settled = true;\n clearTimeout(timer);\n reject(err);\n });\n child.on(\"exit\", (code) => {\n if (settled) return;\n settled = true;\n clearTimeout(timer);\n reject(\n new Error(\n `${target.name}'s Storybook exited (code ${code}) before reporting its URL.`,\n ),\n );\n });\n });\n}\n\n/** Adapts a resolved `HarnessWebServerConfig` into a `LaunchTarget`. */\nexport function toLaunchTarget(\n name: string,\n server: HarnessWebServerConfig,\n): LaunchTarget {\n return {\n name,\n command: server.command,\n cwd: server.cwd,\n reuseExistingServer: server.reuseExistingServer,\n cacheFile: server.cacheFile,\n timeoutMs: server.timeout,\n };\n}\n\n/** Reuses an already-running Storybook if `reuseExistingServer` is set and\n * the last-known-port cache points at something still listening; otherwise\n * spawns `target.command` fresh and detects the real port from its output. */\nexport async function launchAndDetectStorybook(\n target: LaunchTarget,\n): Promise<DiscoveredServer> {\n if (target.reuseExistingServer) {\n const cachedPort = readCachedPort(target.cacheFile);\n if (cachedPort !== undefined && (await isPortActive(cachedPort))) {\n console.log(\n `[Dev Launcher] ${target.name} is already running on port ${cachedPort} (reused).`,\n );\n return {\n url: `http://localhost:${cachedPort}`,\n port: cachedPort,\n process: null,\n };\n }\n }\n console.log(`[Dev Launcher] Launching Storybook for ${target.name}...`);\n return spawnAndDetect(target, target.timeoutMs ?? 120 * 1000);\n}\n","import { spawn, type ChildProcess } from \"node:child_process\";\nimport { readFileSync } from \"node:fs\";\nimport { dirname, join } from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\nimport express from \"express\";\nimport { createProxyMiddleware } from \"http-proxy-middleware\";\nimport type { AdapterTesterConfig } from \"./config.js\";\nimport type { HarnessWebServerConfig } from \"./harness/mantineSourceOfTruth.js\";\nimport { launchAndDetectStorybook, toLaunchTarget } from \"./portDiscovery.js\";\n\n/**\n * Interactive Dev Mode: a synced, side-by-side browser view of this\n * project's own Storybook and the source of truth, with per-story note\n * taking and an AI-report export. Boots both Storybooks (reusing them if\n * already running) behind a proxy so the own/target pane — which drives\n * the sync and carries Storybook's nav sidebar — loads same-origin on the\n * left, with the source of truth following along as a bare preview on the\n * right.\n *\n * Config-driven — takes the same `{ engineConfig, webServers }` shape\n * `resolveConfig()` produces, in the same [sourceOfTruth, target] order.\n */\n\nconst distDir = dirname(fileURLToPath(import.meta.url));\n\nfunction openBrowser(url: string): void {\n const startCmd =\n process.platform === \"darwin\"\n ? \"open\"\n : process.platform === \"win32\"\n ? \"start\"\n : \"xdg-open\";\n console.log(`[Dev Launcher] Auto-launching browser: ${url}`);\n spawn(startCmd, [url], { shell: process.platform === \"win32\" }).on(\n \"error\",\n (err) => {\n console.error(`[Dev Launcher] Failed to auto-launch browser:`, err);\n },\n );\n}\n\nexport interface DevServerOptions {\n /** Port the dev-mode proxy UI itself listens on. Defaults to 6010. */\n port?: number;\n}\n\nexport async function startDevServer(\n engineConfig: AdapterTesterConfig,\n webServers: HarnessWebServerConfig[],\n options: DevServerOptions = {},\n): Promise<void> {\n const [sourceOfTruth, target] = engineConfig.targets;\n const [sourceOfTruthServer, targetServer] = webServers;\n if (\n !sourceOfTruth?.sourceOfTruth ||\n !target ||\n target.sourceOfTruth ||\n !sourceOfTruthServer ||\n !targetServer\n ) {\n throw new Error(\n \"adapter-tester dev mode requires exactly two targets: [sourceOfTruth, target] — check adapter-tester.config.json.\",\n );\n }\n\n const devPort = options.port ?? 6010;\n\n // Neither Storybook is pinned to a specific port — each one silently\n // falls back to an OS-assigned port whenever its default/configured one is\n // taken, so the real port is only known once it reports it (see\n // portDiscovery.ts). Booted concurrently since neither depends on the other.\n console.log(\n `[Dev Launcher] Resolving ${sourceOfTruth.name} and ${target.name} Storybooks...`,\n );\n const [sourceOfTruthRunning, targetRunning] = await Promise.all([\n launchAndDetectStorybook(\n toLaunchTarget(sourceOfTruth.name, sourceOfTruthServer),\n ),\n launchAndDetectStorybook(toLaunchTarget(target.name, targetServer)),\n ]);\n console.log(`[Dev Launcher] Both Storybooks are active and responsive!`);\n\n const spawned = [sourceOfTruthRunning.process, targetRunning.process].filter(\n (child): child is ChildProcess => child !== null,\n );\n\n const app = express();\n const publicDir = join(distDir, \"../public\");\n const headerPath = join(distDir, \"../report-header.txt\");\n\n // Serve the Dev Mode UI at the root path ONLY if there is no query string.\n // This allows the iframe (which loads with ?path=/story/...) to pass\n // through to the proxy, avoiding an infinite loop of nested wrappers.\n app.get(\"/\", (req, res, next) => {\n if (req.query.path) {\n next();\n return;\n }\n const html = readFileSync(join(publicDir, \"index.html\"), \"utf8\").replace(\n \"<head>\",\n `<head>\\n <script>window.__ADAPTER_TESTER__ = ${JSON.stringify({\n ownName: target.name,\n sourceOfTruthName: sourceOfTruth.name,\n sourceOfTruthPort: sourceOfTruthRunning.port,\n })};</script>`,\n );\n res.send(html);\n });\n\n // Serve the AI prompt header dynamically so it can be edited externally.\n // `reportHeader` in adapter-tester.config.json overrides the file entirely.\n app.get(\"/report-header.txt\", (req, res) => {\n if (engineConfig.reportHeader !== undefined) {\n res.type(\"text/plain\").send(engineConfig.reportHeader);\n return;\n }\n try {\n res.type(\"text/plain\").send(readFileSync(headerPath, \"utf8\"));\n } catch {\n res.status(500).send(\"Error loading report-header.txt\");\n }\n });\n\n // Proxy everything else to this project's own Storybook, preserving\n // absolute paths (e.g. /@vite/client) so HMR keeps working same-origin.\n // This is the pane that drives the sync and shows Storybook's nav sidebar.\n app.use(\n \"/\",\n createProxyMiddleware({\n target: targetRunning.url,\n changeOrigin: true,\n ws: true,\n }),\n );\n\n let cleaningUp = false;\n const cleanup = () => {\n if (cleaningUp) return;\n cleaningUp = true;\n console.log(\n \"\\n[Dev Launcher] Shutting down Dev Mode server and spawned Storybooks...\",\n );\n for (const child of spawned) child.kill(\"SIGINT\");\n process.exit(0);\n };\n process.on(\"SIGINT\", cleanup);\n process.on(\"SIGTERM\", cleanup);\n\n app.listen(devPort, () => {\n console.log(`\n====================================================\n🚀 Adapter Dev Mode proxy running at:\n http://localhost:${devPort}\n====================================================\n`);\n openBrowser(`http://localhost:${devPort}`);\n });\n}\n","import { Ajv } from \"ajv\";\nimport * as ajvFormatsModule from \"ajv-formats\";\nimport type { FormatsPlugin } from \"ajv-formats\";\nimport schema from \"./adapter-tester.schema.json\" with { type: \"json\" };\n\n// ajv-formats ships an ESM-style `export default` on a CJS build with no\n// `\"type\"` field, which under `moduleResolution: NodeNext` TS resolves to\n// the raw module namespace instead of unwrapping the default — a known\n// ajv-formats/TS interop gap, not a version mismatch.\nconst addFormats = (ajvFormatsModule as unknown as { default: FormatsPlugin })\n .default;\n\nconst ajv = new Ajv({ allErrors: true, strict: true });\naddFormats(ajv);\nconst validate = ajv.compile(schema);\n\n/**\n * Validates a parsed `adapter-tester.config.json` against\n * `adapter-tester.schema.json`. Throws with every violation listed — callers\n * must not silently coerce or drop invalid fields.\n */\nexport function validateFileConfig(data: unknown, path: string): void {\n if (validate(data)) return;\n\n const errors = (validate.errors ?? [])\n .map((error) => {\n const extra = error.params?.additionalProperty\n ? ` '${error.params.additionalProperty}'`\n : \"\";\n return ` - ${error.instancePath || \"root\"} ${error.message}${extra}`;\n })\n .join(\"\\n\");\n throw new Error(`Invalid ${path}:\\n${errors}`);\n}\n","import { existsSync, readFileSync } from \"node:fs\";\nimport { join, resolve } from \"node:path\";\nimport type {\n AdapterTesterConfig,\n SourceOfTruthGoldenLocation,\n StoryOverride,\n} from \"./config.js\";\nimport type { HarnessWebServerConfig } from \"./harness/mantineSourceOfTruth.js\";\nimport { mantineSourceOfTruthWebServer } from \"./harness/mantineSourceOfTruth.js\";\nimport { validateFileConfig } from \"./validateFileConfig.js\";\n\nconst MANTINE_ADAPTER_PACKAGE_NAME = \"@recursica/mantine-adapter\";\n\nexport const CONFIG_FILE_NAME = \"adapter-tester.config.json\";\nconst DEFAULT_STORYBOOK_COMMAND = \"npm run storybook\";\nconst DEFAULT_STORYBOOK_PORT = 6006;\nconst DEFAULT_SOURCE_OF_TRUTH_PORT = 6011;\nconst DEFAULT_SOURCE_OF_TRUTH_NAME = \"Mantine\";\nconst DEFAULT_GOLDEN_THRESHOLD_PIXELS = 10;\nconst DEFAULT_SOURCE_OF_TRUTH_THRESHOLD_PIXELS = 3500;\n\ninterface StorybookTargetFileConfig {\n /** First-guess port only, not authoritative — the real port is\n * auto-detected from this Storybook's own startup output, since Storybook\n * silently falls back to an OS-assigned port whenever this one is taken.\n * Auto-detected from this project's own `scripts.storybook` (a `-p\n * <port>`/`--port <port>` flag) when omitted, falling back to 6006. */\n port?: number;\n /** Command that boots the target's Storybook. Defaults to `npm run storybook`. */\n command?: string;\n /** Directory the command runs in, relative to the config file. Defaults to \".\" */\n cwd?: string;\n}\n\ninterface MantineHarnessSourceOfTruthFileConfig {\n /** Default mode: boots a throwaway harness that installs the published\n * `@recursica/mantine-adapter` from npm — no monorepo checkout required. */\n type?: \"mantine-harness\";\n /** First-guess port only, not authoritative — see `HarnessWebServerConfig.port`. */\n port?: number;\n mantineAdapterVersion?: string;\n storybookTemplateVersion?: string;\n}\n\ninterface UrlSourceOfTruthFileConfig {\n /** Non-standard mode: points at an already-addressable Storybook — e.g. a\n * sibling workspace package's own Storybook inside this monorepo. */\n type: \"url\";\n name?: string;\n /** First-guess port only, not authoritative — see `HarnessWebServerConfig.port`.\n * Defaults to 6011. */\n port?: number;\n command?: string;\n cwd?: string;\n}\n\ntype SourceOfTruthFileConfig =\n | MantineHarnessSourceOfTruthFileConfig\n | UrlSourceOfTruthFileConfig;\n\nexport interface AdapterTesterFileConfig {\n /** Label for this project's own target. Defaults to the unscoped name in\n * this project's package.json (e.g. \"@recursica/mui-adapter\" -> \"mui-adapter\"). */\n name?: string;\n storybook?: StorybookTargetFileConfig;\n sourceOfTruth?: SourceOfTruthFileConfig;\n goldenThresholdPixels?: number;\n sourceOfTruthThresholdPixels?: number;\n stories?: Record<string, StoryOverride>;\n excludeTitlePrefixes?: string[];\n /** Overrides the AI report header text shown in Dev Mode's \"Full Report\"\n * export. Defaults to the contents of `report-header.txt`. */\n reportHeader?: string;\n /**\n * True only for the source-of-truth adapter's own config (mantine-adapter).\n * Skips `sourceOfTruth` entirely — there's nothing above it to diverge\n * from — and runs the own-drift golden check standalone, against just this\n * project's own Storybook. Defaults to false.\n */\n isSourceOfTruthAdapter?: boolean;\n}\n\nexport interface ResolvedAdapterTesterConfig {\n engineConfig: AdapterTesterConfig;\n webServers: HarnessWebServerConfig[];\n}\n\nexport interface ResolveConfigOverrides {\n /** From `--source-of-truth-version`. Overrides `sourceOfTruth.mantineAdapterVersion`. */\n mantineAdapterVersion?: string;\n}\n\nfunction readOwnPackageJson(cwd: string): any {\n const path = join(cwd, \"package.json\");\n if (!existsSync(path)) {\n throw new Error(\n `No package.json found in ${cwd} — run adapter-tester from the root of the project being tested.`,\n );\n }\n return JSON.parse(readFileSync(path, \"utf8\"));\n}\n\nfunction detectOwnPort(cwd: string): number {\n const pkg = readOwnPackageJson(cwd);\n const storybookScript = pkg.scripts?.storybook as string | undefined;\n const match = storybookScript?.match(/(?:-p|--port)[ =](\\d+)/);\n return match ? Number(match[1]) : DEFAULT_STORYBOOK_PORT;\n}\n\nfunction detectOwnName(cwd: string): string {\n const pkg = readOwnPackageJson(cwd);\n const name = pkg.name as string | undefined;\n return name ? name.split(\"/\").pop()! : \"Adapter\";\n}\n\nfunction loadFileConfig(cwd: string): AdapterTesterFileConfig {\n const path = join(cwd, CONFIG_FILE_NAME);\n if (!existsSync(path)) {\n return {};\n }\n const data = JSON.parse(readFileSync(path, \"utf8\"));\n validateFileConfig(data, path);\n return data;\n}\n\n/**\n * Loads `adapter-tester.config.json` from `cwd` (or falls back to defaults\n * when the file doesn't exist) and resolves it into the engine config\n * `resolveVisualRegressionPlan` consumes plus the Playwright `webServer` entries\n * needed to boot both sides of the comparison.\n *\n * Default mode (no `sourceOfTruth`/`storybook` set): compares this project's\n * own Storybook against a throwaway Mantine harness — no monorepo checkout\n * required. Set `sourceOfTruth.type: \"url\"` for the non-standard mode used\n * to compare sibling workspace packages inside this monorepo.\n *\n * `overrides.mantineAdapterVersion` (from `--source-of-truth-version`) pins\n * the mantine-harness install/golden-fetch version for this run, overriding\n * `sourceOfTruth.mantineAdapterVersion`. Throws if passed together with\n * `isSourceOfTruthAdapter` or `sourceOfTruth.type: \"url\"` — neither has a\n * version to pin.\n */\nexport function resolveConfig(\n cwd: string,\n overrides: ResolveConfigOverrides = {},\n): ResolvedAdapterTesterConfig {\n const file = loadFileConfig(cwd);\n const isSourceOfTruthAdapter = file.isSourceOfTruthAdapter ?? false;\n\n if (overrides.mantineAdapterVersion && isSourceOfTruthAdapter) {\n throw new Error(\n \"--source-of-truth-version has no effect on the source-of-truth adapter's own config (isSourceOfTruthAdapter: true) — there's nothing to pin a version for.\",\n );\n }\n\n const ownName = file.name ?? detectOwnName(cwd);\n const ownPort = file.storybook?.port ?? detectOwnPort(cwd);\n const ownCommand = file.storybook?.command ?? DEFAULT_STORYBOOK_COMMAND;\n const ownCwd = resolve(cwd, file.storybook?.cwd ?? \".\");\n const ownWebServer: HarnessWebServerConfig = {\n command: ownCommand,\n port: ownPort,\n cwd: ownCwd,\n reuseExistingServer: !process.env.CI,\n cacheFile: join(cwd, \".adapter-tester\", \"last-port-own.json\"),\n timeout: 120 * 1000,\n };\n\n const sharedEngineConfig = {\n goldenThresholdPixels:\n file.goldenThresholdPixels ?? DEFAULT_GOLDEN_THRESHOLD_PIXELS,\n sourceOfTruthThresholdPixels:\n file.sourceOfTruthThresholdPixels ??\n DEFAULT_SOURCE_OF_TRUTH_THRESHOLD_PIXELS,\n stories: file.stories,\n excludeTitlePrefixes: file.excludeTitlePrefixes,\n reportHeader: file.reportHeader,\n // Keyed off `ownCwd`, not `cwd` — the project actually being tested, not\n // wherever the config file happens to live. Matters whenever\n // `storybook.cwd` points at a sibling package: its goldens must resolve\n // to that package's own `test/golden/` (the same directory used when\n // that package runs adapter-tester directly), not a directory under\n // wherever this config file lives.\n goldenDir: join(ownCwd, \"test\", \"golden\"),\n isSourceOfTruthAdapter,\n // Overwritten by the CLI from --update-golden/--approve-divergence.\n goldenMode: \"check\" as const,\n // Overwritten by the CLI from --divergence-only.\n checkMode: \"own\" as const,\n };\n\n // The source-of-truth adapter's own config has nothing above it to\n // diverge from — no second target, no harness/webServer for it at all.\n if (isSourceOfTruthAdapter) {\n return {\n engineConfig: {\n ...sharedEngineConfig,\n targets: [{ name: ownName, url: `http://localhost:${ownPort}` }],\n },\n webServers: [ownWebServer],\n };\n }\n\n const sourceOfTruth = file.sourceOfTruth ?? {\n type: \"mantine-harness\" as const,\n };\n\n let sourceOfTruthName: string;\n let sourceOfTruthPort: number;\n let sourceOfTruthWebServer: HarnessWebServerConfig;\n let sourceOfTruthGolden: SourceOfTruthGoldenLocation;\n\n if (sourceOfTruth.type === \"url\") {\n if (overrides.mantineAdapterVersion) {\n throw new Error(\n '--source-of-truth-version has no effect with sourceOfTruth.type: \"url\" — that mode reads a sibling package\\'s local checkout directly, not a published version.',\n );\n }\n sourceOfTruthName = sourceOfTruth.name ?? DEFAULT_SOURCE_OF_TRUTH_NAME;\n sourceOfTruthPort = sourceOfTruth.port ?? DEFAULT_SOURCE_OF_TRUTH_PORT;\n const sourceOfTruthCwd = resolve(cwd, sourceOfTruth.cwd ?? \".\");\n sourceOfTruthWebServer = {\n command: sourceOfTruth.command ?? DEFAULT_STORYBOOK_COMMAND,\n port: sourceOfTruthPort,\n cwd: sourceOfTruthCwd,\n reuseExistingServer: !process.env.CI,\n cacheFile: join(cwd, \".adapter-tester\", \"last-port-source-of-truth.json\"),\n timeout: 120 * 1000,\n };\n // Sibling package already checked out locally — read its golden files\n // directly, including any uncommitted local changes. No install, no\n // network call.\n sourceOfTruthGolden = {\n type: \"local\",\n dir: join(sourceOfTruthCwd, \"test\", \"golden\"),\n };\n } else {\n sourceOfTruthName = DEFAULT_SOURCE_OF_TRUTH_NAME;\n sourceOfTruthPort = sourceOfTruth.port ?? DEFAULT_SOURCE_OF_TRUTH_PORT;\n const mantineAdapterVersion =\n overrides.mantineAdapterVersion ?? sourceOfTruth.mantineAdapterVersion;\n sourceOfTruthWebServer = mantineSourceOfTruthWebServer({\n dir: join(cwd, \".adapter-tester/mantine-harness\"),\n port: sourceOfTruthPort,\n mantineAdapterVersion,\n storybookTemplateVersion: sourceOfTruth.storybookTemplateVersion,\n });\n // No local checkout — resolve the installed version against the npm\n // registry and fetch that version's golden files from the public repo.\n // Never needs `sourceOfTruthWebServer` above; the golden check on its\n // own doesn't boot a second Storybook at all (see cli.ts).\n sourceOfTruthGolden = {\n type: \"npm\",\n packageName: MANTINE_ADAPTER_PACKAGE_NAME,\n versionSpec: mantineAdapterVersion ?? \"latest\",\n cacheDir: join(cwd, \".adapter-tester/mantine-golden-cache\"),\n };\n }\n\n return {\n engineConfig: {\n ...sharedEngineConfig,\n targets: [\n {\n name: sourceOfTruthName,\n url: `http://localhost:${sourceOfTruthPort}`,\n sourceOfTruth: true,\n },\n { name: ownName, url: `http://localhost:${ownPort}` },\n ],\n sourceOfTruthGolden,\n },\n // [sourceOfTruth, own] — Dev Mode needs both; the automated golden run\n // (cli.ts) only ever boots the last entry, since its divergence check\n // reads stored golden files, not a live source-of-truth page.\n webServers: [sourceOfTruthWebServer, ownWebServer],\n };\n}\n","import { spawnSync } from \"node:child_process\";\nimport { mkdirSync, writeFileSync } from \"node:fs\";\nimport { dirname, join } from \"node:path\";\nimport { fileURLToPath, pathToFileURL } from \"node:url\";\nimport type { AdapterTesterConfig } from \"./config.js\";\nimport { startDevServer } from \"./devServer.js\";\nimport { resolveConfig } from \"./fileConfig.js\";\nimport type { HarnessWebServerConfig } from \"./harness/mantineSourceOfTruth.js\";\nimport { launchAndDetectStorybook, toLaunchTarget } from \"./portDiscovery.js\";\n\n// `dist/testing.js` is always a sibling of this file — both inside a\n// consumer's node_modules/@recursica/adapter-tester/dist and inside this\n// monorepo's own packages/adapter-tester/dist when self-hosting — so the\n// generated spec below can reach it without depending on how the package\n// itself resolves at import time.\nconst distDir = dirname(fileURLToPath(import.meta.url));\nconst testingEntry = pathToFileURL(join(distDir, \"testing.js\")).href;\n\n// `--source-of-truth-version <value>` takes a value, unlike every other own\n// flag below — pulled out of argv first so the boolean flags/passthrough\n// logic never has to know it exists.\nconst args = process.argv.slice(2);\nlet sourceOfTruthVersion: string | undefined;\nconst sourceOfTruthVersionFlagIndex = args.indexOf(\"--source-of-truth-version\");\nif (sourceOfTruthVersionFlagIndex !== -1) {\n const value = args[sourceOfTruthVersionFlagIndex + 1];\n if (value === undefined || value.startsWith(\"--\")) {\n throw new Error(\n \"--source-of-truth-version requires a value, e.g. --source-of-truth-version 0.53.0\",\n );\n }\n sourceOfTruthVersion = value;\n args.splice(sourceOfTruthVersionFlagIndex, 2);\n}\n\nconst cwd = process.cwd();\nconst { engineConfig, webServers } = resolveConfig(cwd, {\n mantineAdapterVersion: sourceOfTruthVersion,\n});\n\nif (args.includes(\"--update-golden\")) {\n engineConfig.goldenMode = \"update-golden\";\n} else if (args.includes(\"--approve-divergence\")) {\n engineConfig.goldenMode = \"approve-divergence\";\n}\n\nif (args.includes(\"--divergence-only\")) {\n if (engineConfig.isSourceOfTruthAdapter) {\n throw new Error(\n \"--divergence-only has nothing to diverge from — isSourceOfTruthAdapter is true in this project's adapter-tester.config.json.\",\n );\n }\n engineConfig.checkMode = \"divergence\";\n} else if (engineConfig.goldenMode === \"approve-divergence\") {\n throw new Error(\n \"--approve-divergence only makes sense with --divergence-only — there's nothing to approve without the divergence check running.\",\n );\n}\n\nif (args.includes(\"--dry-run\")) {\n console.log(JSON.stringify({ engineConfig, webServers }, null, 2));\n process.exit(0);\n}\n\n// Any arg besides our own flags is passed straight through to `playwright\n// test` — e.g. `npm run adapter-tester:automated -- --grep \"Toast\"` to scope\n// a run to matching stories, instead of every invocation running the full\n// suite. Our own flags are consumed above, not forwarded — Playwright itself\n// doesn't know about them.\nconst OWN_FLAGS = new Set([\n \"--dry-run\",\n \"--serve\",\n \"--update-golden\",\n \"--approve-divergence\",\n \"--divergence-only\",\n]);\nconst passthroughArgs = args.filter((arg) => !OWN_FLAGS.has(arg));\n\n// The bundled build target doesn't support top-level await, so the async\n// work (launching Storybook and detecting its real port) lives in main().\nmain().catch((err) => {\n console.error(err);\n process.exitCode = 1;\n});\n\nasync function main(): Promise<void> {\n if (args.includes(\"--serve\")) {\n if (engineConfig.isSourceOfTruthAdapter) {\n throw new Error(\n \"Dev Mode (--serve) has nothing to sync this project's Storybook against — isSourceOfTruthAdapter is true in this project's adapter-tester.config.json.\",\n );\n }\n // Dual-Storybook interactive Dev Mode — no Playwright, no screenshots.\n // Used by the `adapter-tester` npm script.\n await startDevServer(engineConfig, webServers);\n } else {\n // The golden-image checks never need the source-of-truth adapter's own\n // Storybook running — the divergence check reads its stored golden files,\n // not a live page — so only the last (own) webServer is booted here. Dev\n // Mode above is the one thing that still needs both.\n const ownWebServer = webServers.at(-1);\n if (!ownWebServer) {\n throw new Error(\"resolveConfig() returned no webServers to boot.\");\n }\n await runAutomated(ownWebServer, engineConfig);\n }\n}\n\n/**\n * Boots this project's own Storybook (auto-detecting the port it actually\n * lands on — see portDiscovery.ts), generates a throwaway Playwright config\n * + spec under `.adapter-tester/run/`, and runs the automated pixel-diff\n * suite against it. Used by the `adapter-tester:automated` npm script.\n *\n * Playwright's own `webServer` option can't be used here — it only knows how\n * to poll a port/URL decided *before* the command it spawns runs, but\n * Storybook silently falls back to a different, OS-assigned port whenever\n * its configured one is taken. So this boots and waits for Storybook itself,\n * then points the generated config straight at whatever URL it actually\n * reports.\n */\nasync function runAutomated(\n server: HarnessWebServerConfig,\n config: AdapterTesterConfig,\n): Promise<void> {\n const runDir = join(cwd, \".adapter-tester/run\");\n mkdirSync(runDir, { recursive: true });\n\n const ownTarget = config.targets.at(-1);\n if (!ownTarget) {\n throw new Error(\"resolveConfig() returned no targets to check.\");\n }\n const { url, process: spawned } = await launchAndDetectStorybook(\n toLaunchTarget(ownTarget.name, server),\n );\n ownTarget.url = url;\n\n writeFileSync(\n join(runDir, \"playwright.config.js\"),\n `// Generated by \\`adapter-tester\\` — do not edit, regenerated on every run.\nimport { defineConfig, devices } from \"@playwright/test\";\n\nexport default defineConfig({\n testDir: ${JSON.stringify(runDir)},\n // Each golden check only reads/writes its own story's manifest.json entry,\n // under a lock, so concurrent workers never race each other (see\n // \\`updateManifestEntry\\`). Defaults to 1 worker (1 Chromium instance) to\n // avoid exhausting memory running the full suite; override with\n // \\`--workers <n>\\` (forwarded straight through to Playwright) to parallelize.\n workers: 1,\n fullyParallel: true,\n forbidOnly: !!process.env.CI,\n retries: process.env.CI ? 2 : 0,\n reporter: [[\"html\", { open: \"never\" }], [\"list\"]],\n use: { trace: \"on-first-retry\" },\n projects: [{ name: \"chromium\", use: { ...devices[\"Desktop Chrome\"] } }],\n // No webServer entry — this project's own Storybook is already running by\n // the time this config is used (see runAutomated() in cli.ts).\n});\n`,\n );\n\n writeFileSync(\n join(runDir, \"visual-regression.spec.js\"),\n `// Generated by \\`adapter-tester\\` — do not edit, regenerated on every run.\nimport { test, expect } from \"@playwright/test\";\nimport { resolveVisualRegressionPlan } from ${JSON.stringify(testingEntry)};\n\n// \\`test.describe\\`/\\`test\\` are called here, not inside resolveVisualRegressionPlan,\n// so Playwright's HTML report groups the suite under this file instead of a\n// sourcemapped path into adapter-tester's own library code.\nconst { ownTargetName, suiteLabel, stories, missingFromSourceOfTruth, checkStory } =\n await resolveVisualRegressionPlan(${JSON.stringify(config, null, 2)});\n\ntest.describe(\\`\\${ownTargetName} — \\${suiteLabel}\\`, () => {\n if (missingFromSourceOfTruth.length > 0) {\n test(\"story parity with source of truth\", () => {\n expect(\n missingFromSourceOfTruth,\n \\`\\${missingFromSourceOfTruth.length} stor(y/ies) exist in the source of truth but are missing here. Add the missing story, or mark it \\\\\\`exclude: true\\\\\\` under \\\\\\`stories\\\\\\` in adapter-tester.config.json if intentional.\\`,\n ).toEqual([]);\n });\n }\n for (const story of stories) {\n test(story.id, async ({ browser }, testInfo) => {\n await checkStory(story, browser, testInfo);\n });\n }\n});\n`,\n );\n\n try {\n const result = spawnSync(\n \"npx\",\n [\n \"playwright\",\n \"test\",\n \"--config\",\n join(runDir, \"playwright.config.js\"),\n ...passthroughArgs,\n ],\n { stdio: \"inherit\", cwd, shell: process.platform === \"win32\" },\n );\n process.exitCode = result.status ?? 1;\n } finally {\n // Only tear down the Storybook we spawned — an instance we reused via\n // the last-known-port cache was already running before we got here, and\n // should stay running after.\n spawned?.kill(\"SIGTERM\");\n }\n}\n"],"names":["ANSI_PATTERN","LOCAL_URL_PATTERN","isPortActive","port","resolve","socket","net","readCachedPort","cacheFile","readFileSync","writeCachedPort","mkdirSync","dirname","writeFileSync","spawnAndDetect","target","timeoutMs","reject","child","spawn","settled","timer","handleOutput","data","isError","text","line","label","match","url","_a","_b","err","code","toLaunchTarget","name","server","launchAndDetectStorybook","cachedPort","distDir","fileURLToPath","_documentCurrentScript","openBrowser","startCmd","startDevServer","engineConfig","webServers","options","sourceOfTruth","sourceOfTruthServer","targetServer","devPort","sourceOfTruthRunning","targetRunning","spawned","app","express","publicDir","join","headerPath","req","res","next","html","createProxyMiddleware","cleaningUp","cleanup","addFormats","ajvFormatsModule.default","ajv","Ajv","validate","schema","validateFileConfig","path","errors","error","extra","MANTINE_ADAPTER_PACKAGE_NAME","CONFIG_FILE_NAME","DEFAULT_STORYBOOK_COMMAND","DEFAULT_STORYBOOK_PORT","DEFAULT_SOURCE_OF_TRUTH_PORT","DEFAULT_SOURCE_OF_TRUTH_NAME","DEFAULT_GOLDEN_THRESHOLD_PIXELS","DEFAULT_SOURCE_OF_TRUTH_THRESHOLD_PIXELS","readOwnPackageJson","cwd","existsSync","detectOwnPort","storybookScript","detectOwnName","loadFileConfig","resolveConfig","overrides","file","isSourceOfTruthAdapter","ownName","ownPort","ownCommand","ownCwd","_c","ownWebServer","sharedEngineConfig","sourceOfTruthName","sourceOfTruthPort","sourceOfTruthWebServer","sourceOfTruthGolden","sourceOfTruthCwd","mantineAdapterVersion","mantineSourceOfTruthWebServer","testingEntry","pathToFileURL","args","sourceOfTruthVersion","sourceOfTruthVersionFlagIndex","value","OWN_FLAGS","passthroughArgs","arg","main","runAutomated","config","runDir","ownTarget","result","spawnSync"],"mappings":";4UA2CA,MAAMA,EAAe,kBACfC,EAAoB,sCAE1B,SAASC,EAAaC,EAAgC,CACpD,OAAO,IAAI,QAAS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AA;AAAA;AAAA;AAAA;AAAA;AAAA,sCAMpC,KAAK,UAAUW,EAAQ,KAAM,CAAC,CAAC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,CAAA,EAoBnE,GAAI,CACF,MAAMG,EAASC,EAAAA,UACb,MACA,CACE,aACA,OACA,WACApE,EAAAA,KAAKiE,EAAQ,sBAAsB,EACnC,GAAGL,EAAA,EAEL,CAAE,MAAO,UAAW,IAAA/B,EAAK,MAAO,QAAQ,WAAa,OAAA,CAAQ,EAE/D,QAAQ,SAAWsC,EAAO,QAAU,CACtC,QAAA,CAIEvE,GAAA,MAAAA,EAAS,KAAK,UAChB,CACF"}
package/dist/cli.js CHANGED
@@ -1,8 +1,8 @@
1
1
  #!/usr/bin/env node
2
- import { spawn as _, spawnSync as q } from "node:child_process";
3
- import { readFileSync as S, mkdirSync as F, writeFileSync as O, existsSync as I } from "node:fs";
4
- import { dirname as D, join as a, resolve as j } from "node:path";
5
- import { fileURLToPath as M, pathToFileURL as H } from "node:url";
2
+ import { spawn as F, spawnSync as J } from "node:child_process";
3
+ import { readFileSync as S, mkdirSync as _, writeFileSync as O, existsSync as I } from "node:fs";
4
+ import { dirname as P, join as a, resolve as j } from "node:path";
5
+ import { fileURLToPath as M, pathToFileURL as q } from "node:url";
6
6
  import W from "express";
7
7
  import { createProxyMiddleware as B } from "http-proxy-middleware";
8
8
  import K from "node:net";
@@ -30,12 +30,12 @@ function te(e) {
30
30
  }
31
31
  }
32
32
  function re(e, t) {
33
- F(D(e), { recursive: !0 }), O(e, JSON.stringify({ port: t }));
33
+ _(P(e), { recursive: !0 }), O(e, JSON.stringify({ port: t }));
34
34
  }
35
35
  function oe(e, t) {
36
36
  return new Promise((r, o) => {
37
37
  var y, w;
38
- const s = _(e.command, {
38
+ const s = F(e.command, {
39
39
  cwd: e.cwd,
40
40
  stdio: "pipe",
41
41
  shell: !0
@@ -98,10 +98,10 @@ async function A(e) {
98
98
  }
99
99
  return console.log(`[Dev Launcher] Launching Storybook for ${e.name}...`), oe(e, e.timeoutMs ?? 120 * 1e3);
100
100
  }
101
- const N = D(M(import.meta.url));
101
+ const N = P(M(import.meta.url));
102
102
  function se(e) {
103
103
  const t = process.platform === "darwin" ? "open" : process.platform === "win32" ? "start" : "xdg-open";
104
- console.log(`[Dev Launcher] Auto-launching browser: ${e}`), _(t, [e], { shell: process.platform === "win32" }).on(
104
+ console.log(`[Dev Launcher] Auto-launching browser: ${e}`), F(t, [e], { shell: process.platform === "win32" }).on(
105
105
  "error",
106
106
  (r) => {
107
107
  console.error("[Dev Launcher] Failed to auto-launch browser:", r);
@@ -133,7 +133,7 @@ async function ne(e, t, r = {}) {
133
133
  b();
134
134
  return;
135
135
  }
136
- const J = S(a(l, "index.html"), "utf8").replace(
136
+ const H = S(a(l, "index.html"), "utf8").replace(
137
137
  "<head>",
138
138
  `<head>
139
139
  <script>window.__ADAPTER_TESTER__ = ${JSON.stringify({
@@ -142,8 +142,12 @@ async function ne(e, t, r = {}) {
142
142
  sourceOfTruthPort: y.port
143
143
  })};<\/script>`
144
144
  );
145
- T.send(J);
145
+ T.send(H);
146
146
  }), u.get("/report-header.txt", (f, T) => {
147
+ if (e.reportHeader !== void 0) {
148
+ T.type("text/plain").send(e.reportHeader);
149
+ return;
150
+ }
147
151
  try {
148
152
  T.type("text/plain").send(S(v, "utf8"));
149
153
  } catch {
@@ -177,7 +181,7 @@ async function ne(e, t, r = {}) {
177
181
  `), se(`http://localhost:${h}`);
178
182
  });
179
183
  }
180
- const ie = "http://json-schema.org/draft-07/schema#", ae = "https://github.com/borderux/recursica/tree/main/packages/adapter-tester/src/adapter-tester.schema.json", ce = "adapter-tester.config.json", ue = "Configuration for @recursica/adapter-tester. All fields are optional — an adapter repo with a normal `storybook` npm script needs no config file at all.", de = "object", le = !1, pe = { $schema: { type: "string", description: 'Optional pointer to this schema for editor autocomplete, e.g. "https://raw.githubusercontent.com/borderux/recursica/main/packages/adapter-tester/src/adapter-tester.schema.json".' }, name: { type: "string", description: `Label for this project's own target. Defaults to the unscoped name in this project's package.json (e.g. "@recursica/some-adapter" -> "some-adapter").` }, storybook: { type: "object", additionalProperties: !1, description: "This project's own Storybook target.", properties: { port: { type: "integer", minimum: 1, maximum: 65535, description: "First-guess port only, not authoritative — the real port is auto-detected from this Storybook's own startup output, since Storybook silently falls back to an OS-assigned port whenever this one is taken. Auto-detected from this project's own `scripts.storybook` (a `-p <port>`/`--port <port>` flag) when omitted, falling back to 6006." }, command: { type: "string", description: "Command that boots the target's Storybook. Defaults to `npm run storybook`." }, cwd: { type: "string", description: 'Directory the command runs in, relative to the config file. Defaults to ".".' } } }, sourceOfTruth: { description: 'The comparison target. Defaults to `{ "type": "mantine-harness" }`.', oneOf: [{ type: "object", additionalProperties: !1, description: "Default mode: boots a throwaway harness that installs the published @recursica/mantine-adapter from npm — no monorepo checkout required.", properties: { type: { const: "mantine-harness" }, port: { type: "integer", minimum: 1, maximum: 65535, description: "First-guess port only, not authoritative — the real port is auto-detected from the throwaway harness's Storybook's own startup output." }, mantineAdapterVersion: { type: "string", description: "npm version/tag of @recursica/mantine-adapter to install in the harness. Defaults to `latest`." }, storybookTemplateVersion: { type: "string", description: "npm version/tag of @recursica/storybook-template to install in the harness. Defaults to `latest`." } } }, { type: "object", additionalProperties: !1, description: "Non-standard mode: points at an already-addressable Storybook — e.g. a sibling workspace package's own Storybook inside this monorepo.", required: ["type"], properties: { type: { const: "url" }, name: { type: "string", description: 'Label for the source-of-truth target. Defaults to "Mantine".' }, port: { type: "integer", minimum: 1, maximum: 65535, description: "First-guess port only, not authoritative — the real port is auto-detected from the source-of-truth Storybook's own startup output. Defaults to 6011." }, command: { type: "string", description: "Command that boots the source-of-truth Storybook. Defaults to `npm run storybook`." }, cwd: { type: "string", description: 'Directory the command runs in, relative to the config file. Defaults to ".".' } } }] }, isSourceOfTruthAdapter: { type: "boolean", description: "True only for the source-of-truth adapter's own config (mantine-adapter). Skips `sourceOfTruth` entirely — there's nothing above it to diverge from — and runs the own-drift golden check standalone, against just this project's own Storybook. Defaults to false." }, goldenThresholdPixels: { type: "number", minimum: 0, description: "Global visual diff threshold for the own-drift check (this project's live render vs. its own committed `test/golden/` image), in mismatched pixels, before a story is considered a failure. Same library/component on both sides, so this should stay tight. Defaults to 10. AI agents must not modify this field — see AGENT.md.", default: 10 }, sourceOfTruthThresholdPixels: { type: "number", minimum: 0, description: "Global visual diff threshold for the source-of-truth divergence check (this project's golden vs. the source-of-truth adapter's golden), in mismatched pixels, before a difference is flagged. Comparing across two different component libraries has legitimate structural variation (native control widgets, font rendering, etc.), so this is expected to be set much higher than `goldenThresholdPixels`. Ignored on the source-of-truth adapter's own config (`isSourceOfTruthAdapter: true`), which has no divergence check. Defaults to 3500. AI agents must not modify this field — see AGENT.md.", default: 3500 }, stories: { type: "object", additionalProperties: { type: "object", additionalProperties: !1, properties: { goldenThreshold: { type: "number", minimum: 0, description: "Diff threshold override for matching stories' own-drift check, in mismatched pixels. Overrides `goldenThresholdPixels`." }, sourceOfTruthThreshold: { type: "number", minimum: 0, description: "Diff threshold override for matching stories' source-of-truth divergence check, in mismatched pixels. Overrides `sourceOfTruthThresholdPixels`." }, exclude: { type: "boolean", description: "Skip matching stories entirely — no own-drift check, no divergence check, no golden captured. For stories that don't have a cross-adapter counterpart; use `excludeTitlePrefixes` to drop a whole title instead." } } }, description: "Per-story overrides, keyed by story id prefix (a story matches if its id equals the key or starts with it). When more than one key matches a story, the longest (most specific) key wins." }, excludeTitlePrefixes: { type: "array", items: { type: "string" }, description: "Storybook title prefixes to exclude from comparison, in addition to the built-in denylist (`Theme/*`, `Tokens/*`, `Introduction`)." } }, he = {
184
+ const ie = "http://json-schema.org/draft-07/schema#", ae = "https://github.com/borderux/recursica/tree/main/packages/adapter-tester/src/adapter-tester.schema.json", ce = "adapter-tester.config.json", ue = "Configuration for @recursica/adapter-tester. All fields are optional — an adapter repo with a normal `storybook` npm script needs no config file at all.", de = "object", le = !1, pe = { $schema: { type: "string", description: 'Optional pointer to this schema for editor autocomplete, e.g. "https://raw.githubusercontent.com/borderux/recursica/main/packages/adapter-tester/src/adapter-tester.schema.json".' }, name: { type: "string", description: `Label for this project's own target. Defaults to the unscoped name in this project's package.json (e.g. "@recursica/some-adapter" -> "some-adapter").` }, storybook: { type: "object", additionalProperties: !1, description: "This project's own Storybook target.", properties: { port: { type: "integer", minimum: 1, maximum: 65535, description: "First-guess port only, not authoritative — the real port is auto-detected from this Storybook's own startup output, since Storybook silently falls back to an OS-assigned port whenever this one is taken. Auto-detected from this project's own `scripts.storybook` (a `-p <port>`/`--port <port>` flag) when omitted, falling back to 6006." }, command: { type: "string", description: "Command that boots the target's Storybook. Defaults to `npm run storybook`." }, cwd: { type: "string", description: 'Directory the command runs in, relative to the config file. Defaults to ".".' } } }, sourceOfTruth: { description: 'The comparison target. Defaults to `{ "type": "mantine-harness" }`.', oneOf: [{ type: "object", additionalProperties: !1, description: "Default mode: boots a throwaway harness that installs the published @recursica/mantine-adapter from npm — no monorepo checkout required.", properties: { type: { const: "mantine-harness" }, port: { type: "integer", minimum: 1, maximum: 65535, description: "First-guess port only, not authoritative — the real port is auto-detected from the throwaway harness's Storybook's own startup output." }, mantineAdapterVersion: { type: "string", description: "npm version/tag of @recursica/mantine-adapter to install in the harness. Defaults to `latest`." }, storybookTemplateVersion: { type: "string", description: "npm version/tag of @recursica/storybook-template to install in the harness. Defaults to `latest`." } } }, { type: "object", additionalProperties: !1, description: "Non-standard mode: points at an already-addressable Storybook — e.g. a sibling workspace package's own Storybook inside this monorepo.", required: ["type"], properties: { type: { const: "url" }, name: { type: "string", description: 'Label for the source-of-truth target. Defaults to "Mantine".' }, port: { type: "integer", minimum: 1, maximum: 65535, description: "First-guess port only, not authoritative — the real port is auto-detected from the source-of-truth Storybook's own startup output. Defaults to 6011." }, command: { type: "string", description: "Command that boots the source-of-truth Storybook. Defaults to `npm run storybook`." }, cwd: { type: "string", description: 'Directory the command runs in, relative to the config file. Defaults to ".".' } } }] }, isSourceOfTruthAdapter: { type: "boolean", description: "True only for the source-of-truth adapter's own config (mantine-adapter). Skips `sourceOfTruth` entirely — there's nothing above it to diverge from — and runs the own-drift golden check standalone, against just this project's own Storybook. Defaults to false." }, goldenThresholdPixels: { type: "number", minimum: 0, description: "Global visual diff threshold for the own-drift check (this project's live render vs. its own committed `test/golden/` image), in mismatched pixels, before a story is considered a failure. Same library/component on both sides, so this should stay tight. Defaults to 10. AI agents must not modify this field — see AGENT.md.", default: 10 }, sourceOfTruthThresholdPixels: { type: "number", minimum: 0, description: "Global visual diff threshold for the source-of-truth divergence check (this project's golden vs. the source-of-truth adapter's golden), in mismatched pixels, before a difference is flagged. Comparing across two different component libraries has legitimate structural variation (native control widgets, font rendering, etc.), so this is expected to be set much higher than `goldenThresholdPixels`. Ignored on the source-of-truth adapter's own config (`isSourceOfTruthAdapter: true`), which has no divergence check. Defaults to 3500. AI agents must not modify this field — see AGENT.md.", default: 3500 }, stories: { type: "object", additionalProperties: { type: "object", additionalProperties: !1, properties: { goldenThreshold: { type: "number", minimum: 0, description: "Diff threshold override for matching stories' own-drift check, in mismatched pixels. Overrides `goldenThresholdPixels`." }, sourceOfTruthThreshold: { type: "number", minimum: 0, description: "Diff threshold override for matching stories' source-of-truth divergence check, in mismatched pixels. Overrides `sourceOfTruthThresholdPixels`." }, exclude: { type: "boolean", description: "Skip matching stories entirely — no own-drift check, no divergence check, no golden captured. For stories that don't have a cross-adapter counterpart; use `excludeTitlePrefixes` to drop a whole title instead." } } }, description: "Per-story overrides, keyed by story id prefix (a story matches if its id equals the key or starts with it). When more than one key matches a story, the longest (most specific) key wins." }, excludeTitlePrefixes: { type: "array", items: { type: "string" }, description: "Storybook title prefixes to exclude from comparison, in addition to the built-in denylist (`Theme/*`, `Tokens/*`, `Introduction`)." }, reportHeader: { type: "string", description: 'Overrides the AI report header text shown in Dev Mode\'s "Full Report" export. Defaults to the contents of `report-header.txt`.' } }, he = {
181
185
  $schema: ie,
182
186
  $id: ae,
183
187
  title: ce,
@@ -199,7 +203,7 @@ function me(e, t) {
199
203
  throw new Error(`Invalid ${t}:
200
204
  ${r}`);
201
205
  }
202
- const ge = "@recursica/mantine-adapter", ye = "adapter-tester.config.json", L = "npm run storybook", we = 6006, C = 6011, R = "Mantine", ve = 10, Te = 3500;
206
+ const ge = "@recursica/mantine-adapter", ye = "adapter-tester.config.json", L = "npm run storybook", we = 6006, R = 6011, C = "Mantine", ve = 10, Te = 3500;
203
207
  function G(e) {
204
208
  const t = a(e, "package.json");
205
209
  if (!I(t))
@@ -243,6 +247,7 @@ function Oe(e, t = {}) {
243
247
  sourceOfTruthThresholdPixels: r.sourceOfTruthThresholdPixels ?? Te,
244
248
  stories: r.stories,
245
249
  excludeTitlePrefixes: r.excludeTitlePrefixes,
250
+ reportHeader: r.reportHeader,
246
251
  // Keyed off `ownCwd`, not `cwd` — the project actually being tested, not
247
252
  // wherever the config file happens to live. Matters whenever
248
253
  // `storybook.cwd` points at a sibling package: its goldens must resolve
@@ -273,7 +278,7 @@ function Oe(e, t = {}) {
273
278
  throw new Error(
274
279
  `--source-of-truth-version has no effect with sourceOfTruth.type: "url" — that mode reads a sibling package's local checkout directly, not a published version.`
275
280
  );
276
- u = i.name ?? R, l = i.port ?? C;
281
+ u = i.name ?? C, l = i.port ?? R;
277
282
  const b = j(e, i.cwd ?? ".");
278
283
  v = {
279
284
  command: i.command ?? L,
@@ -287,7 +292,7 @@ function Oe(e, t = {}) {
287
292
  dir: a(b, "test", "golden")
288
293
  };
289
294
  } else {
290
- u = R, l = i.port ?? C;
295
+ u = C, l = i.port ?? R;
291
296
  const b = t.mantineAdapterVersion ?? i.mantineAdapterVersion;
292
297
  v = X({
293
298
  dir: a(e, ".adapter-tester/mantine-harness"),
@@ -320,7 +325,7 @@ function Oe(e, t = {}) {
320
325
  webServers: [v, y]
321
326
  };
322
327
  }
323
- const xe = D(M(import.meta.url)), Ae = H(a(xe, "testing.js")).href, g = process.argv.slice(2);
328
+ const xe = P(M(import.meta.url)), Ae = q(a(xe, "testing.js")).href, g = process.argv.slice(2);
324
329
  let V;
325
330
  const k = g.indexOf("--source-of-truth-version");
326
331
  if (k !== -1) {
@@ -331,7 +336,7 @@ if (k !== -1) {
331
336
  );
332
337
  V = e, g.splice(k, 2);
333
338
  }
334
- const E = process.cwd(), { engineConfig: m, webServers: P } = Oe(E, {
339
+ const E = process.cwd(), { engineConfig: m, webServers: D } = Oe(E, {
335
340
  mantineAdapterVersion: V
336
341
  });
337
342
  g.includes("--update-golden") ? m.goldenMode = "update-golden" : g.includes("--approve-divergence") && (m.goldenMode = "approve-divergence");
@@ -345,26 +350,26 @@ if (g.includes("--divergence-only")) {
345
350
  throw new Error(
346
351
  "--approve-divergence only makes sense with --divergence-only — there's nothing to approve without the divergence check running."
347
352
  );
348
- g.includes("--dry-run") && (console.log(JSON.stringify({ engineConfig: m, webServers: P }, null, 2)), process.exit(0));
353
+ g.includes("--dry-run") && (console.log(JSON.stringify({ engineConfig: m, webServers: D }, null, 2)), process.exit(0));
349
354
  const Ee = /* @__PURE__ */ new Set([
350
355
  "--dry-run",
351
356
  "--serve",
352
357
  "--update-golden",
353
358
  "--approve-divergence",
354
359
  "--divergence-only"
355
- ]), Pe = g.filter((e) => !Ee.has(e));
356
- De().catch((e) => {
360
+ ]), De = g.filter((e) => !Ee.has(e));
361
+ Pe().catch((e) => {
357
362
  console.error(e), process.exitCode = 1;
358
363
  });
359
- async function De() {
364
+ async function Pe() {
360
365
  if (g.includes("--serve")) {
361
366
  if (m.isSourceOfTruthAdapter)
362
367
  throw new Error(
363
368
  "Dev Mode (--serve) has nothing to sync this project's Storybook against — isSourceOfTruthAdapter is true in this project's adapter-tester.config.json."
364
369
  );
365
- await ne(m, P);
370
+ await ne(m, D);
366
371
  } else {
367
- const e = P.at(-1);
372
+ const e = D.at(-1);
368
373
  if (!e)
369
374
  throw new Error("resolveConfig() returned no webServers to boot.");
370
375
  await je(e, m);
@@ -372,7 +377,7 @@ async function De() {
372
377
  }
373
378
  async function je(e, t) {
374
379
  const r = a(E, ".adapter-tester/run");
375
- F(r, { recursive: !0 });
380
+ _(r, { recursive: !0 });
376
381
  const o = t.targets.at(-1);
377
382
  if (!o)
378
383
  throw new Error("resolveConfig() returned no targets to check.");
@@ -386,10 +391,12 @@ import { defineConfig, devices } from "@playwright/test";
386
391
 
387
392
  export default defineConfig({
388
393
  testDir: ${JSON.stringify(r)},
389
- // Stories run across Playwright's default worker pool each golden check
390
- // only reads/writes its own story's manifest.json entry, under a lock, so
391
- // concurrent workers never race each other (see \`updateManifestEntry\`).
392
- // Override with \`--workers <n>\` (forwarded straight through to Playwright).
394
+ // Each golden check only reads/writes its own story's manifest.json entry,
395
+ // under a lock, so concurrent workers never race each other (see
396
+ // \`updateManifestEntry\`). Defaults to 1 worker (1 Chromium instance) to
397
+ // avoid exhausting memory running the full suite; override with
398
+ // \`--workers <n>\` (forwarded straight through to Playwright) to parallelize.
399
+ workers: 1,
393
400
  fullyParallel: true,
394
401
  forbidOnly: !!process.env.CI,
395
402
  retries: process.env.CI ? 2 : 0,
@@ -430,14 +437,14 @@ test.describe(\`\${ownTargetName} — \${suiteLabel}\`, () => {
430
437
  `
431
438
  );
432
439
  try {
433
- const d = q(
440
+ const d = J(
434
441
  "npx",
435
442
  [
436
443
  "playwright",
437
444
  "test",
438
445
  "--config",
439
446
  a(r, "playwright.config.js"),
440
- ...Pe
447
+ ...De
441
448
  ],
442
449
  { stdio: "inherit", cwd: E, shell: process.platform === "win32" }
443
450
  );