@storywright/cli 0.4.1 → 0.5.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.
@@ -54,6 +54,13 @@ var DEFAULT_CONFIG = {
54
54
  hooks: {}
55
55
  };
56
56
 
57
+ // src/config/types.ts
58
+ var STANDARD_BROWSERS = /* @__PURE__ */ new Set([
59
+ "chromium",
60
+ "firefox",
61
+ "webkit"
62
+ ]);
63
+
57
64
  // src/config/index.ts
58
65
  function defineConfig(config) {
59
66
  return config;
@@ -91,7 +98,34 @@ async function loadConfig(cwd = process.cwd(), overrides) {
91
98
  if (overrides) {
92
99
  merged = deepMerge(merged, overrides);
93
100
  }
94
- return merged;
101
+ const result = merged;
102
+ validateConfig(result);
103
+ return result;
104
+ }
105
+ function validateConfig(config) {
106
+ for (const browser of config.browsers) {
107
+ const options = config.browserOptions[browser];
108
+ if (!STANDARD_BROWSERS.has(browser) && !options?.browserName) {
109
+ throw new Error(
110
+ `Custom browser project '${browser}' requires 'browserName' in browserOptions.
111
+ Example:
112
+ browserOptions: {
113
+ '${browser}': { browserName: 'webkit', ... }
114
+ }
115
+ Valid browserName values: 'chromium', 'firefox', 'webkit'.
116
+
117
+ Error code: SW_E_MISSING_BROWSER_NAME`
118
+ );
119
+ }
120
+ if (options?.browserName && !STANDARD_BROWSERS.has(options.browserName)) {
121
+ throw new Error(
122
+ `Invalid browserName '${options.browserName}' for browser project '${browser}'.
123
+ Valid values: 'chromium', 'firefox', 'webkit'.
124
+
125
+ Error code: SW_E_INVALID_BROWSER_NAME`
126
+ );
127
+ }
128
+ }
95
129
  }
96
130
 
97
131
  // src/reporter/cli-reporter.ts
@@ -258,11 +292,15 @@ import picomatch3 from "picomatch";
258
292
  // src/playwright/config-generator.ts
259
293
  function generatePlaywrightConfig(config, options) {
260
294
  const projects = config.browsers.map((browser) => {
261
- const browserOptions = config.browserOptions[browser];
262
- const useObj = browserOptions ? JSON.stringify(browserOptions, null, " ") : getDefaultBrowserUse(browser);
295
+ const rawOptions = config.browserOptions[browser];
296
+ const useObj = buildBrowserUseObject(browser, rawOptions);
297
+ const useStr = JSON.stringify(useObj, null, " ");
298
+ const testMatch = options.testMatchByBrowser?.[browser];
299
+ const testMatchLine2 = testMatch ? `
300
+ testMatch: '${escapeBackslash(testMatch)}',` : "";
263
301
  return ` {
264
- name: '${browser}',
265
- use: ${useObj},
302
+ name: '${browser}',${testMatchLine2}
303
+ use: ${useStr},
266
304
  }`;
267
305
  });
268
306
  const workers = config.workers === "auto" ? "'100%'" : String(config.workers);
@@ -277,12 +315,13 @@ function generatePlaywrightConfig(config, options) {
277
315
  }
278
316
  }
279
317
  reporterEntries.push(` ['${escapeBackslash(options.reporterPath)}']`);
318
+ const testMatchLine = options.testMatchByBrowser ? "" : ` testMatch: '${escapeBackslash(options.testMatch)}',
319
+ `;
280
320
  return `import { defineConfig } from '@playwright/test';
281
321
 
282
322
  export default defineConfig({
283
323
  testDir: '${escapeBackslash(options.tmpDir)}',
284
- testMatch: '${escapeBackslash(options.testMatch)}',
285
- snapshotDir: '${escapeBackslash(options.snapshotDir)}',
324
+ ${testMatchLine} snapshotDir: '${escapeBackslash(options.snapshotDir)}',
286
325
  snapshotPathTemplate: '{snapshotDir}/{arg}-{projectName}{ext}',
287
326
  timeout: ${config.timeout.test},
288
327
  expect: {
@@ -312,17 +351,25 @@ ${projects.join(",\n")}
312
351
  });
313
352
  `;
314
353
  }
315
- function getDefaultBrowserUse(browser) {
316
- switch (browser) {
317
- case "chromium":
318
- return "{ browserName: 'chromium' }";
319
- case "firefox":
320
- return "{ browserName: 'firefox' }";
321
- case "webkit":
322
- return "{ browserName: 'webkit' }";
323
- default:
324
- return `{ browserName: '${browser}' }`;
354
+ function buildBrowserUseObject(browser, rawOptions) {
355
+ let browserName;
356
+ if (rawOptions?.browserName) {
357
+ browserName = rawOptions.browserName;
358
+ } else if (STANDARD_BROWSERS.has(browser)) {
359
+ browserName = browser;
360
+ } else {
361
+ throw new Error(
362
+ `Cannot resolve browserName for custom browser project '${browser}'.
363
+
364
+ Error code: SW_E_INTERNAL_BROWSER_RESOLVE`
365
+ );
325
366
  }
367
+ const useObj = { browserName };
368
+ if (rawOptions) {
369
+ const { browserName: _, exclude: __, ...rest } = rawOptions;
370
+ Object.assign(useObj, rest);
371
+ }
372
+ return useObj;
326
373
  }
327
374
  function escapeBackslash(str) {
328
375
  return str.replace(/\\/g, "/");
@@ -330,6 +377,7 @@ function escapeBackslash(str) {
330
377
 
331
378
  // src/playwright/test-generator.ts
332
379
  function generateTestFile(config, options) {
380
+ const disableAnimations = config.animations === "disabled";
333
381
  return `import { test, expect } from '@playwright/test';
334
382
  import { readFileSync } from 'node:fs';
335
383
 
@@ -361,7 +409,12 @@ test.describe.parallel('visual regression testing', () => {
361
409
  await page.goto(\`/iframe.html?id=\${story.id}\`, {
362
410
  waitUntil: 'domcontentloaded',
363
411
  });
364
-
412
+ ${disableAnimations ? `
413
+ // Force-disable all CSS animations and transitions
414
+ await page.addStyleTag({
415
+ content: '*, *::before, *::after { animation-duration: 0s !important; animation-delay: 0s !important; transition-duration: 0s !important; transition-delay: 0s !important; }',
416
+ });
417
+ ` : ""}
365
418
  // Wait for story to render: content inside #storybook-root OR portal content on body
366
419
  await page.waitForFunction(() => {
367
420
  const root = document.getElementById('storybook-root');
@@ -378,14 +431,50 @@ test.describe.parallel('visual regression testing', () => {
378
431
  // Wait for web fonts to finish loading
379
432
  await page.waitForFunction(() => document.fonts.ready);
380
433
 
381
- // Wait for all images to finish loading (lazy-loaded, dynamic src, etc.)
382
- await page.waitForFunction(() => {
383
- const images = document.querySelectorAll('img');
384
- return Array.from(images).every(img => img.complete);
434
+ // Force lazy-loaded images to eager and wait for all images with timeout
435
+ await page.evaluate(async () => {
436
+ const lazyImages = document.querySelectorAll('img[loading="lazy"]');
437
+ for (const img of lazyImages) {
438
+ (img as HTMLImageElement).loading = 'eager';
439
+ }
440
+
441
+ const images = Array.from(document.images).filter((img) => !img.complete);
442
+ await Promise.all(
443
+ images.map(
444
+ (img) =>
445
+ new Promise<void>((resolve) => {
446
+ const timeout = setTimeout(resolve, 5000);
447
+ img.onload = img.onerror = () => {
448
+ clearTimeout(timeout);
449
+ resolve();
450
+ };
451
+ }),
452
+ ),
453
+ );
454
+ });
455
+ ${disableAnimations ? `
456
+ // Force opacity:1 on images to counteract fade-in effects
457
+ await page.evaluate(() => {
458
+ document.querySelectorAll('img').forEach((img) => {
459
+ img.style.setProperty('opacity', '1', 'important');
460
+ });
385
461
  });
462
+ ` : ""}
463
+ // Allow async renders to settle (multiple animation frames)
464
+ await page.waitForFunction(
465
+ () =>
466
+ new Promise((resolve) => {
467
+ let count = 0;
468
+ const tick = () => {
469
+ if (++count >= 3) return resolve(true);
470
+ requestAnimationFrame(tick);
471
+ };
472
+ requestAnimationFrame(tick);
473
+ }),
474
+ );
386
475
 
387
- // Allow async renders (portals, modals, lazy components) to settle
388
- await page.waitForFunction(() => new Promise(resolve => requestAnimationFrame(() => resolve(true))));
476
+ // Final stabilization delay for layout shifts
477
+ await page.waitForTimeout(200);
389
478
 
390
479
  await expect(page).toHaveScreenshot(
391
480
  [story.title, \`\${story.id}.png\`],
@@ -652,6 +741,21 @@ function filterStories(storyIndex, config) {
652
741
  }
653
742
  return { ...storyIndex, entries };
654
743
  }
744
+ function excludeStoriesForBrowser(storyIndex, excludePatterns) {
745
+ if (excludePatterns.length === 0) {
746
+ return storyIndex;
747
+ }
748
+ const excludeMatchers = excludePatterns.map((p) => picomatch2(p));
749
+ const entries = {};
750
+ for (const [id, story] of Object.entries(storyIndex.entries)) {
751
+ const fullName = `${story.title}/${story.name}`;
752
+ const isExcluded = excludeMatchers.some((m) => m(fullName));
753
+ if (!isExcluded) {
754
+ entries[id] = story;
755
+ }
756
+ }
757
+ return { ...storyIndex, entries };
758
+ }
655
759
 
656
760
  // src/core/engine.ts
657
761
  var STORIES_PER_FILE = 50;
@@ -706,18 +810,51 @@ async function runTests(config, options = {}, cwd = process.cwd()) {
706
810
  logger.info(`${Object.keys(targetStories.entries).length} stories affected by changes`);
707
811
  }
708
812
  await baselinePromise;
709
- const chunks = chunkStories(targetStories.entries);
710
- const testFilePattern = chunks.length === 1 ? "storywright-0.spec.ts" : "storywright-*.spec.ts";
711
- for (let i = 0; i < chunks.length; i++) {
712
- const chunkIndex = { ...targetStories, entries: chunks[i] };
713
- const chunkPath = path5.join(tmpDir, `target-stories-${i}.json`);
714
- await fs4.writeFile(chunkPath, JSON.stringify(chunkIndex));
715
- const testContent = generateTestFile(config.screenshot, {
716
- targetStoriesPath: chunkPath.replace(/\\/g, "/")
717
- });
718
- await fs4.writeFile(path5.join(tmpDir, `storywright-${i}.spec.ts`), testContent);
813
+ let testFilePattern;
814
+ let testMatchByBrowser;
815
+ const browserExcludesExist = config.browsers.some(
816
+ (b) => (config.browserOptions[b]?.exclude ?? []).length > 0
817
+ );
818
+ if (browserExcludesExist) {
819
+ testMatchByBrowser = {};
820
+ for (const browser of config.browsers) {
821
+ const browserExclude = config.browserOptions[browser]?.exclude ?? [];
822
+ const browserStories = excludeStoriesForBrowser(targetStories, browserExclude);
823
+ if (Object.keys(browserStories.entries).length === 0) {
824
+ logger.warn(
825
+ `${browser}: All stories excluded by browser-specific 'exclude' patterns. No tests will run for this browser.`
826
+ );
827
+ }
828
+ const browserChunks = chunkStories(browserStories.entries);
829
+ testMatchByBrowser[browser] = browserChunks.length === 1 ? `storywright-${browser}-0.spec.ts` : `storywright-${browser}-*.spec.ts`;
830
+ for (let i = 0; i < browserChunks.length; i++) {
831
+ const chunkIndex = { ...browserStories, entries: browserChunks[i] };
832
+ const chunkPath = path5.join(tmpDir, `target-stories-${browser}-${i}.json`);
833
+ await fs4.writeFile(chunkPath, JSON.stringify(chunkIndex));
834
+ const testContent = generateTestFile(config.screenshot, {
835
+ targetStoriesPath: chunkPath.replace(/\\/g, "/")
836
+ });
837
+ await fs4.writeFile(path5.join(tmpDir, `storywright-${browser}-${i}.spec.ts`), testContent);
838
+ }
839
+ logger.info(
840
+ `${browser}: ${Object.keys(browserStories.entries).length} stories, ${browserChunks.length} test file(s)`
841
+ );
842
+ }
843
+ testFilePattern = "storywright-*.spec.ts";
844
+ } else {
845
+ const chunks = chunkStories(targetStories.entries);
846
+ testFilePattern = chunks.length === 1 ? "storywright-0.spec.ts" : "storywright-*.spec.ts";
847
+ for (let i = 0; i < chunks.length; i++) {
848
+ const chunkIndex = { ...targetStories, entries: chunks[i] };
849
+ const chunkPath = path5.join(tmpDir, `target-stories-${i}.json`);
850
+ await fs4.writeFile(chunkPath, JSON.stringify(chunkIndex));
851
+ const testContent = generateTestFile(config.screenshot, {
852
+ targetStoriesPath: chunkPath.replace(/\\/g, "/")
853
+ });
854
+ await fs4.writeFile(path5.join(tmpDir, `storywright-${i}.spec.ts`), testContent);
855
+ }
856
+ logger.info(`${chunks.length} test file(s) generated`);
719
857
  }
720
- logger.info(`${chunks.length} test file(s) generated`);
721
858
  const reporterWrapperPath = path5.join(tmpDir, "reporter.mjs");
722
859
  const resolvedReporterPath = resolveReporterPath().replace(/\\/g, "/");
723
860
  const reporterOutputDir = reportDir.replace(/\\/g, "/");
@@ -740,6 +877,7 @@ export default class extends StorywrightReporter {
740
877
  snapshotDir: snapshotDir.replace(/\\/g, "/"),
741
878
  reporterPath: reporterWrapperPath.replace(/\\/g, "/"),
742
879
  testMatch: testFilePattern,
880
+ testMatchByBrowser,
743
881
  shard: options.shard,
744
882
  reporters: options.reporters
745
883
  });
@@ -834,4 +972,4 @@ export {
834
972
  runTests,
835
973
  updateBaselines
836
974
  };
837
- //# sourceMappingURL=chunk-XVHJJ6NP.js.map
975
+ //# sourceMappingURL=chunk-XYP273ZX.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/config/index.ts","../src/config/defaults.ts","../src/config/types.ts","../src/reporter/cli-reporter.ts","../src/storage/local.ts","../src/storage/index.ts","../src/utils/logger.ts","../src/core/engine.ts","../src/playwright/config-generator.ts","../src/playwright/test-generator.ts","../src/resolver/index.ts","../src/utils/path.ts","../src/utils/process.ts","../src/core/storybook.ts"],"sourcesContent":["import { loadConfig as unconfigLoad } from 'unconfig';\nimport { DEFAULT_CONFIG } from './defaults.js';\nimport { STANDARD_BROWSERS } from './types.js';\nimport type { DeepPartial, StorywrightConfig } from './types.js';\n\nexport function defineConfig(\n\tconfig: DeepPartial<StorywrightConfig>,\n): DeepPartial<StorywrightConfig> {\n\treturn config;\n}\n\nfunction isPlainObject(value: unknown): value is Record<string, unknown> {\n\treturn value !== null && typeof value === 'object' && !Array.isArray(value);\n}\n\nfunction deepMerge(\n\ttarget: Record<string, unknown>,\n\tsource: Record<string, unknown>,\n): Record<string, unknown> {\n\tconst result: Record<string, unknown> = { ...target };\n\tfor (const key of Object.keys(source)) {\n\t\tconst sourceVal = source[key];\n\t\tconst targetVal = result[key];\n\t\tif (isPlainObject(sourceVal) && isPlainObject(targetVal)) {\n\t\t\tresult[key] = deepMerge(targetVal, sourceVal);\n\t\t} else if (sourceVal !== undefined) {\n\t\t\tresult[key] = sourceVal;\n\t\t}\n\t}\n\treturn result;\n}\n\nexport async function loadConfig(\n\tcwd: string = process.cwd(),\n\toverrides?: DeepPartial<StorywrightConfig>,\n): Promise<StorywrightConfig> {\n\tconst { config: userConfig } = await unconfigLoad<DeepPartial<StorywrightConfig>>({\n\t\tsources: [\n\t\t\t{\n\t\t\t\tfiles: 'storywright.config',\n\t\t\t\textensions: ['ts', 'js', 'mjs'],\n\t\t\t},\n\t\t],\n\t\tcwd,\n\t});\n\n\tlet merged = DEFAULT_CONFIG as unknown as Record<string, unknown>;\n\tif (userConfig) {\n\t\tmerged = deepMerge(merged, userConfig as Record<string, unknown>);\n\t}\n\tif (overrides) {\n\t\tmerged = deepMerge(merged, overrides as Record<string, unknown>);\n\t}\n\tconst result = merged as unknown as StorywrightConfig;\n\tvalidateConfig(result);\n\treturn result;\n}\n\nfunction validateConfig(config: StorywrightConfig): void {\n\tfor (const browser of config.browsers) {\n\t\tconst options = config.browserOptions[browser];\n\n\t\tif (!STANDARD_BROWSERS.has(browser) && !options?.browserName) {\n\t\t\tthrow new Error(\n\t\t\t\t`Custom browser project '${browser}' requires 'browserName' in browserOptions.\\nExample:\\n browserOptions: {\\n '${browser}': { browserName: 'webkit', ... }\\n }\\nValid browserName values: 'chromium', 'firefox', 'webkit'.\\n\\nError code: SW_E_MISSING_BROWSER_NAME`,\n\t\t\t);\n\t\t}\n\n\t\tif (options?.browserName && !STANDARD_BROWSERS.has(options.browserName)) {\n\t\t\tthrow new Error(\n\t\t\t\t`Invalid browserName '${options.browserName}' for browser project '${browser}'.\\nValid values: 'chromium', 'firefox', 'webkit'.\\n\\nError code: SW_E_INVALID_BROWSER_NAME`,\n\t\t\t);\n\t\t}\n\t}\n}\n\nexport type { StorywrightConfig, DeepPartial } from './types.js';\n","import type { StorywrightConfig } from './types.js';\n\nexport const DEFAULT_CONFIG: StorywrightConfig = {\n\tstorybook: {\n\t\tstaticDir: 'storybook-static',\n\t\tbuildCommand: 'npx storybook build --stats-json',\n\t\turl: undefined,\n\t\tcompatibility: 'auto',\n\t},\n\n\tbrowsers: ['chromium'],\n\tbrowserOptions: {},\n\n\tscreenshot: {\n\t\tfullPage: true,\n\t\tanimations: 'disabled',\n\t\tthreshold: 0.02,\n\t\tmaxDiffPixelRatio: 0.02,\n\t\tfreezeTime: '2024-01-01T00:00:00',\n\t\ttimezone: 'UTC',\n\t\tlocale: 'en-US',\n\t\tseed: 1,\n\t},\n\n\tdiffDetection: {\n\t\tenabled: true,\n\t\twatchFiles: ['package.json', 'package-lock.json', '.storybook/**/*'],\n\t\tbaseBranch: 'main',\n\t},\n\n\tstorage: {\n\t\tprovider: 'local',\n\t\tlocal: {\n\t\t\tbaselineDir: '.storywright/baselines',\n\t\t},\n\t\ts3: {\n\t\t\tbucket: '',\n\t\t\tprefix: 'storywright/baselines',\n\t\t\tregion: 'ap-northeast-1',\n\t\t\tcompression: 'zstd',\n\t\t},\n\t},\n\n\treport: {\n\t\toutputDir: '.storywright/report',\n\t\ttitle: 'Storywright Report',\n\t},\n\n\tworkers: 'auto',\n\tretries: 0,\n\n\ttimeout: {\n\t\ttest: 30000,\n\t\tnavigation: 20000,\n\t\texpect: 10000,\n\t},\n\n\tinclude: ['**'],\n\texclude: [],\n\n\thooks: {},\n};\n","import type { Page } from '@playwright/test';\n\nexport interface StorywrightConfig {\n\tstorybook: StorybookConfig;\n\tbrowsers: BrowserName[];\n\tbrowserOptions: Record<string, BrowserOption>;\n\tscreenshot: ScreenshotConfig;\n\tdiffDetection: DiffDetectionConfig;\n\tstorage: StorageConfig;\n\treport: ReportConfig;\n\tworkers: number | 'auto';\n\tretries: number;\n\ttimeout: TimeoutConfig;\n\tinclude: string[];\n\texclude: string[];\n\thooks: HooksConfig;\n}\n\nexport type BrowserName = 'chromium' | 'firefox' | 'webkit' | (string & {});\n\nexport type PlaywrightBrowserName = 'chromium' | 'firefox' | 'webkit';\n\nexport const STANDARD_BROWSERS: ReadonlySet<string> = new Set<PlaywrightBrowserName>([\n\t'chromium',\n\t'firefox',\n\t'webkit',\n]);\n\nexport interface BrowserOption {\n\tbrowserName?: PlaywrightBrowserName;\n\tviewport?: { width: number; height: number };\n\tdeviceScaleFactor?: number;\n\tisMobile?: boolean;\n\thasTouch?: boolean;\n\tuserAgent?: string;\n\texclude?: string[];\n}\n\nexport interface StorybookConfig {\n\tstaticDir: string;\n\tbuildCommand: string;\n\turl?: string;\n\tcompatibility: 'auto' | 'v8';\n}\n\nexport interface ScreenshotConfig {\n\tfullPage: boolean;\n\tanimations: 'disabled' | 'allow';\n\tthreshold: number;\n\tmaxDiffPixelRatio: number;\n\tfreezeTime: string;\n\ttimezone: string;\n\tlocale: string;\n\tseed: number;\n}\n\nexport interface DiffDetectionConfig {\n\tenabled: boolean;\n\twatchFiles: string[];\n\tbaseBranch: string;\n}\n\nexport interface StorageConfig {\n\tprovider: 'local' | 's3';\n\tlocal: LocalStorageConfig;\n\ts3: S3StorageConfig;\n}\n\nexport interface LocalStorageConfig {\n\tbaselineDir: string;\n}\n\nexport interface S3StorageConfig {\n\tbucket: string;\n\tprefix: string;\n\tregion: string;\n\tcompression: 'zstd' | 'gzip' | 'none';\n}\n\nexport interface ReportConfig {\n\toutputDir: string;\n\ttitle: string;\n}\n\nexport interface TimeoutConfig {\n\ttest: number;\n\tnavigation: number;\n\texpect: number;\n}\n\nexport interface StoryContext {\n\tid: string;\n\ttitle: string;\n\tname: string;\n}\n\nexport interface HooksConfig {\n\tbeforeScreenshot?: (page: Page, story: StoryContext) => Promise<void>;\n\tafterScreenshot?: (page: Page, story: StoryContext) => Promise<void>;\n}\n\nexport type DeepPartial<T> = {\n\t[P in keyof T]?: T[P] extends object ? DeepPartial<T[P]> : T[P];\n};\n","import type { TestSummary } from '../core/types.js';\n\nexport function formatSummary(summary: TestSummary, options?: { reportPath?: string }): string {\n\tconst durationSec = Math.round(summary.duration / 1000);\n\tconst minutes = Math.floor(durationSec / 60);\n\tconst seconds = durationSec % 60;\n\tconst durationStr = minutes > 0 ? `${minutes}m ${seconds}s` : `${seconds}s`;\n\n\tconst lines: string[] = [\n\t\t'',\n\t\t'Storywright Results',\n\t\t'\\u2550'.repeat(42),\n\t\t` Total: ${summary.total} Passed: ${summary.passed} Failed: ${summary.failed} Skipped: ${summary.skipped}`,\n\t\t` Duration: ${durationStr}`,\n\t\t` Browsers: ${summary.browsers.join(', ')}`,\n\t];\n\n\tconst newFailures = summary.failures.filter((f) => f.type === 'new');\n\tconst diffFailures = summary.failures.filter((f) => f.type !== 'new');\n\n\tif (newFailures.length > 0) {\n\t\tlines.push('');\n\t\tlines.push(' New (no baseline):');\n\t\tfor (const failure of newFailures) {\n\t\t\tlines.push(` \\u25cb ${failure.story}: ${failure.variant} (${failure.browser})`);\n\t\t}\n\t}\n\n\tif (diffFailures.length > 0) {\n\t\tlines.push('');\n\t\tlines.push(' Failed:');\n\t\tfor (const failure of diffFailures) {\n\t\t\tlines.push(` \\u2717 ${failure.story}: ${failure.variant} (${failure.browser})`);\n\t\t\tif (failure.diffRatio > 0) {\n\t\t\t\tconst pct = (failure.diffRatio * 100).toFixed(1);\n\t\t\t\tlines.push(` \\u2192 Diff: ${pct}% pixels changed`);\n\t\t\t}\n\t\t}\n\t}\n\n\tconst reportPath = options?.reportPath ?? '.storywright/report/index.html';\n\tlines.push('');\n\tlines.push(` Report: ${reportPath}`);\n\tlines.push('\\u2550'.repeat(42));\n\tlines.push('');\n\n\treturn lines.join('\\n');\n}\n","import { execFile } from 'node:child_process';\nimport fs from 'node:fs/promises';\nimport path from 'node:path';\nimport { promisify } from 'node:util';\nimport type { DownloadOptions, StorageAdapter, UploadOptions } from './types.js';\n\nconst execFileAsync = promisify(execFile);\n\nexport class LocalStorageAdapter implements StorageAdapter {\n\tconstructor(private readonly baselineDir: string) {}\n\n\tasync download(options: DownloadOptions): Promise<void> {\n\t\ttry {\n\t\t\tawait fs.access(this.baselineDir);\n\t\t} catch {\n\t\t\treturn;\n\t\t}\n\t\tawait fs.cp(this.baselineDir, options.destDir, { recursive: true });\n\t}\n\n\tasync upload(options: UploadOptions): Promise<void> {\n\t\tconst resolvedSource = path.resolve(options.sourceDir);\n\t\tconst resolvedDest = path.resolve(this.baselineDir);\n\t\tif (resolvedSource === resolvedDest) {\n\t\t\treturn;\n\t\t}\n\t\tawait fs.mkdir(this.baselineDir, { recursive: true });\n\t\tawait fs.cp(options.sourceDir, this.baselineDir, { recursive: true });\n\t}\n\n\tasync exists(_branch: string): Promise<boolean> {\n\t\ttry {\n\t\t\tawait fs.access(this.baselineDir);\n\t\t\tconst entries = await fs.readdir(this.baselineDir);\n\t\t\treturn entries.length > 0;\n\t\t} catch {\n\t\t\treturn false;\n\t\t}\n\t}\n\n\t/**\n\t * Extract baselines from a git branch using `git ls-tree` + `git show`.\n\t * Binary-safe (PNG files) via `encoding: 'buffer'`.\n\t */\n\tasync downloadFromGit(branch: string, destDir: string, cwd: string): Promise<void> {\n\t\tconst gitPath = this.baselineDir.split(path.sep).join('/');\n\n\t\tlet lsOutput: string;\n\t\ttry {\n\t\t\tconst result = await execFileAsync(\n\t\t\t\t'git',\n\t\t\t\t['ls-tree', '-r', '--name-only', branch, '--', gitPath],\n\t\t\t\t{ cwd },\n\t\t\t);\n\t\t\tlsOutput = result.stdout;\n\t\t} catch (error) {\n\t\t\tthrow new Error(\n\t\t\t\t`Failed to list baselines from git branch '${branch}': ${error instanceof Error ? error.message : error}`,\n\t\t\t);\n\t\t}\n\n\t\tconst files = lsOutput.trim().split('\\n').filter(Boolean);\n\t\tif (files.length === 0) {\n\t\t\treturn;\n\t\t}\n\n\t\tawait fs.mkdir(destDir, { recursive: true });\n\n\t\tconst posixBaselineDir = this.baselineDir.split(path.sep).join('/').replace(/\\/+$/, '');\n\n\t\tfor (const file of files) {\n\t\t\tlet content: Buffer;\n\t\t\ttry {\n\t\t\t\tconst result = await execFileAsync('git', ['show', `${branch}:${file}`], {\n\t\t\t\t\tcwd,\n\t\t\t\t\tencoding: 'buffer' as unknown as BufferEncoding,\n\t\t\t\t\tmaxBuffer: 50 * 1024 * 1024,\n\t\t\t\t});\n\t\t\t\tcontent = result.stdout as unknown as Buffer;\n\t\t\t} catch (error) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Failed to extract '${file}' from git branch '${branch}': ${error instanceof Error ? error.message : error}`,\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tconst relativePath = file.slice(posixBaselineDir.length + 1);\n\t\t\tconst destPath = path.join(destDir, ...relativePath.split('/'));\n\t\t\tawait fs.mkdir(path.dirname(destPath), { recursive: true });\n\t\t\tawait fs.writeFile(destPath, content);\n\t\t}\n\t}\n}\n","import { createRequire } from 'node:module';\nimport type { StorageConfig } from '../config/types.js';\nimport { LocalStorageAdapter } from './local.js';\nimport type { StorageAdapter } from './types.js';\n\nexport function createStorageAdapter(config: StorageConfig): StorageAdapter {\n\tswitch (config.provider) {\n\t\tcase 'local':\n\t\t\treturn new LocalStorageAdapter(config.local.baselineDir);\n\t\tcase 's3':\n\t\t\treturn loadS3Adapter(config);\n\t\tdefault:\n\t\t\tthrow new Error(`Unknown storage provider: ${config.provider}`);\n\t}\n}\n\nfunction loadS3Adapter(config: StorageConfig): StorageAdapter {\n\ttry {\n\t\tconst require = createRequire(import.meta.url);\n\t\tconst { S3StorageAdapter } = require('@storywright/storage-s3') as {\n\t\t\tS3StorageAdapter: new (cfg: {\n\t\t\t\tbucket: string;\n\t\t\t\tprefix: string;\n\t\t\t\tregion: string;\n\t\t\t\tcompression?: string;\n\t\t\t}) => StorageAdapter;\n\t\t};\n\t\treturn new S3StorageAdapter(config.s3);\n\t} catch {\n\t\tthrow new Error(\n\t\t\t'S3 storage adapter requires the @storywright/storage-s3 package.\\nInstall it with: pnpm add @storywright/storage-s3',\n\t\t);\n\t}\n}\n\nexport type { StorageAdapter, DownloadOptions, UploadOptions } from './types.js';\n","import { createConsola } from 'consola';\n\nconst isCI = !!(\n\tprocess.env.CI ||\n\tprocess.env.GITHUB_ACTIONS ||\n\tprocess.env.CIRCLECI ||\n\tprocess.env.GITLAB_CI\n);\n\nexport const logger = createConsola({\n\tlevel: process.env.STORYWRIGHT_DEBUG ? 5 : 3,\n});\n\nexport { isCI };\n","import fs from 'node:fs/promises';\nimport path from 'node:path';\nimport picomatch from 'picomatch';\nimport type { StorywrightConfig } from '../config/types.js';\nimport { generatePlaywrightConfig } from '../playwright/config-generator.js';\nimport { generateTestFile } from '../playwright/test-generator.js';\nimport { resolveAffectedStories } from '../resolver/index.js';\nimport { createStorageAdapter } from '../storage/index.js';\nimport { logger } from '../utils/logger.js';\nimport { resolveOutputDir } from '../utils/path.js';\nimport { exec } from '../utils/process.js';\nimport {\n\tbuildStorybook,\n\tdiscoverStories,\n\texcludeStoriesForBrowser,\n\tfilterStories,\n} from './storybook.js';\nimport type { Story, StoryIndex, TestSummary } from './types.js';\n\nexport interface TestOptions {\n\tdiffOnly?: boolean;\n\tshard?: string;\n\tupdateSnapshots?: boolean;\n\tfilter?: string;\n\toutputDir?: string;\n\treporters?: string[];\n}\n\nexport interface TestRunResult {\n\texitCode: number;\n\tsummary?: TestSummary;\n\treportDir?: string;\n\tsnapshotDir?: string;\n}\n\nconst STORIES_PER_FILE = 50;\n\nfunction resolveReporterPath(): string {\n\t// Resolve relative to this file's dist location\n\tconst thisDir = new URL('.', import.meta.url).pathname;\n\treturn path.resolve(thisDir, 'playwright', 'reporter.js');\n}\n\nfunction chunkStories(entries: Record<string, Story>): Record<string, Story>[] {\n\tconst keys = Object.keys(entries);\n\tif (keys.length === 0) return [{}];\n\tconst chunks: Record<string, Story>[] = [];\n\tfor (let i = 0; i < keys.length; i += STORIES_PER_FILE) {\n\t\tconst chunk: Record<string, Story> = {};\n\t\tfor (const key of keys.slice(i, i + STORIES_PER_FILE)) {\n\t\t\tchunk[key] = entries[key];\n\t\t}\n\t\tchunks.push(chunk);\n\t}\n\treturn chunks;\n}\n\nexport async function runTests(\n\tconfig: StorywrightConfig,\n\toptions: TestOptions = {},\n\tcwd: string = process.cwd(),\n): Promise<TestRunResult> {\n\tconst outputRoot = options.outputDir\n\t\t? path.resolve(cwd, options.outputDir)\n\t\t: resolveOutputDir(cwd, '.storywright');\n\tconst tmpDir = path.join(outputRoot, 'tmp');\n\tconst reportDir = options.outputDir\n\t\t? path.join(outputRoot, 'report')\n\t\t: path.resolve(cwd, config.report.outputDir);\n\tconst storybookDir = path.resolve(cwd, config.storybook.staticDir);\n\tconst snapshotDir = path.join(tmpDir, 'snapshots');\n\n\t// Prepare directories early for parallel operations\n\tawait fs.mkdir(snapshotDir, { recursive: true });\n\n\t// Start baseline download in parallel with Storybook build\n\tconst storage = createStorageAdapter(config.storage);\n\tconst baselinePromise = storage\n\t\t.download({ branch: 'current', destDir: snapshotDir })\n\t\t.catch(() => {\n\t\t\tlogger.info('No existing baselines found');\n\t\t});\n\n\t// 1. Build Storybook if needed\n\tawait buildStorybook(config, cwd);\n\n\t// 2. Discover & filter stories\n\tlogger.start('Discovering stories...');\n\tconst allStories = await discoverStories(config, cwd);\n\tlet targetStories = filterStories(allStories, config);\n\n\t// Apply --filter option\n\tif (options.filter) {\n\t\ttargetStories = applyFilter(targetStories, options.filter);\n\t}\n\n\tlogger.info(`${Object.keys(targetStories.entries).length} stories found`);\n\n\t// 3. Diff-only: resolve affected stories (default in CI)\n\tconst effectiveDiffOnly = options.diffOnly ?? !!process.env.CI;\n\tif (effectiveDiffOnly && config.diffDetection.enabled) {\n\t\tlogger.start('Resolving dependencies...');\n\t\tconst diffResult = await resolveAffectedStories(\n\t\t\ttargetStories,\n\t\t\tconfig.diffDetection,\n\t\t\tstorybookDir,\n\t\t\tcwd,\n\t\t);\n\t\tif (!diffResult.allStories) {\n\t\t\ttargetStories = diffResult.targetStories;\n\t\t}\n\t\tlogger.info(`${Object.keys(targetStories.entries).length} stories affected by changes`);\n\t}\n\n\t// 4. Wait for baseline download to complete\n\tawait baselinePromise;\n\n\t// 5. Generate split test files for better worker distribution\n\tlet testFilePattern: string;\n\tlet testMatchByBrowser: Record<string, string> | undefined;\n\n\tconst browserExcludesExist = config.browsers.some(\n\t\t(b) => (config.browserOptions[b]?.exclude ?? []).length > 0,\n\t);\n\n\tif (browserExcludesExist) {\n\t\t// Generate per-browser test files when any browser has specific excludes\n\t\ttestMatchByBrowser = {};\n\n\t\tfor (const browser of config.browsers) {\n\t\t\tconst browserExclude = config.browserOptions[browser]?.exclude ?? [];\n\t\t\tconst browserStories = excludeStoriesForBrowser(targetStories, browserExclude);\n\n\t\t\tif (Object.keys(browserStories.entries).length === 0) {\n\t\t\t\tlogger.warn(\n\t\t\t\t\t`${browser}: All stories excluded by browser-specific 'exclude' patterns. No tests will run for this browser.`,\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tconst browserChunks = chunkStories(browserStories.entries);\n\n\t\t\ttestMatchByBrowser[browser] =\n\t\t\t\tbrowserChunks.length === 1\n\t\t\t\t\t? `storywright-${browser}-0.spec.ts`\n\t\t\t\t\t: `storywright-${browser}-*.spec.ts`;\n\n\t\t\tfor (let i = 0; i < browserChunks.length; i++) {\n\t\t\t\tconst chunkIndex: StoryIndex = { ...browserStories, entries: browserChunks[i] };\n\t\t\t\tconst chunkPath = path.join(tmpDir, `target-stories-${browser}-${i}.json`);\n\t\t\t\tawait fs.writeFile(chunkPath, JSON.stringify(chunkIndex));\n\n\t\t\t\tconst testContent = generateTestFile(config.screenshot, {\n\t\t\t\t\ttargetStoriesPath: chunkPath.replace(/\\\\/g, '/'),\n\t\t\t\t});\n\t\t\t\tawait fs.writeFile(path.join(tmpDir, `storywright-${browser}-${i}.spec.ts`), testContent);\n\t\t\t}\n\n\t\t\tlogger.info(\n\t\t\t\t`${browser}: ${Object.keys(browserStories.entries).length} stories, ${browserChunks.length} test file(s)`,\n\t\t\t);\n\t\t}\n\n\t\ttestFilePattern = 'storywright-*.spec.ts';\n\t} else {\n\t\t// Default: shared test files for all browsers\n\t\tconst chunks = chunkStories(targetStories.entries);\n\t\ttestFilePattern = chunks.length === 1 ? 'storywright-0.spec.ts' : 'storywright-*.spec.ts';\n\n\t\tfor (let i = 0; i < chunks.length; i++) {\n\t\t\tconst chunkIndex: StoryIndex = { ...targetStories, entries: chunks[i] };\n\t\t\tconst chunkPath = path.join(tmpDir, `target-stories-${i}.json`);\n\t\t\tawait fs.writeFile(chunkPath, JSON.stringify(chunkIndex));\n\n\t\t\tconst testContent = generateTestFile(config.screenshot, {\n\t\t\t\ttargetStoriesPath: chunkPath.replace(/\\\\/g, '/'),\n\t\t\t});\n\t\t\tawait fs.writeFile(path.join(tmpDir, `storywright-${i}.spec.ts`), testContent);\n\t\t}\n\n\t\tlogger.info(`${chunks.length} test file(s) generated`);\n\t}\n\n\t// 6. Generate Playwright config\n\tconst reporterWrapperPath = path.join(tmpDir, 'reporter.mjs');\n\tconst resolvedReporterPath = resolveReporterPath().replace(/\\\\/g, '/');\n\tconst reporterOutputDir = reportDir.replace(/\\\\/g, '/');\n\n\tawait fs.writeFile(\n\t\treporterWrapperPath,\n\t\t`import StorywrightReporter from '${resolvedReporterPath}';\\nexport default class extends StorywrightReporter {\\n constructor() { super({ outputDir: '${reporterOutputDir}' }); }\\n}\\n`,\n\t);\n\n\t// Determine Storybook URL\n\tlet actualStorybookUrl = config.storybook.url;\n\tconst needsServer = !actualStorybookUrl;\n\n\tif (needsServer) {\n\t\tactualStorybookUrl = 'http://localhost:6007';\n\t}\n\n\tconst playwrightConfig = generatePlaywrightConfig(config, {\n\t\ttmpDir: tmpDir.replace(/\\\\/g, '/'),\n\t\tstorybookUrl: actualStorybookUrl ?? 'http://localhost:6007',\n\t\tsnapshotDir: snapshotDir.replace(/\\\\/g, '/'),\n\t\treporterPath: reporterWrapperPath.replace(/\\\\/g, '/'),\n\t\ttestMatch: testFilePattern,\n\t\ttestMatchByBrowser,\n\t\tshard: options.shard,\n\t\treporters: options.reporters,\n\t});\n\n\tconst configPath = path.join(tmpDir, 'playwright.config.ts');\n\tawait fs.writeFile(configPath, playwrightConfig);\n\n\t// 7. Run Playwright tests\n\tlogger.start('Running tests...');\n\tconst args = ['playwright', 'test', '--config', configPath];\n\n\tif (options.updateSnapshots) {\n\t\targs.push('--update-snapshots');\n\t}\n\n\t// Start static server if needed\n\tlet serverProc: { kill: () => void } | undefined;\n\tif (needsServer) {\n\t\tserverProc = await startStaticServer(storybookDir, 6007);\n\t}\n\n\ttry {\n\t\tconst result = await exec('npx', args, { cwd, inherit: true });\n\n\t\t// 8. Read results\n\t\tlet summary: TestSummary | undefined;\n\t\ttry {\n\t\t\tconst summaryPath = path.join(reportDir, 'summary.json');\n\t\t\tconst summaryContent = await fs.readFile(summaryPath, 'utf-8');\n\t\t\tsummary = JSON.parse(summaryContent);\n\t\t} catch {\n\t\t\t// summary may not exist if no tests ran\n\t\t}\n\n\t\t// 9. Map exit codes per SPEC §14.2\n\t\tconst exitCode = mapExitCode(result.exitCode, summary);\n\n\t\treturn { exitCode, summary, reportDir, snapshotDir };\n\t} finally {\n\t\tserverProc?.kill();\n\t}\n}\n\nexport async function updateBaselines(\n\tconfig: StorywrightConfig,\n\toptions: { all?: boolean; upload?: boolean } = {},\n\tcwd: string = process.cwd(),\n): Promise<void> {\n\tconst result = await runTests(config, { updateSnapshots: true, diffOnly: !options.all }, cwd);\n\n\tif (result.exitCode !== 0) {\n\t\tlogger.warn('Some tests failed during baseline update');\n\t}\n\n\t// Save updated snapshots back to baselineDir (local disk operation)\n\tif (result.snapshotDir) {\n\t\tconst baselineDir = path.resolve(cwd, config.storage.local.baselineDir);\n\t\tawait fs.mkdir(baselineDir, { recursive: true });\n\t\tawait fs.cp(result.snapshotDir, baselineDir, { recursive: true });\n\t\tlogger.success(`Baselines saved to ${config.storage.local.baselineDir}`);\n\t}\n\n\t// --upload: upload to remote storage (S3 etc.) only when explicitly requested\n\tif (options.upload) {\n\t\tconst storage = createStorageAdapter(config.storage);\n\t\tconst baselineDir = path.resolve(cwd, config.storage.local.baselineDir);\n\t\tawait storage.upload({\n\t\t\tbranch: 'current',\n\t\t\tsourceDir: baselineDir,\n\t\t});\n\t\tlogger.success('Baselines uploaded to remote storage');\n\t}\n}\n\nfunction applyFilter(storyIndex: StoryIndex, filter: string): StoryIndex {\n\tconst matcher = picomatch(filter);\n\tconst entries: Record<string, StoryIndex['entries'][string]> = {};\n\tfor (const [id, story] of Object.entries(storyIndex.entries)) {\n\t\tconst fullName = `${story.title}/${story.name}`;\n\t\tif (matcher(fullName) || matcher(story.title) || matcher(story.id)) {\n\t\t\tentries[id] = story;\n\t\t}\n\t}\n\treturn { ...storyIndex, entries };\n}\n\nfunction mapExitCode(playwrightCode: number, summary?: TestSummary): number {\n\t// SPEC §14.2: 0 = success (no diff), 1 = success (diff found), 2 = execution error, 130 = SIGINT\n\tif (playwrightCode === 130 || playwrightCode === 143) {\n\t\treturn 130; // SIGINT / SIGTERM\n\t}\n\tif (summary) {\n\t\tif (summary.failed > 0) return 1;\n\t\tif (summary.total === 0 && playwrightCode !== 0) return 2;\n\t\treturn 0;\n\t}\n\t// No summary = likely execution error\n\treturn playwrightCode === 0 ? 0 : 2;\n}\n\nasync function startStaticServer(dir: string, port: number): Promise<{ kill: () => void }> {\n\tconst { createServer } = await import('node:http');\n\tconst sirv = (await import('sirv')).default;\n\n\tconst handler = sirv(dir, { single: false, dev: false });\n\tconst server = createServer(handler);\n\n\tawait new Promise<void>((resolve, reject) => {\n\t\tserver.on('error', reject);\n\t\tserver.listen(port, () => resolve());\n\t});\n\n\treturn { kill: () => server.close() };\n}\n","import { STANDARD_BROWSERS } from '../config/types.js';\nimport type { BrowserOption, StorywrightConfig } from '../config/types.js';\n\nexport function generatePlaywrightConfig(\n\tconfig: StorywrightConfig,\n\toptions: {\n\t\ttmpDir: string;\n\t\tstorybookUrl: string;\n\t\tsnapshotDir: string;\n\t\treporterPath: string;\n\t\ttestMatch: string;\n\t\ttestMatchByBrowser?: Record<string, string>;\n\t\tshard?: string;\n\t\treporters?: string[];\n\t},\n): string {\n\tconst projects = config.browsers.map((browser) => {\n\t\tconst rawOptions = config.browserOptions[browser];\n\t\tconst useObj = buildBrowserUseObject(browser, rawOptions);\n\t\tconst useStr = JSON.stringify(useObj, null, '\\t\\t');\n\t\tconst testMatch = options.testMatchByBrowser?.[browser];\n\t\tconst testMatchLine = testMatch ? `\\n\\t\\t\\ttestMatch: '${escapeBackslash(testMatch)}',` : '';\n\t\treturn `\\t\\t{\n\\t\\t\\tname: '${browser}',${testMatchLine}\n\\t\\t\\tuse: ${useStr},\n\\t\\t}`;\n\t});\n\n\tconst workers = config.workers === 'auto' ? \"'100%'\" : String(config.workers);\n\n\tconst shard = options.shard\n\t\t? `\\tshard: { current: ${options.shard.split('/')[0]}, total: ${options.shard.split('/')[1]} },`\n\t\t: '';\n\n\t// Build reporter list: always include custom reporter, plus user-requested ones\n\tconst reporterEntries: string[] = [];\n\tconst requestedReporters = options.reporters ?? ['default', 'html'];\n\tfor (const r of requestedReporters) {\n\t\tif (r === 'default' || r === 'list') {\n\t\t\treporterEntries.push(\"\\t\\t['list']\");\n\t\t} else if (r !== 'html') {\n\t\t\t// Pass through other built-in Playwright reporters (dot, json, junit, etc.)\n\t\t\treporterEntries.push(`\\t\\t['${r}']`);\n\t\t}\n\t}\n\t// Always include custom storywright reporter\n\treporterEntries.push(`\\t\\t['${escapeBackslash(options.reporterPath)}']`);\n\n\tconst testMatchLine = options.testMatchByBrowser\n\t\t? ''\n\t\t: `\\ttestMatch: '${escapeBackslash(options.testMatch)}',\\n`;\n\n\treturn `import { defineConfig } from '@playwright/test';\n\nexport default defineConfig({\n\\ttestDir: '${escapeBackslash(options.tmpDir)}',\n${testMatchLine}\\tsnapshotDir: '${escapeBackslash(options.snapshotDir)}',\n\\tsnapshotPathTemplate: '{snapshotDir}/{arg}-{projectName}{ext}',\n\\ttimeout: ${config.timeout.test},\n\\texpect: {\n\\t\\ttoHaveScreenshot: {\n\\t\\t\\tmaxDiffPixelRatio: ${config.screenshot.maxDiffPixelRatio},\n\\t\\t\\tthreshold: ${config.screenshot.threshold},\n\\t\\t},\n\\t\\ttimeout: ${config.timeout.expect},\n\\t},\n\\tfullyParallel: true,\n\\tforbidOnly: !!process.env.CI,\n\\tretries: ${config.retries},\n\\tworkers: ${workers},\n${shard}\n\\treporter: [\n${reporterEntries.join(',\\n')}\n\\t],\n\\tuse: {\n\\t\\tbaseURL: '${options.storybookUrl}',\n\\t\\tnavigationTimeout: ${config.timeout.navigation},\n\\t\\ttimezoneId: '${config.screenshot.timezone}',\n\\t\\tlocale: '${config.screenshot.locale}',\n\\t},\n\\tprojects: [\n${projects.join(',\\n')}\n\\t],\n});\n`;\n}\n\nfunction buildBrowserUseObject(\n\tbrowser: string,\n\trawOptions?: BrowserOption,\n): Record<string, unknown> {\n\tlet browserName: string;\n\tif (rawOptions?.browserName) {\n\t\tbrowserName = rawOptions.browserName;\n\t} else if (STANDARD_BROWSERS.has(browser)) {\n\t\tbrowserName = browser;\n\t} else {\n\t\tthrow new Error(\n\t\t\t`Cannot resolve browserName for custom browser project '${browser}'.\\n\\nError code: SW_E_INTERNAL_BROWSER_RESOLVE`,\n\t\t);\n\t}\n\tconst useObj: Record<string, unknown> = { browserName };\n\n\tif (rawOptions) {\n\t\tconst { browserName: _, exclude: __, ...rest } = rawOptions;\n\t\tObject.assign(useObj, rest);\n\t}\n\n\treturn useObj;\n}\n\nfunction escapeBackslash(str: string): string {\n\treturn str.replace(/\\\\/g, '/');\n}\n","import type { ScreenshotConfig } from '../config/types.js';\n\nexport function generateTestFile(\n\tconfig: ScreenshotConfig,\n\toptions: {\n\t\ttargetStoriesPath: string;\n\t},\n): string {\n\tconst disableAnimations = config.animations === 'disabled';\n\n\treturn `import { test, expect } from '@playwright/test';\nimport { readFileSync } from 'node:fs';\n\nconst targetList = JSON.parse(\n\\treadFileSync('${escapeBackslash(options.targetStoriesPath)}', 'utf-8'),\n);\n\ntest.describe.parallel('visual regression testing', () => {\n\\tif (Object.keys(targetList.entries).length === 0) {\n\\t\\ttest('no stories to test', () => {\n\\t\\t\\texpect(true).toBeTruthy();\n\\t\\t});\n\\t}\n\n\\tfor (const story of Object.values(targetList.entries)) {\n\\t\\ttest(\\`\\${story.title}: \\${story.name}\\`, async ({ page }) => {\n\\t\\t\\t// Freeze time for reproducibility\n\\t\\t\\tawait page.clock.install({ time: new Date('${config.freezeTime}') });\n\n\\t\\t\\t// Seed Math.random for reproducibility\n\\t\\t\\tawait page.addInitScript((seed) => {\n\\t\\t\\t\\tlet s = seed;\n\\t\\t\\t\\tMath.random = () => {\n\\t\\t\\t\\t\\ts = (s * 16807 + 0) % 2147483647;\n\\t\\t\\t\\t\\treturn (s - 1) / 2147483646;\n\\t\\t\\t\\t};\n\\t\\t\\t}, ${config.seed});\n\n\\t\\t\\tawait page.goto(\\`/iframe.html?id=\\${story.id}\\`, {\n\\t\\t\\t\\twaitUntil: 'domcontentloaded',\n\\t\\t\\t});\n${\n\tdisableAnimations\n\t\t? `\n\\t\\t\\t// Force-disable all CSS animations and transitions\n\\t\\t\\tawait page.addStyleTag({\n\\t\\t\\t\\tcontent: '*, *::before, *::after { animation-duration: 0s !important; animation-delay: 0s !important; transition-duration: 0s !important; transition-delay: 0s !important; }',\n\\t\\t\\t});\n`\n\t\t: ''\n}\n\\t\\t\\t// Wait for story to render: content inside #storybook-root OR portal content on body\n\\t\\t\\tawait page.waitForFunction(() => {\n\\t\\t\\t\\tconst root = document.getElementById('storybook-root');\n\\t\\t\\t\\tif (!root) return false;\n\\t\\t\\t\\tif (root.childElementCount > 0) return true;\n\\t\\t\\t\\t// Portal: check for elements on body that aren't part of Storybook's skeleton\n\\t\\t\\t\\tfor (const el of document.body.children) {\n\\t\\t\\t\\t\\tif (el.tagName === 'SCRIPT' || el.id === 'storybook-root' || el.id === 'storybook-docs') continue;\n\\t\\t\\t\\t\\treturn true;\n\\t\\t\\t\\t}\n\\t\\t\\t\\treturn false;\n\\t\\t\\t}, { timeout: 10000 });\n\n\\t\\t\\t// Wait for web fonts to finish loading\n\\t\\t\\tawait page.waitForFunction(() => document.fonts.ready);\n\n\\t\\t\\t// Force lazy-loaded images to eager and wait for all images with timeout\n\\t\\t\\tawait page.evaluate(async () => {\n\\t\\t\\t\\tconst lazyImages = document.querySelectorAll('img[loading=\"lazy\"]');\n\\t\\t\\t\\tfor (const img of lazyImages) {\n\\t\\t\\t\\t\\t(img as HTMLImageElement).loading = 'eager';\n\\t\\t\\t\\t}\n\n\\t\\t\\t\\tconst images = Array.from(document.images).filter((img) => !img.complete);\n\\t\\t\\t\\tawait Promise.all(\n\\t\\t\\t\\t\\timages.map(\n\\t\\t\\t\\t\\t\\t(img) =>\n\\t\\t\\t\\t\\t\\t\\tnew Promise<void>((resolve) => {\n\\t\\t\\t\\t\\t\\t\\t\\tconst timeout = setTimeout(resolve, 5000);\n\\t\\t\\t\\t\\t\\t\\t\\timg.onload = img.onerror = () => {\n\\t\\t\\t\\t\\t\\t\\t\\t\\tclearTimeout(timeout);\n\\t\\t\\t\\t\\t\\t\\t\\t\\tresolve();\n\\t\\t\\t\\t\\t\\t\\t\\t};\n\\t\\t\\t\\t\\t\\t\\t}),\n\\t\\t\\t\\t\\t),\n\\t\\t\\t\\t);\n\\t\\t\\t});\n${\n\tdisableAnimations\n\t\t? `\n\\t\\t\\t// Force opacity:1 on images to counteract fade-in effects\n\\t\\t\\tawait page.evaluate(() => {\n\\t\\t\\t\\tdocument.querySelectorAll('img').forEach((img) => {\n\\t\\t\\t\\t\\timg.style.setProperty('opacity', '1', 'important');\n\\t\\t\\t\\t});\n\\t\\t\\t});\n`\n\t\t: ''\n}\n\\t\\t\\t// Allow async renders to settle (multiple animation frames)\n\\t\\t\\tawait page.waitForFunction(\n\\t\\t\\t\\t() =>\n\\t\\t\\t\\t\\tnew Promise((resolve) => {\n\\t\\t\\t\\t\\t\\tlet count = 0;\n\\t\\t\\t\\t\\t\\tconst tick = () => {\n\\t\\t\\t\\t\\t\\t\\tif (++count >= 3) return resolve(true);\n\\t\\t\\t\\t\\t\\t\\trequestAnimationFrame(tick);\n\\t\\t\\t\\t\\t\\t};\n\\t\\t\\t\\t\\t\\trequestAnimationFrame(tick);\n\\t\\t\\t\\t\\t}),\n\\t\\t\\t);\n\n\\t\\t\\t// Final stabilization delay for layout shifts\n\\t\\t\\tawait page.waitForTimeout(200);\n\n\\t\\t\\tawait expect(page).toHaveScreenshot(\n\\t\\t\\t\\t[story.title, \\`\\${story.id}.png\\`],\n\\t\\t\\t\\t{\n\\t\\t\\t\\t\\tanimations: '${config.animations}',\n\\t\\t\\t\\t\\tfullPage: ${config.fullPage},\n\\t\\t\\t\\t\\tthreshold: ${config.threshold},\n\\t\\t\\t\\t\\tmaxDiffPixelRatio: ${config.maxDiffPixelRatio},\n\\t\\t\\t\\t},\n\\t\\t\\t);\n\\t\\t});\n\\t}\n});\n`;\n}\n\nfunction escapeBackslash(str: string): string {\n\treturn str.replace(/\\\\/g, '/');\n}\n","import fs from 'node:fs/promises';\nimport path from 'node:path';\nimport picomatch from 'picomatch';\nimport { simpleGit } from 'simple-git';\nimport type { DiffDetectionConfig } from '../config/types.js';\nimport type { StatsIndex, StatsModule, StoryIndex } from '../core/types.js';\nimport { logger } from '../utils/logger.js';\nimport { normalizePath, stripLeadingDotSlash } from '../utils/path.js';\n\nexport interface DependencyResolver {\n\tgetDependencies(filePath: string): string[];\n\tgetStoriesForFiles(pathList: string[]): StoryIndex;\n}\n\nconst STORY_FILE_PATTERNS = ['.stories.', '.mdx'];\n\nfunction isStoryFile(moduleName: string): boolean {\n\treturn STORY_FILE_PATTERNS.some((p) => moduleName.includes(p));\n}\n\nexport class StorybookStatsDependencyResolver implements DependencyResolver {\n\tprivate moduleMap: Record<string, StatsModule>;\n\n\tconstructor(\n\t\tprivate statsJson: StatsIndex,\n\t\tprivate storiesJson: StoryIndex,\n\t) {\n\t\tthis.moduleMap = {};\n\t\tfor (const mod of statsJson.modules) {\n\t\t\t// Key by normalized name (primary) and normalized id (fallback)\n\t\t\tconst normalizedName = normalizePath(mod.name);\n\t\t\tthis.moduleMap[normalizedName] = mod;\n\t\t\tconst normalizedId = normalizePath(mod.id);\n\t\t\tif (normalizedId !== normalizedName) {\n\t\t\t\tthis.moduleMap[normalizedId] ??= mod;\n\t\t\t}\n\t\t}\n\t}\n\n\tgetDependencies(filePath: string): string[] {\n\t\tconst normalizedPath = normalizePath(filePath);\n\t\tconst dependencies = this.collectDependencies(normalizedPath);\n\n\t\tif (this.moduleMap[normalizedPath]) {\n\t\t\tdependencies.add(normalizedPath);\n\t\t}\n\n\t\treturn [...dependencies];\n\t}\n\n\tgetStoriesForFiles(pathList: string[]): StoryIndex {\n\t\tconst result: StoryIndex = { v: this.storiesJson.v, entries: {} };\n\n\t\tfor (const filePath of pathList) {\n\t\t\t// Finding #2 + #3: lookup via normalized moduleMap (name primary, id fallback)\n\t\t\tconst normalizedPath = normalizePath(filePath);\n\t\t\tconst stats = this.moduleMap[normalizedPath];\n\t\t\tif (!stats) continue;\n\n\t\t\t// Finding #1: collect ALL story reasons, not just first\n\t\t\tconst storyReasons = stats.reasons.filter((r) => isStoryFile(r.moduleName));\n\t\t\tfor (const reason of storyReasons) {\n\t\t\t\tconst normalizedImportPath = normalizePath(reason.moduleName);\n\t\t\t\t// Collect ALL matching story entries per reason\n\t\t\t\tfor (const storyObj of Object.values(this.storiesJson.entries)) {\n\t\t\t\t\tif (storyObj.type !== 'story') continue;\n\t\t\t\t\tif (normalizePath(storyObj.importPath) === normalizedImportPath) {\n\t\t\t\t\t\tresult.entries[storyObj.id] = storyObj;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn result;\n\t}\n\n\tprivate collectDependencies(name: string, result = new Set<string>()): Set<string> {\n\t\tconst mod = this.moduleMap[normalizePath(name)];\n\t\tif (mod) {\n\t\t\tfor (const reason of mod.reasons) {\n\t\t\t\tif (!result.has(reason.moduleName)) {\n\t\t\t\t\tresult.add(reason.moduleName);\n\t\t\t\t\tthis.collectDependencies(reason.moduleName, result);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn result;\n\t}\n}\n\nexport interface DiffResult {\n\tallStories: boolean;\n\ttargetStories: StoryIndex;\n}\n\ninterface DiffFileEntry {\n\tfile: string;\n\tfrom?: string;\n}\n\nexport async function resolveAffectedStories(\n\tstoriesJson: StoryIndex,\n\tconfig: DiffDetectionConfig,\n\tstorybookStaticDir: string,\n\tcwd: string,\n): Promise<DiffResult> {\n\tconst git = simpleGit({ baseDir: cwd });\n\n\t// Get diff summary\n\tlet diffEntries: DiffFileEntry[];\n\ttry {\n\t\tconst mergeBase = await git.raw(['merge-base', config.baseBranch, 'HEAD']);\n\t\tconst diff = await git.diffSummary([mergeBase.trim(), 'HEAD']);\n\t\tdiffEntries = diff.files.map((f) => ({\n\t\t\tfile: f.file,\n\t\t\t// Handle renames: include both old and new paths\n\t\t\tfrom: 'from' in f ? (f as { from: string }).from : undefined,\n\t\t}));\n\t} catch {\n\t\tlogger.warn('Failed to resolve git diff, running all stories');\n\t\treturn { allStories: true, targetStories: storiesJson };\n\t}\n\n\tif (diffEntries.length === 0) {\n\t\tlogger.info('No changed files detected');\n\t\treturn { allStories: false, targetStories: { v: storiesJson.v, entries: {} } };\n\t}\n\n\t// Collect all affected paths (including rename sources)\n\tconst allPaths: string[] = [];\n\tfor (const entry of diffEntries) {\n\t\tallPaths.push(entry.file);\n\t\tif (entry.from) {\n\t\t\tallPaths.push(entry.from);\n\t\t}\n\t}\n\n\t// Check watchFiles\n\tfor (const file of allPaths) {\n\t\tfor (const pattern of config.watchFiles) {\n\t\t\tif (picomatch(pattern)(file)) {\n\t\t\t\tlogger.info(`Watch file changed: ${file}, running all stories`);\n\t\t\t\treturn { allStories: true, targetStories: storiesJson };\n\t\t\t}\n\t\t}\n\t}\n\n\t// Load stats json for dependency resolution\n\tconst statsPath = path.resolve(storybookStaticDir, 'preview-stats.json');\n\tlet statsJson: StatsIndex;\n\ttry {\n\t\tstatsJson = JSON.parse(await fs.readFile(statsPath, 'utf-8'));\n\t} catch {\n\t\tlogger.warn('preview-stats.json not found, running all stories');\n\t\treturn { allStories: true, targetStories: storiesJson };\n\t}\n\n\tconst resolver = new StorybookStatsDependencyResolver(statsJson, storiesJson);\n\tconst targetStories: StoryIndex = { v: storiesJson.v, entries: {} };\n\n\t// Direct story file matches (both .stories.* and .mdx)\n\tfor (const file of allPaths) {\n\t\tconst matchedStories = Object.values(storiesJson.entries).filter(\n\t\t\t(story) => stripLeadingDotSlash(story.importPath) === file,\n\t\t);\n\t\tfor (const story of matchedStories) {\n\t\t\ttargetStories.entries[story.id] = story;\n\t\t}\n\t}\n\n\t// Dependency-based matches\n\tfor (const file of allPaths) {\n\t\tconst deps = resolver.getDependencies(normalizePath(file));\n\t\tconst depStories = resolver.getStoriesForFiles(deps);\n\t\tfor (const [id, story] of Object.entries(depStories.entries)) {\n\t\t\ttargetStories.entries[id] = story;\n\t\t}\n\t}\n\n\tlogger.info(`Resolved ${Object.keys(targetStories.entries).length} affected stories`);\n\treturn { allStories: false, targetStories };\n}\n","import path from 'node:path';\n\nexport function normalizePath(filePath: string): string {\n\tconst normalized = filePath.replace(/\\\\/g, '/');\n\tif (normalized.startsWith('./')) {\n\t\treturn normalized;\n\t}\n\treturn `./${normalized}`;\n}\n\nexport function stripLeadingDotSlash(filePath: string): string {\n\treturn filePath.replace(/^\\.\\//, '');\n}\n\nexport function resolveOutputDir(outputDir: string, ...segments: string[]): string {\n\treturn path.resolve(outputDir, ...segments);\n}\n","import { spawn } from 'node:child_process';\n\nexport interface ExecResult {\n\texitCode: number;\n\tstdout: string;\n\tstderr: string;\n}\n\nexport function exec(\n\tcommand: string,\n\targs: string[],\n\toptions?: { cwd?: string; env?: Record<string, string>; inherit?: boolean },\n): Promise<ExecResult> {\n\treturn new Promise((resolve, reject) => {\n\t\tconst proc = spawn(command, args, {\n\t\t\tcwd: options?.cwd,\n\t\t\tenv: { ...process.env, ...options?.env },\n\t\t\tstdio: options?.inherit ? ['ignore', 'inherit', 'inherit'] : ['ignore', 'pipe', 'pipe'],\n\t\t\tshell: false,\n\t\t});\n\n\t\tlet stdout = '';\n\t\tlet stderr = '';\n\n\t\tif (!options?.inherit) {\n\t\t\tproc.stdout?.on('data', (data: Buffer) => {\n\t\t\t\tstdout += data.toString();\n\t\t\t});\n\n\t\t\tproc.stderr?.on('data', (data: Buffer) => {\n\t\t\t\tstderr += data.toString();\n\t\t\t});\n\t\t}\n\n\t\tproc.on('error', reject);\n\n\t\tproc.on('close', (code) => {\n\t\t\tresolve({ exitCode: code ?? 1, stdout, stderr });\n\t\t});\n\t});\n}\n","import fs from 'node:fs/promises';\nimport path from 'node:path';\nimport picomatch from 'picomatch';\nimport type { StorywrightConfig } from '../config/types.js';\nimport { logger } from '../utils/logger.js';\nimport { exec } from '../utils/process.js';\nimport type { Story, StoryIndex } from './types.js';\n\nexport async function buildStorybook(config: StorywrightConfig, cwd: string): Promise<void> {\n\tif (config.storybook.url) {\n\t\tlogger.info('Using running Storybook at', config.storybook.url);\n\t\treturn;\n\t}\n\n\tconst staticDir = path.resolve(cwd, config.storybook.staticDir);\n\ttry {\n\t\tawait fs.access(path.join(staticDir, 'index.json'));\n\t\tlogger.info('Storybook already built at', staticDir);\n\t\treturn;\n\t} catch {\n\t\t// need to build\n\t}\n\n\tlogger.start('Building Storybook...');\n\tconst [command, ...args] = config.storybook.buildCommand.split(' ');\n\tconst result = await exec(command, args, { cwd });\n\tif (result.exitCode !== 0) {\n\t\tthrow new Error(\n\t\t\t`Storybook build failed (exit code ${result.exitCode}):\\n${result.stderr}\\n\\nError code: SW_E_STORYBOOK_BUILD_FAILED`,\n\t\t);\n\t}\n\tlogger.success('Storybook built');\n}\n\nexport async function discoverStories(config: StorywrightConfig, cwd: string): Promise<StoryIndex> {\n\tconst staticDir = path.resolve(cwd, config.storybook.staticDir);\n\tconst indexPath = path.join(staticDir, 'index.json');\n\n\ttry {\n\t\tawait fs.access(indexPath);\n\t} catch {\n\t\tthrow new Error(\n\t\t\t`Storybook build directory not found at '${config.storybook.staticDir}/'\\n\\n Run one of the following:\\n $ npx storybook build --stats-json\\n $ npx storywright test --storybook-url http://localhost:6006\\n\\n Error code: SW_E_STORYBOOK_DIR_NOT_FOUND`,\n\t\t);\n\t}\n\n\tconst raw = JSON.parse(await fs.readFile(indexPath, 'utf-8'));\n\tconst indexJson = normalizeStoryIndex(raw, config.storybook.compatibility);\n\n\t// Version check\n\tif (indexJson.v < 4) {\n\t\tthrow new Error(\n\t\t\t'Storybook 7.x or earlier is not supported. Storywright requires Storybook 8 or later.\\n\\nError code: SW_E_STORYBOOK_UNSUPPORTED',\n\t\t);\n\t}\n\n\treturn indexJson;\n}\n\n/**\n * Parse Storybook index.json (v8+).\n */\nfunction normalizeStoryIndex(\n\traw: Record<string, unknown>,\n\t_compatibility: 'auto' | 'v8',\n): StoryIndex {\n\tconst version = typeof raw.v === 'number' ? raw.v : 0;\n\tconst entries = (raw.entries ?? {}) as Record<string, Story>;\n\n\treturn { v: version, entries };\n}\n\nexport function filterStories(storyIndex: StoryIndex, config: StorywrightConfig): StoryIndex {\n\tconst entries: Record<string, Story> = {};\n\tconst includeMatchers = config.include.map((p) => picomatch(p));\n\tconst excludeMatchers = config.exclude.map((p) => picomatch(p));\n\n\tfor (const [id, story] of Object.entries(storyIndex.entries)) {\n\t\t// Skip docs entries\n\t\tif (story.type === 'docs') continue;\n\t\tif (story.name === 'Docs') continue;\n\n\t\tconst fullName = `${story.title}/${story.name}`;\n\n\t\t// Check include patterns\n\t\tconst isIncluded = includeMatchers.some((m) => m(fullName));\n\t\tif (!isIncluded) continue;\n\n\t\t// Check exclude patterns\n\t\tconst isExcluded = excludeMatchers.some((m) => m(fullName));\n\t\tif (isExcluded) continue;\n\n\t\tentries[id] = story;\n\t}\n\n\treturn { ...storyIndex, entries };\n}\n\nexport function excludeStoriesForBrowser(\n\tstoryIndex: StoryIndex,\n\texcludePatterns: string[],\n): StoryIndex {\n\tif (excludePatterns.length === 0) {\n\t\treturn storyIndex;\n\t}\n\n\tconst excludeMatchers = excludePatterns.map((p) => picomatch(p));\n\tconst entries: Record<string, Story> = {};\n\n\tfor (const [id, story] of Object.entries(storyIndex.entries)) {\n\t\tconst fullName = `${story.title}/${story.name}`;\n\t\tconst isExcluded = excludeMatchers.some((m) => m(fullName));\n\t\tif (!isExcluded) {\n\t\t\tentries[id] = story;\n\t\t}\n\t}\n\n\treturn { ...storyIndex, entries };\n}\n"],"mappings":";AAAA,SAAS,cAAc,oBAAoB;;;ACEpC,IAAM,iBAAoC;AAAA,EAChD,WAAW;AAAA,IACV,WAAW;AAAA,IACX,cAAc;AAAA,IACd,KAAK;AAAA,IACL,eAAe;AAAA,EAChB;AAAA,EAEA,UAAU,CAAC,UAAU;AAAA,EACrB,gBAAgB,CAAC;AAAA,EAEjB,YAAY;AAAA,IACX,UAAU;AAAA,IACV,YAAY;AAAA,IACZ,WAAW;AAAA,IACX,mBAAmB;AAAA,IACnB,YAAY;AAAA,IACZ,UAAU;AAAA,IACV,QAAQ;AAAA,IACR,MAAM;AAAA,EACP;AAAA,EAEA,eAAe;AAAA,IACd,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AM,MAAM,QAAQ,CAAC;AAAA,EACpC,CAAC;AAED,SAAO,EAAE,MAAM,MAAM,OAAO,MAAM,EAAE;AACrC;","names":["require","fs","path","picomatch","testMatchLine","escapeBackslash","fs","path","path","path","fs","fs","path","picomatch","path","fs","picomatch","path","fs","picomatch"]}
package/dist/cli.js CHANGED
@@ -6,7 +6,7 @@ import {
6
6
  logger,
7
7
  runTests,
8
8
  updateBaselines
9
- } from "./chunk-XVHJJ6NP.js";
9
+ } from "./chunk-XYP273ZX.js";
10
10
  import {
11
11
  generateHtmlReport
12
12
  } from "./chunk-HPK2VJXG.js";
@@ -370,7 +370,7 @@ var uploadCommand = defineCommand6({
370
370
  var main = defineCommand7({
371
371
  meta: {
372
372
  name: "storywright",
373
- version: "0.1.0",
373
+ version: "0.5.0",
374
374
  description: "Zero-config visual regression testing powered by Storybook + Playwright"
375
375
  },
376
376
  subCommands: {
package/dist/cli.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/cli/index.ts","../src/cli/commands/download.ts","../src/cli/commands/init.ts","../src/cli/commands/report.ts","../src/cli/commands/test.ts","../src/cli/commands/update.ts","../src/cli/commands/upload.ts"],"sourcesContent":["import { defineCommand, runMain } from 'citty';\nimport { downloadCommand } from './commands/download.js';\nimport { initCommand } from './commands/init.js';\nimport { reportCommand } from './commands/report.js';\nimport { testCommand } from './commands/test.js';\nimport { updateCommand } from './commands/update.js';\nimport { uploadCommand } from './commands/upload.js';\n\nconst main = defineCommand({\n\tmeta: {\n\t\tname: 'storywright',\n\t\tversion: '0.1.0',\n\t\tdescription: 'Zero-config visual regression testing powered by Storybook + Playwright',\n\t},\n\tsubCommands: {\n\t\ttest: testCommand,\n\t\tupdate: updateCommand,\n\t\tupload: uploadCommand,\n\t\tdownload: downloadCommand,\n\t\treport: reportCommand,\n\t\tinit: initCommand,\n\t},\n});\n\nrunMain(main);\n","import path from 'node:path';\nimport { defineCommand } from 'citty';\nimport { loadConfig } from '../../config/index.js';\nimport { createStorageAdapter } from '../../storage/index.js';\nimport { LocalStorageAdapter } from '../../storage/local.js';\nimport { logger } from '../../utils/logger.js';\n\nexport const downloadCommand = defineCommand({\n\tmeta: {\n\t\tname: 'download',\n\t\tdescription: 'Download baselines from storage',\n\t},\n\targs: {\n\t\tbranch: {\n\t\t\ttype: 'string',\n\t\t\tdescription: 'Branch to download baselines from',\n\t\t\tdefault: 'main',\n\t\t},\n\t},\n\tasync run({ args }) {\n\t\tconst config = await loadConfig();\n\t\tconst storage = createStorageAdapter(config.storage);\n\t\tconst destDir = path.resolve(config.storage.local.baselineDir);\n\t\tconst branch = args.branch ?? 'main';\n\n\t\tif (storage instanceof LocalStorageAdapter) {\n\t\t\tlogger.start(`Extracting baselines from git branch '${branch}'...`);\n\t\t\ttry {\n\t\t\t\tawait storage.downloadFromGit(branch, destDir, process.cwd());\n\t\t\t\tlogger.success('Baselines extracted from git');\n\t\t\t} catch (error) {\n\t\t\t\tlogger.error(String(error));\n\t\t\t\tlogger.info(\n\t\t\t\t\t'Hint: ensure you are in a git repository with sufficient history (fetch-depth: 0)',\n\t\t\t\t);\n\t\t\t\tprocess.exit(2);\n\t\t\t}\n\t\t} else {\n\t\t\tlogger.start(`Downloading baselines from ${branch}...`);\n\t\t\tawait storage.download({ branch, destDir });\n\t\t\tlogger.success('Baselines downloaded');\n\t\t}\n\t},\n});\n","import fs from 'node:fs/promises';\nimport path from 'node:path';\nimport { defineCommand } from 'citty';\nimport { logger } from '../../utils/logger.js';\n\nconst CONFIG_TEMPLATE = `import { defineConfig } from '@storywright/cli';\n\nexport default defineConfig({\n\\t// Storybook settings\n\\tstorybook: {\n\\t\\tstaticDir: 'storybook-static',\n\\t},\n\n\\t// Browsers to test\n\\tbrowsers: ['chromium'],\n\n\\t// Screenshot settings\n\\tscreenshot: {\n\\t\\tfullPage: true,\n\\t\\tanimations: 'disabled',\n\\t\\tthreshold: 0.02,\n\\t\\tmaxDiffPixelRatio: 0.02,\n\\t},\n\n\\t// Storage settings\n\\tstorage: {\n\\t\\tprovider: 'local',\n\\t},\n});\n`;\n\nexport const initCommand = defineCommand({\n\tmeta: {\n\t\tname: 'init',\n\t\tdescription: 'Initialize storywright configuration',\n\t},\n\targs: {},\n\tasync run() {\n\t\tconst configPath = path.resolve('storywright.config.ts');\n\t\ttry {\n\t\t\tawait fs.access(configPath);\n\t\t\tlogger.warn('storywright.config.ts already exists');\n\t\t\treturn;\n\t\t} catch {\n\t\t\t// file doesn't exist, create it\n\t\t}\n\n\t\tawait fs.writeFile(configPath, CONFIG_TEMPLATE);\n\t\tlogger.success('Created storywright.config.ts');\n\n\t\t// Add .storywright temp/report dirs to .gitignore if exists\n\t\t// Note: .storywright/baselines/ should be tracked by git\n\t\tconst gitignorePath = path.resolve('.gitignore');\n\t\ttry {\n\t\t\tconst content = await fs.readFile(gitignorePath, 'utf-8');\n\t\t\tif (!content.includes('.storywright')) {\n\t\t\t\tawait fs.appendFile(\n\t\t\t\t\tgitignorePath,\n\t\t\t\t\t'\\n# Storywright\\n.storywright/tmp/\\n.storywright/report/\\n',\n\t\t\t\t);\n\t\t\t\tlogger.info('Added .storywright/tmp/ and .storywright/report/ to .gitignore');\n\t\t\t}\n\t\t} catch {\n\t\t\t// no .gitignore\n\t\t}\n\t},\n});\n","import fs from 'node:fs/promises';\nimport path from 'node:path';\nimport { defineCommand } from 'citty';\nimport picomatch from 'picomatch';\nimport { loadConfig } from '../../config/index.js';\nimport type { TestSummary } from '../../core/types.js';\nimport { generateHtmlReport } from '../../playwright/reporter.js';\nimport { logger } from '../../utils/logger.js';\n\nasync function globFiles(pattern: string, cwd: string): Promise<string[]> {\n\tconst matcher = picomatch(pattern);\n\tconst results: string[] = [];\n\n\tasync function walk(dir: string): Promise<void> {\n\t\tconst entries = await fs.readdir(dir, { withFileTypes: true });\n\t\tfor (const entry of entries) {\n\t\t\tconst fullPath = path.join(dir, entry.name);\n\t\t\tconst relativePath = path.relative(cwd, fullPath).replace(/\\\\/g, '/');\n\t\t\tif (entry.isDirectory()) {\n\t\t\t\tawait walk(fullPath);\n\t\t\t} else if (matcher(relativePath)) {\n\t\t\t\tresults.push(fullPath);\n\t\t\t}\n\t\t}\n\t}\n\n\tawait walk(cwd);\n\treturn results;\n}\n\nexport const reportCommand = defineCommand({\n\tmeta: {\n\t\tname: 'report',\n\t\tdescription: 'Generate or open the report',\n\t},\n\targs: {\n\t\topen: {\n\t\t\ttype: 'boolean',\n\t\t\tdescription: 'Open report in browser',\n\t\t\tdefault: false,\n\t\t},\n\t\tmerge: {\n\t\t\ttype: 'boolean',\n\t\t\tdescription: 'Merge multiple summary files',\n\t\t\tdefault: false,\n\t\t},\n\t\tfrom: {\n\t\t\ttype: 'string',\n\t\t\tdescription: 'Glob pattern for summary files to merge',\n\t\t},\n\t},\n\tasync run({ args }) {\n\t\tconst config = await loadConfig();\n\t\tconst reportDir = path.resolve(config.report.outputDir);\n\n\t\tif (args.merge && args.from) {\n\t\t\tlogger.start('Merging reports...');\n\t\t\tconst files = await globFiles(args.from, process.cwd());\n\n\t\t\tconst merged: TestSummary = {\n\t\t\t\ttotal: 0,\n\t\t\t\tpassed: 0,\n\t\t\t\tfailed: 0,\n\t\t\t\tskipped: 0,\n\t\t\t\tduration: 0,\n\t\t\t\ttimestamp: new Date().toISOString(),\n\t\t\t\tbrowsers: [],\n\t\t\t\tfailures: [],\n\t\t\t};\n\n\t\t\tfor (const file of files) {\n\t\t\t\tconst content = await fs.readFile(file, 'utf-8');\n\t\t\t\tconst summary: TestSummary = JSON.parse(content);\n\t\t\t\tmerged.total += summary.total;\n\t\t\t\tmerged.passed += summary.passed;\n\t\t\t\tmerged.failed += summary.failed;\n\t\t\t\tmerged.skipped += summary.skipped;\n\t\t\t\tmerged.duration = Math.max(merged.duration, summary.duration);\n\t\t\t\tmerged.browsers = [...new Set([...merged.browsers, ...summary.browsers])];\n\t\t\t\tmerged.failures.push(...summary.failures);\n\t\t\t}\n\n\t\t\tawait fs.mkdir(reportDir, { recursive: true });\n\t\t\tawait fs.writeFile(path.join(reportDir, 'summary.json'), JSON.stringify(merged, null, 2));\n\n\t\t\tconst html = generateHtmlReport(merged);\n\t\t\tawait fs.writeFile(path.join(reportDir, 'index.html'), html);\n\t\t\tlogger.success(`Merged ${files.length} reports → index.html generated`);\n\t\t}\n\n\t\tif (args.open) {\n\t\t\tconst reportPath = path.join(reportDir, 'index.html');\n\t\t\tconst { exec: execCb } = await import('node:child_process');\n\t\t\tconst platform = process.platform;\n\t\t\tconst cmd = platform === 'darwin' ? 'open' : platform === 'win32' ? 'start' : 'xdg-open';\n\t\t\texecCb(`${cmd} ${reportPath}`);\n\t\t\tlogger.success('Report opened');\n\t\t}\n\t},\n});\n","import { defineCommand } from 'citty';\nimport { loadConfig } from '../../config/index.js';\nimport type { DeepPartial, StorywrightConfig } from '../../config/types.js';\nimport { runTests } from '../../core/engine.js';\nimport { formatSummary } from '../../reporter/cli-reporter.js';\n\nexport const testCommand = defineCommand({\n\tmeta: {\n\t\tname: 'test',\n\t\tdescription: 'Run visual regression tests',\n\t},\n\targs: {\n\t\tbrowsers: {\n\t\t\ttype: 'string',\n\t\t\tdescription: 'Browsers to test (comma-separated)',\n\t\t},\n\t\tshard: {\n\t\t\ttype: 'string',\n\t\t\tdescription: 'Shard specification (index/total)',\n\t\t},\n\t\t'diff-only': {\n\t\t\ttype: 'boolean',\n\t\t\tdescription: 'Only test stories affected by git changes',\n\t\t\tdefault: false,\n\t\t},\n\t\tthreshold: {\n\t\t\ttype: 'string',\n\t\t\tdescription: 'Pixel color threshold (0-1)',\n\t\t},\n\t\t'max-diff-pixel-ratio': {\n\t\t\ttype: 'string',\n\t\t\tdescription: 'Maximum diff pixel ratio (0-1)',\n\t\t},\n\t\t'storybook-url': {\n\t\t\ttype: 'string',\n\t\t\tdescription: 'URL of running Storybook',\n\t\t},\n\t\t'storybook-dir': {\n\t\t\ttype: 'string',\n\t\t\tdescription: 'Storybook build directory',\n\t\t},\n\t\t'update-snapshots': {\n\t\t\ttype: 'boolean',\n\t\t\tdescription: 'Update baseline snapshots',\n\t\t\tdefault: false,\n\t\t},\n\t\t'full-page': {\n\t\t\ttype: 'boolean',\n\t\t\tdescription: 'Take full page screenshots',\n\t\t},\n\t\tworkers: {\n\t\t\ttype: 'string',\n\t\t\tdescription: 'Number of parallel workers',\n\t\t},\n\t\tretries: {\n\t\t\ttype: 'string',\n\t\t\tdescription: 'Number of retries for failed tests',\n\t\t},\n\t\tfilter: {\n\t\t\ttype: 'string',\n\t\t\tdescription: 'Filter stories by glob pattern',\n\t\t},\n\t\t'output-dir': {\n\t\t\ttype: 'string',\n\t\t\tdescription: 'Output root directory (.storywright by default)',\n\t\t},\n\t\treporters: {\n\t\t\ttype: 'string',\n\t\t\tdescription: 'Reporters (comma-separated, e.g. default,html)',\n\t\t},\n\t},\n\tasync run({ args }) {\n\t\tconst overrides: DeepPartial<StorywrightConfig> = {};\n\n\t\tif (args.browsers) {\n\t\t\toverrides.browsers = args.browsers.split(',').map((b) => b.trim());\n\t\t}\n\t\tif (args.threshold) {\n\t\t\toverrides.screenshot = { ...overrides.screenshot, threshold: Number(args.threshold) };\n\t\t}\n\t\tif (args['max-diff-pixel-ratio']) {\n\t\t\toverrides.screenshot = {\n\t\t\t\t...overrides.screenshot,\n\t\t\t\tmaxDiffPixelRatio: Number(args['max-diff-pixel-ratio']),\n\t\t\t};\n\t\t}\n\t\tif (args['storybook-url']) {\n\t\t\toverrides.storybook = { ...overrides.storybook, url: args['storybook-url'] };\n\t\t}\n\t\tif (args['storybook-dir']) {\n\t\t\toverrides.storybook = { ...overrides.storybook, staticDir: args['storybook-dir'] };\n\t\t}\n\t\tif (args['full-page'] !== undefined) {\n\t\t\toverrides.screenshot = { ...overrides.screenshot, fullPage: args['full-page'] };\n\t\t}\n\t\tif (args.workers) {\n\t\t\toverrides.workers = args.workers === 'auto' ? 'auto' : Number(args.workers);\n\t\t}\n\t\tif (args.retries) {\n\t\t\toverrides.retries = Number(args.retries);\n\t\t}\n\n\t\tconst config = await loadConfig(process.cwd(), overrides);\n\t\tconst result = await runTests(\n\t\t\tconfig,\n\t\t\t{\n\t\t\t\tdiffOnly: args['diff-only'],\n\t\t\t\tshard: args.shard,\n\t\t\t\tupdateSnapshots: args['update-snapshots'],\n\t\t\t\tfilter: args.filter,\n\t\t\t\toutputDir: args['output-dir'],\n\t\t\t\treporters: args.reporters?.split(',').map((r) => r.trim()),\n\t\t\t},\n\t\t\tprocess.cwd(),\n\t\t);\n\n\t\tif (result.summary) {\n\t\t\tconst reportPath = result.reportDir ? `${result.reportDir}/index.html` : undefined;\n\t\t\tconsole.log(formatSummary(result.summary, { reportPath }));\n\t\t}\n\n\t\tprocess.exit(result.exitCode);\n\t},\n});\n","import { defineCommand } from 'citty';\nimport { loadConfig } from '../../config/index.js';\nimport { updateBaselines } from '../../core/engine.js';\n\nexport const updateCommand = defineCommand({\n\tmeta: {\n\t\tname: 'update',\n\t\tdescription: 'Update baseline snapshots',\n\t},\n\targs: {\n\t\tall: {\n\t\t\ttype: 'boolean',\n\t\t\tdescription: 'Regenerate all baselines',\n\t\t\tdefault: false,\n\t\t},\n\t\tupload: {\n\t\t\ttype: 'boolean',\n\t\t\tdescription: 'Upload baselines after update',\n\t\t\tdefault: false,\n\t\t},\n\t},\n\tasync run({ args }) {\n\t\tconst config = await loadConfig();\n\t\tawait updateBaselines(config, { all: args.all, upload: args.upload });\n\t},\n});\n","import path from 'node:path';\nimport { defineCommand } from 'citty';\nimport { loadConfig } from '../../config/index.js';\nimport { createStorageAdapter } from '../../storage/index.js';\nimport { logger } from '../../utils/logger.js';\n\nexport const uploadCommand = defineCommand({\n\tmeta: {\n\t\tname: 'upload',\n\t\tdescription: 'Upload baselines to remote storage',\n\t},\n\targs: {},\n\tasync run() {\n\t\tconst config = await loadConfig();\n\t\tconst storage = createStorageAdapter(config.storage);\n\t\tconst snapshotDir = path.resolve(config.storage.local.baselineDir);\n\n\t\tlogger.start('Uploading baselines...');\n\t\tawait storage.upload({\n\t\t\tbranch: 'current',\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,KAAK,OAAO,CAAC;AAAA,EACrE;AACD,CAAC;;;ACzBD,OAAOC,WAAU;AACjB,SAAS,iBAAAC,sBAAqB;AAKvB,IAAM,gBAAgBC,eAAc;AAAA,EAC1C,MAAM;AAAA,IACL,MAAM;AAAA,IACN,aAAa;AAAA,EACd;AAAA,EACA,MAAM,CAAC;AAAA,EACP,MAAM,MAAM;AACX,UAAM,SAAS,MAAM,WAAW;AAChC,UAAM,UAAU,qBAAqB,OAAO,OAAO;AACnD,UAAM,cAAcC,MAAK,QAAQ,OAAO,QAAQ,MAAM,WAAW;AAEjE,WAAO,MAAM,wBAAwB;AACrC,UAAM,QAAQ,OAAO;AAAA,MACpB,QAAQ;AAAA,MACR,WAAW;AAAA,IACZ,CAAC;AACD,WAAO,QAAQ,oBAAoB;AAAA,EACpC;AACD,CAAC;;;ANhBD,IAAM,OAAOC,eAAc;AAAA,EAC1B,MAAM;AAAA,IACL,MAAM;AAAA,IACN,SAAS;AAAA,IACT,aAAa;AAAA,EACd;AAAA,EACA,aAAa;AAAA,IACZ,MAAM;AAAA,IACN,QAAQ;AAAA,IACR,QAAQ;AAAA,IACR,UAAU;AAAA,IACV,QAAQ;AAAA,IACR,MAAM;AAAA,EACP;AACD,CAAC;AAED,QAAQ,IAAI;","names":["defineCommand","path","defineCommand","defineCommand","path","fs","path","defineCommand","fs","path","defineCommand","defineCommand","defineCommand","defineCommand","defineCommand","path","defineCommand","defineCommand","path","defineCommand"]}
1
+ {"version":3,"sources":["../src/cli/index.ts","../src/cli/commands/download.ts","../src/cli/commands/init.ts","../src/cli/commands/report.ts","../src/cli/commands/test.ts","../src/cli/commands/update.ts","../src/cli/commands/upload.ts"],"sourcesContent":["import { defineCommand, runMain } from 'citty';\nimport { downloadCommand } from './commands/download.js';\nimport { initCommand } from './commands/init.js';\nimport { reportCommand } from './commands/report.js';\nimport { testCommand } from './commands/test.js';\nimport { updateCommand } from './commands/update.js';\nimport { uploadCommand } from './commands/upload.js';\n\nconst main = defineCommand({\n\tmeta: {\n\t\tname: 'storywright',\n\t\tversion: __PKG_VERSION__,\n\t\tdescription: 'Zero-config visual regression testing powered by Storybook + Playwright',\n\t},\n\tsubCommands: {\n\t\ttest: testCommand,\n\t\tupdate: updateCommand,\n\t\tupload: uploadCommand,\n\t\tdownload: downloadCommand,\n\t\treport: reportCommand,\n\t\tinit: initCommand,\n\t},\n});\n\nrunMain(main);\n","import path from 'node:path';\nimport { defineCommand } from 'citty';\nimport { loadConfig } from '../../config/index.js';\nimport { createStorageAdapter } from '../../storage/index.js';\nimport { LocalStorageAdapter } from '../../storage/local.js';\nimport { logger } from '../../utils/logger.js';\n\nexport const downloadCommand = defineCommand({\n\tmeta: {\n\t\tname: 'download',\n\t\tdescription: 'Download baselines from storage',\n\t},\n\targs: {\n\t\tbranch: {\n\t\t\ttype: 'string',\n\t\t\tdescription: 'Branch to download baselines from',\n\t\t\tdefault: 'main',\n\t\t},\n\t},\n\tasync run({ args }) {\n\t\tconst config = await loadConfig();\n\t\tconst storage = createStorageAdapter(config.storage);\n\t\tconst destDir = path.resolve(config.storage.local.baselineDir);\n\t\tconst branch = args.branch ?? 'main';\n\n\t\tif (storage instanceof LocalStorageAdapter) {\n\t\t\tlogger.start(`Extracting baselines from git branch '${branch}'...`);\n\t\t\ttry {\n\t\t\t\tawait storage.downloadFromGit(branch, destDir, process.cwd());\n\t\t\t\tlogger.success('Baselines extracted from git');\n\t\t\t} catch (error) {\n\t\t\t\tlogger.error(String(error));\n\t\t\t\tlogger.info(\n\t\t\t\t\t'Hint: ensure you are in a git repository with sufficient history (fetch-depth: 0)',\n\t\t\t\t);\n\t\t\t\tprocess.exit(2);\n\t\t\t}\n\t\t} else {\n\t\t\tlogger.start(`Downloading baselines from ${branch}...`);\n\t\t\tawait storage.download({ branch, destDir });\n\t\t\tlogger.success('Baselines downloaded');\n\t\t}\n\t},\n});\n","import fs from 'node:fs/promises';\nimport path from 'node:path';\nimport { defineCommand } from 'citty';\nimport { logger } from '../../utils/logger.js';\n\nconst CONFIG_TEMPLATE = `import { defineConfig } from '@storywright/cli';\n\nexport default defineConfig({\n\\t// Storybook settings\n\\tstorybook: {\n\\t\\tstaticDir: 'storybook-static',\n\\t},\n\n\\t// Browsers to test\n\\tbrowsers: ['chromium'],\n\n\\t// Screenshot settings\n\\tscreenshot: {\n\\t\\tfullPage: true,\n\\t\\tanimations: 'disabled',\n\\t\\tthreshold: 0.02,\n\\t\\tmaxDiffPixelRatio: 0.02,\n\\t},\n\n\\t// Storage settings\n\\tstorage: {\n\\t\\tprovider: 'local',\n\\t},\n});\n`;\n\nexport const initCommand = defineCommand({\n\tmeta: {\n\t\tname: 'init',\n\t\tdescription: 'Initialize storywright configuration',\n\t},\n\targs: {},\n\tasync run() {\n\t\tconst configPath = path.resolve('storywright.config.ts');\n\t\ttry {\n\t\t\tawait fs.access(configPath);\n\t\t\tlogger.warn('storywright.config.ts already exists');\n\t\t\treturn;\n\t\t} catch {\n\t\t\t// file doesn't exist, create it\n\t\t}\n\n\t\tawait fs.writeFile(configPath, CONFIG_TEMPLATE);\n\t\tlogger.success('Created storywright.config.ts');\n\n\t\t// Add .storywright temp/report dirs to .gitignore if exists\n\t\t// Note: .storywright/baselines/ should be tracked by git\n\t\tconst gitignorePath = path.resolve('.gitignore');\n\t\ttry {\n\t\t\tconst content = await fs.readFile(gitignorePath, 'utf-8');\n\t\t\tif (!content.includes('.storywright')) {\n\t\t\t\tawait fs.appendFile(\n\t\t\t\t\tgitignorePath,\n\t\t\t\t\t'\\n# Storywright\\n.storywright/tmp/\\n.storywright/report/\\n',\n\t\t\t\t);\n\t\t\t\tlogger.info('Added .storywright/tmp/ and .storywright/report/ to .gitignore');\n\t\t\t}\n\t\t} catch {\n\t\t\t// no .gitignore\n\t\t}\n\t},\n});\n","import fs from 'node:fs/promises';\nimport path from 'node:path';\nimport { defineCommand } from 'citty';\nimport picomatch from 'picomatch';\nimport { loadConfig } from '../../config/index.js';\nimport type { TestSummary } from '../../core/types.js';\nimport { generateHtmlReport } from '../../playwright/reporter.js';\nimport { logger } from '../../utils/logger.js';\n\nasync function globFiles(pattern: string, cwd: string): Promise<string[]> {\n\tconst matcher = picomatch(pattern);\n\tconst results: string[] = [];\n\n\tasync function walk(dir: string): Promise<void> {\n\t\tconst entries = await fs.readdir(dir, { withFileTypes: true });\n\t\tfor (const entry of entries) {\n\t\t\tconst fullPath = path.join(dir, entry.name);\n\t\t\tconst relativePath = path.relative(cwd, fullPath).replace(/\\\\/g, '/');\n\t\t\tif (entry.isDirectory()) {\n\t\t\t\tawait walk(fullPath);\n\t\t\t} else if (matcher(relativePath)) {\n\t\t\t\tresults.push(fullPath);\n\t\t\t}\n\t\t}\n\t}\n\n\tawait walk(cwd);\n\treturn results;\n}\n\nexport const reportCommand = defineCommand({\n\tmeta: {\n\t\tname: 'report',\n\t\tdescription: 'Generate or open the report',\n\t},\n\targs: {\n\t\topen: {\n\t\t\ttype: 'boolean',\n\t\t\tdescription: 'Open report in browser',\n\t\t\tdefault: false,\n\t\t},\n\t\tmerge: {\n\t\t\ttype: 'boolean',\n\t\t\tdescription: 'Merge multiple summary files',\n\t\t\tdefault: false,\n\t\t},\n\t\tfrom: {\n\t\t\ttype: 'string',\n\t\t\tdescription: 'Glob pattern for summary files to merge',\n\t\t},\n\t},\n\tasync run({ args }) {\n\t\tconst config = await loadConfig();\n\t\tconst reportDir = path.resolve(config.report.outputDir);\n\n\t\tif (args.merge && args.from) {\n\t\t\tlogger.start('Merging reports...');\n\t\t\tconst files = await globFiles(args.from, process.cwd());\n\n\t\t\tconst merged: TestSummary = {\n\t\t\t\ttotal: 0,\n\t\t\t\tpassed: 0,\n\t\t\t\tfailed: 0,\n\t\t\t\tskipped: 0,\n\t\t\t\tduration: 0,\n\t\t\t\ttimestamp: new Date().toISOString(),\n\t\t\t\tbrowsers: [],\n\t\t\t\tfailures: [],\n\t\t\t};\n\n\t\t\tfor (const file of files) {\n\t\t\t\tconst content = await fs.readFile(file, 'utf-8');\n\t\t\t\tconst summary: TestSummary = JSON.parse(content);\n\t\t\t\tmerged.total += summary.total;\n\t\t\t\tmerged.passed += summary.passed;\n\t\t\t\tmerged.failed += summary.failed;\n\t\t\t\tmerged.skipped += summary.skipped;\n\t\t\t\tmerged.duration = Math.max(merged.duration, summary.duration);\n\t\t\t\tmerged.browsers = [...new Set([...merged.browsers, ...summary.browsers])];\n\t\t\t\tmerged.failures.push(...summary.failures);\n\t\t\t}\n\n\t\t\tawait fs.mkdir(reportDir, { recursive: true });\n\t\t\tawait fs.writeFile(path.join(reportDir, 'summary.json'), JSON.stringify(merged, null, 2));\n\n\t\t\tconst html = generateHtmlReport(merged);\n\t\t\tawait fs.writeFile(path.join(reportDir, 'index.html'), html);\n\t\t\tlogger.success(`Merged ${files.length} reports → index.html generated`);\n\t\t}\n\n\t\tif (args.open) {\n\t\t\tconst reportPath = path.join(reportDir, 'index.html');\n\t\t\tconst { exec: execCb } = await import('node:child_process');\n\t\t\tconst platform = process.platform;\n\t\t\tconst cmd = platform === 'darwin' ? 'open' : platform === 'win32' ? 'start' : 'xdg-open';\n\t\t\texecCb(`${cmd} ${reportPath}`);\n\t\t\tlogger.success('Report opened');\n\t\t}\n\t},\n});\n","import { defineCommand } from 'citty';\nimport { loadConfig } from '../../config/index.js';\nimport type { DeepPartial, StorywrightConfig } from '../../config/types.js';\nimport { runTests } from '../../core/engine.js';\nimport { formatSummary } from '../../reporter/cli-reporter.js';\n\nexport const testCommand = defineCommand({\n\tmeta: {\n\t\tname: 'test',\n\t\tdescription: 'Run visual regression tests',\n\t},\n\targs: {\n\t\tbrowsers: {\n\t\t\ttype: 'string',\n\t\t\tdescription: 'Browsers to test (comma-separated)',\n\t\t},\n\t\tshard: {\n\t\t\ttype: 'string',\n\t\t\tdescription: 'Shard specification (index/total)',\n\t\t},\n\t\t'diff-only': {\n\t\t\ttype: 'boolean',\n\t\t\tdescription: 'Only test stories affected by git changes',\n\t\t\tdefault: false,\n\t\t},\n\t\tthreshold: {\n\t\t\ttype: 'string',\n\t\t\tdescription: 'Pixel color threshold (0-1)',\n\t\t},\n\t\t'max-diff-pixel-ratio': {\n\t\t\ttype: 'string',\n\t\t\tdescription: 'Maximum diff pixel ratio (0-1)',\n\t\t},\n\t\t'storybook-url': {\n\t\t\ttype: 'string',\n\t\t\tdescription: 'URL of running Storybook',\n\t\t},\n\t\t'storybook-dir': {\n\t\t\ttype: 'string',\n\t\t\tdescription: 'Storybook build directory',\n\t\t},\n\t\t'update-snapshots': {\n\t\t\ttype: 'boolean',\n\t\t\tdescription: 'Update baseline snapshots',\n\t\t\tdefault: false,\n\t\t},\n\t\t'full-page': {\n\t\t\ttype: 'boolean',\n\t\t\tdescription: 'Take full page screenshots',\n\t\t},\n\t\tworkers: {\n\t\t\ttype: 'string',\n\t\t\tdescription: 'Number of parallel workers',\n\t\t},\n\t\tretries: {\n\t\t\ttype: 'string',\n\t\t\tdescription: 'Number of retries for failed tests',\n\t\t},\n\t\tfilter: {\n\t\t\ttype: 'string',\n\t\t\tdescription: 'Filter stories by glob pattern',\n\t\t},\n\t\t'output-dir': {\n\t\t\ttype: 'string',\n\t\t\tdescription: 'Output root directory (.storywright by default)',\n\t\t},\n\t\treporters: {\n\t\t\ttype: 'string',\n\t\t\tdescription: 'Reporters (comma-separated, e.g. default,html)',\n\t\t},\n\t},\n\tasync run({ args }) {\n\t\tconst overrides: DeepPartial<StorywrightConfig> = {};\n\n\t\tif (args.browsers) {\n\t\t\toverrides.browsers = args.browsers.split(',').map((b) => b.trim());\n\t\t}\n\t\tif (args.threshold) {\n\t\t\toverrides.screenshot = { ...overrides.screenshot, threshold: Number(args.threshold) };\n\t\t}\n\t\tif (args['max-diff-pixel-ratio']) {\n\t\t\toverrides.screenshot = {\n\t\t\t\t...overrides.screenshot,\n\t\t\t\tmaxDiffPixelRatio: Number(args['max-diff-pixel-ratio']),\n\t\t\t};\n\t\t}\n\t\tif (args['storybook-url']) {\n\t\t\toverrides.storybook = { ...overrides.storybook, url: args['storybook-url'] };\n\t\t}\n\t\tif (args['storybook-dir']) {\n\t\t\toverrides.storybook = { ...overrides.storybook, staticDir: args['storybook-dir'] };\n\t\t}\n\t\tif (args['full-page'] !== undefined) {\n\t\t\toverrides.screenshot = { ...overrides.screenshot, fullPage: args['full-page'] };\n\t\t}\n\t\tif (args.workers) {\n\t\t\toverrides.workers = args.workers === 'auto' ? 'auto' : Number(args.workers);\n\t\t}\n\t\tif (args.retries) {\n\t\t\toverrides.retries = Number(args.retries);\n\t\t}\n\n\t\tconst config = await loadConfig(process.cwd(), overrides);\n\t\tconst result = await runTests(\n\t\t\tconfig,\n\t\t\t{\n\t\t\t\tdiffOnly: args['diff-only'],\n\t\t\t\tshard: args.shard,\n\t\t\t\tupdateSnapshots: args['update-snapshots'],\n\t\t\t\tfilter: args.filter,\n\t\t\t\toutputDir: args['output-dir'],\n\t\t\t\treporters: args.reporters?.split(',').map((r) => r.trim()),\n\t\t\t},\n\t\t\tprocess.cwd(),\n\t\t);\n\n\t\tif (result.summary) {\n\t\t\tconst reportPath = result.reportDir ? `${result.reportDir}/index.html` : undefined;\n\t\t\tconsole.log(formatSummary(result.summary, { reportPath }));\n\t\t}\n\n\t\tprocess.exit(result.exitCode);\n\t},\n});\n","import { defineCommand } from 'citty';\nimport { loadConfig } from '../../config/index.js';\nimport { updateBaselines } from '../../core/engine.js';\n\nexport const updateCommand = defineCommand({\n\tmeta: {\n\t\tname: 'update',\n\t\tdescription: 'Update baseline snapshots',\n\t},\n\targs: {\n\t\tall: {\n\t\t\ttype: 'boolean',\n\t\t\tdescription: 'Regenerate all baselines',\n\t\t\tdefault: false,\n\t\t},\n\t\tupload: {\n\t\t\ttype: 'boolean',\n\t\t\tdescription: 'Upload baselines after update',\n\t\t\tdefault: false,\n\t\t},\n\t},\n\tasync run({ args }) {\n\t\tconst config = await loadConfig();\n\t\tawait updateBaselines(config, { all: args.all, upload: args.upload });\n\t},\n});\n","import path from 'node:path';\nimport { defineCommand } from 'citty';\nimport { loadConfig } from '../../config/index.js';\nimport { createStorageAdapter } from '../../storage/index.js';\nimport { logger } from '../../utils/logger.js';\n\nexport const uploadCommand = defineCommand({\n\tmeta: {\n\t\tname: 'upload',\n\t\tdescription: 'Upload baselines to remote storage',\n\t},\n\targs: {},\n\tasync run() {\n\t\tconst config = await loadConfig();\n\t\tconst storage = createStorageAdapter(config.storage);\n\t\tconst snapshotDir = path.resolve(config.storage.local.baselineDir);\n\n\t\tlogger.start('Uploading baselines...');\n\t\tawait storage.upload({\n\t\t\tbranch: 'current',\n\t\t\tsourceDir: snapshotDir,\n\t\t});\n\t\tlogger.success('Baselines uploaded');\n\t},\n});\n"],"mappings":";;;;;;;;;;;;;;AAAA,SAAS,iBAAAA,gBAAe,eAAe;;;ACAvC,OAAO,UAAU;AACjB,SAAS,qBAAqB;AAMvB,IAAM,kBAAkB,cAAc;AAAA,EAC5C,MAAM;AAAA,IACL,MAAM;AAAA,IACN,aAAa;AAAA,EACd;AAAA,EACA,MAAM;AAAA,IACL,QAAQ;AAAA,MACP,MAAM;AAAA,MACN,aAAa;AAAA,MACb,SAAS;AAAA,IACV;AAAA,EACD;AAAA,EACA,MAAM,IAAI,EAAE,KAAK,GAAG;AACnB,UAAM,SAAS,MAAM,WAAW;AAChC,UAAM,UAAU,qBAAqB,OAAO,OAAO;AACnD,UAAM,UAAU,KAAK,QAAQ,OAAO,QAAQ,MAAM,WAAW;AAC7D,UAAM,SAAS,KAAK,UAAU;AAE9B,QAAI,mBAAmB,qBAAqB;AAC3C,aAAO,MAAM,yCAAyC,MAAM,MAAM;AAClE,UAAI;AACH,cAAM,QAAQ,gBAAgB,QAAQ,SAAS,QAAQ,IAAI,CAAC;AAC5D,eAAO,QAAQ,8BAA8B;AAAA,MAC9C,SAAS,OAAO;AACf,eAAO,MAAM,OAAO,KAAK,CAAC;AAC1B,eAAO;AAAA,UACN;AAAA,QACD;AACA,gBAAQ,KAAK,CAAC;AAAA,MACf;AAAA,IACD,OAAO;AACN,aAAO,MAAM,8BAA8B,MAAM,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;AAAA,EACA,MAAM;AAAA,IACL,KAAK;AAAA,MACJ,MAAM;AAAA,MACN,aAAa;AAAA,MACb,SAAS;AAAA,IACV;AAAA,IACA,QAAQ;AAAA,MACP,MAAM;AAAA,MACN,aAAa;AAAA,MACb,SAAS;AAAA,IACV;AAAA,EACD;AAAA,EACA,MAAM,IAAI,EAAE,KAAK,GAAG;AACnB,UAAM,SAAS,MAAM,WAAW;AAChC,UAAM,gBAAgB,QAAQ,EAAE,KAAK,KAAK,KAAK,QAAQ,KAAK,OAAO,CAAC;AAAA,EACrE;AACD,CAAC;;;ACzBD,OAAOC,WAAU;AACjB,SAAS,iBAAAC,sBAAqB;AAKvB,IAAM,gBAAgBC,eAAc;AAAA,EAC1C,MAAM;AAAA,IACL,MAAM;AAAA,IACN,aAAa;AAAA,EACd;AAAA,EACA,MAAM,CAAC;AAAA,EACP,MAAM,MAAM;AACX,UAAM,SAAS,MAAM,WAAW;AAChC,UAAM,UAAU,qBAAqB,OAAO,OAAO;AACnD,UAAM,cAAcC,MAAK,QAAQ,OAAO,QAAQ,MAAM,WAAW;AAEjE,WAAO,MAAM,wBAAwB;AACrC,UAAM,QAAQ,OAAO;AAAA,MACpB,QAAQ;AAAA,MACR,WAAW;AAAA,IACZ,CAAC;AACD,WAAO,QAAQ,oBAAoB;AAAA,EACpC;AACD,CAAC;;;ANhBD,IAAM,OAAOC,eAAc;AAAA,EAC1B,MAAM;AAAA,IACL,MAAM;AAAA,IACN,SAAS;AAAA,IACT,aAAa;AAAA,EACd;AAAA,EACA,aAAa;AAAA,IACZ,MAAM;AAAA,IACN,QAAQ;AAAA,IACR,QAAQ;AAAA,IACR,UAAU;AAAA,IACV,QAAQ;AAAA,IACR,MAAM;AAAA,EACP;AACD,CAAC;AAED,QAAQ,IAAI;","names":["defineCommand","path","defineCommand","defineCommand","path","fs","path","defineCommand","fs","path","defineCommand","defineCommand","defineCommand","defineCommand","defineCommand","path","defineCommand","defineCommand","path","defineCommand"]}
package/dist/index.d.ts CHANGED
@@ -18,7 +18,9 @@ interface StorywrightConfig {
18
18
  hooks: HooksConfig;
19
19
  }
20
20
  type BrowserName = 'chromium' | 'firefox' | 'webkit' | (string & {});
21
+ type PlaywrightBrowserName = 'chromium' | 'firefox' | 'webkit';
21
22
  interface BrowserOption {
23
+ browserName?: PlaywrightBrowserName;
22
24
  viewport?: {
23
25
  width: number;
24
26
  height: number;
@@ -27,6 +29,7 @@ interface BrowserOption {
27
29
  isMobile?: boolean;
28
30
  hasTouch?: boolean;
29
31
  userAgent?: string;
32
+ exclude?: string[];
30
33
  }
31
34
  interface StorybookConfig {
32
35
  staticDir: string;
@@ -133,4 +136,4 @@ interface ReportData {
133
136
  results: TestResult[];
134
137
  }
135
138
 
136
- export { type DeepPartial, type DownloadOptions, type ReportData, type StorageAdapter, type StorywrightConfig, TestResult, TestSummary, type UploadOptions, createStorywright, defineConfig, loadConfig };
139
+ export { type DeepPartial, type DownloadOptions, type PlaywrightBrowserName, type ReportData, type StorageAdapter, type StorywrightConfig, TestResult, TestSummary, type UploadOptions, createStorywright, defineConfig, loadConfig };
package/dist/index.js CHANGED
@@ -6,7 +6,7 @@ import {
6
6
  loadConfig,
7
7
  runTests,
8
8
  updateBaselines
9
- } from "./chunk-XVHJJ6NP.js";
9
+ } from "./chunk-XYP273ZX.js";
10
10
 
11
11
  // src/core/index.ts
12
12
  import path from "path";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@storywright/cli",
3
- "version": "0.4.1",
3
+ "version": "0.5.0",
4
4
  "description": "Zero-config visual regression testing powered by Storybook + Playwright",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -31,7 +31,7 @@
31
31
  "simple-git": "^3.27.0",
32
32
  "unconfig": "^0.6.0",
33
33
  "picomatch": "^4.0.2",
34
- "@storywright/report": "0.4.1"
34
+ "@storywright/report": "0.5.0"
35
35
  },
36
36
  "devDependencies": {
37
37
  "@playwright/test": "^1.50.0",
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/config/index.ts","../src/config/defaults.ts","../src/reporter/cli-reporter.ts","../src/storage/local.ts","../src/storage/index.ts","../src/utils/logger.ts","../src/core/engine.ts","../src/playwright/config-generator.ts","../src/playwright/test-generator.ts","../src/resolver/index.ts","../src/utils/path.ts","../src/utils/process.ts","../src/core/storybook.ts"],"sourcesContent":["import { loadConfig as unconfigLoad } from 'unconfig';\nimport { DEFAULT_CONFIG } from './defaults.js';\nimport type { DeepPartial, StorywrightConfig } from './types.js';\n\nexport function defineConfig(\n\tconfig: DeepPartial<StorywrightConfig>,\n): DeepPartial<StorywrightConfig> {\n\treturn config;\n}\n\nfunction isPlainObject(value: unknown): value is Record<string, unknown> {\n\treturn value !== null && typeof value === 'object' && !Array.isArray(value);\n}\n\nfunction deepMerge(\n\ttarget: Record<string, unknown>,\n\tsource: Record<string, unknown>,\n): Record<string, unknown> {\n\tconst result: Record<string, unknown> = { ...target };\n\tfor (const key of Object.keys(source)) {\n\t\tconst sourceVal = source[key];\n\t\tconst targetVal = result[key];\n\t\tif (isPlainObject(sourceVal) && isPlainObject(targetVal)) {\n\t\t\tresult[key] = deepMerge(targetVal, sourceVal);\n\t\t} else if (sourceVal !== undefined) {\n\t\t\tresult[key] = sourceVal;\n\t\t}\n\t}\n\treturn result;\n}\n\nexport async function loadConfig(\n\tcwd: string = process.cwd(),\n\toverrides?: DeepPartial<StorywrightConfig>,\n): Promise<StorywrightConfig> {\n\tconst { config: userConfig } = await unconfigLoad<DeepPartial<StorywrightConfig>>({\n\t\tsources: [\n\t\t\t{\n\t\t\t\tfiles: 'storywright.config',\n\t\t\t\textensions: ['ts', 'js', 'mjs'],\n\t\t\t},\n\t\t],\n\t\tcwd,\n\t});\n\n\tlet merged = DEFAULT_CONFIG as unknown as Record<string, unknown>;\n\tif (userConfig) {\n\t\tmerged = deepMerge(merged, userConfig as Record<string, unknown>);\n\t}\n\tif (overrides) {\n\t\tmerged = deepMerge(merged, overrides as Record<string, unknown>);\n\t}\n\treturn merged as unknown as StorywrightConfig;\n}\n\nexport type { StorywrightConfig, DeepPartial } from './types.js';\n","import type { StorywrightConfig } from './types.js';\n\nexport const DEFAULT_CONFIG: StorywrightConfig = {\n\tstorybook: {\n\t\tstaticDir: 'storybook-static',\n\t\tbuildCommand: 'npx storybook build --stats-json',\n\t\turl: undefined,\n\t\tcompatibility: 'auto',\n\t},\n\n\tbrowsers: ['chromium'],\n\tbrowserOptions: {},\n\n\tscreenshot: {\n\t\tfullPage: true,\n\t\tanimations: 'disabled',\n\t\tthreshold: 0.02,\n\t\tmaxDiffPixelRatio: 0.02,\n\t\tfreezeTime: '2024-01-01T00:00:00',\n\t\ttimezone: 'UTC',\n\t\tlocale: 'en-US',\n\t\tseed: 1,\n\t},\n\n\tdiffDetection: {\n\t\tenabled: true,\n\t\twatchFiles: ['package.json', 'package-lock.json', '.storybook/**/*'],\n\t\tbaseBranch: 'main',\n\t},\n\n\tstorage: {\n\t\tprovider: 'local',\n\t\tlocal: {\n\t\t\tbaselineDir: '.storywright/baselines',\n\t\t},\n\t\ts3: {\n\t\t\tbucket: '',\n\t\t\tprefix: 'storywright/baselines',\n\t\t\tregion: 'ap-northeast-1',\n\t\t\tcompression: 'zstd',\n\t\t},\n\t},\n\n\treport: {\n\t\toutputDir: '.storywright/report',\n\t\ttitle: 'Storywright Report',\n\t},\n\n\tworkers: 'auto',\n\tretries: 0,\n\n\ttimeout: {\n\t\ttest: 30000,\n\t\tnavigation: 20000,\n\t\texpect: 10000,\n\t},\n\n\tinclude: ['**'],\n\texclude: [],\n\n\thooks: {},\n};\n","import type { TestSummary } from '../core/types.js';\n\nexport function formatSummary(summary: TestSummary, options?: { reportPath?: string }): string {\n\tconst durationSec = Math.round(summary.duration / 1000);\n\tconst minutes = Math.floor(durationSec / 60);\n\tconst seconds = durationSec % 60;\n\tconst durationStr = minutes > 0 ? `${minutes}m ${seconds}s` : `${seconds}s`;\n\n\tconst lines: string[] = [\n\t\t'',\n\t\t'Storywright Results',\n\t\t'\\u2550'.repeat(42),\n\t\t` Total: ${summary.total} Passed: ${summary.passed} Failed: ${summary.failed} Skipped: ${summary.skipped}`,\n\t\t` Duration: ${durationStr}`,\n\t\t` Browsers: ${summary.browsers.join(', ')}`,\n\t];\n\n\tconst newFailures = summary.failures.filter((f) => f.type === 'new');\n\tconst diffFailures = summary.failures.filter((f) => f.type !== 'new');\n\n\tif (newFailures.length > 0) {\n\t\tlines.push('');\n\t\tlines.push(' New (no baseline):');\n\t\tfor (const failure of newFailures) {\n\t\t\tlines.push(` \\u25cb ${failure.story}: ${failure.variant} (${failure.browser})`);\n\t\t}\n\t}\n\n\tif (diffFailures.length > 0) {\n\t\tlines.push('');\n\t\tlines.push(' Failed:');\n\t\tfor (const failure of diffFailures) {\n\t\t\tlines.push(` \\u2717 ${failure.story}: ${failure.variant} (${failure.browser})`);\n\t\t\tif (failure.diffRatio > 0) {\n\t\t\t\tconst pct = (failure.diffRatio * 100).toFixed(1);\n\t\t\t\tlines.push(` \\u2192 Diff: ${pct}% pixels changed`);\n\t\t\t}\n\t\t}\n\t}\n\n\tconst reportPath = options?.reportPath ?? '.storywright/report/index.html';\n\tlines.push('');\n\tlines.push(` Report: ${reportPath}`);\n\tlines.push('\\u2550'.repeat(42));\n\tlines.push('');\n\n\treturn lines.join('\\n');\n}\n","import { execFile } from 'node:child_process';\nimport fs from 'node:fs/promises';\nimport path from 'node:path';\nimport { promisify } from 'node:util';\nimport type { DownloadOptions, StorageAdapter, UploadOptions } from './types.js';\n\nconst execFileAsync = promisify(execFile);\n\nexport class LocalStorageAdapter implements StorageAdapter {\n\tconstructor(private readonly baselineDir: string) {}\n\n\tasync download(options: DownloadOptions): Promise<void> {\n\t\ttry {\n\t\t\tawait fs.access(this.baselineDir);\n\t\t} catch {\n\t\t\treturn;\n\t\t}\n\t\tawait fs.cp(this.baselineDir, options.destDir, { recursive: true });\n\t}\n\n\tasync upload(options: UploadOptions): Promise<void> {\n\t\tconst resolvedSource = path.resolve(options.sourceDir);\n\t\tconst resolvedDest = path.resolve(this.baselineDir);\n\t\tif (resolvedSource === resolvedDest) {\n\t\t\treturn;\n\t\t}\n\t\tawait fs.mkdir(this.baselineDir, { recursive: true });\n\t\tawait fs.cp(options.sourceDir, this.baselineDir, { recursive: true });\n\t}\n\n\tasync exists(_branch: string): Promise<boolean> {\n\t\ttry {\n\t\t\tawait fs.access(this.baselineDir);\n\t\t\tconst entries = await fs.readdir(this.baselineDir);\n\t\t\treturn entries.length > 0;\n\t\t} catch {\n\t\t\treturn false;\n\t\t}\n\t}\n\n\t/**\n\t * Extract baselines from a git branch using `git ls-tree` + `git show`.\n\t * Binary-safe (PNG files) via `encoding: 'buffer'`.\n\t */\n\tasync downloadFromGit(branch: string, destDir: string, cwd: string): Promise<void> {\n\t\tconst gitPath = this.baselineDir.split(path.sep).join('/');\n\n\t\tlet lsOutput: string;\n\t\ttry {\n\t\t\tconst result = await execFileAsync(\n\t\t\t\t'git',\n\t\t\t\t['ls-tree', '-r', '--name-only', branch, '--', gitPath],\n\t\t\t\t{ cwd },\n\t\t\t);\n\t\t\tlsOutput = result.stdout;\n\t\t} catch (error) {\n\t\t\tthrow new Error(\n\t\t\t\t`Failed to list baselines from git branch '${branch}': ${error instanceof Error ? error.message : error}`,\n\t\t\t);\n\t\t}\n\n\t\tconst files = lsOutput.trim().split('\\n').filter(Boolean);\n\t\tif (files.length === 0) {\n\t\t\treturn;\n\t\t}\n\n\t\tawait fs.mkdir(destDir, { recursive: true });\n\n\t\tconst posixBaselineDir = this.baselineDir.split(path.sep).join('/').replace(/\\/+$/, '');\n\n\t\tfor (const file of files) {\n\t\t\tlet content: Buffer;\n\t\t\ttry {\n\t\t\t\tconst result = await execFileAsync('git', ['show', `${branch}:${file}`], {\n\t\t\t\t\tcwd,\n\t\t\t\t\tencoding: 'buffer' as unknown as BufferEncoding,\n\t\t\t\t\tmaxBuffer: 50 * 1024 * 1024,\n\t\t\t\t});\n\t\t\t\tcontent = result.stdout as unknown as Buffer;\n\t\t\t} catch (error) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Failed to extract '${file}' from git branch '${branch}': ${error instanceof Error ? error.message : error}`,\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tconst relativePath = file.slice(posixBaselineDir.length + 1);\n\t\t\tconst destPath = path.join(destDir, ...relativePath.split('/'));\n\t\t\tawait fs.mkdir(path.dirname(destPath), { recursive: true });\n\t\t\tawait fs.writeFile(destPath, content);\n\t\t}\n\t}\n}\n","import { createRequire } from 'node:module';\nimport type { StorageConfig } from '../config/types.js';\nimport { LocalStorageAdapter } from './local.js';\nimport type { StorageAdapter } from './types.js';\n\nexport function createStorageAdapter(config: StorageConfig): StorageAdapter {\n\tswitch (config.provider) {\n\t\tcase 'local':\n\t\t\treturn new LocalStorageAdapter(config.local.baselineDir);\n\t\tcase 's3':\n\t\t\treturn loadS3Adapter(config);\n\t\tdefault:\n\t\t\tthrow new Error(`Unknown storage provider: ${config.provider}`);\n\t}\n}\n\nfunction loadS3Adapter(config: StorageConfig): StorageAdapter {\n\ttry {\n\t\tconst require = createRequire(import.meta.url);\n\t\tconst { S3StorageAdapter } = require('@storywright/storage-s3') as {\n\t\t\tS3StorageAdapter: new (cfg: {\n\t\t\t\tbucket: string;\n\t\t\t\tprefix: string;\n\t\t\t\tregion: string;\n\t\t\t\tcompression?: string;\n\t\t\t}) => StorageAdapter;\n\t\t};\n\t\treturn new S3StorageAdapter(config.s3);\n\t} catch {\n\t\tthrow new Error(\n\t\t\t'S3 storage adapter requires the @storywright/storage-s3 package.\\nInstall it with: pnpm add @storywright/storage-s3',\n\t\t);\n\t}\n}\n\nexport type { StorageAdapter, DownloadOptions, UploadOptions } from './types.js';\n","import { createConsola } from 'consola';\n\nconst isCI = !!(\n\tprocess.env.CI ||\n\tprocess.env.GITHUB_ACTIONS ||\n\tprocess.env.CIRCLECI ||\n\tprocess.env.GITLAB_CI\n);\n\nexport const logger = createConsola({\n\tlevel: process.env.STORYWRIGHT_DEBUG ? 5 : 3,\n});\n\nexport { isCI };\n","import fs from 'node:fs/promises';\nimport path from 'node:path';\nimport picomatch from 'picomatch';\nimport type { StorywrightConfig } from '../config/types.js';\nimport { generatePlaywrightConfig } from '../playwright/config-generator.js';\nimport { generateTestFile } from '../playwright/test-generator.js';\nimport { resolveAffectedStories } from '../resolver/index.js';\nimport { createStorageAdapter } from '../storage/index.js';\nimport { logger } from '../utils/logger.js';\nimport { resolveOutputDir } from '../utils/path.js';\nimport { exec } from '../utils/process.js';\nimport { buildStorybook, discoverStories, filterStories } from './storybook.js';\nimport type { Story, StoryIndex, TestSummary } from './types.js';\n\nexport interface TestOptions {\n\tdiffOnly?: boolean;\n\tshard?: string;\n\tupdateSnapshots?: boolean;\n\tfilter?: string;\n\toutputDir?: string;\n\treporters?: string[];\n}\n\nexport interface TestRunResult {\n\texitCode: number;\n\tsummary?: TestSummary;\n\treportDir?: string;\n\tsnapshotDir?: string;\n}\n\nconst STORIES_PER_FILE = 50;\n\nfunction resolveReporterPath(): string {\n\t// Resolve relative to this file's dist location\n\tconst thisDir = new URL('.', import.meta.url).pathname;\n\treturn path.resolve(thisDir, 'playwright', 'reporter.js');\n}\n\nfunction chunkStories(entries: Record<string, Story>): Record<string, Story>[] {\n\tconst keys = Object.keys(entries);\n\tif (keys.length === 0) return [{}];\n\tconst chunks: Record<string, Story>[] = [];\n\tfor (let i = 0; i < keys.length; i += STORIES_PER_FILE) {\n\t\tconst chunk: Record<string, Story> = {};\n\t\tfor (const key of keys.slice(i, i + STORIES_PER_FILE)) {\n\t\t\tchunk[key] = entries[key];\n\t\t}\n\t\tchunks.push(chunk);\n\t}\n\treturn chunks;\n}\n\nexport async function runTests(\n\tconfig: StorywrightConfig,\n\toptions: TestOptions = {},\n\tcwd: string = process.cwd(),\n): Promise<TestRunResult> {\n\tconst outputRoot = options.outputDir\n\t\t? path.resolve(cwd, options.outputDir)\n\t\t: resolveOutputDir(cwd, '.storywright');\n\tconst tmpDir = path.join(outputRoot, 'tmp');\n\tconst reportDir = options.outputDir\n\t\t? path.join(outputRoot, 'report')\n\t\t: path.resolve(cwd, config.report.outputDir);\n\tconst storybookDir = path.resolve(cwd, config.storybook.staticDir);\n\tconst snapshotDir = path.join(tmpDir, 'snapshots');\n\n\t// Prepare directories early for parallel operations\n\tawait fs.mkdir(snapshotDir, { recursive: true });\n\n\t// Start baseline download in parallel with Storybook build\n\tconst storage = createStorageAdapter(config.storage);\n\tconst baselinePromise = storage\n\t\t.download({ branch: 'current', destDir: snapshotDir })\n\t\t.catch(() => {\n\t\t\tlogger.info('No existing baselines found');\n\t\t});\n\n\t// 1. Build Storybook if needed\n\tawait buildStorybook(config, cwd);\n\n\t// 2. Discover & filter stories\n\tlogger.start('Discovering stories...');\n\tconst allStories = await discoverStories(config, cwd);\n\tlet targetStories = filterStories(allStories, config);\n\n\t// Apply --filter option\n\tif (options.filter) {\n\t\ttargetStories = applyFilter(targetStories, options.filter);\n\t}\n\n\tlogger.info(`${Object.keys(targetStories.entries).length} stories found`);\n\n\t// 3. Diff-only: resolve affected stories (default in CI)\n\tconst effectiveDiffOnly = options.diffOnly ?? !!process.env.CI;\n\tif (effectiveDiffOnly && config.diffDetection.enabled) {\n\t\tlogger.start('Resolving dependencies...');\n\t\tconst diffResult = await resolveAffectedStories(\n\t\t\ttargetStories,\n\t\t\tconfig.diffDetection,\n\t\t\tstorybookDir,\n\t\t\tcwd,\n\t\t);\n\t\tif (!diffResult.allStories) {\n\t\t\ttargetStories = diffResult.targetStories;\n\t\t}\n\t\tlogger.info(`${Object.keys(targetStories.entries).length} stories affected by changes`);\n\t}\n\n\t// 4. Wait for baseline download to complete\n\tawait baselinePromise;\n\n\t// 5. Generate split test files for better worker distribution\n\tconst chunks = chunkStories(targetStories.entries);\n\tconst testFilePattern = chunks.length === 1 ? 'storywright-0.spec.ts' : 'storywright-*.spec.ts';\n\n\tfor (let i = 0; i < chunks.length; i++) {\n\t\tconst chunkIndex: StoryIndex = { ...targetStories, entries: chunks[i] };\n\t\tconst chunkPath = path.join(tmpDir, `target-stories-${i}.json`);\n\t\tawait fs.writeFile(chunkPath, JSON.stringify(chunkIndex));\n\n\t\tconst testContent = generateTestFile(config.screenshot, {\n\t\t\ttargetStoriesPath: chunkPath.replace(/\\\\/g, '/'),\n\t\t});\n\t\tawait fs.writeFile(path.join(tmpDir, `storywright-${i}.spec.ts`), testContent);\n\t}\n\n\tlogger.info(`${chunks.length} test file(s) generated`);\n\n\t// 6. Generate Playwright config\n\tconst reporterWrapperPath = path.join(tmpDir, 'reporter.mjs');\n\tconst resolvedReporterPath = resolveReporterPath().replace(/\\\\/g, '/');\n\tconst reporterOutputDir = reportDir.replace(/\\\\/g, '/');\n\n\tawait fs.writeFile(\n\t\treporterWrapperPath,\n\t\t`import StorywrightReporter from '${resolvedReporterPath}';\\nexport default class extends StorywrightReporter {\\n constructor() { super({ outputDir: '${reporterOutputDir}' }); }\\n}\\n`,\n\t);\n\n\t// Determine Storybook URL\n\tlet actualStorybookUrl = config.storybook.url;\n\tconst needsServer = !actualStorybookUrl;\n\n\tif (needsServer) {\n\t\tactualStorybookUrl = 'http://localhost:6007';\n\t}\n\n\tconst playwrightConfig = generatePlaywrightConfig(config, {\n\t\ttmpDir: tmpDir.replace(/\\\\/g, '/'),\n\t\tstorybookUrl: actualStorybookUrl ?? 'http://localhost:6007',\n\t\tsnapshotDir: snapshotDir.replace(/\\\\/g, '/'),\n\t\treporterPath: reporterWrapperPath.replace(/\\\\/g, '/'),\n\t\ttestMatch: testFilePattern,\n\t\tshard: options.shard,\n\t\treporters: options.reporters,\n\t});\n\n\tconst configPath = path.join(tmpDir, 'playwright.config.ts');\n\tawait fs.writeFile(configPath, playwrightConfig);\n\n\t// 7. Run Playwright tests\n\tlogger.start('Running tests...');\n\tconst args = ['playwright', 'test', '--config', configPath];\n\n\tif (options.updateSnapshots) {\n\t\targs.push('--update-snapshots');\n\t}\n\n\t// Start static server if needed\n\tlet serverProc: { kill: () => void } | undefined;\n\tif (needsServer) {\n\t\tserverProc = await startStaticServer(storybookDir, 6007);\n\t}\n\n\ttry {\n\t\tconst result = await exec('npx', args, { cwd, inherit: true });\n\n\t\t// 8. Read results\n\t\tlet summary: TestSummary | undefined;\n\t\ttry {\n\t\t\tconst summaryPath = path.join(reportDir, 'summary.json');\n\t\t\tconst summaryContent = await fs.readFile(summaryPath, 'utf-8');\n\t\t\tsummary = JSON.parse(summaryContent);\n\t\t} catch {\n\t\t\t// summary may not exist if no tests ran\n\t\t}\n\n\t\t// 9. Map exit codes per SPEC §14.2\n\t\tconst exitCode = mapExitCode(result.exitCode, summary);\n\n\t\treturn { exitCode, summary, reportDir, snapshotDir };\n\t} finally {\n\t\tserverProc?.kill();\n\t}\n}\n\nexport async function updateBaselines(\n\tconfig: StorywrightConfig,\n\toptions: { all?: boolean; upload?: boolean } = {},\n\tcwd: string = process.cwd(),\n): Promise<void> {\n\tconst result = await runTests(config, { updateSnapshots: true, diffOnly: !options.all }, cwd);\n\n\tif (result.exitCode !== 0) {\n\t\tlogger.warn('Some tests failed during baseline update');\n\t}\n\n\t// Save updated snapshots back to baselineDir (local disk operation)\n\tif (result.snapshotDir) {\n\t\tconst baselineDir = path.resolve(cwd, config.storage.local.baselineDir);\n\t\tawait fs.mkdir(baselineDir, { recursive: true });\n\t\tawait fs.cp(result.snapshotDir, baselineDir, { recursive: true });\n\t\tlogger.success(`Baselines saved to ${config.storage.local.baselineDir}`);\n\t}\n\n\t// --upload: upload to remote storage (S3 etc.) only when explicitly requested\n\tif (options.upload) {\n\t\tconst storage = createStorageAdapter(config.storage);\n\t\tconst baselineDir = path.resolve(cwd, config.storage.local.baselineDir);\n\t\tawait storage.upload({\n\t\t\tbranch: 'current',\n\t\t\tsourceDir: baselineDir,\n\t\t});\n\t\tlogger.success('Baselines uploaded to remote storage');\n\t}\n}\n\nfunction applyFilter(storyIndex: StoryIndex, filter: string): StoryIndex {\n\tconst matcher = picomatch(filter);\n\tconst entries: Record<string, StoryIndex['entries'][string]> = {};\n\tfor (const [id, story] of Object.entries(storyIndex.entries)) {\n\t\tconst fullName = `${story.title}/${story.name}`;\n\t\tif (matcher(fullName) || matcher(story.title) || matcher(story.id)) {\n\t\t\tentries[id] = story;\n\t\t}\n\t}\n\treturn { ...storyIndex, entries };\n}\n\nfunction mapExitCode(playwrightCode: number, summary?: TestSummary): number {\n\t// SPEC §14.2: 0 = success (no diff), 1 = success (diff found), 2 = execution error, 130 = SIGINT\n\tif (playwrightCode === 130 || playwrightCode === 143) {\n\t\treturn 130; // SIGINT / SIGTERM\n\t}\n\tif (summary) {\n\t\tif (summary.failed > 0) return 1;\n\t\tif (summary.total === 0 && playwrightCode !== 0) return 2;\n\t\treturn 0;\n\t}\n\t// No summary = likely execution error\n\treturn playwrightCode === 0 ? 0 : 2;\n}\n\nasync function startStaticServer(dir: string, port: number): Promise<{ kill: () => void }> {\n\tconst { createServer } = await import('node:http');\n\tconst sirv = (await import('sirv')).default;\n\n\tconst handler = sirv(dir, { single: false, dev: false });\n\tconst server = createServer(handler);\n\n\tawait new Promise<void>((resolve, reject) => {\n\t\tserver.on('error', reject);\n\t\tserver.listen(port, () => resolve());\n\t});\n\n\treturn { kill: () => server.close() };\n}\n","import type { StorywrightConfig } from '../config/types.js';\n\nexport function generatePlaywrightConfig(\n\tconfig: StorywrightConfig,\n\toptions: {\n\t\ttmpDir: string;\n\t\tstorybookUrl: string;\n\t\tsnapshotDir: string;\n\t\treporterPath: string;\n\t\ttestMatch: string;\n\t\tshard?: string;\n\t\treporters?: string[];\n\t},\n): string {\n\tconst projects = config.browsers.map((browser) => {\n\t\tconst browserOptions = config.browserOptions[browser];\n\t\tconst useObj = browserOptions\n\t\t\t? JSON.stringify(browserOptions, null, '\\t\\t')\n\t\t\t: getDefaultBrowserUse(browser);\n\t\treturn `\\t\\t{\n\\t\\t\\tname: '${browser}',\n\\t\\t\\tuse: ${useObj},\n\\t\\t}`;\n\t});\n\n\tconst workers = config.workers === 'auto' ? \"'100%'\" : String(config.workers);\n\n\tconst shard = options.shard\n\t\t? `\\tshard: { current: ${options.shard.split('/')[0]}, total: ${options.shard.split('/')[1]} },`\n\t\t: '';\n\n\t// Build reporter list: always include custom reporter, plus user-requested ones\n\tconst reporterEntries: string[] = [];\n\tconst requestedReporters = options.reporters ?? ['default', 'html'];\n\tfor (const r of requestedReporters) {\n\t\tif (r === 'default' || r === 'list') {\n\t\t\treporterEntries.push(\"\\t\\t['list']\");\n\t\t} else if (r !== 'html') {\n\t\t\t// Pass through other built-in Playwright reporters (dot, json, junit, etc.)\n\t\t\treporterEntries.push(`\\t\\t['${r}']`);\n\t\t}\n\t}\n\t// Always include custom storywright reporter\n\treporterEntries.push(`\\t\\t['${escapeBackslash(options.reporterPath)}']`);\n\n\treturn `import { defineConfig } from '@playwright/test';\n\nexport default defineConfig({\n\\ttestDir: '${escapeBackslash(options.tmpDir)}',\n\\ttestMatch: '${escapeBackslash(options.testMatch)}',\n\\tsnapshotDir: '${escapeBackslash(options.snapshotDir)}',\n\\tsnapshotPathTemplate: '{snapshotDir}/{arg}-{projectName}{ext}',\n\\ttimeout: ${config.timeout.test},\n\\texpect: {\n\\t\\ttoHaveScreenshot: {\n\\t\\t\\tmaxDiffPixelRatio: ${config.screenshot.maxDiffPixelRatio},\n\\t\\t\\tthreshold: ${config.screenshot.threshold},\n\\t\\t},\n\\t\\ttimeout: ${config.timeout.expect},\n\\t},\n\\tfullyParallel: true,\n\\tforbidOnly: !!process.env.CI,\n\\tretries: ${config.retries},\n\\tworkers: ${workers},\n${shard}\n\\treporter: [\n${reporterEntries.join(',\\n')}\n\\t],\n\\tuse: {\n\\t\\tbaseURL: '${options.storybookUrl}',\n\\t\\tnavigationTimeout: ${config.timeout.navigation},\n\\t\\ttimezoneId: '${config.screenshot.timezone}',\n\\t\\tlocale: '${config.screenshot.locale}',\n\\t},\n\\tprojects: [\n${projects.join(',\\n')}\n\\t],\n});\n`;\n}\n\nfunction getDefaultBrowserUse(browser: string): string {\n\tswitch (browser) {\n\t\tcase 'chromium':\n\t\t\treturn \"{ browserName: 'chromium' }\";\n\t\tcase 'firefox':\n\t\t\treturn \"{ browserName: 'firefox' }\";\n\t\tcase 'webkit':\n\t\t\treturn \"{ browserName: 'webkit' }\";\n\t\tdefault:\n\t\t\treturn `{ browserName: '${browser}' }`;\n\t}\n}\n\nfunction escapeBackslash(str: string): string {\n\treturn str.replace(/\\\\/g, '/');\n}\n","import type { ScreenshotConfig } from '../config/types.js';\n\nexport function generateTestFile(\n\tconfig: ScreenshotConfig,\n\toptions: {\n\t\ttargetStoriesPath: string;\n\t},\n): string {\n\treturn `import { test, expect } from '@playwright/test';\nimport { readFileSync } from 'node:fs';\n\nconst targetList = JSON.parse(\n\\treadFileSync('${escapeBackslash(options.targetStoriesPath)}', 'utf-8'),\n);\n\ntest.describe.parallel('visual regression testing', () => {\n\\tif (Object.keys(targetList.entries).length === 0) {\n\\t\\ttest('no stories to test', () => {\n\\t\\t\\texpect(true).toBeTruthy();\n\\t\\t});\n\\t}\n\n\\tfor (const story of Object.values(targetList.entries)) {\n\\t\\ttest(\\`\\${story.title}: \\${story.name}\\`, async ({ page }) => {\n\\t\\t\\t// Freeze time for reproducibility\n\\t\\t\\tawait page.clock.install({ time: new Date('${config.freezeTime}') });\n\n\\t\\t\\t// Seed Math.random for reproducibility\n\\t\\t\\tawait page.addInitScript((seed) => {\n\\t\\t\\t\\tlet s = seed;\n\\t\\t\\t\\tMath.random = () => {\n\\t\\t\\t\\t\\ts = (s * 16807 + 0) % 2147483647;\n\\t\\t\\t\\t\\treturn (s - 1) / 2147483646;\n\\t\\t\\t\\t};\n\\t\\t\\t}, ${config.seed});\n\n\\t\\t\\tawait page.goto(\\`/iframe.html?id=\\${story.id}\\`, {\n\\t\\t\\t\\twaitUntil: 'domcontentloaded',\n\\t\\t\\t});\n\n\\t\\t\\t// Wait for story to render: content inside #storybook-root OR portal content on body\n\\t\\t\\tawait page.waitForFunction(() => {\n\\t\\t\\t\\tconst root = document.getElementById('storybook-root');\n\\t\\t\\t\\tif (!root) return false;\n\\t\\t\\t\\tif (root.childElementCount > 0) return true;\n\\t\\t\\t\\t// Portal: check for elements on body that aren't part of Storybook's skeleton\n\\t\\t\\t\\tfor (const el of document.body.children) {\n\\t\\t\\t\\t\\tif (el.tagName === 'SCRIPT' || el.id === 'storybook-root' || el.id === 'storybook-docs') continue;\n\\t\\t\\t\\t\\treturn true;\n\\t\\t\\t\\t}\n\\t\\t\\t\\treturn false;\n\\t\\t\\t}, { timeout: 10000 });\n\n\\t\\t\\t// Wait for web fonts to finish loading\n\\t\\t\\tawait page.waitForFunction(() => document.fonts.ready);\n\n\\t\\t\\t// Wait for all images to finish loading (lazy-loaded, dynamic src, etc.)\n\\t\\t\\tawait page.waitForFunction(() => {\n\\t\\t\\t\\tconst images = document.querySelectorAll('img');\n\\t\\t\\t\\treturn Array.from(images).every(img => img.complete);\n\\t\\t\\t});\n\n\\t\\t\\t// Allow async renders (portals, modals, lazy components) to settle\n\\t\\t\\tawait page.waitForFunction(() => new Promise(resolve => requestAnimationFrame(() => resolve(true))));\n\n\\t\\t\\tawait expect(page).toHaveScreenshot(\n\\t\\t\\t\\t[story.title, \\`\\${story.id}.png\\`],\n\\t\\t\\t\\t{\n\\t\\t\\t\\t\\tanimations: '${config.animations}',\n\\t\\t\\t\\t\\tfullPage: ${config.fullPage},\n\\t\\t\\t\\t\\tthreshold: ${config.threshold},\n\\t\\t\\t\\t\\tmaxDiffPixelRatio: ${config.maxDiffPixelRatio},\n\\t\\t\\t\\t},\n\\t\\t\\t);\n\\t\\t});\n\\t}\n});\n`;\n}\n\nfunction escapeBackslash(str: string): string {\n\treturn str.replace(/\\\\/g, '/');\n}\n","import fs from 'node:fs/promises';\nimport path from 'node:path';\nimport picomatch from 'picomatch';\nimport { simpleGit } from 'simple-git';\nimport type { DiffDetectionConfig } from '../config/types.js';\nimport type { StatsIndex, StatsModule, StoryIndex } from '../core/types.js';\nimport { logger } from '../utils/logger.js';\nimport { normalizePath, stripLeadingDotSlash } from '../utils/path.js';\n\nexport interface DependencyResolver {\n\tgetDependencies(filePath: string): string[];\n\tgetStoriesForFiles(pathList: string[]): StoryIndex;\n}\n\nconst STORY_FILE_PATTERNS = ['.stories.', '.mdx'];\n\nfunction isStoryFile(moduleName: string): boolean {\n\treturn STORY_FILE_PATTERNS.some((p) => moduleName.includes(p));\n}\n\nexport class StorybookStatsDependencyResolver implements DependencyResolver {\n\tprivate moduleMap: Record<string, StatsModule>;\n\n\tconstructor(\n\t\tprivate statsJson: StatsIndex,\n\t\tprivate storiesJson: StoryIndex,\n\t) {\n\t\tthis.moduleMap = {};\n\t\tfor (const mod of statsJson.modules) {\n\t\t\t// Key by normalized name (primary) and normalized id (fallback)\n\t\t\tconst normalizedName = normalizePath(mod.name);\n\t\t\tthis.moduleMap[normalizedName] = mod;\n\t\t\tconst normalizedId = normalizePath(mod.id);\n\t\t\tif (normalizedId !== normalizedName) {\n\t\t\t\tthis.moduleMap[normalizedId] ??= mod;\n\t\t\t}\n\t\t}\n\t}\n\n\tgetDependencies(filePath: string): string[] {\n\t\tconst normalizedPath = normalizePath(filePath);\n\t\tconst dependencies = this.collectDependencies(normalizedPath);\n\n\t\tif (this.moduleMap[normalizedPath]) {\n\t\t\tdependencies.add(normalizedPath);\n\t\t}\n\n\t\treturn [...dependencies];\n\t}\n\n\tgetStoriesForFiles(pathList: string[]): StoryIndex {\n\t\tconst result: StoryIndex = { v: this.storiesJson.v, entries: {} };\n\n\t\tfor (const filePath of pathList) {\n\t\t\t// Finding #2 + #3: lookup via normalized moduleMap (name primary, id fallback)\n\t\t\tconst normalizedPath = normalizePath(filePath);\n\t\t\tconst stats = this.moduleMap[normalizedPath];\n\t\t\tif (!stats) continue;\n\n\t\t\t// Finding #1: collect ALL story reasons, not just first\n\t\t\tconst storyReasons = stats.reasons.filter((r) => isStoryFile(r.moduleName));\n\t\t\tfor (const reason of storyReasons) {\n\t\t\t\tconst normalizedImportPath = normalizePath(reason.moduleName);\n\t\t\t\t// Collect ALL matching story entries per reason\n\t\t\t\tfor (const storyObj of Object.values(this.storiesJson.entries)) {\n\t\t\t\t\tif (storyObj.type !== 'story') continue;\n\t\t\t\t\tif (normalizePath(storyObj.importPath) === normalizedImportPath) {\n\t\t\t\t\t\tresult.entries[storyObj.id] = storyObj;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn result;\n\t}\n\n\tprivate collectDependencies(name: string, result = new Set<string>()): Set<string> {\n\t\tconst mod = this.moduleMap[normalizePath(name)];\n\t\tif (mod) {\n\t\t\tfor (const reason of mod.reasons) {\n\t\t\t\tif (!result.has(reason.moduleName)) {\n\t\t\t\t\tresult.add(reason.moduleName);\n\t\t\t\t\tthis.collectDependencies(reason.moduleName, result);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn result;\n\t}\n}\n\nexport interface DiffResult {\n\tallStories: boolean;\n\ttargetStories: StoryIndex;\n}\n\ninterface DiffFileEntry {\n\tfile: string;\n\tfrom?: string;\n}\n\nexport async function resolveAffectedStories(\n\tstoriesJson: StoryIndex,\n\tconfig: DiffDetectionConfig,\n\tstorybookStaticDir: string,\n\tcwd: string,\n): Promise<DiffResult> {\n\tconst git = simpleGit({ baseDir: cwd });\n\n\t// Get diff summary\n\tlet diffEntries: DiffFileEntry[];\n\ttry {\n\t\tconst mergeBase = await git.raw(['merge-base', config.baseBranch, 'HEAD']);\n\t\tconst diff = await git.diffSummary([mergeBase.trim(), 'HEAD']);\n\t\tdiffEntries = diff.files.map((f) => ({\n\t\t\tfile: f.file,\n\t\t\t// Handle renames: include both old and new paths\n\t\t\tfrom: 'from' in f ? (f as { from: string }).from : undefined,\n\t\t}));\n\t} catch {\n\t\tlogger.warn('Failed to resolve git diff, running all stories');\n\t\treturn { allStories: true, targetStories: storiesJson };\n\t}\n\n\tif (diffEntries.length === 0) {\n\t\tlogger.info('No changed files detected');\n\t\treturn { allStories: false, targetStories: { v: storiesJson.v, entries: {} } };\n\t}\n\n\t// Collect all affected paths (including rename sources)\n\tconst allPaths: string[] = [];\n\tfor (const entry of diffEntries) {\n\t\tallPaths.push(entry.file);\n\t\tif (entry.from) {\n\t\t\tallPaths.push(entry.from);\n\t\t}\n\t}\n\n\t// Check watchFiles\n\tfor (const file of allPaths) {\n\t\tfor (const pattern of config.watchFiles) {\n\t\t\tif (picomatch(pattern)(file)) {\n\t\t\t\tlogger.info(`Watch file changed: ${file}, running all stories`);\n\t\t\t\treturn { allStories: true, targetStories: storiesJson };\n\t\t\t}\n\t\t}\n\t}\n\n\t// Load stats json for dependency resolution\n\tconst statsPath = path.resolve(storybookStaticDir, 'preview-stats.json');\n\tlet statsJson: StatsIndex;\n\ttry {\n\t\tstatsJson = JSON.parse(await fs.readFile(statsPath, 'utf-8'));\n\t} catch {\n\t\tlogger.warn('preview-stats.json not found, running all stories');\n\t\treturn { allStories: true, targetStories: storiesJson };\n\t}\n\n\tconst resolver = new StorybookStatsDependencyResolver(statsJson, storiesJson);\n\tconst targetStories: StoryIndex = { v: storiesJson.v, entries: {} };\n\n\t// Direct story file matches (both .stories.* and .mdx)\n\tfor (const file of allPaths) {\n\t\tconst matchedStories = Object.values(storiesJson.entries).filter(\n\t\t\t(story) => stripLeadingDotSlash(story.importPath) === file,\n\t\t);\n\t\tfor (const story of matchedStories) {\n\t\t\ttargetStories.entries[story.id] = story;\n\t\t}\n\t}\n\n\t// Dependency-based matches\n\tfor (const file of allPaths) {\n\t\tconst deps = resolver.getDependencies(normalizePath(file));\n\t\tconst depStories = resolver.getStoriesForFiles(deps);\n\t\tfor (const [id, story] of Object.entries(depStories.entries)) {\n\t\t\ttargetStories.entries[id] = story;\n\t\t}\n\t}\n\n\tlogger.info(`Resolved ${Object.keys(targetStories.entries).length} affected stories`);\n\treturn { allStories: false, targetStories };\n}\n","import path from 'node:path';\n\nexport function normalizePath(filePath: string): string {\n\tconst normalized = filePath.replace(/\\\\/g, '/');\n\tif (normalized.startsWith('./')) {\n\t\treturn normalized;\n\t}\n\treturn `./${normalized}`;\n}\n\nexport function stripLeadingDotSlash(filePath: string): string {\n\treturn filePath.replace(/^\\.\\//, '');\n}\n\nexport function resolveOutputDir(outputDir: string, ...segments: string[]): string {\n\treturn path.resolve(outputDir, ...segments);\n}\n","import { spawn } from 'node:child_process';\n\nexport interface ExecResult {\n\texitCode: number;\n\tstdout: string;\n\tstderr: string;\n}\n\nexport function exec(\n\tcommand: string,\n\targs: string[],\n\toptions?: { cwd?: string; env?: Record<string, string>; inherit?: boolean },\n): Promise<ExecResult> {\n\treturn new Promise((resolve, reject) => {\n\t\tconst proc = spawn(command, args, {\n\t\t\tcwd: options?.cwd,\n\t\t\tenv: { ...process.env, ...options?.env },\n\t\t\tstdio: options?.inherit ? ['ignore', 'inherit', 'inherit'] : ['ignore', 'pipe', 'pipe'],\n\t\t\tshell: false,\n\t\t});\n\n\t\tlet stdout = '';\n\t\tlet stderr = '';\n\n\t\tif (!options?.inherit) {\n\t\t\tproc.stdout?.on('data', (data: Buffer) => {\n\t\t\t\tstdout += data.toString();\n\t\t\t});\n\n\t\t\tproc.stderr?.on('data', (data: Buffer) => {\n\t\t\t\tstderr += data.toString();\n\t\t\t});\n\t\t}\n\n\t\tproc.on('error', reject);\n\n\t\tproc.on('close', (code) => {\n\t\t\tresolve({ exitCode: code ?? 1, stdout, stderr });\n\t\t});\n\t});\n}\n","import fs from 'node:fs/promises';\nimport path from 'node:path';\nimport picomatch from 'picomatch';\nimport type { StorywrightConfig } from '../config/types.js';\nimport { logger } from '../utils/logger.js';\nimport { exec } from '../utils/process.js';\nimport type { Story, StoryIndex } from './types.js';\n\nexport async function buildStorybook(config: StorywrightConfig, cwd: string): Promise<void> {\n\tif (config.storybook.url) {\n\t\tlogger.info('Using running Storybook at', config.storybook.url);\n\t\treturn;\n\t}\n\n\tconst staticDir = path.resolve(cwd, config.storybook.staticDir);\n\ttry {\n\t\tawait fs.access(path.join(staticDir, 'index.json'));\n\t\tlogger.info('Storybook already built at', staticDir);\n\t\treturn;\n\t} catch {\n\t\t// need to build\n\t}\n\n\tlogger.start('Building Storybook...');\n\tconst [command, ...args] = config.storybook.buildCommand.split(' ');\n\tconst result = await exec(command, args, { cwd });\n\tif (result.exitCode !== 0) {\n\t\tthrow new Error(\n\t\t\t`Storybook build failed (exit code ${result.exitCode}):\\n${result.stderr}\\n\\nError code: SW_E_STORYBOOK_BUILD_FAILED`,\n\t\t);\n\t}\n\tlogger.success('Storybook built');\n}\n\nexport async function discoverStories(config: StorywrightConfig, cwd: string): Promise<StoryIndex> {\n\tconst staticDir = path.resolve(cwd, config.storybook.staticDir);\n\tconst indexPath = path.join(staticDir, 'index.json');\n\n\ttry {\n\t\tawait fs.access(indexPath);\n\t} catch {\n\t\tthrow new Error(\n\t\t\t`Storybook build directory not found at '${config.storybook.staticDir}/'\\n\\n Run one of the following:\\n $ npx storybook build --stats-json\\n $ npx storywright test --storybook-url http://localhost:6006\\n\\n Error code: SW_E_STORYBOOK_DIR_NOT_FOUND`,\n\t\t);\n\t}\n\n\tconst raw = JSON.parse(await fs.readFile(indexPath, 'utf-8'));\n\tconst indexJson = normalizeStoryIndex(raw, config.storybook.compatibility);\n\n\t// Version check\n\tif (indexJson.v < 4) {\n\t\tthrow new Error(\n\t\t\t'Storybook 7.x or earlier is not supported. Storywright requires Storybook 8 or later.\\n\\nError code: SW_E_STORYBOOK_UNSUPPORTED',\n\t\t);\n\t}\n\n\treturn indexJson;\n}\n\n/**\n * Parse Storybook index.json (v8+).\n */\nfunction normalizeStoryIndex(\n\traw: Record<string, unknown>,\n\t_compatibility: 'auto' | 'v8',\n): StoryIndex {\n\tconst version = typeof raw.v === 'number' ? raw.v : 0;\n\tconst entries = (raw.entries ?? {}) as Record<string, Story>;\n\n\treturn { v: version, entries };\n}\n\nexport function filterStories(storyIndex: StoryIndex, config: StorywrightConfig): StoryIndex {\n\tconst entries: Record<string, Story> = {};\n\tconst includeMatchers = config.include.map((p) => picomatch(p));\n\tconst excludeMatchers = config.exclude.map((p) => picomatch(p));\n\n\tfor (const [id, story] of Object.entries(storyIndex.entries)) {\n\t\t// Skip docs entries\n\t\tif (story.type === 'docs') continue;\n\t\tif (story.name === 'Docs') continue;\n\n\t\tconst fullName = `${story.title}/${story.name}`;\n\n\t\t// Check include patterns\n\t\tconst isIncluded = includeMatchers.some((m) => m(fullName));\n\t\tif (!isIncluded) continue;\n\n\t\t// Check exclude patterns\n\t\tconst isExcluded = excludeMatchers.some((m) => m(fullName));\n\t\tif (isExcluded) continue;\n\n\t\tentries[id] = story;\n\t}\n\n\treturn { ...storyIndex, entries };\n}\n"],"mappings":";AAAA,SAAS,cAAc,oBAAoB;;;ACEpC,IAAM,iBAAoC;AAAA,EAChD,WAAW;AAAA,IACV,WAAW;AAAA,IACX,cAAc;AAAA,IACd,KAAK;AAAA,IACL,eAAe;AAAA,EAChB;AAAA,EAEA,UAAU,CAAC,UAAU;AAAA,EACrB,gBAAgB,CAAC;AAAA,EAEjB,YAAY;AAAA,IACX,UAAU;AAAA,IACV,YAAY;AAAA,IACZ,WAAW;AAAA,IACX,mBAAmB;AAAA,IACnB,YAAY;AAAA,IACZ,UAAU;AAAA,IACV,QAAQ;AAAA,IACR,MAAM;AAAA,EACP;AAAA,EAEA,eAAe;AAAA,IACd,SAAS;AAAA,IACT,YAAY,CAAC,gBAAgB,qBAAqB,iBAAiB;AAAA,IACnE,YAAY;AAAA,EACb;AAAA,EAEA,SAAS;AAAA,IACR,UAAU;AAAA,IACV,OAAO;AAAA,MACN,aAAa;AAAA,IACd;AAAA,IACA,IAAI;AAAA,MACH,QAAQ;AAAA,MACR,QAAQ;AAAA,MACR,QAAQ;AAAA,MACR,aAAa;AAAA,IACd;AAAA,EACD;AAAA,EAEA,QAAQ;AAAA,IACP,WAAW;AAAA,IACX,OAAO;AAAA,EACR;AAAA,EAEA,SAAS;AAAA,EACT,SAAS;AAAA,EAET,SAAS;AAAA,IACR,MAAM;AAAA,IACN,YAAY;AAAA,IACZ,QAAQ;AAAA,EACT;AAAA,EAEA,SAAS,C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Aa,IAAI,MAAM,OAAO,MAAW;AACjD,QAAM,QAAQ,MAAM,OAAO,MAAM,GAAG;AAEpC,QAAM,UAAU,KAAK,KAAK,EAAE,QAAQ,OAAO,KAAK,MAAM,CAAC;AACvD,QAAM,SAAS,aAAa,OAAO;AAEnC,QAAM,IAAI,QAAc,CAAC,SAAS,WAAW;AAC5C,WAAO,GAAG,SAAS,MAAM;AACzB,WAAO,OAAO,MAAM,MAAM,QAAQ,CAAC;AAAA,EACpC,CAAC;AAED,SAAO,EAAE,MAAM,MAAM,OAAO,MAAM,EAAE;AACrC;","names":["require","fs","path","picomatch","escapeBackslash","fs","path","path","path","fs","fs","path","picomatch","path","fs","picomatch","path","fs","picomatch"]}