@storywright/cli 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/config/index.ts","../src/config/defaults.ts","../src/reporter/cli-reporter.ts","../src/storage/index.ts","../src/storage/local.ts","../src/utils/logger.ts","../src/core/engine.ts","../src/playwright/config-generator.ts","../src/playwright/test-generator.ts","../src/resolver/index.ts","../src/utils/path.ts","../src/utils/process.ts","../src/core/storybook.ts"],"sourcesContent":["import { loadConfig as unconfigLoad } from 'unconfig';\nimport { DEFAULT_CONFIG } from './defaults.js';\nimport type { DeepPartial, StorywrightConfig } from './types.js';\n\nexport function defineConfig(\n\tconfig: DeepPartial<StorywrightConfig>,\n): DeepPartial<StorywrightConfig> {\n\treturn config;\n}\n\nfunction isPlainObject(value: unknown): value is Record<string, unknown> {\n\treturn value !== null && typeof value === 'object' && !Array.isArray(value);\n}\n\nfunction deepMerge(\n\ttarget: Record<string, unknown>,\n\tsource: Record<string, unknown>,\n): Record<string, unknown> {\n\tconst result: Record<string, unknown> = { ...target };\n\tfor (const key of Object.keys(source)) {\n\t\tconst sourceVal = source[key];\n\t\tconst targetVal = result[key];\n\t\tif (isPlainObject(sourceVal) && isPlainObject(targetVal)) {\n\t\t\tresult[key] = deepMerge(targetVal, sourceVal);\n\t\t} else if (sourceVal !== undefined) {\n\t\t\tresult[key] = sourceVal;\n\t\t}\n\t}\n\treturn result;\n}\n\nexport async function loadConfig(\n\tcwd: string = process.cwd(),\n\toverrides?: DeepPartial<StorywrightConfig>,\n): Promise<StorywrightConfig> {\n\tconst { config: userConfig } = await unconfigLoad<DeepPartial<StorywrightConfig>>({\n\t\tsources: [\n\t\t\t{\n\t\t\t\tfiles: 'storywright.config',\n\t\t\t\textensions: ['ts', 'js', 'mjs'],\n\t\t\t},\n\t\t],\n\t\tcwd,\n\t});\n\n\tlet merged = DEFAULT_CONFIG as unknown as Record<string, unknown>;\n\tif (userConfig) {\n\t\tmerged = deepMerge(merged, userConfig as Record<string, unknown>);\n\t}\n\tif (overrides) {\n\t\tmerged = deepMerge(merged, overrides as Record<string, unknown>);\n\t}\n\treturn merged as unknown as StorywrightConfig;\n}\n\nexport type { StorywrightConfig, DeepPartial } from './types.js';\n","import type { StorywrightConfig } from './types.js';\n\nexport const DEFAULT_CONFIG: StorywrightConfig = {\n\tstorybook: {\n\t\tstaticDir: 'storybook-static',\n\t\tbuildCommand: 'npx storybook build --stats-json',\n\t\turl: undefined,\n\t\tcompatibility: 'auto',\n\t},\n\n\tbrowsers: ['chromium'],\n\tbrowserOptions: {},\n\n\tscreenshot: {\n\t\tfullPage: true,\n\t\tanimations: 'disabled',\n\t\tthreshold: 0.02,\n\t\tmaxDiffPixelRatio: 0.02,\n\t\tfreezeTime: '2024-01-01T00:00:00',\n\t\ttimezone: 'UTC',\n\t\tlocale: 'en-US',\n\t\tseed: 1,\n\t},\n\n\tdiffDetection: {\n\t\tenabled: true,\n\t\twatchFiles: ['package.json', 'package-lock.json', '.storybook/**/*'],\n\t\tbaseBranch: 'main',\n\t},\n\n\tstorage: {\n\t\tprovider: 'local',\n\t\tlocal: {\n\t\t\tbaselineDir: '.storywright/baselines',\n\t\t},\n\t\ts3: {\n\t\t\tbucket: '',\n\t\t\tprefix: 'storywright/baselines',\n\t\t\tregion: 'ap-northeast-1',\n\t\t\tcompression: 'zstd',\n\t\t},\n\t},\n\n\treport: {\n\t\toutputDir: '.storywright/report',\n\t\ttitle: 'Storywright Report',\n\t},\n\n\tworkers: 'auto',\n\n\ttimeout: {\n\t\ttest: 30000,\n\t\tnavigation: 20000,\n\t\texpect: 10000,\n\t},\n\n\tinclude: ['**'],\n\texclude: [],\n\n\thooks: {},\n};\n","import type { TestSummary } from '../core/types.js';\n\nexport function formatSummary(summary: TestSummary, options?: { reportPath?: string }): string {\n\tconst durationSec = Math.round(summary.duration / 1000);\n\tconst minutes = Math.floor(durationSec / 60);\n\tconst seconds = durationSec % 60;\n\tconst durationStr = minutes > 0 ? `${minutes}m ${seconds}s` : `${seconds}s`;\n\n\tconst lines: string[] = [\n\t\t'',\n\t\t'Storywright Results',\n\t\t'\\u2550'.repeat(42),\n\t\t` Total: ${summary.total} Passed: ${summary.passed} Failed: ${summary.failed} Skipped: ${summary.skipped}`,\n\t\t` Duration: ${durationStr}`,\n\t\t` Browsers: ${summary.browsers.join(', ')}`,\n\t];\n\n\tconst newFailures = summary.failures.filter((f) => f.type === 'new');\n\tconst diffFailures = summary.failures.filter((f) => f.type !== 'new');\n\n\tif (newFailures.length > 0) {\n\t\tlines.push('');\n\t\tlines.push(' New (no baseline):');\n\t\tfor (const failure of newFailures) {\n\t\t\tlines.push(` \\u25cb ${failure.story}: ${failure.variant} (${failure.browser})`);\n\t\t}\n\t}\n\n\tif (diffFailures.length > 0) {\n\t\tlines.push('');\n\t\tlines.push(' Failed:');\n\t\tfor (const failure of diffFailures) {\n\t\t\tlines.push(` \\u2717 ${failure.story}: ${failure.variant} (${failure.browser})`);\n\t\t\tif (failure.diffRatio > 0) {\n\t\t\t\tconst pct = (failure.diffRatio * 100).toFixed(1);\n\t\t\t\tlines.push(` \\u2192 Diff: ${pct}% pixels changed`);\n\t\t\t}\n\t\t}\n\t}\n\n\tconst reportPath = options?.reportPath ?? '.storywright/report/index.html';\n\tlines.push('');\n\tlines.push(` Report: ${reportPath}`);\n\tlines.push('\\u2550'.repeat(42));\n\tlines.push('');\n\n\treturn lines.join('\\n');\n}\n","import { createRequire } from 'node:module';\nimport type { StorageConfig } from '../config/types.js';\nimport { LocalStorageAdapter } from './local.js';\nimport type { StorageAdapter } from './types.js';\n\nexport function createStorageAdapter(config: StorageConfig): StorageAdapter {\n\tswitch (config.provider) {\n\t\tcase 'local':\n\t\t\treturn new LocalStorageAdapter(config.local.baselineDir);\n\t\tcase 's3':\n\t\t\treturn loadS3Adapter(config);\n\t\tdefault:\n\t\t\tthrow new Error(`Unknown storage provider: ${config.provider}`);\n\t}\n}\n\nfunction loadS3Adapter(config: StorageConfig): StorageAdapter {\n\ttry {\n\t\tconst require = createRequire(import.meta.url);\n\t\tconst { S3StorageAdapter } = require('@storywright/storage-s3') as {\n\t\t\tS3StorageAdapter: new (cfg: {\n\t\t\t\tbucket: string;\n\t\t\t\tprefix: string;\n\t\t\t\tregion: string;\n\t\t\t\tcompression?: string;\n\t\t\t}) => StorageAdapter;\n\t\t};\n\t\treturn new S3StorageAdapter(config.s3);\n\t} catch {\n\t\tthrow new Error(\n\t\t\t'S3 storage adapter requires the @storywright/storage-s3 package.\\nInstall it with: pnpm add @storywright/storage-s3',\n\t\t);\n\t}\n}\n\nexport type { StorageAdapter, DownloadOptions, UploadOptions } from './types.js';\n","import fs from 'node:fs/promises';\nimport path from 'node:path';\nimport type { DownloadOptions, StorageAdapter, UploadOptions } from './types.js';\n\nexport class LocalStorageAdapter implements StorageAdapter {\n\tconstructor(private readonly baselineDir: string) {}\n\n\tasync download(options: DownloadOptions): Promise<void> {\n\t\tconst sourceDir = path.resolve(this.baselineDir, options.branch);\n\t\ttry {\n\t\t\tawait fs.access(sourceDir);\n\t\t} catch {\n\t\t\treturn;\n\t\t}\n\t\tawait fs.cp(sourceDir, options.destDir, { recursive: true });\n\t}\n\n\tasync upload(options: UploadOptions): Promise<void> {\n\t\tconst destDir = path.resolve(this.baselineDir, options.branch);\n\t\tawait fs.mkdir(destDir, { recursive: true });\n\t\tawait fs.cp(options.sourceDir, destDir, { recursive: true });\n\t}\n\n\tasync exists(branch: string): Promise<boolean> {\n\t\tconst dir = path.resolve(this.baselineDir, branch);\n\t\ttry {\n\t\t\tawait fs.access(dir);\n\t\t\treturn true;\n\t\t} catch {\n\t\t\treturn false;\n\t\t}\n\t}\n}\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\tfancy: !isCI,\n\tlevel: process.env.STORYWRIGHT_DEBUG ? 5 : 3,\n});\n\nexport { isCI };\n","import fs from 'node:fs/promises';\nimport path from 'node:path';\nimport picomatch from 'picomatch';\nimport type { StorywrightConfig } from '../config/types.js';\nimport { generatePlaywrightConfig } from '../playwright/config-generator.js';\nimport { generateTestFile } from '../playwright/test-generator.js';\nimport { resolveAffectedStories } from '../resolver/index.js';\nimport { createStorageAdapter } from '../storage/index.js';\nimport { logger } from '../utils/logger.js';\nimport { resolveOutputDir } from '../utils/path.js';\nimport { exec } from '../utils/process.js';\nimport { buildStorybook, discoverStories, filterStories } from './storybook.js';\nimport type { 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}\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\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\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\n\tif (options.diffOnly && 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. Prepare temp directory\n\tawait fs.mkdir(tmpDir, { recursive: true });\n\n\tconst targetStoriesPath = path.join(tmpDir, 'target-stories.json');\n\tawait fs.writeFile(targetStoriesPath, JSON.stringify(targetStories));\n\n\t// 5. Copy baselines to snapshot dir\n\tconst snapshotDir = path.join(tmpDir, 'snapshots');\n\tawait fs.mkdir(snapshotDir, { recursive: true });\n\n\tconst storage = createStorageAdapter(config.storage);\n\ttry {\n\t\tawait storage.download({ branch: 'current', destDir: snapshotDir });\n\t} catch {\n\t\tlogger.info('No existing baselines found');\n\t}\n\n\t// 6. Generate Playwright config & test file\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\tconst testFileName = 'storywright-test.spec.ts';\n\tconst testFilePath = path.join(tmpDir, testFileName);\n\tconst testContent = generateTestFile(config.screenshot, {\n\t\ttargetStoriesPath: targetStoriesPath.replace(/\\\\/g, '/'),\n\t});\n\tawait fs.writeFile(testFilePath, testContent);\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\ttestFile: testFileName,\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 });\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 };\n\t} finally {\n\t\tserverProc?.kill();\n\t}\n}\n\nexport async function updateBaselines(\n\tconfig: StorywrightConfig,\n\toptions: { all?: boolean; upload?: boolean } = {},\n\tcwd: string = process.cwd(),\n): Promise<void> {\n\tconst result = await runTests(config, { updateSnapshots: true, diffOnly: !options.all }, cwd);\n\n\tif (result.exitCode !== 0) {\n\t\tlogger.warn('Some tests failed during baseline update');\n\t}\n\n\tif (options.upload) {\n\t\tconst storage = createStorageAdapter(config.storage);\n\t\tconst baselineDir = path.resolve(cwd, config.storage.local.baselineDir);\n\t\tawait storage.upload({\n\t\t\tbranch: 'current',\n\t\t\tsourceDir: baselineDir,\n\t\t});\n\t\tlogger.success('Baselines uploaded');\n\t}\n\n\tlogger.success('Baselines updated');\n}\n\nfunction applyFilter(storyIndex: StoryIndex, filter: string): StoryIndex {\n\tconst matcher = picomatch(filter);\n\tconst entries: Record<string, StoryIndex['entries'][string]> = {};\n\tfor (const [id, story] of Object.entries(storyIndex.entries)) {\n\t\tconst fullName = `${story.title}/${story.name}`;\n\t\tif (matcher(fullName) || matcher(story.title) || matcher(story.id)) {\n\t\t\tentries[id] = story;\n\t\t}\n\t}\n\treturn { ...storyIndex, entries };\n}\n\nfunction mapExitCode(playwrightCode: number, summary?: TestSummary): number {\n\t// SPEC §14.2: 0 = success (no diff), 1 = success (diff found), 2 = execution error, 130 = SIGINT\n\tif (playwrightCode === 130 || playwrightCode === 143) {\n\t\treturn 130; // SIGINT / SIGTERM\n\t}\n\tif (summary) {\n\t\tif (summary.failed > 0) return 1;\n\t\tif (summary.total === 0 && playwrightCode !== 0) return 2;\n\t\treturn 0;\n\t}\n\t// No summary = likely execution error\n\treturn playwrightCode === 0 ? 0 : 2;\n}\n\nasync function startStaticServer(dir: string, port: number): Promise<{ kill: () => void }> {\n\tconst { createServer } = await import('node:http');\n\tconst sirv = (await import('sirv')).default;\n\n\tconst handler = sirv(dir, { single: false, dev: false });\n\tconst server = createServer(handler);\n\n\tawait new Promise<void>((resolve, reject) => {\n\t\tserver.on('error', reject);\n\t\tserver.listen(port, () => resolve());\n\t});\n\n\treturn { kill: () => server.close() };\n}\n","import type { StorywrightConfig } from '../config/types.js';\n\nexport function generatePlaywrightConfig(\n\tconfig: StorywrightConfig,\n\toptions: {\n\t\ttmpDir: string;\n\t\tstorybookUrl: string;\n\t\tsnapshotDir: string;\n\t\treporterPath: string;\n\t\ttestFile: string;\n\t\tshard?: string;\n\t\treporters?: string[];\n\t},\n): string {\n\tconst projects = config.browsers.map((browser) => {\n\t\tconst browserOptions = config.browserOptions[browser];\n\t\tconst useObj = browserOptions\n\t\t\t? JSON.stringify(browserOptions, null, '\\t\\t')\n\t\t\t: getDefaultBrowserUse(browser);\n\t\treturn `\\t\\t{\n\\t\\t\\tname: '${browser}',\n\\t\\t\\tuse: ${useObj},\n\\t\\t}`;\n\t});\n\n\tconst workers = config.workers === 'auto' ? \"'50%'\" : String(config.workers);\n\n\tconst shard = options.shard\n\t\t? `\\tshard: { current: ${options.shard.split('/')[0]}, total: ${options.shard.split('/')[1]} },`\n\t\t: '';\n\n\t// Build reporter list: always include custom reporter, plus user-requested ones\n\tconst reporterEntries: string[] = [];\n\tconst requestedReporters = options.reporters ?? ['default', 'html'];\n\tfor (const r of requestedReporters) {\n\t\tif (r === 'default' || r === 'list') {\n\t\t\treporterEntries.push(\"\\t\\t['list']\");\n\t\t} else if (r !== 'html') {\n\t\t\t// Pass through other built-in Playwright reporters (dot, json, junit, etc.)\n\t\t\treporterEntries.push(`\\t\\t['${r}']`);\n\t\t}\n\t}\n\t// Always include custom storywright reporter\n\treporterEntries.push(`\\t\\t['${escapeBackslash(options.reporterPath)}']`);\n\n\treturn `import { defineConfig } from '@playwright/test';\n\nexport default defineConfig({\n\\ttestDir: '${escapeBackslash(options.tmpDir)}',\n\\ttestMatch: '${escapeBackslash(options.testFile)}',\n\\tsnapshotDir: '${escapeBackslash(options.snapshotDir)}',\n\\tsnapshotPathTemplate: '{snapshotDir}/{arg}-{projectName}-${config.screenshot.locale}-${config.screenshot.timezone}{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\\tworkers: ${workers},\n${shard}\n\\treporter: [\n${reporterEntries.join(',\\n')}\n\\t],\n\\tuse: {\n\\t\\tbaseURL: '${options.storybookUrl}',\n\\t\\tnavigationTimeout: ${config.timeout.navigation},\n\\t\\ttimezoneId: '${config.screenshot.timezone}',\n\\t\\tlocale: '${config.screenshot.locale}',\n\\t},\n\\tprojects: [\n${projects.join(',\\n')}\n\\t],\n});\n`;\n}\n\nfunction getDefaultBrowserUse(browser: string): string {\n\tswitch (browser) {\n\t\tcase 'chromium':\n\t\t\treturn \"{ browserName: 'chromium' }\";\n\t\tcase 'firefox':\n\t\t\treturn \"{ browserName: 'firefox' }\";\n\t\tcase 'webkit':\n\t\t\treturn \"{ browserName: 'webkit' }\";\n\t\tdefault:\n\t\t\treturn `{ browserName: '${browser}' }`;\n\t}\n}\n\nfunction escapeBackslash(str: string): string {\n\treturn str.replace(/\\\\/g, '/');\n}\n","import type { ScreenshotConfig } from '../config/types.js';\n\nexport function generateTestFile(\n\tconfig: ScreenshotConfig,\n\toptions: {\n\t\ttargetStoriesPath: string;\n\t},\n): string {\n\treturn `import { test, expect } from '@playwright/test';\nimport { readFileSync } from 'node:fs';\n\nconst targetList = JSON.parse(\n\\treadFileSync('${escapeBackslash(options.targetStoriesPath)}', 'utf-8'),\n);\n\ntest.describe.parallel('visual regression testing', () => {\n\\tif (Object.keys(targetList.entries).length === 0) {\n\\t\\ttest('no stories to test', () => {\n\\t\\t\\texpect(true).toBeTruthy();\n\\t\\t});\n\\t}\n\n\\tfor (const story of Object.values(targetList.entries)) {\n\\t\\ttest(\\`\\${story.title}: \\${story.name}\\`, async ({ page }) => {\n\\t\\t\\t// Freeze time for reproducibility\n\\t\\t\\tawait page.clock.install({ time: new Date('${config.freezeTime}') });\n\n\\t\\t\\t// Seed Math.random for reproducibility\n\\t\\t\\tawait page.addInitScript((seed) => {\n\\t\\t\\t\\tlet s = seed;\n\\t\\t\\t\\tMath.random = () => {\n\\t\\t\\t\\t\\ts = (s * 16807 + 0) % 2147483647;\n\\t\\t\\t\\t\\treturn (s - 1) / 2147483646;\n\\t\\t\\t\\t};\n\\t\\t\\t}, ${config.seed});\n\n\\t\\t\\tawait page.goto(\\`/iframe.html?id=\\${story.id}\\`, {\n\\t\\t\\t\\twaitUntil: 'networkidle',\n\\t\\t\\t});\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> },\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: ['ignore', 'pipe', 'pipe'],\n\t\t\tshell: false,\n\t\t});\n\n\t\tlet stdout = '';\n\t\tlet stderr = '';\n\n\t\tproc.stdout.on('data', (data: Buffer) => {\n\t\t\tstdout += data.toString();\n\t\t});\n\n\t\tproc.stderr.on('data', (data: Buffer) => {\n\t\t\tstderr += data.toString();\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 < 3) {\n\t\tthrow new Error(\n\t\t\t'Storybook version 6.x or earlier is not supported.\\n\\nError code: SW_E_STORYBOOK_UNSUPPORTED',\n\t\t);\n\t}\n\n\treturn indexJson;\n}\n\n/**\n * Normalize story index across Storybook 7 / 8 formats.\n * Storybook 7 uses `stories` key, Storybook 8 uses `entries`.\n * Both expose an `index.json` but the shape may differ slightly.\n */\nfunction normalizeStoryIndex(\n\traw: Record<string, unknown>,\n\tcompatibility: 'auto' | 'v7' | 'v8',\n): StoryIndex {\n\tconst version = typeof raw.v === 'number' ? raw.v : 4;\n\n\t// Storybook 7 may use \"stories\" instead of \"entries\"\n\tlet entries: Record<string, Story>;\n\tif (compatibility === 'v7' || (compatibility === 'auto' && raw.stories && !raw.entries)) {\n\t\tentries = (raw.stories ?? raw.entries ?? {}) as Record<string, Story>;\n\t} else {\n\t\tentries = (raw.entries ?? raw.stories ?? {}) as Record<string, Story>;\n\t}\n\n\t// Normalize Storybook 7 entries that may lack `type` field\n\tfor (const [id, entry] of Object.entries(entries)) {\n\t\tif (!entry.type) {\n\t\t\t// In Storybook 7, docs entries often have name \"Docs\"\n\t\t\tentries[id] = { ...entry, type: entry.name === 'Docs' ? 'docs' : 'story' };\n\t\t}\n\t}\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\t// Skip stories with !vrt tag\n\t\tif (story.tags?.includes('!vrt')) continue;\n\n\t\tconst fullName = `${story.title}/${story.name}`;\n\n\t\t// Check include patterns\n\t\tconst isIncluded = includeMatchers.some((m) => m(fullName));\n\t\tif (!isIncluded) continue;\n\n\t\t// Check exclude patterns\n\t\tconst isExcluded = excludeMatchers.some((m) => m(fullName));\n\t\tif (isExcluded) continue;\n\n\t\tentries[id] = story;\n\t}\n\n\treturn { ...storyIndex, entries };\n}\n"],"mappings":";AAAA,SAAS,cAAc,oBAAoB;;;ACEpC,IAAM,iBAAoC;AAAA,EAChD,WAAW;AAAA,IACV,WAAW;AAAA,IACX,cAAc;AAAA,IACd,KAAK;AAAA,IACL,eAAe;AAAA,EAChB;AAAA,EAEA,UAAU,CAAC,UAAU;AAAA,EACrB,gBAAgB,CAAC;AAAA,EAEjB,YAAY;AAAA,IACX,UAAU;AAAA,IACV,YAAY;AAAA,IACZ,WAAW;AAAA,IACX,mBAAmB;AAAA,IACnB,YAAY;AAAA,IACZ,UAAU;AAAA,IACV,QAAQ;AAAA,IACR,MAAM;AAAA,EACP;AAAA,EAEA,eAAe;AAAA,IACd,SAAS;AAAA,IACT,YAAY,CAAC,gBAAgB,qBAAqB,iBAAiB;AAAA,IACnE,YAAY;AAAA,EACb;AAAA,EAEA,SAAS;AAAA,IACR,UAAU;AAAA,IACV,OAAO;AAAA,MACN,aAAa;AAAA,IACd;AAAA,IACA,IAAI;AAAA,MACH,QAAQ;AAAA,MACR,QAAQ;AAAA,MACR,QAAQ;AAAA,MACR,aAAa;AAAA,IACd;AAAA,EACD;AAAA,EAEA,QAAQ;AAAA,IACP,WAAW;AAAA,IACX,OAAO;AAAA,EACR;AAAA,EAEA,SAAS;AAAA,EAET,SAAS;AAAA,IACR,MAAM;AAAA,IACN,YAAY;AAAA,IACZ,QAAQ;AAAA,EACT;AAAA,EAEA,SAAS,CAAC,IAAI;AAAA,EAC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MAAI,mBAAmB,OAAO,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":["require","fs","path","picomatch","escapeBackslash","fs","path","path","path","fs","fs","path","picomatch","path","fs","picomatch","path","fs","picomatch"]}
package/dist/cli.d.ts ADDED
@@ -0,0 +1,2 @@
1
+
2
+ export { }
package/dist/cli.js ADDED
@@ -0,0 +1,363 @@
1
+ import {
2
+ createStorageAdapter,
3
+ formatSummary,
4
+ loadConfig,
5
+ logger,
6
+ runTests,
7
+ updateBaselines
8
+ } from "./chunk-U4KT4Y42.js";
9
+ import {
10
+ generateHtmlReport
11
+ } from "./chunk-FST75QN5.js";
12
+
13
+ // src/cli/index.ts
14
+ import { defineCommand as defineCommand7, runMain } from "citty";
15
+
16
+ // src/cli/commands/download.ts
17
+ import path from "path";
18
+ import { defineCommand } from "citty";
19
+ var downloadCommand = defineCommand({
20
+ meta: {
21
+ name: "download",
22
+ description: "Download baselines from remote storage"
23
+ },
24
+ args: {
25
+ branch: {
26
+ type: "string",
27
+ description: "Branch to download baselines from",
28
+ default: "main"
29
+ }
30
+ },
31
+ async run({ args }) {
32
+ const config = await loadConfig();
33
+ const storage = createStorageAdapter(config.storage);
34
+ const destDir = path.resolve(config.storage.local.baselineDir);
35
+ logger.start(`Downloading baselines from ${args.branch}...`);
36
+ await storage.download({
37
+ branch: args.branch ?? "main",
38
+ destDir
39
+ });
40
+ logger.success("Baselines downloaded");
41
+ }
42
+ });
43
+
44
+ // src/cli/commands/init.ts
45
+ import fs from "fs/promises";
46
+ import path2 from "path";
47
+ import { defineCommand as defineCommand2 } from "citty";
48
+ var CONFIG_TEMPLATE = `import { defineConfig } from '@storywright/cli';
49
+
50
+ export default defineConfig({
51
+ // Storybook settings
52
+ storybook: {
53
+ staticDir: 'storybook-static',
54
+ },
55
+
56
+ // Browsers to test
57
+ browsers: ['chromium'],
58
+
59
+ // Screenshot settings
60
+ screenshot: {
61
+ fullPage: true,
62
+ animations: 'disabled',
63
+ threshold: 0.02,
64
+ maxDiffPixelRatio: 0.02,
65
+ },
66
+
67
+ // Storage settings
68
+ storage: {
69
+ provider: 'local',
70
+ },
71
+ });
72
+ `;
73
+ var initCommand = defineCommand2({
74
+ meta: {
75
+ name: "init",
76
+ description: "Initialize storywright configuration"
77
+ },
78
+ args: {},
79
+ async run() {
80
+ const configPath = path2.resolve("storywright.config.ts");
81
+ try {
82
+ await fs.access(configPath);
83
+ logger.warn("storywright.config.ts already exists");
84
+ return;
85
+ } catch {
86
+ }
87
+ await fs.writeFile(configPath, CONFIG_TEMPLATE);
88
+ logger.success("Created storywright.config.ts");
89
+ const gitignorePath = path2.resolve(".gitignore");
90
+ try {
91
+ const content = await fs.readFile(gitignorePath, "utf-8");
92
+ if (!content.includes(".storywright")) {
93
+ await fs.appendFile(gitignorePath, "\n.storywright/\n");
94
+ logger.info("Added .storywright/ to .gitignore");
95
+ }
96
+ } catch {
97
+ }
98
+ }
99
+ });
100
+
101
+ // src/cli/commands/report.ts
102
+ import fs2 from "fs/promises";
103
+ import path3 from "path";
104
+ import { defineCommand as defineCommand3 } from "citty";
105
+ import picomatch from "picomatch";
106
+ async function globFiles(pattern, cwd) {
107
+ const matcher = picomatch(pattern);
108
+ const results = [];
109
+ async function walk(dir) {
110
+ const entries = await fs2.readdir(dir, { withFileTypes: true });
111
+ for (const entry of entries) {
112
+ const fullPath = path3.join(dir, entry.name);
113
+ const relativePath = path3.relative(cwd, fullPath).replace(/\\/g, "/");
114
+ if (entry.isDirectory()) {
115
+ await walk(fullPath);
116
+ } else if (matcher(relativePath)) {
117
+ results.push(fullPath);
118
+ }
119
+ }
120
+ }
121
+ await walk(cwd);
122
+ return results;
123
+ }
124
+ var reportCommand = defineCommand3({
125
+ meta: {
126
+ name: "report",
127
+ description: "Generate or open the report"
128
+ },
129
+ args: {
130
+ open: {
131
+ type: "boolean",
132
+ description: "Open report in browser",
133
+ default: false
134
+ },
135
+ merge: {
136
+ type: "boolean",
137
+ description: "Merge multiple summary files",
138
+ default: false
139
+ },
140
+ from: {
141
+ type: "string",
142
+ description: "Glob pattern for summary files to merge"
143
+ }
144
+ },
145
+ async run({ args }) {
146
+ const config = await loadConfig();
147
+ const reportDir = path3.resolve(config.report.outputDir);
148
+ if (args.merge && args.from) {
149
+ logger.start("Merging reports...");
150
+ const files = await globFiles(args.from, process.cwd());
151
+ const merged = {
152
+ total: 0,
153
+ passed: 0,
154
+ failed: 0,
155
+ skipped: 0,
156
+ duration: 0,
157
+ timestamp: (/* @__PURE__ */ new Date()).toISOString(),
158
+ browsers: [],
159
+ failures: []
160
+ };
161
+ for (const file of files) {
162
+ const content = await fs2.readFile(file, "utf-8");
163
+ const summary = JSON.parse(content);
164
+ merged.total += summary.total;
165
+ merged.passed += summary.passed;
166
+ merged.failed += summary.failed;
167
+ merged.skipped += summary.skipped;
168
+ merged.duration = Math.max(merged.duration, summary.duration);
169
+ merged.browsers = [.../* @__PURE__ */ new Set([...merged.browsers, ...summary.browsers])];
170
+ merged.failures.push(...summary.failures);
171
+ }
172
+ await fs2.mkdir(reportDir, { recursive: true });
173
+ await fs2.writeFile(path3.join(reportDir, "summary.json"), JSON.stringify(merged, null, 2));
174
+ const html = generateHtmlReport(merged);
175
+ await fs2.writeFile(path3.join(reportDir, "index.html"), html);
176
+ logger.success(`Merged ${files.length} reports \u2192 index.html generated`);
177
+ }
178
+ if (args.open) {
179
+ const reportPath = path3.join(reportDir, "index.html");
180
+ const { exec: execCb } = await import("child_process");
181
+ const platform = process.platform;
182
+ const cmd = platform === "darwin" ? "open" : platform === "win32" ? "start" : "xdg-open";
183
+ execCb(`${cmd} ${reportPath}`);
184
+ logger.success("Report opened");
185
+ }
186
+ }
187
+ });
188
+
189
+ // src/cli/commands/test.ts
190
+ import { defineCommand as defineCommand4 } from "citty";
191
+ var testCommand = defineCommand4({
192
+ meta: {
193
+ name: "test",
194
+ description: "Run visual regression tests"
195
+ },
196
+ args: {
197
+ browsers: {
198
+ type: "string",
199
+ description: "Browsers to test (comma-separated)"
200
+ },
201
+ shard: {
202
+ type: "string",
203
+ description: "Shard specification (index/total)"
204
+ },
205
+ "diff-only": {
206
+ type: "boolean",
207
+ description: "Only test stories affected by git changes",
208
+ default: false
209
+ },
210
+ threshold: {
211
+ type: "string",
212
+ description: "Pixel color threshold (0-1)"
213
+ },
214
+ "max-diff-pixel-ratio": {
215
+ type: "string",
216
+ description: "Maximum diff pixel ratio (0-1)"
217
+ },
218
+ "storybook-url": {
219
+ type: "string",
220
+ description: "URL of running Storybook"
221
+ },
222
+ "storybook-dir": {
223
+ type: "string",
224
+ description: "Storybook build directory"
225
+ },
226
+ "update-snapshots": {
227
+ type: "boolean",
228
+ description: "Update baseline snapshots",
229
+ default: false
230
+ },
231
+ "full-page": {
232
+ type: "boolean",
233
+ description: "Take full page screenshots"
234
+ },
235
+ workers: {
236
+ type: "string",
237
+ description: "Number of parallel workers"
238
+ },
239
+ filter: {
240
+ type: "string",
241
+ description: "Filter stories by glob pattern"
242
+ },
243
+ "output-dir": {
244
+ type: "string",
245
+ description: "Output root directory (.storywright by default)"
246
+ },
247
+ reporters: {
248
+ type: "string",
249
+ description: "Reporters (comma-separated, e.g. default,html)"
250
+ }
251
+ },
252
+ async run({ args }) {
253
+ const overrides = {};
254
+ if (args.browsers) {
255
+ overrides.browsers = args.browsers.split(",").map((b) => b.trim());
256
+ }
257
+ if (args.threshold) {
258
+ overrides.screenshot = { ...overrides.screenshot, threshold: Number(args.threshold) };
259
+ }
260
+ if (args["max-diff-pixel-ratio"]) {
261
+ overrides.screenshot = {
262
+ ...overrides.screenshot,
263
+ maxDiffPixelRatio: Number(args["max-diff-pixel-ratio"])
264
+ };
265
+ }
266
+ if (args["storybook-url"]) {
267
+ overrides.storybook = { ...overrides.storybook, url: args["storybook-url"] };
268
+ }
269
+ if (args["storybook-dir"]) {
270
+ overrides.storybook = { ...overrides.storybook, staticDir: args["storybook-dir"] };
271
+ }
272
+ if (args["full-page"] !== void 0) {
273
+ overrides.screenshot = { ...overrides.screenshot, fullPage: args["full-page"] };
274
+ }
275
+ if (args.workers) {
276
+ overrides.workers = args.workers === "auto" ? "auto" : Number(args.workers);
277
+ }
278
+ const config = await loadConfig(process.cwd(), overrides);
279
+ const result = await runTests(
280
+ config,
281
+ {
282
+ diffOnly: args["diff-only"],
283
+ shard: args.shard,
284
+ updateSnapshots: args["update-snapshots"],
285
+ filter: args.filter,
286
+ outputDir: args["output-dir"],
287
+ reporters: args.reporters?.split(",").map((r) => r.trim())
288
+ },
289
+ process.cwd()
290
+ );
291
+ if (result.summary) {
292
+ const reportPath = result.reportDir ? `${result.reportDir}/index.html` : void 0;
293
+ console.log(formatSummary(result.summary, { reportPath }));
294
+ }
295
+ process.exit(result.exitCode);
296
+ }
297
+ });
298
+
299
+ // src/cli/commands/update.ts
300
+ import { defineCommand as defineCommand5 } from "citty";
301
+ var updateCommand = defineCommand5({
302
+ meta: {
303
+ name: "update",
304
+ description: "Update baseline snapshots"
305
+ },
306
+ args: {
307
+ all: {
308
+ type: "boolean",
309
+ description: "Regenerate all baselines",
310
+ default: false
311
+ },
312
+ upload: {
313
+ type: "boolean",
314
+ description: "Upload baselines after update",
315
+ default: false
316
+ }
317
+ },
318
+ async run({ args }) {
319
+ const config = await loadConfig();
320
+ await updateBaselines(config, { all: args.all, upload: args.upload });
321
+ }
322
+ });
323
+
324
+ // src/cli/commands/upload.ts
325
+ import path4 from "path";
326
+ import { defineCommand as defineCommand6 } from "citty";
327
+ var uploadCommand = defineCommand6({
328
+ meta: {
329
+ name: "upload",
330
+ description: "Upload baselines to remote storage"
331
+ },
332
+ args: {},
333
+ async run() {
334
+ const config = await loadConfig();
335
+ const storage = createStorageAdapter(config.storage);
336
+ const snapshotDir = path4.resolve(config.storage.local.baselineDir);
337
+ logger.start("Uploading baselines...");
338
+ await storage.upload({
339
+ branch: "current",
340
+ sourceDir: snapshotDir
341
+ });
342
+ logger.success("Baselines uploaded");
343
+ }
344
+ });
345
+
346
+ // src/cli/index.ts
347
+ var main = defineCommand7({
348
+ meta: {
349
+ name: "storywright",
350
+ version: "0.1.0",
351
+ description: "Zero-config visual regression testing powered by Storybook + Playwright"
352
+ },
353
+ subCommands: {
354
+ test: testCommand,
355
+ update: updateCommand,
356
+ upload: uploadCommand,
357
+ download: downloadCommand,
358
+ report: reportCommand,
359
+ init: initCommand
360
+ }
361
+ });
362
+ runMain(main);
363
+ //# sourceMappingURL=cli.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/cli/index.ts","../src/cli/commands/download.ts","../src/cli/commands/init.ts","../src/cli/commands/report.ts","../src/cli/commands/test.ts","../src/cli/commands/update.ts","../src/cli/commands/upload.ts"],"sourcesContent":["import { defineCommand, runMain } from 'citty';\nimport { downloadCommand } from './commands/download.js';\nimport { initCommand } from './commands/init.js';\nimport { reportCommand } from './commands/report.js';\nimport { testCommand } from './commands/test.js';\nimport { updateCommand } from './commands/update.js';\nimport { uploadCommand } from './commands/upload.js';\n\nconst main = defineCommand({\n\tmeta: {\n\t\tname: 'storywright',\n\t\tversion: '0.1.0',\n\t\tdescription: 'Zero-config visual regression testing powered by Storybook + Playwright',\n\t},\n\tsubCommands: {\n\t\ttest: testCommand,\n\t\tupdate: updateCommand,\n\t\tupload: uploadCommand,\n\t\tdownload: downloadCommand,\n\t\treport: reportCommand,\n\t\tinit: initCommand,\n\t},\n});\n\nrunMain(main);\n","import path from 'node:path';\nimport { defineCommand } from 'citty';\nimport { loadConfig } from '../../config/index.js';\nimport { createStorageAdapter } from '../../storage/index.js';\nimport { logger } from '../../utils/logger.js';\n\nexport const downloadCommand = defineCommand({\n\tmeta: {\n\t\tname: 'download',\n\t\tdescription: 'Download baselines from remote storage',\n\t},\n\targs: {\n\t\tbranch: {\n\t\t\ttype: 'string',\n\t\t\tdescription: 'Branch to download baselines from',\n\t\t\tdefault: 'main',\n\t\t},\n\t},\n\tasync run({ args }) {\n\t\tconst config = await loadConfig();\n\t\tconst storage = createStorageAdapter(config.storage);\n\t\tconst destDir = path.resolve(config.storage.local.baselineDir);\n\n\t\tlogger.start(`Downloading baselines from ${args.branch}...`);\n\t\tawait storage.download({\n\t\t\tbranch: args.branch ?? 'main',\n\t\t\tdestDir,\n\t\t});\n\t\tlogger.success('Baselines downloaded');\n\t},\n});\n","import fs from 'node:fs/promises';\nimport path from 'node:path';\nimport { defineCommand } from 'citty';\nimport { logger } from '../../utils/logger.js';\n\nconst CONFIG_TEMPLATE = `import { defineConfig } from '@storywright/cli';\n\nexport default defineConfig({\n\\t// Storybook settings\n\\tstorybook: {\n\\t\\tstaticDir: 'storybook-static',\n\\t},\n\n\\t// Browsers to test\n\\tbrowsers: ['chromium'],\n\n\\t// Screenshot settings\n\\tscreenshot: {\n\\t\\tfullPage: true,\n\\t\\tanimations: 'disabled',\n\\t\\tthreshold: 0.02,\n\\t\\tmaxDiffPixelRatio: 0.02,\n\\t},\n\n\\t// Storage settings\n\\tstorage: {\n\\t\\tprovider: 'local',\n\\t},\n});\n`;\n\nexport const initCommand = defineCommand({\n\tmeta: {\n\t\tname: 'init',\n\t\tdescription: 'Initialize storywright configuration',\n\t},\n\targs: {},\n\tasync run() {\n\t\tconst configPath = path.resolve('storywright.config.ts');\n\t\ttry {\n\t\t\tawait fs.access(configPath);\n\t\t\tlogger.warn('storywright.config.ts already exists');\n\t\t\treturn;\n\t\t} catch {\n\t\t\t// file doesn't exist, create it\n\t\t}\n\n\t\tawait fs.writeFile(configPath, CONFIG_TEMPLATE);\n\t\tlogger.success('Created storywright.config.ts');\n\n\t\t// Add .storywright to .gitignore if exists\n\t\tconst gitignorePath = path.resolve('.gitignore');\n\t\ttry {\n\t\t\tconst content = await fs.readFile(gitignorePath, 'utf-8');\n\t\t\tif (!content.includes('.storywright')) {\n\t\t\t\tawait fs.appendFile(gitignorePath, '\\n.storywright/\\n');\n\t\t\t\tlogger.info('Added .storywright/ to .gitignore');\n\t\t\t}\n\t\t} catch {\n\t\t\t// no .gitignore\n\t\t}\n\t},\n});\n","import fs from 'node:fs/promises';\nimport path from 'node:path';\nimport { defineCommand } from 'citty';\nimport picomatch from 'picomatch';\nimport { loadConfig } from '../../config/index.js';\nimport type { TestSummary } from '../../core/types.js';\nimport { generateHtmlReport } from '../../playwright/reporter.js';\nimport { logger } from '../../utils/logger.js';\n\nasync function globFiles(pattern: string, cwd: string): Promise<string[]> {\n\tconst matcher = picomatch(pattern);\n\tconst results: string[] = [];\n\n\tasync function walk(dir: string): Promise<void> {\n\t\tconst entries = await fs.readdir(dir, { withFileTypes: true });\n\t\tfor (const entry of entries) {\n\t\t\tconst fullPath = path.join(dir, entry.name);\n\t\t\tconst relativePath = path.relative(cwd, fullPath).replace(/\\\\/g, '/');\n\t\t\tif (entry.isDirectory()) {\n\t\t\t\tawait walk(fullPath);\n\t\t\t} else if (matcher(relativePath)) {\n\t\t\t\tresults.push(fullPath);\n\t\t\t}\n\t\t}\n\t}\n\n\tawait walk(cwd);\n\treturn results;\n}\n\nexport const reportCommand = defineCommand({\n\tmeta: {\n\t\tname: 'report',\n\t\tdescription: 'Generate or open the report',\n\t},\n\targs: {\n\t\topen: {\n\t\t\ttype: 'boolean',\n\t\t\tdescription: 'Open report in browser',\n\t\t\tdefault: false,\n\t\t},\n\t\tmerge: {\n\t\t\ttype: 'boolean',\n\t\t\tdescription: 'Merge multiple summary files',\n\t\t\tdefault: false,\n\t\t},\n\t\tfrom: {\n\t\t\ttype: 'string',\n\t\t\tdescription: 'Glob pattern for summary files to merge',\n\t\t},\n\t},\n\tasync run({ args }) {\n\t\tconst config = await loadConfig();\n\t\tconst reportDir = path.resolve(config.report.outputDir);\n\n\t\tif (args.merge && args.from) {\n\t\t\tlogger.start('Merging reports...');\n\t\t\tconst files = await globFiles(args.from, process.cwd());\n\n\t\t\tconst merged: TestSummary = {\n\t\t\t\ttotal: 0,\n\t\t\t\tpassed: 0,\n\t\t\t\tfailed: 0,\n\t\t\t\tskipped: 0,\n\t\t\t\tduration: 0,\n\t\t\t\ttimestamp: new Date().toISOString(),\n\t\t\t\tbrowsers: [],\n\t\t\t\tfailures: [],\n\t\t\t};\n\n\t\t\tfor (const file of files) {\n\t\t\t\tconst content = await fs.readFile(file, 'utf-8');\n\t\t\t\tconst summary: TestSummary = JSON.parse(content);\n\t\t\t\tmerged.total += summary.total;\n\t\t\t\tmerged.passed += summary.passed;\n\t\t\t\tmerged.failed += summary.failed;\n\t\t\t\tmerged.skipped += summary.skipped;\n\t\t\t\tmerged.duration = Math.max(merged.duration, summary.duration);\n\t\t\t\tmerged.browsers = [...new Set([...merged.browsers, ...summary.browsers])];\n\t\t\t\tmerged.failures.push(...summary.failures);\n\t\t\t}\n\n\t\t\tawait fs.mkdir(reportDir, { recursive: true });\n\t\t\tawait fs.writeFile(path.join(reportDir, 'summary.json'), JSON.stringify(merged, null, 2));\n\n\t\t\tconst html = generateHtmlReport(merged);\n\t\t\tawait fs.writeFile(path.join(reportDir, 'index.html'), html);\n\t\t\tlogger.success(`Merged ${files.length} reports → index.html generated`);\n\t\t}\n\n\t\tif (args.open) {\n\t\t\tconst reportPath = path.join(reportDir, 'index.html');\n\t\t\tconst { exec: execCb } = await import('node:child_process');\n\t\t\tconst platform = process.platform;\n\t\t\tconst cmd = platform === 'darwin' ? 'open' : platform === 'win32' ? 'start' : 'xdg-open';\n\t\t\texecCb(`${cmd} ${reportPath}`);\n\t\t\tlogger.success('Report opened');\n\t\t}\n\t},\n});\n","import { defineCommand } from 'citty';\nimport { loadConfig } from '../../config/index.js';\nimport type { DeepPartial, StorywrightConfig } from '../../config/types.js';\nimport { runTests } from '../../core/engine.js';\nimport { formatSummary } from '../../reporter/cli-reporter.js';\n\nexport const testCommand = defineCommand({\n\tmeta: {\n\t\tname: 'test',\n\t\tdescription: 'Run visual regression tests',\n\t},\n\targs: {\n\t\tbrowsers: {\n\t\t\ttype: 'string',\n\t\t\tdescription: 'Browsers to test (comma-separated)',\n\t\t},\n\t\tshard: {\n\t\t\ttype: 'string',\n\t\t\tdescription: 'Shard specification (index/total)',\n\t\t},\n\t\t'diff-only': {\n\t\t\ttype: 'boolean',\n\t\t\tdescription: 'Only test stories affected by git changes',\n\t\t\tdefault: false,\n\t\t},\n\t\tthreshold: {\n\t\t\ttype: 'string',\n\t\t\tdescription: 'Pixel color threshold (0-1)',\n\t\t},\n\t\t'max-diff-pixel-ratio': {\n\t\t\ttype: 'string',\n\t\t\tdescription: 'Maximum diff pixel ratio (0-1)',\n\t\t},\n\t\t'storybook-url': {\n\t\t\ttype: 'string',\n\t\t\tdescription: 'URL of running Storybook',\n\t\t},\n\t\t'storybook-dir': {\n\t\t\ttype: 'string',\n\t\t\tdescription: 'Storybook build directory',\n\t\t},\n\t\t'update-snapshots': {\n\t\t\ttype: 'boolean',\n\t\t\tdescription: 'Update baseline snapshots',\n\t\t\tdefault: false,\n\t\t},\n\t\t'full-page': {\n\t\t\ttype: 'boolean',\n\t\t\tdescription: 'Take full page screenshots',\n\t\t},\n\t\tworkers: {\n\t\t\ttype: 'string',\n\t\t\tdescription: 'Number of parallel workers',\n\t\t},\n\t\tfilter: {\n\t\t\ttype: 'string',\n\t\t\tdescription: 'Filter stories by glob pattern',\n\t\t},\n\t\t'output-dir': {\n\t\t\ttype: 'string',\n\t\t\tdescription: 'Output root directory (.storywright by default)',\n\t\t},\n\t\treporters: {\n\t\t\ttype: 'string',\n\t\t\tdescription: 'Reporters (comma-separated, e.g. default,html)',\n\t\t},\n\t},\n\tasync run({ args }) {\n\t\tconst overrides: DeepPartial<StorywrightConfig> = {};\n\n\t\tif (args.browsers) {\n\t\t\toverrides.browsers = args.browsers.split(',').map((b) => b.trim());\n\t\t}\n\t\tif (args.threshold) {\n\t\t\toverrides.screenshot = { ...overrides.screenshot, threshold: Number(args.threshold) };\n\t\t}\n\t\tif (args['max-diff-pixel-ratio']) {\n\t\t\toverrides.screenshot = {\n\t\t\t\t...overrides.screenshot,\n\t\t\t\tmaxDiffPixelRatio: Number(args['max-diff-pixel-ratio']),\n\t\t\t};\n\t\t}\n\t\tif (args['storybook-url']) {\n\t\t\toverrides.storybook = { ...overrides.storybook, url: args['storybook-url'] };\n\t\t}\n\t\tif (args['storybook-dir']) {\n\t\t\toverrides.storybook = { ...overrides.storybook, staticDir: args['storybook-dir'] };\n\t\t}\n\t\tif (args['full-page'] !== undefined) {\n\t\t\toverrides.screenshot = { ...overrides.screenshot, fullPage: args['full-page'] };\n\t\t}\n\t\tif (args.workers) {\n\t\t\toverrides.workers = args.workers === 'auto' ? 'auto' : Number(args.workers);\n\t\t}\n\n\t\tconst config = await loadConfig(process.cwd(), overrides);\n\t\tconst result = await runTests(\n\t\t\tconfig,\n\t\t\t{\n\t\t\t\tdiffOnly: args['diff-only'],\n\t\t\t\tshard: args.shard,\n\t\t\t\tupdateSnapshots: args['update-snapshots'],\n\t\t\t\tfilter: args.filter,\n\t\t\t\toutputDir: args['output-dir'],\n\t\t\t\treporters: args.reporters?.split(',').map((r) => r.trim()),\n\t\t\t},\n\t\t\tprocess.cwd(),\n\t\t);\n\n\t\tif (result.summary) {\n\t\t\tconst reportPath = result.reportDir ? `${result.reportDir}/index.html` : undefined;\n\t\t\tconsole.log(formatSummary(result.summary, { reportPath }));\n\t\t}\n\n\t\tprocess.exit(result.exitCode);\n\t},\n});\n","import { defineCommand } from 'citty';\nimport { loadConfig } from '../../config/index.js';\nimport { updateBaselines } from '../../core/engine.js';\n\nexport const updateCommand = defineCommand({\n\tmeta: {\n\t\tname: 'update',\n\t\tdescription: 'Update baseline snapshots',\n\t},\n\targs: {\n\t\tall: {\n\t\t\ttype: 'boolean',\n\t\t\tdescription: 'Regenerate all baselines',\n\t\t\tdefault: false,\n\t\t},\n\t\tupload: {\n\t\t\ttype: 'boolean',\n\t\t\tdescription: 'Upload baselines after update',\n\t\t\tdefault: false,\n\t\t},\n\t},\n\tasync run({ args }) {\n\t\tconst config = await loadConfig();\n\t\tawait updateBaselines(config, { all: args.all, upload: args.upload });\n\t},\n});\n","import path from 'node:path';\nimport { defineCommand } from 'citty';\nimport { loadConfig } from '../../config/index.js';\nimport { createStorageAdapter } from '../../storage/index.js';\nimport { logger } from '../../utils/logger.js';\n\nexport const uploadCommand = defineCommand({\n\tmeta: {\n\t\tname: 'upload',\n\t\tdescription: 'Upload baselines to remote storage',\n\t},\n\targs: {},\n\tasync run() {\n\t\tconst config = await loadConfig();\n\t\tconst storage = createStorageAdapter(config.storage);\n\t\tconst snapshotDir = path.resolve(config.storage.local.baselineDir);\n\n\t\tlogger.start('Uploading baselines...');\n\t\tawait storage.upload({\n\t\t\tbranch: 'current',\n\t\t\tsourceDir: snapshotDir,\n\t\t});\n\t\tlogger.success('Baselines uploaded');\n\t},\n});\n"],"mappings":";;;;;;;;;;;;;AAAA,SAAS,iBAAAA,gBAAe,eAAe;;;ACAvC,OAAO,UAAU;AACjB,SAAS,qBAAqB;AAKvB,IAAM,kBAAkB,cAAc;AAAA,EAC5C,MAAM;AAAA,IACL,MAAM;AAAA,IACN,aAAa;AAAA,EACd;AAAA,EACA,MAAM;AAAA,IACL,QAAQ;AAAA,MACP,MAAM;AAAA,MACN,aAAa;AAAA,MACb,SAAS;AAAA,IACV;AA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defineCommand","fs","path","defineCommand","defineCommand","defineCommand","defineCommand","defineCommand","path","defineCommand","defineCommand","path","defineCommand"]}
@@ -0,0 +1,134 @@
1
+ import { Page } from '@playwright/test';
2
+ import { T as TestSummary, a as TestResult } from './types-DqV0YrhZ.js';
3
+ export { F as FailureEntry, S as Story, b as StoryIndex } from './types-DqV0YrhZ.js';
4
+
5
+ interface StorywrightConfig {
6
+ storybook: StorybookConfig;
7
+ browsers: BrowserName[];
8
+ browserOptions: Record<string, BrowserOption>;
9
+ screenshot: ScreenshotConfig;
10
+ diffDetection: DiffDetectionConfig;
11
+ storage: StorageConfig;
12
+ report: ReportConfig;
13
+ workers: number | 'auto';
14
+ timeout: TimeoutConfig;
15
+ include: string[];
16
+ exclude: string[];
17
+ hooks: HooksConfig;
18
+ }
19
+ type BrowserName = 'chromium' | 'firefox' | 'webkit' | (string & {});
20
+ interface BrowserOption {
21
+ viewport?: {
22
+ width: number;
23
+ height: number;
24
+ };
25
+ deviceScaleFactor?: number;
26
+ isMobile?: boolean;
27
+ hasTouch?: boolean;
28
+ userAgent?: string;
29
+ }
30
+ interface StorybookConfig {
31
+ staticDir: string;
32
+ buildCommand: string;
33
+ url?: string;
34
+ compatibility: 'auto' | 'v7' | 'v8';
35
+ }
36
+ interface ScreenshotConfig {
37
+ fullPage: boolean;
38
+ animations: 'disabled' | 'allow';
39
+ threshold: number;
40
+ maxDiffPixelRatio: number;
41
+ freezeTime: string;
42
+ timezone: string;
43
+ locale: string;
44
+ seed: number;
45
+ }
46
+ interface DiffDetectionConfig {
47
+ enabled: boolean;
48
+ watchFiles: string[];
49
+ baseBranch: string;
50
+ }
51
+ interface StorageConfig {
52
+ provider: 'local' | 's3';
53
+ local: LocalStorageConfig;
54
+ s3: S3StorageConfig;
55
+ }
56
+ interface LocalStorageConfig {
57
+ baselineDir: string;
58
+ }
59
+ interface S3StorageConfig {
60
+ bucket: string;
61
+ prefix: string;
62
+ region: string;
63
+ compression: 'zstd' | 'gzip' | 'none';
64
+ }
65
+ interface ReportConfig {
66
+ outputDir: string;
67
+ title: string;
68
+ }
69
+ interface TimeoutConfig {
70
+ test: number;
71
+ navigation: number;
72
+ expect: number;
73
+ }
74
+ interface StoryContext {
75
+ id: string;
76
+ title: string;
77
+ name: string;
78
+ }
79
+ interface HooksConfig {
80
+ beforeScreenshot?: (page: Page, story: StoryContext) => Promise<void>;
81
+ afterScreenshot?: (page: Page, story: StoryContext) => Promise<void>;
82
+ }
83
+ type DeepPartial<T> = {
84
+ [P in keyof T]?: T[P] extends object ? DeepPartial<T[P]> : T[P];
85
+ };
86
+
87
+ declare function defineConfig(config: DeepPartial<StorywrightConfig>): DeepPartial<StorywrightConfig>;
88
+ declare function loadConfig(cwd?: string, overrides?: DeepPartial<StorywrightConfig>): Promise<StorywrightConfig>;
89
+
90
+ interface TestRunResult {
91
+ exitCode: number;
92
+ summary?: TestSummary;
93
+ reportDir?: string;
94
+ }
95
+
96
+ interface Storywright {
97
+ test(options?: {
98
+ diffOnly?: boolean;
99
+ browsers?: string[];
100
+ shard?: string;
101
+ filter?: string;
102
+ }): Promise<TestRunResult>;
103
+ update(options?: {
104
+ all?: boolean;
105
+ }): Promise<void>;
106
+ upload(): Promise<void>;
107
+ download(options?: {
108
+ branch?: string;
109
+ }): Promise<void>;
110
+ generateReport(result: TestRunResult): string | undefined;
111
+ }
112
+ declare function createStorywright(userConfig?: DeepPartial<StorywrightConfig>, cwd?: string): Promise<Storywright>;
113
+
114
+ interface StorageAdapter {
115
+ download(options: DownloadOptions): Promise<void>;
116
+ upload(options: UploadOptions): Promise<void>;
117
+ exists(branch: string): Promise<boolean>;
118
+ }
119
+ interface DownloadOptions {
120
+ branch: string;
121
+ destDir: string;
122
+ }
123
+ interface UploadOptions {
124
+ branch: string;
125
+ sourceDir: string;
126
+ compression?: 'zstd' | 'gzip' | 'none';
127
+ }
128
+
129
+ interface ReportData {
130
+ summary: TestSummary;
131
+ results: TestResult[];
132
+ }
133
+
134
+ export { type DeepPartial, type DownloadOptions, type ReportData, type StorageAdapter, type StorywrightConfig, TestResult, TestSummary, type UploadOptions, createStorywright, defineConfig, loadConfig };