@storywright/cli 0.5.4 → 0.5.5
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.
|
@@ -781,10 +781,13 @@ async function runTests(config, options = {}, cwd = process.cwd()) {
|
|
|
781
781
|
const storybookDir = path5.resolve(cwd, config.storybook.staticDir);
|
|
782
782
|
const snapshotDir = path5.join(tmpDir, "snapshots");
|
|
783
783
|
await fs4.mkdir(snapshotDir, { recursive: true });
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
784
|
+
let baselinePromise;
|
|
785
|
+
if (!options.updateSnapshots) {
|
|
786
|
+
const storage = await createStorageAdapter(config.storage);
|
|
787
|
+
baselinePromise = storage.download({ branch: "current", destDir: snapshotDir, onProgress: (msg) => logger.info(msg) }).catch(() => {
|
|
788
|
+
logger.info("No existing baselines found");
|
|
789
|
+
});
|
|
790
|
+
}
|
|
788
791
|
await buildStorybook(config, cwd);
|
|
789
792
|
logger.start("Discovering stories...");
|
|
790
793
|
const allStories = await discoverStories(config, cwd);
|
|
@@ -931,7 +934,8 @@ async function updateBaselines(config, options = {}, cwd = process.cwd()) {
|
|
|
931
934
|
await storage.upload({
|
|
932
935
|
branch: "current",
|
|
933
936
|
sourceDir: baselineDir,
|
|
934
|
-
shard: options.shard
|
|
937
|
+
shard: options.shard,
|
|
938
|
+
onProgress: (msg) => logger.info(msg)
|
|
935
939
|
});
|
|
936
940
|
logger.success("Baselines uploaded to remote storage");
|
|
937
941
|
}
|
|
@@ -981,4 +985,4 @@ export {
|
|
|
981
985
|
runTests,
|
|
982
986
|
updateBaselines
|
|
983
987
|
};
|
|
984
|
-
//# sourceMappingURL=chunk-
|
|
988
|
+
//# sourceMappingURL=chunk-KIUCJ6V6.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 type { StorageConfig } from '../config/types.js';\nimport { LocalStorageAdapter } from './local.js';\nimport type { StorageAdapter } from './types.js';\n\nexport async function createStorageAdapter(config: StorageConfig): Promise<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 await loadS3Adapter(config);\n\t\tdefault:\n\t\t\tthrow new Error(`Unknown storage provider: ${config.provider}`);\n\t}\n}\n\nasync function loadS3Adapter(config: StorageConfig): Promise<StorageAdapter> {\n\ttry {\n\t\tconst { S3StorageAdapter } = await import('@storywright/storage-s3');\n\t\treturn new S3StorageAdapter(config.s3) as StorageAdapter;\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\t// Skip download when updating snapshots (update command) — baselines are regenerated\n\tlet baselinePromise: Promise<void> | undefined;\n\tif (!options.updateSnapshots) {\n\t\tconst storage = await createStorageAdapter(config.storage);\n\t\tbaselinePromise = storage\n\t\t\t.download({ branch: 'current', destDir: snapshotDir, onProgress: (msg) => logger.info(msg) })\n\t\t\t.catch(() => {\n\t\t\t\tlogger.info('No existing baselines found');\n\t\t\t});\n\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; shard?: string; filter?: string } = {},\n\tcwd: string = process.cwd(),\n): Promise<TestRunResult> {\n\tconst result = await runTests(\n\t\tconfig,\n\t\t{\n\t\t\tupdateSnapshots: true,\n\t\t\tdiffOnly: !options.all,\n\t\t\tshard: options.shard,\n\t\t\tfilter: options.filter,\n\t\t},\n\t\tcwd,\n\t);\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 = await 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\tshard: options.shard,\n\t\t\tonProgress: (msg) => logger.info(msg),\n\t\t});\n\t\tlogger.success('Baselines uploaded to remote storage');\n\t}\n\n\treturn result;\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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,SAAS,EAAG,QAAO;AAC/B,QAAI,QAAQ,UAAU,KAAK,mBAAmB,EAAG,QAAO;AACxD,WAAO;AAAA,EACR;AAEA,SAAO,mBAAmB,IAAI,IAAI;AACnC;AAEA,eAAe,kBAAkB,KAAa,MAA6C;AAC1F,QAAM,EAAE,aAAa,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":["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-
|
|
9
|
+
} from "./chunk-KIUCJ6V6.js";
|
|
10
10
|
import {
|
|
11
11
|
generateHtmlReport
|
|
12
12
|
} from "./chunk-HPK2VJXG.js";
|
|
@@ -418,7 +418,7 @@ var uploadCommand = defineCommand6({
|
|
|
418
418
|
var main = defineCommand7({
|
|
419
419
|
meta: {
|
|
420
420
|
name: "storywright",
|
|
421
|
-
version: "0.5.
|
|
421
|
+
version: "0.5.5",
|
|
422
422
|
description: "Zero-config visual regression testing powered by Storybook + Playwright"
|
|
423
423
|
},
|
|
424
424
|
subCommands: {
|
package/dist/index.d.ts
CHANGED
|
@@ -126,11 +126,13 @@ interface StorageAdapter {
|
|
|
126
126
|
interface DownloadOptions {
|
|
127
127
|
branch: string;
|
|
128
128
|
destDir: string;
|
|
129
|
+
onProgress?: (message: string) => void;
|
|
129
130
|
}
|
|
130
131
|
interface UploadOptions {
|
|
131
132
|
branch: string;
|
|
132
133
|
sourceDir: string;
|
|
133
134
|
shard?: string;
|
|
135
|
+
onProgress?: (message: string) => void;
|
|
134
136
|
}
|
|
135
137
|
|
|
136
138
|
interface ReportData {
|
package/dist/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
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 type { StorageConfig } from '../config/types.js';\nimport { LocalStorageAdapter } from './local.js';\nimport type { StorageAdapter } from './types.js';\n\nexport async function createStorageAdapter(config: StorageConfig): Promise<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 await loadS3Adapter(config);\n\t\tdefault:\n\t\t\tthrow new Error(`Unknown storage provider: ${config.provider}`);\n\t}\n}\n\nasync function loadS3Adapter(config: StorageConfig): Promise<StorageAdapter> {\n\ttry {\n\t\tconst { S3StorageAdapter } = await import('@storywright/storage-s3');\n\t\treturn new S3StorageAdapter(config.s3) as StorageAdapter;\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 = await 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; shard?: string; filter?: string } = {},\n\tcwd: string = process.cwd(),\n): Promise<TestRunResult> {\n\tconst result = await runTests(\n\t\tconfig,\n\t\t{\n\t\t\tupdateSnapshots: true,\n\t\t\tdiffOnly: !options.all,\n\t\t\tshard: options.shard,\n\t\t\tfilter: options.filter,\n\t\t},\n\t\tcwd,\n\t);\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 = await 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\tshard: options.shard,\n\t\t});\n\t\tlogger.success('Baselines uploaded to remote storage');\n\t}\n\n\treturn result;\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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,mBAAmB,KAAK;AACrD,WAAO;AAAA,EACR;AACA,MAAI,SAAS;AACZ,QAAI,QAAQ,SAAS,EAAG,QAAO;AAC/B,QAAI,QAAQ,UAAU,KAAK,mBAAmB,EAAG,QAAO;AACxD,WAAO;AAAA,EACR;AAEA,SAAO,mBAAmB,IAAI,IAAI;AACnC;AAEA,eAAe,kBAAkB,KAAa,MAA6C;AAC1F,QAAM,EAAE,aAAa,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":["fs","path","picomatch","testMatchLine","escapeBackslash","fs","path","path","path","fs","fs","path","picomatch","path","fs","picomatch","path","fs","picomatch"]}
|