@recursica/adapter-tester 5.3.1 → 5.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -0
- package/dist/cli.cjs +12 -11
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +354 -212
- package/dist/cli.js.map +1 -1
- package/dist/devServer.d.ts +5 -2
- package/dist/devServer.d.ts.map +1 -1
- package/dist/harness/mantineSourceOfTruth.d.ts.map +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.html +226 -3
- package/dist/index.js +1 -1
- package/dist/{mantineSourceOfTruth-6KZlsQ67.cjs → mantineSourceOfTruth-DiQas6OS.cjs} +29 -16
- package/dist/mantineSourceOfTruth-DiQas6OS.cjs.map +1 -0
- package/dist/{mantineSourceOfTruth-CAKhcVCT.js → mantineSourceOfTruth-xUEi1k8U.js} +42 -29
- package/dist/mantineSourceOfTruth-xUEi1k8U.js.map +1 -0
- package/dist/runVisualRegression-CQk97Qkv.js +5051 -0
- package/dist/runVisualRegression-CQk97Qkv.js.map +1 -0
- package/dist/runVisualRegression-DNafR8Lb.cjs +13 -0
- package/dist/runVisualRegression-DNafR8Lb.cjs.map +1 -0
- package/dist/testing/runVisualRegression.d.ts +16 -2
- package/dist/testing/runVisualRegression.d.ts.map +1 -1
- package/dist/testing.cjs +1 -5
- package/dist/testing.cjs.map +1 -1
- package/dist/testing.js +2 -380
- package/dist/testing.js.map +1 -1
- package/package.json +3 -2
- package/public/index.html +226 -3
- package/dist/index-C6uYPRmx.cjs +0 -9
- package/dist/index-C6uYPRmx.cjs.map +0 -1
- package/dist/index-DqQzFSAH.js +0 -4667
- package/dist/index-DqQzFSAH.js.map +0 -1
- package/dist/mantineSourceOfTruth-6KZlsQ67.cjs.map +0 -1
- package/dist/mantineSourceOfTruth-CAKhcVCT.js.map +0 -1
package/dist/cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.js","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 @recursica/adapter-mui-v7), 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 {\n HarnessWebServerConfig,\n MantineSourceOfTruthTokensSource,\n} from \"./harness/mantineSourceOfTruth.js\";\nimport { mantineSourceOfTruthWebServer } from \"./harness/mantineSourceOfTruth.js\";\nimport { validateFileConfig } from \"./validateFileConfig.js\";\n\nconst MANTINE_ADAPTER_PACKAGE_NAME = \"@recursica/adapter-mantine-v8\";\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/adapter-mantine-v8` 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 /** See `MantineSourceOfTruthTokensSource`. Defaults to `\"target\"` — the\n * harness renders Mantine's components with *this* project's own\n * committed Recursica tokens, not Mantine's own bundled snapshot or (the\n * one thing neither ever means) the retired `@recursica/official-release`\n * package. Set to `\"mantine-package\"` to test against\n * `@recursica/adapter-mantine-v8`'s own bundled tokens instead. */\n tokensSource?: MantineSourceOfTruthTokensSource;\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/adapter-mui-v7\" -> \"adapter-mui-v7\"). */\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 (@recursica/adapter-mantine-v8).\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 const tokensSource: MantineSourceOfTruthTokensSource =\n sourceOfTruth.tokensSource ?? \"target\";\n sourceOfTruthWebServer = mantineSourceOfTruthWebServer({\n dir: join(cwd, \".adapter-tester/mantine-harness\"),\n port: sourceOfTruthPort,\n mantineAdapterVersion,\n storybookTemplateVersion: sourceOfTruth.storybookTemplateVersion,\n tokensSource,\n // `ownCwd`, not `cwd` — the project actually being tested (same\n // reasoning `goldenDir` above uses), source of the 4 token files\n // copied into the harness when `tokensSource` is \"target\".\n targetDir: ownCwd,\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\n// `--story <story-id>` scopes a run to exactly one story — pulled out the\n// same way, ahead of the passthrough logic, since it's consumed here (to\n// filter the generated spec) rather than forwarded to Playwright. Equivalent\n// to `--grep \"<story-id>\"`, but exact-match and easier to reach for when\n// iterating on a single component.\nlet storyId: string | undefined;\nconst storyFlagIndex = args.indexOf(\"--story\");\nif (storyFlagIndex !== -1) {\n const value = args[storyFlagIndex + 1];\n if (value === undefined || value.startsWith(\"--\")) {\n throw new Error(\n \"--story requires a story id, e.g. --story ui-kit-button--loading\",\n );\n }\n storyId = value;\n args.splice(storyFlagIndex, 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\n// Set from \\`--story <story-id>\\` — scopes this run to exactly one story and\n// skips the (suite-wide) parity check, which has nothing to do with it.\nconst storyId = ${JSON.stringify(storyId ?? null)};\nconst scopedStories = storyId\n ? stories.filter((story) => story.id === storyId)\n : stories;\nif (storyId && scopedStories.length === 0) {\n throw new Error(\\`--story \"\\${storyId}\" matched no story in this Storybook.\\`);\n}\n\ntest.describe(\\`\\${ownTargetName} — \\${suiteLabel}\\`, () => {\n if (!storyId && 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 scopedStories) {\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","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","tokensSource","mantineSourceOfTruthWebServer","testingEntry","pathToFileURL","args","sourceOfTruthVersion","sourceOfTruthVersionFlagIndex","value","storyId","storyFlagIndex","OWN_FLAGS","passthroughArgs","arg","main","runAutomated","config","runDir","ownTarget","result","spawnSync"],"mappings":";;;;;;;;;;AA2CA,MAAMA,KAAe,mBACfC,KAAoB;AAE1B,SAASC,GAAaC,GAAgC;AACpD,SAAO,IAAI,QAAQ,CAACC,MAAY;AAC9B,UAAMC,IAAS,IAAIC,EAAI,OAAA;AACvB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AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAAA;AA0B/C,MAAI;AACF,UAAMU,IAASC;AAAA,MACb;AAAA,MACA;AAAA,QACE;AAAA,QACA;AAAA,QACA;AAAA,QACAvE,EAAKoE,GAAQ,sBAAsB;AAAA,QACnC,GAAGL;AAAA,MAAA;AAAA,MAEL,EAAE,OAAO,WAAW,KAAAlC,GAAK,OAAO,QAAQ,aAAa,QAAA;AAAA,IAAQ;AAE/D,YAAQ,WAAWyC,EAAO,UAAU;AAAA,EACtC,UAAA;AAIE,IAAA1E,KAAA,QAAAA,EAAS,KAAK;AAAA,EAChB;AACF;"}
|
|
1
|
+
{"version":3,"file":"cli.js","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 @recursica/adapter-mui-v7), 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 { existsSync, readFileSync, writeFileSync } from \"node:fs\";\nimport { dirname, join } from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\nimport { chromium, type Browser } from \"@playwright/test\";\nimport express from \"express\";\nimport { createProxyMiddleware } from \"http-proxy-middleware\";\nimport type { AdapterTesterConfig } from \"./config.js\";\nimport { diffPngBuffers } from \"./golden/diffPng.js\";\nimport {\n resolveSourceOfTruthGolden,\n type SourceOfTruthGolden,\n} from \"./golden/resolveSourceOfTruthGolden.js\";\nimport {\n captureStoryScreenshot,\n resolveThreshold,\n resolveViewport,\n} from \"./testing/runVisualRegression.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\n/** Version of `@recursica/adapter-mantine-v8` installed in the harness (or\n * read from a local source-of-truth checkout's own package.json). */\nfunction readInstalledMantineVersion(cwd: string): string {\n const installed = join(\n cwd,\n \"node_modules/@recursica/adapter-mantine-v8/package.json\",\n );\n const path = existsSync(installed) ? installed : join(cwd, \"package.json\");\n return JSON.parse(readFileSync(path, \"utf8\")).version;\n}\n\nconst DEFAULT_DEV_PORT = 6010;\n\nexport interface DevServerOptions {\n /** Port the dev-mode proxy UI itself listens on. Defaults to 6010, stepping to the next free port if taken. */\n port?: number;\n /** Absolute path of `adapter-tester.config.json`, where per-story\n * threshold overrides are saved. */\n configPath: string;\n}\n\n/** Everything the Dev Mode diff UI needs about one story's divergence. */\ninterface GoldenDiffResult {\n status: \"ok\" | \"no-golden\" | \"size-mismatch\";\n /** `null` unless `status` is `\"ok\"`. */\n diffPixels: number | null;\n threshold: number;\n viewport: { width: number; height: number };\n /** PNG data URLs. `golden` is `null` for `\"no-golden\"`; `diff` is `null`\n * unless `status` is `\"ok\"`. */\n golden: string | null;\n diff: string | null;\n}\n\nconst toDataUrl = (png: Buffer) =>\n `data:image/png;base64,${png.toString(\"base64\")}`;\n\n/** Registers the Dev Mode `/__golden/*` routes: capture this project's live\n * story at its configured viewport, diff it against the source-of-truth\n * golden exactly as the divergence check does, and persist threshold edits. */\nfunction registerGoldenRoutes(\n app: express.Express,\n engineConfig: AdapterTesterConfig,\n targetUrl: string,\n golden: SourceOfTruthGolden | Error,\n configPath: string,\n): { close: () => Promise<void> } {\n let browser: Promise<Browser> | undefined;\n // Captures run one at a time — each is a full page load, and a flurry from\n // rapid story switching shouldn't pile up headless pages.\n let queue: Promise<unknown> = Promise.resolve();\n\n const thresholdFor = (id: string) =>\n resolveThreshold(\n id,\n Object.fromEntries(\n Object.entries(engineConfig.stories ?? {})\n .filter(([, o]) => o.sourceOfTruthThreshold !== undefined)\n .map(([key, o]) => [key, o.sourceOfTruthThreshold!]),\n ),\n engineConfig.sourceOfTruthThresholdPixels,\n );\n\n const computeDiff = async (id: string): Promise<GoldenDiffResult> => {\n browser ??= chromium.launch();\n const page = await (await browser).newPage();\n const viewport = resolveViewport(id, engineConfig.stories ?? {});\n try {\n await page.setViewportSize(viewport);\n await page.goto(`${targetUrl}/iframe.html?id=${id}&viewMode=story`, {\n waitUntil: \"networkidle\",\n });\n const live = await captureStoryScreenshot(page);\n const goldenImage = await (golden as SourceOfTruthGolden).readImage(id);\n const threshold = thresholdFor(id);\n if (!goldenImage) {\n return {\n status: \"no-golden\",\n diffPixels: null,\n threshold,\n viewport,\n golden: null,\n diff: null,\n };\n }\n const { diffPixels, diffImage } = diffPngBuffers(live, goldenImage);\n return {\n status: diffImage ? \"ok\" : \"size-mismatch\",\n diffPixels: diffImage ? diffPixels : null,\n threshold,\n viewport,\n golden: toDataUrl(goldenImage),\n diff: diffImage ? toDataUrl(diffImage) : null,\n };\n } finally {\n await page.close();\n }\n };\n\n app.get(\"/__golden/diff\", (req, res) => {\n if (golden instanceof Error) {\n res.status(503).json({ error: golden.message });\n return;\n }\n const id = String(req.query.id ?? \"\");\n if (!id) {\n res.status(400).json({ error: \"id is required\" });\n return;\n }\n const run = queue.then(() => computeDiff(id));\n queue = run.catch(() => undefined);\n run.then(\n (result) => res.json(result),\n (err: Error) => res.status(500).json({ error: err.message }),\n );\n });\n\n app.get(\"/__golden/image\", async (req, res) => {\n const image =\n golden instanceof Error\n ? null\n : await golden.readImage(String(req.query.id ?? \"\"));\n if (!image) {\n res.status(404).end();\n return;\n }\n res.type(\"image/png\").send(image);\n });\n\n app.post(\"/__golden/threshold\", express.json(), (req, res) => {\n const { id, value } = req.body ?? {};\n if (\n typeof id !== \"string\" ||\n !id ||\n !Number.isInteger(value) ||\n value < 0\n ) {\n res\n .status(400)\n .json({ error: \"id (string) and value (integer >= 0) are required\" });\n return;\n }\n const file = existsSync(configPath)\n ? JSON.parse(readFileSync(configPath, \"utf8\"))\n : {};\n file.stories = {\n ...file.stories,\n [id]: { ...file.stories?.[id], sourceOfTruthThreshold: value },\n };\n writeFileSync(configPath, JSON.stringify(file, null, 2) + \"\\n\");\n engineConfig.stories = {\n ...engineConfig.stories,\n [id]: { ...engineConfig.stories?.[id], sourceOfTruthThreshold: value },\n };\n res.json({ id, value });\n });\n\n return {\n close: async () => {\n if (browser) await (await browser).close();\n },\n };\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 !targetServer ||\n !sourceOfTruthServer\n ) {\n throw new Error(\n \"adapter-tester dev mode requires exactly two targets: [sourceOfTruth, target] — check adapter-tester.config.json.\",\n );\n }\n if (!engineConfig.sourceOfTruthGolden) {\n throw new Error(\n \"adapter-tester dev mode needs a sourceOfTruthGolden location to diff against — check adapter-tester.config.json.\",\n );\n }\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, sourceOfTruthGolden] =\n await Promise.all([\n launchAndDetectStorybook(\n toLaunchTarget(sourceOfTruth.name, sourceOfTruthServer),\n ),\n launchAndDetectStorybook(toLaunchTarget(target.name, targetServer)),\n // The live Storybooks still work without the golden (e.g. offline), so\n // a failure here only disables Golden/Compute Diff, loudly.\n resolveSourceOfTruthGolden(engineConfig.sourceOfTruthGolden).catch(\n (err: Error) => {\n console.warn(\n `[Dev Launcher] WARNING: source-of-truth golden unavailable — Golden and Compute Diff are disabled: ${err.message}`,\n );\n return err;\n },\n ),\n ]);\n console.log(`[Dev Launcher] Dev Mode is ready!`);\n\n const spawned = [sourceOfTruthRunning.process, targetRunning.process].filter(\n (child): child is ChildProcess => !!child,\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 const sourceOfTruthVersion = readInstalledMantineVersion(\n sourceOfTruthServer.cwd,\n );\n const goldenRoutes = registerGoldenRoutes(\n app,\n engineConfig,\n targetRunning.url,\n sourceOfTruthGolden,\n options.configPath,\n );\n\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 sourceOfTruthVersion,\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 void goldenRoutes.close().finally(() => process.exit(0));\n };\n process.on(\"SIGINT\", cleanup);\n process.on(\"SIGTERM\", cleanup);\n\n // An explicit `--port` is strict. The default 6010 is only a first guess:\n // another Dev Mode instance often already holds it, so step to the next\n // free port rather than crash.\n const firstPort = options.port ?? DEFAULT_DEV_PORT;\n const lastPort = options.port ? firstPort : firstPort + 19;\n let boundPort = firstPort;\n for (;;) {\n try {\n await new Promise<void>((resolve, reject) => {\n const server = app.listen(boundPort);\n server.once(\"listening\", () => resolve());\n server.once(\"error\", reject);\n });\n break;\n } catch (err) {\n const code = (err as NodeJS.ErrnoException).code;\n if (code !== \"EADDRINUSE\" || boundPort >= lastPort) {\n console.error(\n `[Dev Launcher] Dev Mode server failed to listen on port ${boundPort}: ${(err as Error).message}. Pass --port <n> to use another port.`,\n );\n for (const child of spawned) child.kill(\"SIGINT\");\n process.exit(1);\n }\n console.log(\n `[Dev Launcher] Port ${boundPort} is in use, trying ${boundPort + 1}...`,\n );\n boundPort++;\n }\n }\n\n console.log(`\n====================================================\n🚀 Adapter Dev Mode proxy running at:\n http://localhost:${boundPort}\n====================================================\n`);\n openBrowser(`http://localhost:${boundPort}`);\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 {\n HarnessWebServerConfig,\n MantineSourceOfTruthTokensSource,\n} from \"./harness/mantineSourceOfTruth.js\";\nimport { mantineSourceOfTruthWebServer } from \"./harness/mantineSourceOfTruth.js\";\nimport { validateFileConfig } from \"./validateFileConfig.js\";\n\nconst MANTINE_ADAPTER_PACKAGE_NAME = \"@recursica/adapter-mantine-v8\";\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/adapter-mantine-v8` 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 /** See `MantineSourceOfTruthTokensSource`. Defaults to `\"target\"` — the\n * harness renders Mantine's components with *this* project's own\n * committed Recursica tokens, not Mantine's own bundled snapshot or (the\n * one thing neither ever means) the retired `@recursica/official-release`\n * package. Set to `\"mantine-package\"` to test against\n * `@recursica/adapter-mantine-v8`'s own bundled tokens instead. */\n tokensSource?: MantineSourceOfTruthTokensSource;\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/adapter-mui-v7\" -> \"adapter-mui-v7\"). */\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 (@recursica/adapter-mantine-v8).\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 const tokensSource: MantineSourceOfTruthTokensSource =\n sourceOfTruth.tokensSource ?? \"target\";\n sourceOfTruthWebServer = mantineSourceOfTruthWebServer({\n dir: join(cwd, \".adapter-tester/mantine-harness\"),\n port: sourceOfTruthPort,\n mantineAdapterVersion,\n storybookTemplateVersion: sourceOfTruth.storybookTemplateVersion,\n tokensSource,\n // `ownCwd`, not `cwd` — the project actually being tested (same\n // reasoning `goldenDir` above uses), source of the 4 token files\n // copied into the harness when `tokensSource` is \"target\".\n targetDir: ownCwd,\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 { CONFIG_FILE_NAME, 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\n// `--port <n>` sets the Dev Mode proxy port (default 6010) — pulled out the\n// same way, since it's consumed here rather than forwarded to Playwright.\nlet devPort: number | undefined;\nconst portFlagIndex = args.indexOf(\"--port\");\nif (portFlagIndex !== -1) {\n const value = args[portFlagIndex + 1];\n devPort = Number(value);\n if (value === undefined || !Number.isInteger(devPort) || devPort <= 0) {\n throw new Error(\"--port requires a port number, e.g. --port 6020\");\n }\n args.splice(portFlagIndex, 2);\n}\n\n// `--story <story-id>` scopes a run to exactly one story — pulled out the\n// same way, ahead of the passthrough logic, since it's consumed here (to\n// filter the generated spec) rather than forwarded to Playwright. Equivalent\n// to `--grep \"<story-id>\"`, but exact-match and easier to reach for when\n// iterating on a single component.\nlet storyId: string | undefined;\nconst storyFlagIndex = args.indexOf(\"--story\");\nif (storyFlagIndex !== -1) {\n const value = args[storyFlagIndex + 1];\n if (value === undefined || value.startsWith(\"--\")) {\n throw new Error(\n \"--story requires a story id, e.g. --story ui-kit-button--loading\",\n );\n }\n storyId = value;\n args.splice(storyFlagIndex, 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 port: devPort,\n configPath: join(cwd, CONFIG_FILE_NAME),\n });\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\n// Set from \\`--story <story-id>\\` — scopes this run to exactly one story and\n// skips the (suite-wide) parity check, which has nothing to do with it.\nconst storyId = ${JSON.stringify(storyId ?? null)};\nconst scopedStories = storyId\n ? stories.filter((story) => story.id === storyId)\n : stories;\nif (storyId && scopedStories.length === 0) {\n throw new Error(\\`--story \"\\${storyId}\" matched no story in this Storybook.\\`);\n}\n\ntest.describe(\\`\\${ownTargetName} — \\${suiteLabel}\\`, () => {\n if (!storyId && 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 scopedStories) {\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","openBrowser","startCmd","readInstalledMantineVersion","cwd","installed","join","path","existsSync","DEFAULT_DEV_PORT","toDataUrl","png","registerGoldenRoutes","app","engineConfig","targetUrl","golden","configPath","browser","queue","thresholdFor","id","resolveThreshold","key","o","computeDiff","chromium","page","viewport","resolveViewport","live","captureStoryScreenshot","goldenImage","threshold","diffPixels","diffImage","diffPngBuffers","req","res","run","result","image","express","value","file","startDevServer","webServers","options","sourceOfTruth","sourceOfTruthServer","targetServer","sourceOfTruthRunning","targetRunning","sourceOfTruthGolden","resolveSourceOfTruthGolden","spawned","publicDir","headerPath","sourceOfTruthVersion","goldenRoutes","next","html","createProxyMiddleware","cleaningUp","cleanup","firstPort","lastPort","boundPort","addFormats","ajvFormatsModule.default","ajv","Ajv","validate","schema","validateFileConfig","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","detectOwnPort","storybookScript","detectOwnName","loadFileConfig","resolveConfig","overrides","isSourceOfTruthAdapter","ownName","ownPort","ownCommand","ownCwd","_c","ownWebServer","sharedEngineConfig","sourceOfTruthName","sourceOfTruthPort","sourceOfTruthWebServer","sourceOfTruthCwd","mantineAdapterVersion","tokensSource","mantineSourceOfTruthWebServer","testingEntry","pathToFileURL","args","sourceOfTruthVersionFlagIndex","devPort","portFlagIndex","storyId","storyFlagIndex","OWN_FLAGS","passthroughArgs","arg","main","runAutomated","config","runDir","ownTarget","spawnSync"],"mappings":";;;;;;;;;;;AA2CA,MAAMA,KAAe,mBACfC,KAAoB;AAE1B,SAASC,GAAaC,GAAgC;AACpD,SAAO,IAAI,QAAQ,CAACC,MAAY;AAC9B,UAAMC,IAAS,IA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,UAAUP,MAAW,IAAI,CAAC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAAA;AA0B/C,MAAI;AACF,UAAM1E,IAASoF;AAAA,MACb;AAAA,MACA;AAAA,QACE;AAAA,QACA;AAAA,QACA;AAAA,QACAtH,EAAKoH,GAAQ,sBAAsB;AAAA,QACnC,GAAGL;AAAA,MAAA;AAAA,MAEL,EAAE,OAAO,WAAW,KAAAjH,GAAK,OAAO,QAAQ,aAAa,QAAA;AAAA,IAAQ;AAE/D,YAAQ,WAAWoC,EAAO,UAAU;AAAA,EACtC,UAAA;AAIE,IAAAe,KAAA,QAAAA,EAAS,KAAK;AAAA,EAChB;AACF;"}
|
package/dist/devServer.d.ts
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import { AdapterTesterConfig } from './config.js';
|
|
2
2
|
import { HarnessWebServerConfig } from './harness/mantineSourceOfTruth.js';
|
|
3
3
|
export interface DevServerOptions {
|
|
4
|
-
/** Port the dev-mode proxy UI itself listens on. Defaults to 6010. */
|
|
4
|
+
/** Port the dev-mode proxy UI itself listens on. Defaults to 6010, stepping to the next free port if taken. */
|
|
5
5
|
port?: number;
|
|
6
|
+
/** Absolute path of `adapter-tester.config.json`, where per-story
|
|
7
|
+
* threshold overrides are saved. */
|
|
8
|
+
configPath: string;
|
|
6
9
|
}
|
|
7
|
-
export declare function startDevServer(engineConfig: AdapterTesterConfig, webServers: HarnessWebServerConfig[], options
|
|
10
|
+
export declare function startDevServer(engineConfig: AdapterTesterConfig, webServers: HarnessWebServerConfig[], options: DevServerOptions): Promise<void>;
|
|
8
11
|
//# sourceMappingURL=devServer.d.ts.map
|
package/dist/devServer.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"devServer.d.ts","sourceRoot":"","sources":["../src/devServer.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"devServer.d.ts","sourceRoot":"","sources":["../src/devServer.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAWvD,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,mCAAmC,CAAC;AA+ChF,MAAM,WAAW,gBAAgB;IAC/B,+GAA+G;IAC/G,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;wCACoC;IACpC,UAAU,EAAE,MAAM,CAAC;CACpB;AAiJD,wBAAsB,cAAc,CAClC,YAAY,EAAE,mBAAmB,EACjC,UAAU,EAAE,sBAAsB,EAAE,EACpC,OAAO,EAAE,gBAAgB,GACxB,OAAO,CAAC,IAAI,CAAC,CAiKf"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mantineSourceOfTruth.d.ts","sourceRoot":"","sources":["../../src/harness/mantineSourceOfTruth.ts"],"names":[],"mappings":"AAWA;;;;;;;;;;;;;GAaG;AAEH;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,MAAM,MAAM,gCAAgC,GAAG,QAAQ,GAAG,iBAAiB,CAAC;AAE5E,MAAM,WAAW,kCAAkC;IACjD;;;OAGG;IACH,GAAG,EAAE,MAAM,CAAC;IACZ;gFAC4E;IAC5E,IAAI,EAAE,MAAM,CAAC;IACb,iFAAiF;IACjF,qBAAqB,CAAC,EAAE,MAAM,CAAC;IAC/B,iFAAiF;IACjF,wBAAwB,CAAC,EAAE,MAAM,CAAC;IAClC,sEAAsE;IACtE,YAAY,CAAC,EAAE,gCAAgC,CAAC;IAChD;;;;OAIG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,sBAAsB;IACrC,OAAO,EAAE,MAAM,CAAC;IAChB;;;;mBAIe;IACf,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,MAAM,CAAC;IACZ,mBAAmB,EAAE,OAAO,CAAC;IAC7B;iEAC6D;IAC7D,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;CACjB;
|
|
1
|
+
{"version":3,"file":"mantineSourceOfTruth.d.ts","sourceRoot":"","sources":["../../src/harness/mantineSourceOfTruth.ts"],"names":[],"mappings":"AAWA;;;;;;;;;;;;;GAaG;AAEH;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,MAAM,MAAM,gCAAgC,GAAG,QAAQ,GAAG,iBAAiB,CAAC;AAE5E,MAAM,WAAW,kCAAkC;IACjD;;;OAGG;IACH,GAAG,EAAE,MAAM,CAAC;IACZ;gFAC4E;IAC5E,IAAI,EAAE,MAAM,CAAC;IACb,iFAAiF;IACjF,qBAAqB,CAAC,EAAE,MAAM,CAAC;IAC/B,iFAAiF;IACjF,wBAAwB,CAAC,EAAE,MAAM,CAAC;IAClC,sEAAsE;IACtE,YAAY,CAAC,EAAE,gCAAgC,CAAC;IAChD;;;;OAIG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,sBAAsB;IACrC,OAAO,EAAE,MAAM,CAAC;IAChB;;;;mBAIe;IACf,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,MAAM,CAAC;IACZ,mBAAmB,EAAE,OAAO,CAAC;IAC7B;iEAC6D;IAC7D,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;CACjB;AA0MD,8EAA8E;AAC9E,wBAAgB,mCAAmC,CACjD,OAAO,EAAE,kCAAkC,GAC1C,MAAM,CAoCR;AAED;;;GAGG;AACH,wBAAgB,6BAA6B,CAC3C,OAAO,EAAE,kCAAkC,GAC1C,sBAAsB,CA2BxB"}
|
package/dist/index.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("./mantineSourceOfTruth-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("./mantineSourceOfTruth-DiQas6OS.cjs");function n(r){const e=r.targets.filter(t=>t.sourceOfTruth).length;if(e!==1)throw new Error(`adapter-tester config must mark exactly one target as sourceOfTruth (found ${e})`);return r}function o(r){const e=r.targets.find(t=>t.sourceOfTruth);if(!e)throw new Error("adapter-tester config has no target marked sourceOfTruth");return e}exports.mantineSourceOfTruthWebServer=u.mantineSourceOfTruthWebServer;exports.scaffoldMantineSourceOfTruthHarness=u.scaffoldMantineSourceOfTruthHarness;exports.defineAdapterTesterConfig=n;exports.getSourceOfTruth=o;
|
|
2
2
|
//# sourceMappingURL=index.cjs.map
|
package/dist/index.html
CHANGED
|
@@ -20,7 +20,10 @@
|
|
|
20
20
|
position: relative;
|
|
21
21
|
}
|
|
22
22
|
.header {
|
|
23
|
-
|
|
23
|
+
height: 42px;
|
|
24
|
+
box-sizing: border-box;
|
|
25
|
+
flex: 0 0 42px;
|
|
26
|
+
padding: 0 15px;
|
|
24
27
|
background-color: #252526;
|
|
25
28
|
border-bottom: 1px solid #333;
|
|
26
29
|
font-size: 13px;
|
|
@@ -41,6 +44,81 @@
|
|
|
41
44
|
.status.connected {
|
|
42
45
|
color: #4CAF50;
|
|
43
46
|
}
|
|
47
|
+
.diff-tools {
|
|
48
|
+
display: none;
|
|
49
|
+
align-items: center;
|
|
50
|
+
gap: 8px;
|
|
51
|
+
text-transform: none;
|
|
52
|
+
letter-spacing: normal;
|
|
53
|
+
font-weight: normal;
|
|
54
|
+
font-size: 12px;
|
|
55
|
+
}
|
|
56
|
+
.diff-badge {
|
|
57
|
+
padding: 2px 8px;
|
|
58
|
+
border-radius: 10px;
|
|
59
|
+
background: #444;
|
|
60
|
+
color: #fff;
|
|
61
|
+
font-weight: 600;
|
|
62
|
+
}
|
|
63
|
+
.diff-badge.under { background: #2e7d32; }
|
|
64
|
+
.diff-badge.over { background: #c62828; }
|
|
65
|
+
.diff-tools input {
|
|
66
|
+
width: 70px;
|
|
67
|
+
background: #1e1e1e;
|
|
68
|
+
color: #fff;
|
|
69
|
+
border: 1px solid #555;
|
|
70
|
+
border-radius: 3px;
|
|
71
|
+
padding: 2px 4px;
|
|
72
|
+
}
|
|
73
|
+
.diff-tools button, .golden-tabs > button {
|
|
74
|
+
background: #3a3d41;
|
|
75
|
+
color: #fff;
|
|
76
|
+
border: 1px solid #555;
|
|
77
|
+
border-radius: 3px;
|
|
78
|
+
padding: 2px 8px;
|
|
79
|
+
cursor: pointer;
|
|
80
|
+
}
|
|
81
|
+
.diff-tools button:disabled { opacity: 0.5; cursor: default; }
|
|
82
|
+
.golden-tabs button.active { background: #007acc; border-color: #007acc; }
|
|
83
|
+
.golden-tabs { align-items: center; }
|
|
84
|
+
#goldenView {
|
|
85
|
+
display: none;
|
|
86
|
+
flex: 1;
|
|
87
|
+
flex-direction: column;
|
|
88
|
+
min-height: 0;
|
|
89
|
+
background: #fff;
|
|
90
|
+
}
|
|
91
|
+
.golden-tabs {
|
|
92
|
+
display: flex;
|
|
93
|
+
gap: 6px;
|
|
94
|
+
margin-left: auto;
|
|
95
|
+
margin-right: 12px;
|
|
96
|
+
text-transform: none;
|
|
97
|
+
letter-spacing: normal;
|
|
98
|
+
font-weight: normal;
|
|
99
|
+
font-size: 12px;
|
|
100
|
+
}
|
|
101
|
+
#goldenImgWrap {
|
|
102
|
+
flex: 1;
|
|
103
|
+
overflow: auto;
|
|
104
|
+
background: #e6e6e6;
|
|
105
|
+
}
|
|
106
|
+
#goldenImgWrap { position: relative; }
|
|
107
|
+
#goldenImg { display: block; max-width: none; }
|
|
108
|
+
#goldenSpinner {
|
|
109
|
+
display: none;
|
|
110
|
+
position: absolute;
|
|
111
|
+
top: 50%;
|
|
112
|
+
left: 50%;
|
|
113
|
+
width: 36px;
|
|
114
|
+
height: 36px;
|
|
115
|
+
margin: -18px 0 0 -18px;
|
|
116
|
+
border: 4px solid #bbb;
|
|
117
|
+
border-top-color: #007acc;
|
|
118
|
+
border-radius: 50%;
|
|
119
|
+
animation: golden-spin 0.8s linear infinite;
|
|
120
|
+
}
|
|
121
|
+
@keyframes golden-spin { to { transform: rotate(360deg); } }
|
|
44
122
|
iframe {
|
|
45
123
|
flex: 1;
|
|
46
124
|
border: none;
|
|
@@ -178,12 +256,25 @@
|
|
|
178
256
|
<div class="right-top" id="rightTop">
|
|
179
257
|
<div class="header">
|
|
180
258
|
<span id="sourceOfTruthLabel">Source of Truth</span>
|
|
259
|
+
<span class="golden-tabs" id="goldenTabs">
|
|
260
|
+
<button data-view="live" class="active">Live</button>
|
|
261
|
+
<button data-view="golden">Golden</button>
|
|
262
|
+
<button data-view="diff" id="computeDiffBtn">Compute Diff</button>
|
|
263
|
+
<span class="diff-tools" id="diffResult">
|
|
264
|
+
<input type="number" min="0" step="1" id="thresholdInput" title="Threshold (pixels)">
|
|
265
|
+
<button id="saveThresholdBtn" disabled>Save</button>
|
|
266
|
+
<span class="diff-badge" id="diffBadge"></span>
|
|
267
|
+
</span>
|
|
268
|
+
</span>
|
|
181
269
|
<span class="status connected" id="sourceOfTruthStatus">Ready</span>
|
|
182
270
|
</div>
|
|
183
271
|
<!-- Spacer to align the view with the own Storybook's header (40px) -->
|
|
184
|
-
<div style="height: 40px; flex: 0 0 40px; background-color: #fff; border-bottom: 1px solid #e6e6e6; box-sizing: border-box;"></div>
|
|
272
|
+
<div id="sotSpacer" style="height: 40px; flex: 0 0 40px; background-color: #fff; border-bottom: 1px solid #e6e6e6; box-sizing: border-box;"></div>
|
|
185
273
|
<!-- Load the bare source-of-truth component preview -->
|
|
186
274
|
<iframe id="sourceOfTruth" src=""></iframe>
|
|
275
|
+
<div id="goldenView">
|
|
276
|
+
<div id="goldenImgWrap"><img id="goldenImg" alt=""><div id="goldenSpinner"></div></div>
|
|
277
|
+
</div>
|
|
187
278
|
</div>
|
|
188
279
|
|
|
189
280
|
<div class="h-divider" id="hDivider"></div>
|
|
@@ -216,7 +307,7 @@
|
|
|
216
307
|
// Injected by the dev server — see src/devServer.ts.
|
|
217
308
|
const devConfig = window.__ADAPTER_TESTER__ || { ownName: 'Target', sourceOfTruthName: 'Source of Truth', sourceOfTruthPort: 6011 };
|
|
218
309
|
document.getElementById('ownLabel').textContent = devConfig.ownName;
|
|
219
|
-
document.getElementById('sourceOfTruthLabel').textContent = `${devConfig.sourceOfTruthName} (
|
|
310
|
+
document.getElementById('sourceOfTruthLabel').textContent = `${devConfig.sourceOfTruthName} v${devConfig.sourceOfTruthVersion} (Truth)`;
|
|
220
311
|
|
|
221
312
|
const ownIframe = document.getElementById('own');
|
|
222
313
|
const sourceOfTruthIframe = document.getElementById('sourceOfTruth');
|
|
@@ -402,6 +493,133 @@
|
|
|
402
493
|
}
|
|
403
494
|
});
|
|
404
495
|
|
|
496
|
+
|
|
497
|
+
// Diff this project's story against the source-of-truth
|
|
498
|
+
// golden at the configured viewport, computed server-side (see
|
|
499
|
+
// src/devServer.ts), not from what the visible panes happen to show.
|
|
500
|
+
const diffBadge = document.getElementById('diffBadge');
|
|
501
|
+
const thresholdInput = document.getElementById('thresholdInput');
|
|
502
|
+
const diffResult = document.getElementById('diffResult');
|
|
503
|
+
const saveThresholdBtn = document.getElementById('saveThresholdBtn');
|
|
504
|
+
const computeDiffBtn = document.getElementById('computeDiffBtn');
|
|
505
|
+
const goldenView = document.getElementById('goldenView');
|
|
506
|
+
const goldenImg = document.getElementById('goldenImg');
|
|
507
|
+
const goldenSpinner = document.getElementById('goldenSpinner');
|
|
508
|
+
const sourceOfTruthStatusLabel = document.getElementById('sourceOfTruthStatus');
|
|
509
|
+
let goldenResult = null;
|
|
510
|
+
let computing = false;
|
|
511
|
+
let goldenViewKind = 'live';
|
|
512
|
+
let goldenStoryId = '';
|
|
513
|
+
let goldenRequest = 0;
|
|
514
|
+
let savedThreshold = null;
|
|
515
|
+
let thresholdStoryId = '';
|
|
516
|
+
|
|
517
|
+
function renderBadge() {
|
|
518
|
+
const r = goldenResult;
|
|
519
|
+
diffResult.style.display = r ? 'inline-flex' : 'none';
|
|
520
|
+
if (!r) return;
|
|
521
|
+
diffBadge.className = 'diff-badge';
|
|
522
|
+
if (r.status === 'no-golden') {
|
|
523
|
+
diffBadge.textContent = 'No golden';
|
|
524
|
+
} else if (r.status === 'size-mismatch') {
|
|
525
|
+
diffBadge.textContent = 'Size mismatch';
|
|
526
|
+
diffBadge.classList.add('over');
|
|
527
|
+
} else {
|
|
528
|
+
diffBadge.textContent = r.diffPixels.toLocaleString();
|
|
529
|
+
diffBadge.classList.add(r.diffPixels > Number(thresholdInput.value) ? 'over' : 'under');
|
|
530
|
+
}
|
|
531
|
+
saveThresholdBtn.disabled = thresholdInput.value === '' || Number(thresholdInput.value) === savedThreshold;
|
|
532
|
+
}
|
|
533
|
+
|
|
534
|
+
// Live shows the source-of-truth's live Storybook; Golden shows its
|
|
535
|
+
// stored golden image; Compute Diff shows the diff overlay.
|
|
536
|
+
function renderGoldenImage() {
|
|
537
|
+
const live = goldenViewKind === 'live';
|
|
538
|
+
sourceOfTruthIframe.style.display = live ? '' : 'none';
|
|
539
|
+
document.getElementById('sotSpacer').style.display = live ? '' : 'none';
|
|
540
|
+
goldenView.style.display = live ? 'none' : 'flex';
|
|
541
|
+
goldenSpinner.style.display = !live && goldenViewKind === 'diff' && computing ? 'block' : 'none';
|
|
542
|
+
if (live) return;
|
|
543
|
+
const src = goldenViewKind === 'golden'
|
|
544
|
+
? `/__golden/image?id=${encodeURIComponent(goldenStoryId)}`
|
|
545
|
+
: goldenResult && goldenResult.diff;
|
|
546
|
+
if (src) goldenImg.src = src; else goldenImg.removeAttribute('src');
|
|
547
|
+
sourceOfTruthStatusLabel.textContent = '';
|
|
548
|
+
if (goldenViewKind === 'diff' && !computing && goldenResult && !goldenResult.diff) {
|
|
549
|
+
sourceOfTruthStatusLabel.textContent = 'No diff image';
|
|
550
|
+
}
|
|
551
|
+
}
|
|
552
|
+
|
|
553
|
+
function resetDiff() {
|
|
554
|
+
goldenRequest++;
|
|
555
|
+
goldenResult = null;
|
|
556
|
+
computing = false;
|
|
557
|
+
computeDiffBtn.disabled = false;
|
|
558
|
+
renderBadge();
|
|
559
|
+
renderGoldenImage();
|
|
560
|
+
}
|
|
561
|
+
|
|
562
|
+
async function refreshDiff() {
|
|
563
|
+
if (!goldenStoryId) return;
|
|
564
|
+
const request = ++goldenRequest;
|
|
565
|
+
goldenResult = null;
|
|
566
|
+
computing = true;
|
|
567
|
+
computeDiffBtn.disabled = true;
|
|
568
|
+
renderBadge();
|
|
569
|
+
renderGoldenImage();
|
|
570
|
+
try {
|
|
571
|
+
const response = await fetch(`/__golden/diff?id=${encodeURIComponent(goldenStoryId)}`);
|
|
572
|
+
const data = await response.json();
|
|
573
|
+
if (request !== goldenRequest) return;
|
|
574
|
+
if (!response.ok) throw new Error(data.error);
|
|
575
|
+
goldenResult = data;
|
|
576
|
+
savedThreshold = data.threshold;
|
|
577
|
+
// Recomputing keeps an edited threshold; a new story starts from the
|
|
578
|
+
// configured one.
|
|
579
|
+
if (thresholdStoryId !== goldenStoryId) {
|
|
580
|
+
thresholdInput.value = data.threshold;
|
|
581
|
+
thresholdStoryId = goldenStoryId;
|
|
582
|
+
}
|
|
583
|
+
} catch (err) {
|
|
584
|
+
if (request !== goldenRequest) return;
|
|
585
|
+
alert(`Diff failed: ${err.message}`);
|
|
586
|
+
}
|
|
587
|
+
computing = false;
|
|
588
|
+
computeDiffBtn.disabled = false;
|
|
589
|
+
renderBadge();
|
|
590
|
+
renderGoldenImage();
|
|
591
|
+
}
|
|
592
|
+
|
|
593
|
+
thresholdInput.addEventListener('input', renderBadge);
|
|
594
|
+
// Save writes this story's override (`stories.<id>.sourceOfTruthThreshold`)
|
|
595
|
+
// to the config file.
|
|
596
|
+
saveThresholdBtn.addEventListener('click', async () => {
|
|
597
|
+
const value = Number(thresholdInput.value);
|
|
598
|
+
const response = await fetch('/__golden/threshold', {
|
|
599
|
+
method: 'POST',
|
|
600
|
+
headers: { 'Content-Type': 'application/json' },
|
|
601
|
+
body: JSON.stringify({ id: goldenStoryId, value }),
|
|
602
|
+
});
|
|
603
|
+
if (!response.ok) {
|
|
604
|
+
alert(`Could not save threshold: ${(await response.json()).error}`);
|
|
605
|
+
return;
|
|
606
|
+
}
|
|
607
|
+
savedThreshold = value;
|
|
608
|
+
renderBadge();
|
|
609
|
+
});
|
|
610
|
+
goldenImg.addEventListener('error', () => {
|
|
611
|
+
if (goldenViewKind === 'golden') sourceOfTruthStatusLabel.textContent = 'No golden image';
|
|
612
|
+
});
|
|
613
|
+
document.querySelectorAll('.golden-tabs > button').forEach((button) => {
|
|
614
|
+
button.addEventListener('click', () => {
|
|
615
|
+
goldenViewKind = button.dataset.view;
|
|
616
|
+
document.querySelectorAll('.golden-tabs > button').forEach((b) => b.classList.toggle('active', b === button));
|
|
617
|
+
renderGoldenImage();
|
|
618
|
+
// Compute Diff runs the diff every time it is pressed.
|
|
619
|
+
if (goldenViewKind === 'diff') refreshDiff();
|
|
620
|
+
});
|
|
621
|
+
});
|
|
622
|
+
|
|
405
623
|
// Same-Origin Polling Syncing
|
|
406
624
|
let lastUrl = '';
|
|
407
625
|
setInterval(() => {
|
|
@@ -440,6 +658,11 @@
|
|
|
440
658
|
window.history.replaceState({}, '', outerUrl.pathname + outerUrl.search);
|
|
441
659
|
}
|
|
442
660
|
|
|
661
|
+
if (goldenStoryId !== id) {
|
|
662
|
+
goldenStoryId = id;
|
|
663
|
+
resetDiff();
|
|
664
|
+
}
|
|
665
|
+
|
|
443
666
|
let sotUrl = `http://localhost:${devConfig.sourceOfTruthPort}/iframe.html?id=${id}&viewMode=story`;
|
|
444
667
|
if (args) {
|
|
445
668
|
sotUrl += `&args=${args}`;
|
package/dist/index.js
CHANGED