@storywright/cli 1.3.1 → 1.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +208 -0
- package/dist/{chunk-4537J4LQ.js → chunk-TL2W442S.js} +4 -2
- package/dist/chunk-TL2W442S.js.map +1 -0
- package/dist/cli.js +2 -2
- package/dist/index.js +1 -1
- package/package.json +7 -2
- package/dist/chunk-4537J4LQ.js.map +0 -1
package/README.md
ADDED
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
# @storywright/cli
|
|
2
|
+
|
|
3
|
+
<p>
|
|
4
|
+
<a href="https://www.npmjs.com/package/@storywright/cli"><img src="https://img.shields.io/npm/v/@storywright/cli.svg" alt="npm version"></a>
|
|
5
|
+
<a href="https://github.com/macloud-developer/storywright/blob/main/LICENSE"><img src="https://img.shields.io/npm/l/@storywright/cli.svg" alt="license"></a>
|
|
6
|
+
</p>
|
|
7
|
+
|
|
8
|
+
> Self-hosted visual regression testing powered by Storybook + Playwright
|
|
9
|
+
|
|
10
|
+
Storywright captures screenshots from Storybook stories, compares them with baselines, and reports visual regressions.
|
|
11
|
+
|
|
12
|
+
## Features
|
|
13
|
+
|
|
14
|
+
- Quick start with `npx @storywright/cli test`
|
|
15
|
+
- Diff-only test selection from git changes
|
|
16
|
+
- Multi-browser execution (Chromium, Firefox, WebKit)
|
|
17
|
+
- HTML report generation (`summary.json` + `index.html`)
|
|
18
|
+
- Baseline storage: local filesystem or S3 adapter
|
|
19
|
+
- CI-friendly workflow with sharding and merge report
|
|
20
|
+
- Configurable hooks (`beforeScreenshot` / `afterScreenshot`)
|
|
21
|
+
- Programmatic API for custom integrations
|
|
22
|
+
|
|
23
|
+
## Requirements
|
|
24
|
+
|
|
25
|
+
- Node.js `>=20`
|
|
26
|
+
- Storybook `>=8` (recommended)
|
|
27
|
+
- Playwright `>=1.40`
|
|
28
|
+
|
|
29
|
+
## Quick Start
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
npm install -D @storywright/cli @playwright/test
|
|
33
|
+
npx playwright install --with-deps chromium
|
|
34
|
+
npx storywright test
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
Default outputs:
|
|
38
|
+
|
|
39
|
+
- Report: `.storywright/report/index.html`
|
|
40
|
+
- Summary: `.storywright/report/summary.json`
|
|
41
|
+
- Temp artifacts: `.storywright/tmp`
|
|
42
|
+
|
|
43
|
+
## Configuration
|
|
44
|
+
|
|
45
|
+
Generate a starter config:
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
npx storywright init
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
Example `storywright.config.ts`:
|
|
52
|
+
|
|
53
|
+
```ts
|
|
54
|
+
import { defineConfig } from "@storywright/cli";
|
|
55
|
+
|
|
56
|
+
export default defineConfig({
|
|
57
|
+
storybook: {
|
|
58
|
+
staticDir: "storybook-static",
|
|
59
|
+
buildCommand: "npx storybook build --stats-json",
|
|
60
|
+
},
|
|
61
|
+
browsers: ["chromium", "webkit"],
|
|
62
|
+
screenshot: {
|
|
63
|
+
fullPage: true,
|
|
64
|
+
animations: "disabled",
|
|
65
|
+
threshold: 0.02,
|
|
66
|
+
maxDiffPixelRatio: 0.02,
|
|
67
|
+
},
|
|
68
|
+
storage: {
|
|
69
|
+
provider: "local",
|
|
70
|
+
branch: "main",
|
|
71
|
+
local: { baselineDir: ".storywright/baselines" },
|
|
72
|
+
},
|
|
73
|
+
});
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
See the [full configuration reference](https://github.com/macloud-developer/storywright#configuration) for all options.
|
|
77
|
+
|
|
78
|
+
## CLI Commands
|
|
79
|
+
|
|
80
|
+
### `storywright test`
|
|
81
|
+
|
|
82
|
+
Run visual regression tests.
|
|
83
|
+
|
|
84
|
+
```bash
|
|
85
|
+
npx storywright test [options]
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
| Option | Description |
|
|
89
|
+
| ------------------------ | ----------------------------------------- |
|
|
90
|
+
| `--browsers` | Browsers to test (comma-separated) |
|
|
91
|
+
| `--diff-only` | Only test stories affected by git changes |
|
|
92
|
+
| `--filter` | Filter stories by glob pattern |
|
|
93
|
+
| `--shard` | Shard specification (e.g. `1/3`) |
|
|
94
|
+
| `--workers` | Number of parallel workers |
|
|
95
|
+
| `--retries` | Number of retries for failed tests |
|
|
96
|
+
| `--threshold` | Pixel color threshold (0–1) |
|
|
97
|
+
| `--max-diff-pixel-ratio` | Maximum diff pixel ratio (0–1) |
|
|
98
|
+
| `--storybook-url` | URL of running Storybook |
|
|
99
|
+
| `--output-dir` | Output root directory |
|
|
100
|
+
| `--reporters` | Reporters (comma-separated) |
|
|
101
|
+
|
|
102
|
+
### `storywright update`
|
|
103
|
+
|
|
104
|
+
Update baseline snapshots.
|
|
105
|
+
|
|
106
|
+
```bash
|
|
107
|
+
npx storywright update [options]
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
| Option | Description |
|
|
111
|
+
| ---------- | --------------------------------------------- |
|
|
112
|
+
| `--all` | Regenerate all baselines (default: diff-only) |
|
|
113
|
+
| `--upload` | Upload baselines after update |
|
|
114
|
+
| `--filter` | Filter stories by glob pattern |
|
|
115
|
+
| `--shard` | Shard specification |
|
|
116
|
+
|
|
117
|
+
### `storywright upload`
|
|
118
|
+
|
|
119
|
+
Upload baselines to remote storage.
|
|
120
|
+
|
|
121
|
+
```bash
|
|
122
|
+
npx storywright upload [--shard 1/3]
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
### `storywright download`
|
|
126
|
+
|
|
127
|
+
Download baselines from storage.
|
|
128
|
+
|
|
129
|
+
```bash
|
|
130
|
+
npx storywright download [--branch main]
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
### `storywright report`
|
|
134
|
+
|
|
135
|
+
Generate or open the HTML report.
|
|
136
|
+
|
|
137
|
+
```bash
|
|
138
|
+
npx storywright report [--open] [--merge --from "reports/*/summary.json"]
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
### `storywright init`
|
|
142
|
+
|
|
143
|
+
Initialize configuration file.
|
|
144
|
+
|
|
145
|
+
```bash
|
|
146
|
+
npx storywright init
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
## Exit Codes
|
|
150
|
+
|
|
151
|
+
| Code | Meaning |
|
|
152
|
+
| ----- | -------------------------------------------- |
|
|
153
|
+
| `0` | Success — no visual diffs |
|
|
154
|
+
| `1` | Success — visual diffs found (review needed) |
|
|
155
|
+
| `2` | Execution error |
|
|
156
|
+
| `130` | Interrupted (SIGINT / SIGTERM) |
|
|
157
|
+
|
|
158
|
+
## Programmatic API
|
|
159
|
+
|
|
160
|
+
```ts
|
|
161
|
+
import { createStorywright } from "@storywright/cli";
|
|
162
|
+
|
|
163
|
+
const sw = await createStorywright();
|
|
164
|
+
|
|
165
|
+
const result = await sw.test({ diffOnly: true });
|
|
166
|
+
sw.generateReport(result);
|
|
167
|
+
|
|
168
|
+
if (result.exitCode === 1) {
|
|
169
|
+
console.log("Visual diffs detected");
|
|
170
|
+
}
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
## Storage
|
|
174
|
+
|
|
175
|
+
### Local (default)
|
|
176
|
+
|
|
177
|
+
Baselines are stored in `.storywright/baselines/` and committed to git.
|
|
178
|
+
|
|
179
|
+
### S3
|
|
180
|
+
|
|
181
|
+
Install the S3 adapter:
|
|
182
|
+
|
|
183
|
+
```bash
|
|
184
|
+
npm install -D @storywright/storage-s3
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
```ts
|
|
188
|
+
export default defineConfig({
|
|
189
|
+
storage: {
|
|
190
|
+
provider: "s3",
|
|
191
|
+
branch: "main",
|
|
192
|
+
s3: {
|
|
193
|
+
bucket: "my-bucket",
|
|
194
|
+
prefix: "storywright/baselines",
|
|
195
|
+
region: "ap-northeast-1",
|
|
196
|
+
compression: "zstd",
|
|
197
|
+
},
|
|
198
|
+
},
|
|
199
|
+
});
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
## CI Setup
|
|
203
|
+
|
|
204
|
+
See the [CI Setup Guide](https://github.com/macloud-developer/storywright/blob/main/docs/ci-setup.md) for GitHub Actions / CircleCI workflow examples.
|
|
205
|
+
|
|
206
|
+
## License
|
|
207
|
+
|
|
208
|
+
MIT
|
|
@@ -324,6 +324,7 @@ export default defineConfig({
|
|
|
324
324
|
${testMatchLine} snapshotDir: '${escapeBackslash(options.snapshotDir)}',
|
|
325
325
|
snapshotPathTemplate: '{snapshotDir}/{arg}-{projectName}{ext}',
|
|
326
326
|
timeout: ${config.timeout.test},
|
|
327
|
+
updateSnapshots: '${options.updateSnapshots ? "all" : "none"}',
|
|
327
328
|
expect: {
|
|
328
329
|
toHaveScreenshot: {
|
|
329
330
|
maxDiffPixelRatio: ${config.screenshot.maxDiffPixelRatio},
|
|
@@ -831,7 +832,8 @@ export default class extends StorywrightReporter {
|
|
|
831
832
|
testMatch: testFilePattern,
|
|
832
833
|
testMatchByBrowser,
|
|
833
834
|
shard: options.shard,
|
|
834
|
-
reporters: options.reporters
|
|
835
|
+
reporters: options.reporters,
|
|
836
|
+
updateSnapshots: options.updateSnapshots
|
|
835
837
|
});
|
|
836
838
|
const configPath = path5.join(tmpDir, "playwright.config.ts");
|
|
837
839
|
await fs4.writeFile(configPath, playwrightConfig);
|
|
@@ -936,4 +938,4 @@ export {
|
|
|
936
938
|
runTests,
|
|
937
939
|
updateBaselines
|
|
938
940
|
};
|
|
939
|
-
//# sourceMappingURL=chunk-
|
|
941
|
+
//# sourceMappingURL=chunk-TL2W442S.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 config: DeepPartial<StorywrightConfig>,\n): DeepPartial<StorywrightConfig> {\n return config;\n}\n\nfunction isPlainObject(value: unknown): value is Record<string, unknown> {\n return value !== null && typeof value === \"object\" && !Array.isArray(value);\n}\n\nfunction deepMerge(\n target: Record<string, unknown>,\n source: Record<string, unknown>,\n): Record<string, unknown> {\n const result: Record<string, unknown> = { ...target };\n for (const key of Object.keys(source)) {\n const sourceVal = source[key];\n const targetVal = result[key];\n if (isPlainObject(sourceVal) && isPlainObject(targetVal)) {\n result[key] = deepMerge(targetVal, sourceVal);\n } else if (sourceVal !== undefined) {\n result[key] = sourceVal;\n }\n }\n return result;\n}\n\nexport async function loadConfig(\n cwd: string = process.cwd(),\n overrides?: DeepPartial<StorywrightConfig>,\n): Promise<StorywrightConfig> {\n const { config: userConfig } = await unconfigLoad<DeepPartial<StorywrightConfig>>({\n sources: [\n {\n files: \"storywright.config\",\n extensions: [\"ts\", \"js\", \"mjs\"],\n },\n ],\n cwd,\n });\n\n let merged = DEFAULT_CONFIG as unknown as Record<string, unknown>;\n if (userConfig) {\n merged = deepMerge(merged, userConfig as Record<string, unknown>);\n }\n if (overrides) {\n merged = deepMerge(merged, overrides as Record<string, unknown>);\n }\n const result = merged as unknown as StorywrightConfig;\n validateConfig(result);\n return result;\n}\n\nfunction validateConfig(config: StorywrightConfig): void {\n for (const browser of config.browsers) {\n const options = config.browserOptions[browser];\n\n if (!STANDARD_BROWSERS.has(browser) && !options?.browserName) {\n throw new Error(\n `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 );\n }\n\n if (options?.browserName && !STANDARD_BROWSERS.has(options.browserName)) {\n throw new Error(\n `Invalid browserName '${options.browserName}' for browser project '${browser}'.\\nValid values: 'chromium', 'firefox', 'webkit'.\\n\\nError code: SW_E_INVALID_BROWSER_NAME`,\n );\n }\n }\n}\n\nexport type { StorywrightConfig, DeepPartial } from \"./types.js\";\n","import type { StorywrightConfig } from \"./types.js\";\n\nexport const DEFAULT_CONFIG: StorywrightConfig = {\n storybook: {\n staticDir: \"storybook-static\",\n buildCommand: \"npx storybook build --stats-json\",\n url: undefined,\n compatibility: \"auto\",\n },\n\n browsers: [\"chromium\"],\n browserOptions: {},\n\n screenshot: {\n fullPage: true,\n animations: \"disabled\",\n threshold: 0.02,\n maxDiffPixelRatio: 0.02,\n freezeTime: \"2024-01-01T00:00:00\",\n timezone: \"UTC\",\n locale: \"en-US\",\n seed: 1,\n },\n\n diffDetection: {\n enabled: true,\n watchFiles: [\"package.json\", \"package-lock.json\", \".storybook/**/*\"],\n baseBranch: \"main\",\n baseBranchDiffDepth: 1,\n },\n\n storage: {\n provider: \"local\",\n branch: \"main\",\n local: {\n baselineDir: \".storywright/baselines\",\n },\n s3: {\n bucket: \"\",\n prefix: \"storywright/baselines\",\n region: \"ap-northeast-1\",\n compression: \"zstd\",\n },\n },\n\n report: {\n outputDir: \".storywright/report\",\n title: \"Storywright Report\",\n },\n\n workers: \"auto\",\n retries: 0,\n\n timeout: {\n test: 30000,\n navigation: 20000,\n expect: 10000,\n },\n\n include: [\"**\"],\n exclude: [],\n\n hooks: {},\n};\n","import type { Page } from \"@playwright/test\";\n\nexport interface StorywrightConfig {\n storybook: StorybookConfig;\n browsers: BrowserName[];\n browserOptions: Record<string, BrowserOption>;\n screenshot: ScreenshotConfig;\n diffDetection: DiffDetectionConfig;\n storage: StorageConfig;\n report: ReportConfig;\n workers: number | \"auto\";\n retries: number;\n timeout: TimeoutConfig;\n include: string[];\n exclude: string[];\n hooks: 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 \"chromium\",\n \"firefox\",\n \"webkit\",\n]);\n\nexport interface BrowserOption {\n browserName?: PlaywrightBrowserName;\n viewport?: { width: number; height: number };\n deviceScaleFactor?: number;\n isMobile?: boolean;\n hasTouch?: boolean;\n userAgent?: string;\n exclude?: string[];\n}\n\nexport interface StorybookConfig {\n staticDir: string;\n buildCommand: string;\n url?: string;\n compatibility: \"auto\" | \"v8\";\n}\n\nexport interface ScreenshotConfig {\n fullPage: boolean;\n animations: \"disabled\" | \"allow\";\n threshold: number;\n maxDiffPixelRatio: number;\n freezeTime: string;\n timezone: string;\n locale: string;\n seed: number;\n}\n\nexport interface DiffDetectionConfig {\n enabled: boolean;\n watchFiles: string[];\n baseBranch: string;\n baseBranchDiffDepth: number;\n}\n\nexport interface StorageConfig {\n provider: \"local\" | \"s3\";\n branch: string;\n local: LocalStorageConfig;\n s3: S3StorageConfig;\n}\n\nexport interface LocalStorageConfig {\n baselineDir: string;\n}\n\nexport interface S3StorageConfig {\n bucket: string;\n prefix: string;\n region: string;\n compression: \"zstd\" | \"gzip\" | \"none\";\n}\n\nexport interface ReportConfig {\n outputDir: string;\n title: string;\n}\n\nexport interface TimeoutConfig {\n test: number;\n navigation: number;\n expect: number;\n}\n\nexport interface StoryContext {\n id: string;\n title: string;\n name: string;\n}\n\nexport interface HooksConfig {\n beforeScreenshot?: (page: Page, story: StoryContext) => Promise<void>;\n afterScreenshot?: (page: Page, story: StoryContext) => Promise<void>;\n}\n\nexport type DeepPartial<T> = {\n [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 const durationSec = Math.round(summary.duration / 1000);\n const minutes = Math.floor(durationSec / 60);\n const seconds = durationSec % 60;\n const durationStr = minutes > 0 ? `${minutes}m ${seconds}s` : `${seconds}s`;\n\n const lines: string[] = [\n \"\",\n \"Storywright Results\",\n \"\\u2550\".repeat(42),\n ` Total: ${summary.total} Passed: ${summary.passed} Failed: ${summary.failed} Skipped: ${summary.skipped}`,\n ` Duration: ${durationStr}`,\n ` Browsers: ${summary.browsers.join(\", \")}`,\n ];\n\n const newFailures = summary.entries.filter((f) => f.type === \"new\");\n const diffFailures = summary.entries.filter((f) => f.type === \"diff\");\n\n if (newFailures.length > 0) {\n lines.push(\"\");\n lines.push(\" New (no baseline):\");\n for (const failure of newFailures) {\n lines.push(` \\u25cb ${failure.story}: ${failure.variant} (${failure.browser})`);\n }\n }\n\n if (diffFailures.length > 0) {\n lines.push(\"\");\n lines.push(\" Failed:\");\n for (const failure of diffFailures) {\n lines.push(` \\u2717 ${failure.story}: ${failure.variant} (${failure.browser})`);\n if (failure.diffRatio > 0) {\n const pct = (failure.diffRatio * 100).toFixed(1);\n lines.push(` \\u2192 Diff: ${pct}% pixels changed`);\n }\n }\n }\n\n const reportPath = options?.reportPath ?? \".storywright/report/index.html\";\n lines.push(\"\");\n lines.push(` Report: ${reportPath}`);\n lines.push(\"\\u2550\".repeat(42));\n lines.push(\"\");\n\n return 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 constructor(private readonly baselineDir: string) {}\n\n async download(options: DownloadOptions): Promise<void> {\n try {\n await fs.access(this.baselineDir);\n } catch {\n return;\n }\n await fs.cp(this.baselineDir, options.destDir, { recursive: true });\n }\n\n async upload(options: UploadOptions): Promise<void> {\n const resolvedSource = path.resolve(options.sourceDir);\n const resolvedDest = path.resolve(this.baselineDir);\n if (resolvedSource === resolvedDest) {\n return;\n }\n await fs.mkdir(this.baselineDir, { recursive: true });\n await fs.cp(options.sourceDir, this.baselineDir, { recursive: true });\n }\n\n async exists(_branch: string): Promise<boolean> {\n try {\n await fs.access(this.baselineDir);\n const entries = await fs.readdir(this.baselineDir);\n return entries.length > 0;\n } catch {\n return false;\n }\n }\n\n /**\n * Extract baselines from a git branch using `git ls-tree` + `git show`.\n * Binary-safe (PNG files) via `encoding: 'buffer'`.\n */\n async downloadFromGit(branch: string, destDir: string, cwd: string): Promise<void> {\n const gitPath = this.baselineDir.split(path.sep).join(\"/\");\n\n let lsOutput: string;\n try {\n const result = await execFileAsync(\n \"git\",\n [\"ls-tree\", \"-r\", \"--name-only\", branch, \"--\", gitPath],\n { cwd },\n );\n lsOutput = result.stdout;\n } catch (error) {\n throw new Error(\n `Failed to list baselines from git branch '${branch}': ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n\n const files = lsOutput.trim().split(\"\\n\").filter(Boolean);\n if (files.length === 0) {\n return;\n }\n\n await fs.mkdir(destDir, { recursive: true });\n\n const posixBaselineDir = this.baselineDir.split(path.sep).join(\"/\").replace(/\\/+$/, \"\");\n\n for (const file of files) {\n let content: Buffer;\n try {\n const result = await execFileAsync(\"git\", [\"show\", `${branch}:${file}`], {\n cwd,\n encoding: \"buffer\" as unknown as BufferEncoding,\n maxBuffer: 50 * 1024 * 1024,\n });\n content = result.stdout as unknown as Buffer;\n } catch (error) {\n throw new Error(\n `Failed to extract '${file}' from git branch '${branch}': ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n\n const relativePath = file.slice(posixBaselineDir.length + 1);\n const destPath = path.join(destDir, ...relativePath.split(\"/\"));\n await fs.mkdir(path.dirname(destPath), { recursive: true });\n await fs.writeFile(destPath, content);\n }\n }\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 switch (config.provider) {\n case \"local\":\n return new LocalStorageAdapter(config.local.baselineDir);\n case \"s3\":\n return await loadS3Adapter(config);\n default:\n throw new Error(`Unknown storage provider: ${String(config.provider)}`);\n }\n}\n\nasync function loadS3Adapter(config: StorageConfig): Promise<StorageAdapter> {\n try {\n const { S3StorageAdapter } = await import(\"@storywright/storage-s3\");\n return new S3StorageAdapter(config.s3) as StorageAdapter;\n } catch {\n throw new Error(\n \"S3 storage adapter requires the @storywright/storage-s3 package.\\nInstall it with: pnpm add @storywright/storage-s3\",\n );\n }\n}\n\nexport type { StorageAdapter, DownloadOptions, UploadOptions } from \"./types.js\";\n","import { createConsola } from \"consola\";\n\nconst isCI = !!(\n process.env.CI ||\n process.env.GITHUB_ACTIONS ||\n process.env.CIRCLECI ||\n process.env.GITLAB_CI\n);\n\nexport const logger = createConsola({\n level: 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 buildStorybook,\n discoverStories,\n excludeStoriesForBrowser,\n filterStories,\n} from \"./storybook.js\";\nimport type { Story, StoryIndex, TestSummary } from \"./types.js\";\n\nexport interface TestOptions {\n diffOnly?: boolean;\n shard?: string;\n updateSnapshots?: boolean;\n filter?: string;\n outputDir?: string;\n reporters?: string[];\n}\n\nexport interface TestRunResult {\n exitCode: number;\n summary?: TestSummary;\n reportDir?: string;\n snapshotDir?: string;\n}\n\nconst STORIES_PER_FILE = 50;\n\nfunction resolveReporterPath(): string {\n // Resolve relative to this file's dist location\n const thisDir = new URL(\".\", import.meta.url).pathname;\n return path.resolve(thisDir, \"playwright\", \"reporter.js\");\n}\n\nfunction chunkStories(entries: Record<string, Story>): Record<string, Story>[] {\n const keys = Object.keys(entries);\n if (keys.length === 0) return [{}];\n const chunks: Record<string, Story>[] = [];\n for (let i = 0; i < keys.length; i += STORIES_PER_FILE) {\n const chunk: Record<string, Story> = {};\n for (const key of keys.slice(i, i + STORIES_PER_FILE)) {\n chunk[key] = entries[key];\n }\n chunks.push(chunk);\n }\n return chunks;\n}\n\nexport async function runTests(\n config: StorywrightConfig,\n options: TestOptions = {},\n cwd: string = process.cwd(),\n): Promise<TestRunResult> {\n const outputRoot = options.outputDir\n ? path.resolve(cwd, options.outputDir)\n : resolveOutputDir(cwd, \".storywright\");\n const tmpDir = path.join(outputRoot, \"tmp\");\n const reportDir = options.outputDir\n ? path.join(outputRoot, \"report\")\n : path.resolve(cwd, config.report.outputDir);\n const storybookDir = path.resolve(cwd, config.storybook.staticDir);\n const snapshotDir = path.join(tmpDir, \"snapshots\");\n\n // Prepare directories early for parallel operations\n await fs.mkdir(snapshotDir, { recursive: true });\n\n // Start baseline download in parallel with Storybook build\n // Skip download when updating snapshots (update command) — baselines are regenerated\n let baselinePromise: Promise<void> | undefined;\n if (!options.updateSnapshots) {\n const storage = await createStorageAdapter(config.storage);\n baselinePromise = storage\n .download({\n branch: config.storage.branch,\n destDir: snapshotDir,\n onProgress: (msg) => logger.info(msg),\n })\n .catch(() => {\n logger.info(\"No existing baselines found\");\n });\n }\n\n // 1. Build Storybook if needed\n await buildStorybook(config, cwd);\n\n // 2. Discover & filter stories\n logger.start(\"Discovering stories...\");\n const allStories = await discoverStories(config, cwd);\n let targetStories = filterStories(allStories, config);\n\n // Apply --filter option\n if (options.filter) {\n targetStories = applyFilter(targetStories, options.filter);\n }\n\n logger.info(`${Object.keys(targetStories.entries).length} stories found`);\n\n // 3. Diff-only: resolve affected stories (default in CI)\n const effectiveDiffOnly = options.diffOnly ?? !!process.env.CI;\n if (effectiveDiffOnly && config.diffDetection.enabled) {\n logger.start(\"Resolving dependencies...\");\n const diffResult = await resolveAffectedStories(\n targetStories,\n config.diffDetection,\n storybookDir,\n cwd,\n );\n if (!diffResult.allStories) {\n targetStories = diffResult.targetStories;\n }\n logger.info(`${Object.keys(targetStories.entries).length} stories affected by changes`);\n }\n\n // 4. Wait for baseline download to complete\n await baselinePromise;\n\n // 5. Generate split test files for better worker distribution\n let testFilePattern: string;\n let testMatchByBrowser: Record<string, string> | undefined;\n\n const browserExcludesExist = config.browsers.some(\n (b) => (config.browserOptions[b]?.exclude ?? []).length > 0,\n );\n\n if (browserExcludesExist) {\n // Generate per-browser test files when any browser has specific excludes\n testMatchByBrowser = {};\n\n for (const browser of config.browsers) {\n const browserExclude = config.browserOptions[browser]?.exclude ?? [];\n const browserStories = excludeStoriesForBrowser(targetStories, browserExclude);\n\n if (Object.keys(browserStories.entries).length === 0) {\n logger.warn(\n `${browser}: All stories excluded by browser-specific 'exclude' patterns. No tests will run for this browser.`,\n );\n }\n\n const browserChunks = chunkStories(browserStories.entries);\n\n testMatchByBrowser[browser] =\n browserChunks.length === 1\n ? `storywright-${browser}-0.spec.ts`\n : `storywright-${browser}-*.spec.ts`;\n\n for (let i = 0; i < browserChunks.length; i++) {\n const chunkIndex: StoryIndex = {\n ...browserStories,\n entries: browserChunks[i],\n };\n const chunkPath = path.join(tmpDir, `target-stories-${browser}-${i}.json`);\n await fs.writeFile(chunkPath, JSON.stringify(chunkIndex));\n\n const testContent = generateTestFile(config.screenshot, {\n targetStoriesPath: chunkPath.replace(/\\\\/g, \"/\"),\n });\n await fs.writeFile(path.join(tmpDir, `storywright-${browser}-${i}.spec.ts`), testContent);\n }\n\n logger.info(\n `${browser}: ${Object.keys(browserStories.entries).length} stories, ${\n browserChunks.length\n } test file(s)`,\n );\n }\n\n testFilePattern = \"storywright-*.spec.ts\";\n } else {\n // Default: shared test files for all browsers\n const chunks = chunkStories(targetStories.entries);\n testFilePattern = chunks.length === 1 ? \"storywright-0.spec.ts\" : \"storywright-*.spec.ts\";\n\n for (let i = 0; i < chunks.length; i++) {\n const chunkIndex: StoryIndex = { ...targetStories, entries: chunks[i] };\n const chunkPath = path.join(tmpDir, `target-stories-${i}.json`);\n await fs.writeFile(chunkPath, JSON.stringify(chunkIndex));\n\n const testContent = generateTestFile(config.screenshot, {\n targetStoriesPath: chunkPath.replace(/\\\\/g, \"/\"),\n });\n await fs.writeFile(path.join(tmpDir, `storywright-${i}.spec.ts`), testContent);\n }\n\n logger.info(`${chunks.length} test file(s) generated`);\n }\n\n // 6. Generate Playwright config\n const reporterWrapperPath = path.join(tmpDir, \"reporter.mjs\");\n const resolvedReporterPath = resolveReporterPath().replace(/\\\\/g, \"/\");\n const reporterOutputDir = reportDir.replace(/\\\\/g, \"/\");\n\n await fs.writeFile(\n reporterWrapperPath,\n `import StorywrightReporter from '${resolvedReporterPath}';\\nexport default class extends StorywrightReporter {\\n constructor() { super({ outputDir: '${reporterOutputDir}' }); }\\n}\\n`,\n );\n\n // Determine Storybook URL\n let actualStorybookUrl = config.storybook.url;\n const needsServer = !actualStorybookUrl;\n\n if (needsServer) {\n actualStorybookUrl = \"http://localhost:6007\";\n }\n\n const playwrightConfig = generatePlaywrightConfig(config, {\n tmpDir: tmpDir.replace(/\\\\/g, \"/\"),\n storybookUrl: actualStorybookUrl ?? \"http://localhost:6007\",\n snapshotDir: snapshotDir.replace(/\\\\/g, \"/\"),\n reporterPath: reporterWrapperPath.replace(/\\\\/g, \"/\"),\n testMatch: testFilePattern,\n testMatchByBrowser,\n shard: options.shard,\n reporters: options.reporters,\n updateSnapshots: options.updateSnapshots,\n });\n\n const configPath = path.join(tmpDir, \"playwright.config.ts\");\n await fs.writeFile(configPath, playwrightConfig);\n\n // 7. Run Playwright tests\n logger.start(\"Running tests...\");\n const args = [\"playwright\", \"test\", \"--config\", configPath];\n\n if (options.updateSnapshots) {\n args.push(\"--update-snapshots\");\n }\n\n // Start static server if needed\n let serverProc: { kill: () => void } | undefined;\n if (needsServer) {\n serverProc = await startStaticServer(storybookDir, 6007);\n }\n\n try {\n const result = await exec(\"npx\", args, { cwd, inherit: true });\n\n // 8. Read results\n let summary: TestSummary | undefined;\n try {\n const summaryPath = path.join(reportDir, \"summary.json\");\n const summaryContent = await fs.readFile(summaryPath, \"utf-8\");\n summary = JSON.parse(summaryContent);\n } catch {\n // summary may not exist if no tests ran\n }\n\n // 9. Map exit codes per SPEC §14.2\n const exitCode = mapExitCode(result.exitCode, summary);\n\n return { exitCode, summary, reportDir, snapshotDir };\n } finally {\n serverProc?.kill();\n }\n}\n\nexport async function updateBaselines(\n config: StorywrightConfig,\n options: {\n all?: boolean;\n upload?: boolean;\n shard?: string;\n filter?: string;\n } = {},\n cwd: string = process.cwd(),\n): Promise<TestRunResult> {\n const result = await runTests(\n config,\n {\n updateSnapshots: true,\n diffOnly: !options.all,\n shard: options.shard,\n filter: options.filter,\n },\n cwd,\n );\n\n if (result.exitCode !== 0) {\n logger.warn(\"Some tests failed during baseline update\");\n }\n\n // Save updated snapshots back to baselineDir (local disk operation)\n if (result.snapshotDir) {\n const baselineDir = path.resolve(cwd, config.storage.local.baselineDir);\n await fs.mkdir(baselineDir, { recursive: true });\n await fs.cp(result.snapshotDir, baselineDir, { recursive: true });\n logger.success(`Baselines saved to ${config.storage.local.baselineDir}`);\n }\n\n // --upload: upload to remote storage (S3 etc.) only when explicitly requested\n if (options.upload) {\n const storage = await createStorageAdapter(config.storage);\n const baselineDir = path.resolve(cwd, config.storage.local.baselineDir);\n await storage.upload({\n branch: config.storage.branch,\n sourceDir: baselineDir,\n shard: options.shard,\n onProgress: (msg) => logger.info(msg),\n });\n logger.success(\"Baselines uploaded to remote storage\");\n }\n\n return result;\n}\n\nfunction applyFilter(storyIndex: StoryIndex, filter: string): StoryIndex {\n const matcher = picomatch(filter);\n const entries: Record<string, StoryIndex[\"entries\"][string]> = {};\n for (const [id, story] of Object.entries(storyIndex.entries)) {\n const fullName = `${story.title}/${story.name}`;\n if (matcher(fullName) || matcher(story.title) || matcher(story.id)) {\n entries[id] = story;\n }\n }\n return { ...storyIndex, entries };\n}\n\nfunction mapExitCode(playwrightCode: number, summary?: TestSummary): number {\n // SPEC §14.2: 0 = success (no diff), 1 = success (diff found), 2 = execution error, 130 = SIGINT\n if (playwrightCode === 130 || playwrightCode === 143) {\n return 130; // SIGINT / SIGTERM\n }\n if (summary) {\n if (summary.failed > 0) return 1;\n if (summary.total === 0 && playwrightCode !== 0) return 2;\n return 0;\n }\n // No summary = likely execution error\n return playwrightCode === 0 ? 0 : 2;\n}\n\nasync function startStaticServer(dir: string, port: number): Promise<{ kill: () => void }> {\n const { createServer } = await import(\"node:http\");\n const sirv = (await import(\"sirv\")).default;\n\n const handler = sirv(dir, { single: false, dev: false });\n const server = createServer(handler);\n\n await new Promise<void>((resolve, reject) => {\n server.on(\"error\", reject);\n server.listen(port, () => resolve());\n });\n\n return { 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 config: StorywrightConfig,\n options: {\n tmpDir: string;\n storybookUrl: string;\n snapshotDir: string;\n reporterPath: string;\n testMatch: string;\n testMatchByBrowser?: Record<string, string>;\n shard?: string;\n reporters?: string[];\n updateSnapshots?: boolean;\n },\n): string {\n const projects = config.browsers.map((browser) => {\n const rawOptions = config.browserOptions[browser];\n const useObj = buildBrowserUseObject(browser, rawOptions);\n const useStr = JSON.stringify(useObj, null, \"\\t\\t\");\n const testMatch = options.testMatchByBrowser?.[browser];\n const testMatchLine = testMatch ? `\\n\\t\\t\\ttestMatch: '${escapeBackslash(testMatch)}',` : \"\";\n return `\\t\\t{\n\\t\\t\\tname: '${browser}',${testMatchLine}\n\\t\\t\\tuse: ${useStr},\n\\t\\t}`;\n });\n\n const workers = config.workers === \"auto\" ? \"'100%'\" : String(config.workers);\n\n const shard = options.shard\n ? `\\tshard: { current: ${options.shard.split(\"/\")[0]}, total: ${options.shard.split(\"/\")[1]} },`\n : \"\";\n\n // Build reporter list: always include custom reporter, plus user-requested ones\n const reporterEntries: string[] = [];\n const requestedReporters = options.reporters ?? [\"default\", \"html\"];\n for (const r of requestedReporters) {\n if (r === \"default\" || r === \"list\") {\n reporterEntries.push(\"\\t\\t['list']\");\n } else if (r !== \"html\") {\n // Pass through other built-in Playwright reporters (dot, json, junit, etc.)\n reporterEntries.push(`\\t\\t['${r}']`);\n }\n }\n // Always include custom storywright reporter\n reporterEntries.push(`\\t\\t['${escapeBackslash(options.reporterPath)}']`);\n\n const testMatchLine = options.testMatchByBrowser\n ? \"\"\n : `\\ttestMatch: '${escapeBackslash(options.testMatch)}',\\n`;\n\n return `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\\tupdateSnapshots: '${options.updateSnapshots ? \"all\" : \"none\"}',\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 browser: string,\n rawOptions?: BrowserOption,\n): Record<string, unknown> {\n let browserName: string;\n if (rawOptions?.browserName) {\n browserName = rawOptions.browserName;\n } else if (STANDARD_BROWSERS.has(browser)) {\n browserName = browser;\n } else {\n throw new Error(\n `Cannot resolve browserName for custom browser project '${browser}'.\\n\\nError code: SW_E_INTERNAL_BROWSER_RESOLVE`,\n );\n }\n const useObj: Record<string, unknown> = { browserName };\n\n if (rawOptions) {\n const { browserName: _, exclude: __, ...rest } = rawOptions;\n Object.assign(useObj, rest);\n }\n\n return useObj;\n}\n\nfunction escapeBackslash(str: string): string {\n return str.replace(/\\\\/g, \"/\");\n}\n","import type { ScreenshotConfig } from \"../config/types.js\";\n\nexport function generateTestFile(\n config: ScreenshotConfig,\n options: {\n targetStoriesPath: string;\n },\n): string {\n const disableAnimations = config.animations === \"disabled\";\n\n return `import { test, expect } from '@playwright/test';\nimport { readFileSync } from 'node:fs';\nimport { initPage, stabilizePage } from '@storywright/cli/playwright/stabilize';\n\nconst targetList = JSON.parse(\n\\treadFileSync('${escapeBackslash(options.targetStoriesPath)}', 'utf-8'),\n);\n\nconst stabilizeOptions = {\n\\tfreezeTime: '${config.freezeTime}',\n\\tseed: ${config.seed},\n\\tdisableAnimations: ${disableAnimations},\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\\tawait initPage(page, stabilizeOptions);\n\n\\t\\t\\tawait page.goto(\\`/iframe.html?id=\\${story.id}\\`, {\n\\t\\t\\t\\twaitUntil: 'domcontentloaded',\n\\t\\t\\t});\n\n\\t\\t\\tawait stabilizePage(page, stabilizeOptions);\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 return 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 getDependencies(filePath: string): string[];\n getStoriesForFiles(pathList: string[]): StoryIndex;\n}\n\nconst STORY_FILE_PATTERNS = [\".stories.\", \".mdx\"];\n\nfunction isStoryFile(moduleName: string): boolean {\n return STORY_FILE_PATTERNS.some((p) => moduleName.includes(p));\n}\n\nexport class StorybookStatsDependencyResolver implements DependencyResolver {\n private moduleMap: Record<string, StatsModule>;\n\n constructor(\n private statsJson: StatsIndex,\n private storiesJson: StoryIndex,\n ) {\n this.moduleMap = {};\n for (const mod of statsJson.modules) {\n // Key by normalized name (primary) and normalized id (fallback)\n const normalizedName = normalizePath(mod.name);\n this.moduleMap[normalizedName] = mod;\n const normalizedId = normalizePath(mod.id);\n if (normalizedId !== normalizedName) {\n this.moduleMap[normalizedId] ??= mod;\n }\n }\n }\n\n getDependencies(filePath: string): string[] {\n const normalizedPath = normalizePath(filePath);\n const dependencies = this.collectDependencies(normalizedPath);\n\n if (this.moduleMap[normalizedPath]) {\n dependencies.add(normalizedPath);\n }\n\n return [...dependencies];\n }\n\n getStoriesForFiles(pathList: string[]): StoryIndex {\n const result: StoryIndex = { v: this.storiesJson.v, entries: {} };\n\n for (const filePath of pathList) {\n // Finding #2 + #3: lookup via normalized moduleMap (name primary, id fallback)\n const normalizedPath = normalizePath(filePath);\n const stats = this.moduleMap[normalizedPath];\n if (!stats) continue;\n\n // Finding #1: collect ALL story reasons, not just first\n const storyReasons = stats.reasons.filter((r) => isStoryFile(r.moduleName));\n for (const reason of storyReasons) {\n const normalizedImportPath = normalizePath(reason.moduleName);\n // Collect ALL matching story entries per reason\n for (const storyObj of Object.values(this.storiesJson.entries)) {\n if (storyObj.type !== \"story\") continue;\n if (normalizePath(storyObj.importPath) === normalizedImportPath) {\n result.entries[storyObj.id] = storyObj;\n }\n }\n }\n }\n\n return result;\n }\n\n private collectDependencies(name: string, result = new Set<string>()): Set<string> {\n const mod = this.moduleMap[normalizePath(name)];\n if (mod) {\n for (const reason of mod.reasons) {\n if (!result.has(reason.moduleName)) {\n result.add(reason.moduleName);\n this.collectDependencies(reason.moduleName, result);\n }\n }\n }\n return result;\n }\n}\n\nexport interface DiffResult {\n allStories: boolean;\n targetStories: StoryIndex;\n}\n\ninterface DiffFileEntry {\n file: string;\n from?: string;\n}\n\nexport async function resolveAffectedStories(\n storiesJson: StoryIndex,\n config: DiffDetectionConfig,\n storybookStaticDir: string,\n cwd: string,\n): Promise<DiffResult> {\n const git = simpleGit({ baseDir: cwd });\n\n // Get diff summary\n let diffEntries: DiffFileEntry[];\n try {\n // Detect if HEAD is on the base branch (e.g. main)\n const currentBranch = (await git.raw([\"rev-parse\", \"--abbrev-ref\", \"HEAD\"])).trim();\n const isOnBaseBranch = currentBranch === config.baseBranch;\n\n let diffBase: string;\n if (isOnBaseBranch && config.baseBranchDiffDepth > 0) {\n // On the base branch, merge-base == HEAD so diff would be empty.\n // Use HEAD~N to compare against the previous commit(s) instead.\n diffBase = `HEAD~${config.baseBranchDiffDepth}`;\n logger.info(`On base branch '${config.baseBranch}', using ${diffBase} for diff detection`);\n } else {\n const mergeBase = await git.raw([\"merge-base\", config.baseBranch, \"HEAD\"]);\n diffBase = mergeBase.trim();\n }\n\n const diff = await git.diffSummary([diffBase, \"HEAD\"]);\n diffEntries = diff.files.map((f) => ({\n file: f.file,\n // Handle renames: include both old and new paths\n from: \"from\" in f ? (f as { from: string }).from : undefined,\n }));\n } catch {\n logger.warn(\"Failed to resolve git diff, running all stories\");\n return { allStories: true, targetStories: storiesJson };\n }\n\n if (diffEntries.length === 0) {\n logger.info(\"No changed files detected\");\n return { allStories: false, targetStories: { v: storiesJson.v, entries: {} } };\n }\n\n // Collect all affected paths (including rename sources)\n const allPaths: string[] = [];\n for (const entry of diffEntries) {\n allPaths.push(entry.file);\n if (entry.from) {\n allPaths.push(entry.from);\n }\n }\n\n // Check watchFiles\n for (const file of allPaths) {\n for (const pattern of config.watchFiles) {\n if (picomatch(pattern)(file)) {\n logger.info(`Watch file changed: ${file}, running all stories`);\n return { allStories: true, targetStories: storiesJson };\n }\n }\n }\n\n // Load stats json for dependency resolution\n const statsPath = path.resolve(storybookStaticDir, \"preview-stats.json\");\n let statsJson: StatsIndex;\n try {\n statsJson = JSON.parse(await fs.readFile(statsPath, \"utf-8\"));\n } catch {\n logger.warn(\"preview-stats.json not found, running all stories\");\n return { allStories: true, targetStories: storiesJson };\n }\n\n const resolver = new StorybookStatsDependencyResolver(statsJson, storiesJson);\n const targetStories: StoryIndex = { v: storiesJson.v, entries: {} };\n\n // Direct story file matches (both .stories.* and .mdx)\n for (const file of allPaths) {\n const matchedStories = Object.values(storiesJson.entries).filter(\n (story) => stripLeadingDotSlash(story.importPath) === file,\n );\n for (const story of matchedStories) {\n targetStories.entries[story.id] = story;\n }\n }\n\n // Dependency-based matches\n for (const file of allPaths) {\n const deps = resolver.getDependencies(normalizePath(file));\n const depStories = resolver.getStoriesForFiles(deps);\n for (const [id, story] of Object.entries(depStories.entries)) {\n targetStories.entries[id] = story;\n }\n }\n\n logger.info(`Resolved ${Object.keys(targetStories.entries).length} affected stories`);\n return { allStories: false, targetStories };\n}\n","import path from \"node:path\";\n\nexport function normalizePath(filePath: string): string {\n const normalized = filePath.replace(/\\\\/g, \"/\");\n if (normalized.startsWith(\"./\")) {\n return normalized;\n }\n return `./${normalized}`;\n}\n\nexport function stripLeadingDotSlash(filePath: string): string {\n return filePath.replace(/^\\.\\//, \"\");\n}\n\nexport function resolveOutputDir(outputDir: string, ...segments: string[]): string {\n return path.resolve(outputDir, ...segments);\n}\n","import { spawn } from \"node:child_process\";\n\nexport interface ExecResult {\n exitCode: number;\n stdout: string;\n stderr: string;\n}\n\nexport function exec(\n command: string,\n args: string[],\n options?: { cwd?: string; env?: Record<string, string>; inherit?: boolean },\n): Promise<ExecResult> {\n return new Promise((resolve, reject) => {\n const proc = spawn(command, args, {\n cwd: options?.cwd,\n env: { ...process.env, ...options?.env },\n stdio: options?.inherit ? [\"ignore\", \"inherit\", \"inherit\"] : [\"ignore\", \"pipe\", \"pipe\"],\n shell: false,\n });\n\n let stdout = \"\";\n let stderr = \"\";\n\n if (!options?.inherit) {\n proc.stdout?.on(\"data\", (data: Buffer) => {\n stdout += data.toString();\n });\n\n proc.stderr?.on(\"data\", (data: Buffer) => {\n stderr += data.toString();\n });\n }\n\n proc.on(\"error\", reject);\n\n proc.on(\"close\", (code) => {\n resolve({ exitCode: code ?? 1, stdout, stderr });\n });\n });\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 if (config.storybook.url) {\n logger.info(\"Using running Storybook at\", config.storybook.url);\n return;\n }\n\n const staticDir = path.resolve(cwd, config.storybook.staticDir);\n try {\n await fs.access(path.join(staticDir, \"index.json\"));\n logger.info(\"Storybook already built at\", staticDir);\n return;\n } catch {\n // need to build\n }\n\n logger.start(\"Building Storybook...\");\n const [command, ...args] = config.storybook.buildCommand.split(\" \");\n const result = await exec(command, args, { cwd });\n if (result.exitCode !== 0) {\n throw new Error(\n `Storybook build failed (exit code ${result.exitCode}):\\n${result.stderr}\\n\\nError code: SW_E_STORYBOOK_BUILD_FAILED`,\n );\n }\n logger.success(\"Storybook built\");\n}\n\nexport async function discoverStories(config: StorywrightConfig, cwd: string): Promise<StoryIndex> {\n const staticDir = path.resolve(cwd, config.storybook.staticDir);\n const indexPath = path.join(staticDir, \"index.json\");\n\n try {\n await fs.access(indexPath);\n } catch {\n throw new Error(\n `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 );\n }\n\n const raw = JSON.parse(await fs.readFile(indexPath, \"utf-8\"));\n const indexJson = normalizeStoryIndex(raw, config.storybook.compatibility);\n\n // Version check\n if (indexJson.v < 4) {\n throw new Error(\n \"Storybook 7.x or earlier is not supported. Storywright requires Storybook 8 or later.\\n\\nError code: SW_E_STORYBOOK_UNSUPPORTED\",\n );\n }\n\n return indexJson;\n}\n\n/**\n * Parse Storybook index.json (v8+).\n */\nfunction normalizeStoryIndex(\n raw: Record<string, unknown>,\n _compatibility: \"auto\" | \"v8\",\n): StoryIndex {\n const version = typeof raw.v === \"number\" ? raw.v : 0;\n const entries = (raw.entries ?? {}) as Record<string, Story>;\n\n return { v: version, entries };\n}\n\nexport function filterStories(storyIndex: StoryIndex, config: StorywrightConfig): StoryIndex {\n const entries: Record<string, Story> = {};\n const includeMatchers = config.include.map((p) => picomatch(p));\n const excludeMatchers = config.exclude.map((p) => picomatch(p));\n\n for (const [id, story] of Object.entries(storyIndex.entries)) {\n // Skip docs entries\n if (story.type === \"docs\") continue;\n if (story.name === \"Docs\") continue;\n\n const fullName = `${story.title}/${story.name}`;\n\n // Check include patterns\n const isIncluded = includeMatchers.some((m) => m(fullName));\n if (!isIncluded) continue;\n\n // Check exclude patterns\n const isExcluded = excludeMatchers.some((m) => m(fullName));\n if (isExcluded) continue;\n\n entries[id] = story;\n }\n\n return { ...storyIndex, entries };\n}\n\nexport function excludeStoriesForBrowser(\n storyIndex: StoryIndex,\n excludePatterns: string[],\n): StoryIndex {\n if (excludePatterns.length === 0) {\n return storyIndex;\n }\n\n const excludeMatchers = excludePatterns.map((p) => picomatch(p));\n const entries: Record<string, Story> = {};\n\n for (const [id, story] of Object.entries(storyIndex.entries)) {\n const fullName = `${story.title}/${story.name}`;\n const isExcluded = excludeMatchers.some((m) => m(fullName));\n if (!isExcluded) {\n entries[id] = story;\n }\n }\n\n return { ...storyIndex, entries };\n}\n"],"mappings":";AAAA,SAAS,cAAc,oBAAoB;;;ACEpC,IAAM,iBAAoC;AAAA,EAC/C,WAAW;AAAA,IACT,WAAW;AAAA,IACX,cAAc;AAAA,IACd,KAAK;AAAA,IACL,eAAe;AAAA,EACjB;AAAA,EAEA,UAAU,CAAC,UAAU;AAAA,EACrB,gBAAgB,CAAC;AAAA,EAEjB,YAAY;AAAA,IACV,UAAU;AAAA,IACV,YAAY;AAAA,IACZ,WAAW;AAAA,IACX,mBAAmB;AAAA,IACnB,YAAY;AAAA,IACZ,UAAU;AAAA,IACV,QAAQ;AAAA,IACR,MAAM;AAAA,EACR;AAAA,EAEA,eAAe;AAAA,IACb,SAAS;AAAA,IACT,YAAY,CAAC,gBAAgB,qBAAqB,iBAAiB;AAAA,IACnE,YAAY;AAAA,IACZ,qBAAqB;AAAA,EACvB;AAAA,EAEA,SAAS;AAAA,IACP,UAAU;AAAA,IACV,QAAQ;AAAA,IACR,OAAO;AAAA,MACL,aAAa;AAAA,IACf;AAAA,IACA,IAAI;AAAA,MACF,QAAQ;AAAA,MACR,QAAQ;AAAA,MACR,QAAQ;AAAA,MACR,aAAa;AAAA,IACf;AAAA,EACF;AAAA,EAEA,QAAQ;AAAA,IACN,WAAW;AAAA,IACX,OAAO;AAAA,EACT;AAAA,EAEA,SAAS;AAA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;AACtC;","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-TL2W442S.js";
|
|
10
10
|
import {
|
|
11
11
|
generateHtmlReport
|
|
12
12
|
} from "./chunk-HOJE6RXD.js";
|
|
@@ -437,7 +437,7 @@ var uploadCommand = defineCommand6({
|
|
|
437
437
|
var main = defineCommand7({
|
|
438
438
|
meta: {
|
|
439
439
|
name: "storywright",
|
|
440
|
-
version: "1.
|
|
440
|
+
version: "1.4.1",
|
|
441
441
|
description: "Zero-config visual regression testing powered by Storybook + Playwright"
|
|
442
442
|
},
|
|
443
443
|
subCommands: {
|
package/dist/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@storywright/cli",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.4.1",
|
|
4
4
|
"description": "Zero-config visual regression testing powered by Storybook + Playwright",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"playwright",
|
|
@@ -11,6 +11,11 @@
|
|
|
11
11
|
"vrt"
|
|
12
12
|
],
|
|
13
13
|
"license": "MIT",
|
|
14
|
+
"repository": {
|
|
15
|
+
"type": "git",
|
|
16
|
+
"url": "https://github.com/macloud-developer/storywright.git",
|
|
17
|
+
"directory": "packages/@storywright/cli"
|
|
18
|
+
},
|
|
14
19
|
"bin": {
|
|
15
20
|
"storywright": "./bin/storywright.mjs"
|
|
16
21
|
},
|
|
@@ -43,7 +48,7 @@
|
|
|
43
48
|
"simple-git": "^3.32.3",
|
|
44
49
|
"sirv": "^3.0.0",
|
|
45
50
|
"unconfig": "^0.6.0",
|
|
46
|
-
"@storywright/report": "1.
|
|
51
|
+
"@storywright/report": "1.4.1"
|
|
47
52
|
},
|
|
48
53
|
"devDependencies": {
|
|
49
54
|
"@playwright/test": "^1.50.0",
|
|
@@ -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 config: DeepPartial<StorywrightConfig>,\n): DeepPartial<StorywrightConfig> {\n return config;\n}\n\nfunction isPlainObject(value: unknown): value is Record<string, unknown> {\n return value !== null && typeof value === \"object\" && !Array.isArray(value);\n}\n\nfunction deepMerge(\n target: Record<string, unknown>,\n source: Record<string, unknown>,\n): Record<string, unknown> {\n const result: Record<string, unknown> = { ...target };\n for (const key of Object.keys(source)) {\n const sourceVal = source[key];\n const targetVal = result[key];\n if (isPlainObject(sourceVal) && isPlainObject(targetVal)) {\n result[key] = deepMerge(targetVal, sourceVal);\n } else if (sourceVal !== undefined) {\n result[key] = sourceVal;\n }\n }\n return result;\n}\n\nexport async function loadConfig(\n cwd: string = process.cwd(),\n overrides?: DeepPartial<StorywrightConfig>,\n): Promise<StorywrightConfig> {\n const { config: userConfig } = await unconfigLoad<DeepPartial<StorywrightConfig>>({\n sources: [\n {\n files: \"storywright.config\",\n extensions: [\"ts\", \"js\", \"mjs\"],\n },\n ],\n cwd,\n });\n\n let merged = DEFAULT_CONFIG as unknown as Record<string, unknown>;\n if (userConfig) {\n merged = deepMerge(merged, userConfig as Record<string, unknown>);\n }\n if (overrides) {\n merged = deepMerge(merged, overrides as Record<string, unknown>);\n }\n const result = merged as unknown as StorywrightConfig;\n validateConfig(result);\n return result;\n}\n\nfunction validateConfig(config: StorywrightConfig): void {\n for (const browser of config.browsers) {\n const options = config.browserOptions[browser];\n\n if (!STANDARD_BROWSERS.has(browser) && !options?.browserName) {\n throw new Error(\n `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 );\n }\n\n if (options?.browserName && !STANDARD_BROWSERS.has(options.browserName)) {\n throw new Error(\n `Invalid browserName '${options.browserName}' for browser project '${browser}'.\\nValid values: 'chromium', 'firefox', 'webkit'.\\n\\nError code: SW_E_INVALID_BROWSER_NAME`,\n );\n }\n }\n}\n\nexport type { StorywrightConfig, DeepPartial } from \"./types.js\";\n","import type { StorywrightConfig } from \"./types.js\";\n\nexport const DEFAULT_CONFIG: StorywrightConfig = {\n storybook: {\n staticDir: \"storybook-static\",\n buildCommand: \"npx storybook build --stats-json\",\n url: undefined,\n compatibility: \"auto\",\n },\n\n browsers: [\"chromium\"],\n browserOptions: {},\n\n screenshot: {\n fullPage: true,\n animations: \"disabled\",\n threshold: 0.02,\n maxDiffPixelRatio: 0.02,\n freezeTime: \"2024-01-01T00:00:00\",\n timezone: \"UTC\",\n locale: \"en-US\",\n seed: 1,\n },\n\n diffDetection: {\n enabled: true,\n watchFiles: [\"package.json\", \"package-lock.json\", \".storybook/**/*\"],\n baseBranch: \"main\",\n baseBranchDiffDepth: 1,\n },\n\n storage: {\n provider: \"local\",\n branch: \"main\",\n local: {\n baselineDir: \".storywright/baselines\",\n },\n s3: {\n bucket: \"\",\n prefix: \"storywright/baselines\",\n region: \"ap-northeast-1\",\n compression: \"zstd\",\n },\n },\n\n report: {\n outputDir: \".storywright/report\",\n title: \"Storywright Report\",\n },\n\n workers: \"auto\",\n retries: 0,\n\n timeout: {\n test: 30000,\n navigation: 20000,\n expect: 10000,\n },\n\n include: [\"**\"],\n exclude: [],\n\n hooks: {},\n};\n","import type { Page } from \"@playwright/test\";\n\nexport interface StorywrightConfig {\n storybook: StorybookConfig;\n browsers: BrowserName[];\n browserOptions: Record<string, BrowserOption>;\n screenshot: ScreenshotConfig;\n diffDetection: DiffDetectionConfig;\n storage: StorageConfig;\n report: ReportConfig;\n workers: number | \"auto\";\n retries: number;\n timeout: TimeoutConfig;\n include: string[];\n exclude: string[];\n hooks: 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 \"chromium\",\n \"firefox\",\n \"webkit\",\n]);\n\nexport interface BrowserOption {\n browserName?: PlaywrightBrowserName;\n viewport?: { width: number; height: number };\n deviceScaleFactor?: number;\n isMobile?: boolean;\n hasTouch?: boolean;\n userAgent?: string;\n exclude?: string[];\n}\n\nexport interface StorybookConfig {\n staticDir: string;\n buildCommand: string;\n url?: string;\n compatibility: \"auto\" | \"v8\";\n}\n\nexport interface ScreenshotConfig {\n fullPage: boolean;\n animations: \"disabled\" | \"allow\";\n threshold: number;\n maxDiffPixelRatio: number;\n freezeTime: string;\n timezone: string;\n locale: string;\n seed: number;\n}\n\nexport interface DiffDetectionConfig {\n enabled: boolean;\n watchFiles: string[];\n baseBranch: string;\n baseBranchDiffDepth: number;\n}\n\nexport interface StorageConfig {\n provider: \"local\" | \"s3\";\n branch: string;\n local: LocalStorageConfig;\n s3: S3StorageConfig;\n}\n\nexport interface LocalStorageConfig {\n baselineDir: string;\n}\n\nexport interface S3StorageConfig {\n bucket: string;\n prefix: string;\n region: string;\n compression: \"zstd\" | \"gzip\" | \"none\";\n}\n\nexport interface ReportConfig {\n outputDir: string;\n title: string;\n}\n\nexport interface TimeoutConfig {\n test: number;\n navigation: number;\n expect: number;\n}\n\nexport interface StoryContext {\n id: string;\n title: string;\n name: string;\n}\n\nexport interface HooksConfig {\n beforeScreenshot?: (page: Page, story: StoryContext) => Promise<void>;\n afterScreenshot?: (page: Page, story: StoryContext) => Promise<void>;\n}\n\nexport type DeepPartial<T> = {\n [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 const durationSec = Math.round(summary.duration / 1000);\n const minutes = Math.floor(durationSec / 60);\n const seconds = durationSec % 60;\n const durationStr = minutes > 0 ? `${minutes}m ${seconds}s` : `${seconds}s`;\n\n const lines: string[] = [\n \"\",\n \"Storywright Results\",\n \"\\u2550\".repeat(42),\n ` Total: ${summary.total} Passed: ${summary.passed} Failed: ${summary.failed} Skipped: ${summary.skipped}`,\n ` Duration: ${durationStr}`,\n ` Browsers: ${summary.browsers.join(\", \")}`,\n ];\n\n const newFailures = summary.entries.filter((f) => f.type === \"new\");\n const diffFailures = summary.entries.filter((f) => f.type === \"diff\");\n\n if (newFailures.length > 0) {\n lines.push(\"\");\n lines.push(\" New (no baseline):\");\n for (const failure of newFailures) {\n lines.push(` \\u25cb ${failure.story}: ${failure.variant} (${failure.browser})`);\n }\n }\n\n if (diffFailures.length > 0) {\n lines.push(\"\");\n lines.push(\" Failed:\");\n for (const failure of diffFailures) {\n lines.push(` \\u2717 ${failure.story}: ${failure.variant} (${failure.browser})`);\n if (failure.diffRatio > 0) {\n const pct = (failure.diffRatio * 100).toFixed(1);\n lines.push(` \\u2192 Diff: ${pct}% pixels changed`);\n }\n }\n }\n\n const reportPath = options?.reportPath ?? \".storywright/report/index.html\";\n lines.push(\"\");\n lines.push(` Report: ${reportPath}`);\n lines.push(\"\\u2550\".repeat(42));\n lines.push(\"\");\n\n return 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 constructor(private readonly baselineDir: string) {}\n\n async download(options: DownloadOptions): Promise<void> {\n try {\n await fs.access(this.baselineDir);\n } catch {\n return;\n }\n await fs.cp(this.baselineDir, options.destDir, { recursive: true });\n }\n\n async upload(options: UploadOptions): Promise<void> {\n const resolvedSource = path.resolve(options.sourceDir);\n const resolvedDest = path.resolve(this.baselineDir);\n if (resolvedSource === resolvedDest) {\n return;\n }\n await fs.mkdir(this.baselineDir, { recursive: true });\n await fs.cp(options.sourceDir, this.baselineDir, { recursive: true });\n }\n\n async exists(_branch: string): Promise<boolean> {\n try {\n await fs.access(this.baselineDir);\n const entries = await fs.readdir(this.baselineDir);\n return entries.length > 0;\n } catch {\n return false;\n }\n }\n\n /**\n * Extract baselines from a git branch using `git ls-tree` + `git show`.\n * Binary-safe (PNG files) via `encoding: 'buffer'`.\n */\n async downloadFromGit(branch: string, destDir: string, cwd: string): Promise<void> {\n const gitPath = this.baselineDir.split(path.sep).join(\"/\");\n\n let lsOutput: string;\n try {\n const result = await execFileAsync(\n \"git\",\n [\"ls-tree\", \"-r\", \"--name-only\", branch, \"--\", gitPath],\n { cwd },\n );\n lsOutput = result.stdout;\n } catch (error) {\n throw new Error(\n `Failed to list baselines from git branch '${branch}': ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n\n const files = lsOutput.trim().split(\"\\n\").filter(Boolean);\n if (files.length === 0) {\n return;\n }\n\n await fs.mkdir(destDir, { recursive: true });\n\n const posixBaselineDir = this.baselineDir.split(path.sep).join(\"/\").replace(/\\/+$/, \"\");\n\n for (const file of files) {\n let content: Buffer;\n try {\n const result = await execFileAsync(\"git\", [\"show\", `${branch}:${file}`], {\n cwd,\n encoding: \"buffer\" as unknown as BufferEncoding,\n maxBuffer: 50 * 1024 * 1024,\n });\n content = result.stdout as unknown as Buffer;\n } catch (error) {\n throw new Error(\n `Failed to extract '${file}' from git branch '${branch}': ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n\n const relativePath = file.slice(posixBaselineDir.length + 1);\n const destPath = path.join(destDir, ...relativePath.split(\"/\"));\n await fs.mkdir(path.dirname(destPath), { recursive: true });\n await fs.writeFile(destPath, content);\n }\n }\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 switch (config.provider) {\n case \"local\":\n return new LocalStorageAdapter(config.local.baselineDir);\n case \"s3\":\n return await loadS3Adapter(config);\n default:\n throw new Error(`Unknown storage provider: ${String(config.provider)}`);\n }\n}\n\nasync function loadS3Adapter(config: StorageConfig): Promise<StorageAdapter> {\n try {\n const { S3StorageAdapter } = await import(\"@storywright/storage-s3\");\n return new S3StorageAdapter(config.s3) as StorageAdapter;\n } catch {\n throw new Error(\n \"S3 storage adapter requires the @storywright/storage-s3 package.\\nInstall it with: pnpm add @storywright/storage-s3\",\n );\n }\n}\n\nexport type { StorageAdapter, DownloadOptions, UploadOptions } from \"./types.js\";\n","import { createConsola } from \"consola\";\n\nconst isCI = !!(\n process.env.CI ||\n process.env.GITHUB_ACTIONS ||\n process.env.CIRCLECI ||\n process.env.GITLAB_CI\n);\n\nexport const logger = createConsola({\n level: 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 buildStorybook,\n discoverStories,\n excludeStoriesForBrowser,\n filterStories,\n} from \"./storybook.js\";\nimport type { Story, StoryIndex, TestSummary } from \"./types.js\";\n\nexport interface TestOptions {\n diffOnly?: boolean;\n shard?: string;\n updateSnapshots?: boolean;\n filter?: string;\n outputDir?: string;\n reporters?: string[];\n}\n\nexport interface TestRunResult {\n exitCode: number;\n summary?: TestSummary;\n reportDir?: string;\n snapshotDir?: string;\n}\n\nconst STORIES_PER_FILE = 50;\n\nfunction resolveReporterPath(): string {\n // Resolve relative to this file's dist location\n const thisDir = new URL(\".\", import.meta.url).pathname;\n return path.resolve(thisDir, \"playwright\", \"reporter.js\");\n}\n\nfunction chunkStories(entries: Record<string, Story>): Record<string, Story>[] {\n const keys = Object.keys(entries);\n if (keys.length === 0) return [{}];\n const chunks: Record<string, Story>[] = [];\n for (let i = 0; i < keys.length; i += STORIES_PER_FILE) {\n const chunk: Record<string, Story> = {};\n for (const key of keys.slice(i, i + STORIES_PER_FILE)) {\n chunk[key] = entries[key];\n }\n chunks.push(chunk);\n }\n return chunks;\n}\n\nexport async function runTests(\n config: StorywrightConfig,\n options: TestOptions = {},\n cwd: string = process.cwd(),\n): Promise<TestRunResult> {\n const outputRoot = options.outputDir\n ? path.resolve(cwd, options.outputDir)\n : resolveOutputDir(cwd, \".storywright\");\n const tmpDir = path.join(outputRoot, \"tmp\");\n const reportDir = options.outputDir\n ? path.join(outputRoot, \"report\")\n : path.resolve(cwd, config.report.outputDir);\n const storybookDir = path.resolve(cwd, config.storybook.staticDir);\n const snapshotDir = path.join(tmpDir, \"snapshots\");\n\n // Prepare directories early for parallel operations\n await fs.mkdir(snapshotDir, { recursive: true });\n\n // Start baseline download in parallel with Storybook build\n // Skip download when updating snapshots (update command) — baselines are regenerated\n let baselinePromise: Promise<void> | undefined;\n if (!options.updateSnapshots) {\n const storage = await createStorageAdapter(config.storage);\n baselinePromise = storage\n .download({\n branch: config.storage.branch,\n destDir: snapshotDir,\n onProgress: (msg) => logger.info(msg),\n })\n .catch(() => {\n logger.info(\"No existing baselines found\");\n });\n }\n\n // 1. Build Storybook if needed\n await buildStorybook(config, cwd);\n\n // 2. Discover & filter stories\n logger.start(\"Discovering stories...\");\n const allStories = await discoverStories(config, cwd);\n let targetStories = filterStories(allStories, config);\n\n // Apply --filter option\n if (options.filter) {\n targetStories = applyFilter(targetStories, options.filter);\n }\n\n logger.info(`${Object.keys(targetStories.entries).length} stories found`);\n\n // 3. Diff-only: resolve affected stories (default in CI)\n const effectiveDiffOnly = options.diffOnly ?? !!process.env.CI;\n if (effectiveDiffOnly && config.diffDetection.enabled) {\n logger.start(\"Resolving dependencies...\");\n const diffResult = await resolveAffectedStories(\n targetStories,\n config.diffDetection,\n storybookDir,\n cwd,\n );\n if (!diffResult.allStories) {\n targetStories = diffResult.targetStories;\n }\n logger.info(`${Object.keys(targetStories.entries).length} stories affected by changes`);\n }\n\n // 4. Wait for baseline download to complete\n await baselinePromise;\n\n // 5. Generate split test files for better worker distribution\n let testFilePattern: string;\n let testMatchByBrowser: Record<string, string> | undefined;\n\n const browserExcludesExist = config.browsers.some(\n (b) => (config.browserOptions[b]?.exclude ?? []).length > 0,\n );\n\n if (browserExcludesExist) {\n // Generate per-browser test files when any browser has specific excludes\n testMatchByBrowser = {};\n\n for (const browser of config.browsers) {\n const browserExclude = config.browserOptions[browser]?.exclude ?? [];\n const browserStories = excludeStoriesForBrowser(targetStories, browserExclude);\n\n if (Object.keys(browserStories.entries).length === 0) {\n logger.warn(\n `${browser}: All stories excluded by browser-specific 'exclude' patterns. No tests will run for this browser.`,\n );\n }\n\n const browserChunks = chunkStories(browserStories.entries);\n\n testMatchByBrowser[browser] =\n browserChunks.length === 1\n ? `storywright-${browser}-0.spec.ts`\n : `storywright-${browser}-*.spec.ts`;\n\n for (let i = 0; i < browserChunks.length; i++) {\n const chunkIndex: StoryIndex = {\n ...browserStories,\n entries: browserChunks[i],\n };\n const chunkPath = path.join(tmpDir, `target-stories-${browser}-${i}.json`);\n await fs.writeFile(chunkPath, JSON.stringify(chunkIndex));\n\n const testContent = generateTestFile(config.screenshot, {\n targetStoriesPath: chunkPath.replace(/\\\\/g, \"/\"),\n });\n await fs.writeFile(path.join(tmpDir, `storywright-${browser}-${i}.spec.ts`), testContent);\n }\n\n logger.info(\n `${browser}: ${Object.keys(browserStories.entries).length} stories, ${\n browserChunks.length\n } test file(s)`,\n );\n }\n\n testFilePattern = \"storywright-*.spec.ts\";\n } else {\n // Default: shared test files for all browsers\n const chunks = chunkStories(targetStories.entries);\n testFilePattern = chunks.length === 1 ? \"storywright-0.spec.ts\" : \"storywright-*.spec.ts\";\n\n for (let i = 0; i < chunks.length; i++) {\n const chunkIndex: StoryIndex = { ...targetStories, entries: chunks[i] };\n const chunkPath = path.join(tmpDir, `target-stories-${i}.json`);\n await fs.writeFile(chunkPath, JSON.stringify(chunkIndex));\n\n const testContent = generateTestFile(config.screenshot, {\n targetStoriesPath: chunkPath.replace(/\\\\/g, \"/\"),\n });\n await fs.writeFile(path.join(tmpDir, `storywright-${i}.spec.ts`), testContent);\n }\n\n logger.info(`${chunks.length} test file(s) generated`);\n }\n\n // 6. Generate Playwright config\n const reporterWrapperPath = path.join(tmpDir, \"reporter.mjs\");\n const resolvedReporterPath = resolveReporterPath().replace(/\\\\/g, \"/\");\n const reporterOutputDir = reportDir.replace(/\\\\/g, \"/\");\n\n await fs.writeFile(\n reporterWrapperPath,\n `import StorywrightReporter from '${resolvedReporterPath}';\\nexport default class extends StorywrightReporter {\\n constructor() { super({ outputDir: '${reporterOutputDir}' }); }\\n}\\n`,\n );\n\n // Determine Storybook URL\n let actualStorybookUrl = config.storybook.url;\n const needsServer = !actualStorybookUrl;\n\n if (needsServer) {\n actualStorybookUrl = \"http://localhost:6007\";\n }\n\n const playwrightConfig = generatePlaywrightConfig(config, {\n tmpDir: tmpDir.replace(/\\\\/g, \"/\"),\n storybookUrl: actualStorybookUrl ?? \"http://localhost:6007\",\n snapshotDir: snapshotDir.replace(/\\\\/g, \"/\"),\n reporterPath: reporterWrapperPath.replace(/\\\\/g, \"/\"),\n testMatch: testFilePattern,\n testMatchByBrowser,\n shard: options.shard,\n reporters: options.reporters,\n });\n\n const configPath = path.join(tmpDir, \"playwright.config.ts\");\n await fs.writeFile(configPath, playwrightConfig);\n\n // 7. Run Playwright tests\n logger.start(\"Running tests...\");\n const args = [\"playwright\", \"test\", \"--config\", configPath];\n\n if (options.updateSnapshots) {\n args.push(\"--update-snapshots\");\n }\n\n // Start static server if needed\n let serverProc: { kill: () => void } | undefined;\n if (needsServer) {\n serverProc = await startStaticServer(storybookDir, 6007);\n }\n\n try {\n const result = await exec(\"npx\", args, { cwd, inherit: true });\n\n // 8. Read results\n let summary: TestSummary | undefined;\n try {\n const summaryPath = path.join(reportDir, \"summary.json\");\n const summaryContent = await fs.readFile(summaryPath, \"utf-8\");\n summary = JSON.parse(summaryContent);\n } catch {\n // summary may not exist if no tests ran\n }\n\n // 9. Map exit codes per SPEC §14.2\n const exitCode = mapExitCode(result.exitCode, summary);\n\n return { exitCode, summary, reportDir, snapshotDir };\n } finally {\n serverProc?.kill();\n }\n}\n\nexport async function updateBaselines(\n config: StorywrightConfig,\n options: {\n all?: boolean;\n upload?: boolean;\n shard?: string;\n filter?: string;\n } = {},\n cwd: string = process.cwd(),\n): Promise<TestRunResult> {\n const result = await runTests(\n config,\n {\n updateSnapshots: true,\n diffOnly: !options.all,\n shard: options.shard,\n filter: options.filter,\n },\n cwd,\n );\n\n if (result.exitCode !== 0) {\n logger.warn(\"Some tests failed during baseline update\");\n }\n\n // Save updated snapshots back to baselineDir (local disk operation)\n if (result.snapshotDir) {\n const baselineDir = path.resolve(cwd, config.storage.local.baselineDir);\n await fs.mkdir(baselineDir, { recursive: true });\n await fs.cp(result.snapshotDir, baselineDir, { recursive: true });\n logger.success(`Baselines saved to ${config.storage.local.baselineDir}`);\n }\n\n // --upload: upload to remote storage (S3 etc.) only when explicitly requested\n if (options.upload) {\n const storage = await createStorageAdapter(config.storage);\n const baselineDir = path.resolve(cwd, config.storage.local.baselineDir);\n await storage.upload({\n branch: config.storage.branch,\n sourceDir: baselineDir,\n shard: options.shard,\n onProgress: (msg) => logger.info(msg),\n });\n logger.success(\"Baselines uploaded to remote storage\");\n }\n\n return result;\n}\n\nfunction applyFilter(storyIndex: StoryIndex, filter: string): StoryIndex {\n const matcher = picomatch(filter);\n const entries: Record<string, StoryIndex[\"entries\"][string]> = {};\n for (const [id, story] of Object.entries(storyIndex.entries)) {\n const fullName = `${story.title}/${story.name}`;\n if (matcher(fullName) || matcher(story.title) || matcher(story.id)) {\n entries[id] = story;\n }\n }\n return { ...storyIndex, entries };\n}\n\nfunction mapExitCode(playwrightCode: number, summary?: TestSummary): number {\n // SPEC §14.2: 0 = success (no diff), 1 = success (diff found), 2 = execution error, 130 = SIGINT\n if (playwrightCode === 130 || playwrightCode === 143) {\n return 130; // SIGINT / SIGTERM\n }\n if (summary) {\n if (summary.failed > 0) return 1;\n if (summary.total === 0 && playwrightCode !== 0) return 2;\n return 0;\n }\n // No summary = likely execution error\n return playwrightCode === 0 ? 0 : 2;\n}\n\nasync function startStaticServer(dir: string, port: number): Promise<{ kill: () => void }> {\n const { createServer } = await import(\"node:http\");\n const sirv = (await import(\"sirv\")).default;\n\n const handler = sirv(dir, { single: false, dev: false });\n const server = createServer(handler);\n\n await new Promise<void>((resolve, reject) => {\n server.on(\"error\", reject);\n server.listen(port, () => resolve());\n });\n\n return { 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 config: StorywrightConfig,\n options: {\n tmpDir: string;\n storybookUrl: string;\n snapshotDir: string;\n reporterPath: string;\n testMatch: string;\n testMatchByBrowser?: Record<string, string>;\n shard?: string;\n reporters?: string[];\n },\n): string {\n const projects = config.browsers.map((browser) => {\n const rawOptions = config.browserOptions[browser];\n const useObj = buildBrowserUseObject(browser, rawOptions);\n const useStr = JSON.stringify(useObj, null, \"\\t\\t\");\n const testMatch = options.testMatchByBrowser?.[browser];\n const testMatchLine = testMatch ? `\\n\\t\\t\\ttestMatch: '${escapeBackslash(testMatch)}',` : \"\";\n return `\\t\\t{\n\\t\\t\\tname: '${browser}',${testMatchLine}\n\\t\\t\\tuse: ${useStr},\n\\t\\t}`;\n });\n\n const workers = config.workers === \"auto\" ? \"'100%'\" : String(config.workers);\n\n const shard = options.shard\n ? `\\tshard: { current: ${options.shard.split(\"/\")[0]}, total: ${options.shard.split(\"/\")[1]} },`\n : \"\";\n\n // Build reporter list: always include custom reporter, plus user-requested ones\n const reporterEntries: string[] = [];\n const requestedReporters = options.reporters ?? [\"default\", \"html\"];\n for (const r of requestedReporters) {\n if (r === \"default\" || r === \"list\") {\n reporterEntries.push(\"\\t\\t['list']\");\n } else if (r !== \"html\") {\n // Pass through other built-in Playwright reporters (dot, json, junit, etc.)\n reporterEntries.push(`\\t\\t['${r}']`);\n }\n }\n // Always include custom storywright reporter\n reporterEntries.push(`\\t\\t['${escapeBackslash(options.reporterPath)}']`);\n\n const testMatchLine = options.testMatchByBrowser\n ? \"\"\n : `\\ttestMatch: '${escapeBackslash(options.testMatch)}',\\n`;\n\n return `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 browser: string,\n rawOptions?: BrowserOption,\n): Record<string, unknown> {\n let browserName: string;\n if (rawOptions?.browserName) {\n browserName = rawOptions.browserName;\n } else if (STANDARD_BROWSERS.has(browser)) {\n browserName = browser;\n } else {\n throw new Error(\n `Cannot resolve browserName for custom browser project '${browser}'.\\n\\nError code: SW_E_INTERNAL_BROWSER_RESOLVE`,\n );\n }\n const useObj: Record<string, unknown> = { browserName };\n\n if (rawOptions) {\n const { browserName: _, exclude: __, ...rest } = rawOptions;\n Object.assign(useObj, rest);\n }\n\n return useObj;\n}\n\nfunction escapeBackslash(str: string): string {\n return str.replace(/\\\\/g, \"/\");\n}\n","import type { ScreenshotConfig } from \"../config/types.js\";\n\nexport function generateTestFile(\n config: ScreenshotConfig,\n options: {\n targetStoriesPath: string;\n },\n): string {\n const disableAnimations = config.animations === \"disabled\";\n\n return `import { test, expect } from '@playwright/test';\nimport { readFileSync } from 'node:fs';\nimport { initPage, stabilizePage } from '@storywright/cli/playwright/stabilize';\n\nconst targetList = JSON.parse(\n\\treadFileSync('${escapeBackslash(options.targetStoriesPath)}', 'utf-8'),\n);\n\nconst stabilizeOptions = {\n\\tfreezeTime: '${config.freezeTime}',\n\\tseed: ${config.seed},\n\\tdisableAnimations: ${disableAnimations},\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\\tawait initPage(page, stabilizeOptions);\n\n\\t\\t\\tawait page.goto(\\`/iframe.html?id=\\${story.id}\\`, {\n\\t\\t\\t\\twaitUntil: 'domcontentloaded',\n\\t\\t\\t});\n\n\\t\\t\\tawait stabilizePage(page, stabilizeOptions);\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 return 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 getDependencies(filePath: string): string[];\n getStoriesForFiles(pathList: string[]): StoryIndex;\n}\n\nconst STORY_FILE_PATTERNS = [\".stories.\", \".mdx\"];\n\nfunction isStoryFile(moduleName: string): boolean {\n return STORY_FILE_PATTERNS.some((p) => moduleName.includes(p));\n}\n\nexport class StorybookStatsDependencyResolver implements DependencyResolver {\n private moduleMap: Record<string, StatsModule>;\n\n constructor(\n private statsJson: StatsIndex,\n private storiesJson: StoryIndex,\n ) {\n this.moduleMap = {};\n for (const mod of statsJson.modules) {\n // Key by normalized name (primary) and normalized id (fallback)\n const normalizedName = normalizePath(mod.name);\n this.moduleMap[normalizedName] = mod;\n const normalizedId = normalizePath(mod.id);\n if (normalizedId !== normalizedName) {\n this.moduleMap[normalizedId] ??= mod;\n }\n }\n }\n\n getDependencies(filePath: string): string[] {\n const normalizedPath = normalizePath(filePath);\n const dependencies = this.collectDependencies(normalizedPath);\n\n if (this.moduleMap[normalizedPath]) {\n dependencies.add(normalizedPath);\n }\n\n return [...dependencies];\n }\n\n getStoriesForFiles(pathList: string[]): StoryIndex {\n const result: StoryIndex = { v: this.storiesJson.v, entries: {} };\n\n for (const filePath of pathList) {\n // Finding #2 + #3: lookup via normalized moduleMap (name primary, id fallback)\n const normalizedPath = normalizePath(filePath);\n const stats = this.moduleMap[normalizedPath];\n if (!stats) continue;\n\n // Finding #1: collect ALL story reasons, not just first\n const storyReasons = stats.reasons.filter((r) => isStoryFile(r.moduleName));\n for (const reason of storyReasons) {\n const normalizedImportPath = normalizePath(reason.moduleName);\n // Collect ALL matching story entries per reason\n for (const storyObj of Object.values(this.storiesJson.entries)) {\n if (storyObj.type !== \"story\") continue;\n if (normalizePath(storyObj.importPath) === normalizedImportPath) {\n result.entries[storyObj.id] = storyObj;\n }\n }\n }\n }\n\n return result;\n }\n\n private collectDependencies(name: string, result = new Set<string>()): Set<string> {\n const mod = this.moduleMap[normalizePath(name)];\n if (mod) {\n for (const reason of mod.reasons) {\n if (!result.has(reason.moduleName)) {\n result.add(reason.moduleName);\n this.collectDependencies(reason.moduleName, result);\n }\n }\n }\n return result;\n }\n}\n\nexport interface DiffResult {\n allStories: boolean;\n targetStories: StoryIndex;\n}\n\ninterface DiffFileEntry {\n file: string;\n from?: string;\n}\n\nexport async function resolveAffectedStories(\n storiesJson: StoryIndex,\n config: DiffDetectionConfig,\n storybookStaticDir: string,\n cwd: string,\n): Promise<DiffResult> {\n const git = simpleGit({ baseDir: cwd });\n\n // Get diff summary\n let diffEntries: DiffFileEntry[];\n try {\n // Detect if HEAD is on the base branch (e.g. main)\n const currentBranch = (await git.raw([\"rev-parse\", \"--abbrev-ref\", \"HEAD\"])).trim();\n const isOnBaseBranch = currentBranch === config.baseBranch;\n\n let diffBase: string;\n if (isOnBaseBranch && config.baseBranchDiffDepth > 0) {\n // On the base branch, merge-base == HEAD so diff would be empty.\n // Use HEAD~N to compare against the previous commit(s) instead.\n diffBase = `HEAD~${config.baseBranchDiffDepth}`;\n logger.info(`On base branch '${config.baseBranch}', using ${diffBase} for diff detection`);\n } else {\n const mergeBase = await git.raw([\"merge-base\", config.baseBranch, \"HEAD\"]);\n diffBase = mergeBase.trim();\n }\n\n const diff = await git.diffSummary([diffBase, \"HEAD\"]);\n diffEntries = diff.files.map((f) => ({\n file: f.file,\n // Handle renames: include both old and new paths\n from: \"from\" in f ? (f as { from: string }).from : undefined,\n }));\n } catch {\n logger.warn(\"Failed to resolve git diff, running all stories\");\n return { allStories: true, targetStories: storiesJson };\n }\n\n if (diffEntries.length === 0) {\n logger.info(\"No changed files detected\");\n return { allStories: false, targetStories: { v: storiesJson.v, entries: {} } };\n }\n\n // Collect all affected paths (including rename sources)\n const allPaths: string[] = [];\n for (const entry of diffEntries) {\n allPaths.push(entry.file);\n if (entry.from) {\n allPaths.push(entry.from);\n }\n }\n\n // Check watchFiles\n for (const file of allPaths) {\n for (const pattern of config.watchFiles) {\n if (picomatch(pattern)(file)) {\n logger.info(`Watch file changed: ${file}, running all stories`);\n return { allStories: true, targetStories: storiesJson };\n }\n }\n }\n\n // Load stats json for dependency resolution\n const statsPath = path.resolve(storybookStaticDir, \"preview-stats.json\");\n let statsJson: StatsIndex;\n try {\n statsJson = JSON.parse(await fs.readFile(statsPath, \"utf-8\"));\n } catch {\n logger.warn(\"preview-stats.json not found, running all stories\");\n return { allStories: true, targetStories: storiesJson };\n }\n\n const resolver = new StorybookStatsDependencyResolver(statsJson, storiesJson);\n const targetStories: StoryIndex = { v: storiesJson.v, entries: {} };\n\n // Direct story file matches (both .stories.* and .mdx)\n for (const file of allPaths) {\n const matchedStories = Object.values(storiesJson.entries).filter(\n (story) => stripLeadingDotSlash(story.importPath) === file,\n );\n for (const story of matchedStories) {\n targetStories.entries[story.id] = story;\n }\n }\n\n // Dependency-based matches\n for (const file of allPaths) {\n const deps = resolver.getDependencies(normalizePath(file));\n const depStories = resolver.getStoriesForFiles(deps);\n for (const [id, story] of Object.entries(depStories.entries)) {\n targetStories.entries[id] = story;\n }\n }\n\n logger.info(`Resolved ${Object.keys(targetStories.entries).length} affected stories`);\n return { allStories: false, targetStories };\n}\n","import path from \"node:path\";\n\nexport function normalizePath(filePath: string): string {\n const normalized = filePath.replace(/\\\\/g, \"/\");\n if (normalized.startsWith(\"./\")) {\n return normalized;\n }\n return `./${normalized}`;\n}\n\nexport function stripLeadingDotSlash(filePath: string): string {\n return filePath.replace(/^\\.\\//, \"\");\n}\n\nexport function resolveOutputDir(outputDir: string, ...segments: string[]): string {\n return path.resolve(outputDir, ...segments);\n}\n","import { spawn } from \"node:child_process\";\n\nexport interface ExecResult {\n exitCode: number;\n stdout: string;\n stderr: string;\n}\n\nexport function exec(\n command: string,\n args: string[],\n options?: { cwd?: string; env?: Record<string, string>; inherit?: boolean },\n): Promise<ExecResult> {\n return new Promise((resolve, reject) => {\n const proc = spawn(command, args, {\n cwd: options?.cwd,\n env: { ...process.env, ...options?.env },\n stdio: options?.inherit ? [\"ignore\", \"inherit\", \"inherit\"] : [\"ignore\", \"pipe\", \"pipe\"],\n shell: false,\n });\n\n let stdout = \"\";\n let stderr = \"\";\n\n if (!options?.inherit) {\n proc.stdout?.on(\"data\", (data: Buffer) => {\n stdout += data.toString();\n });\n\n proc.stderr?.on(\"data\", (data: Buffer) => {\n stderr += data.toString();\n });\n }\n\n proc.on(\"error\", reject);\n\n proc.on(\"close\", (code) => {\n resolve({ exitCode: code ?? 1, stdout, stderr });\n });\n });\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 if (config.storybook.url) {\n logger.info(\"Using running Storybook at\", config.storybook.url);\n return;\n }\n\n const staticDir = path.resolve(cwd, config.storybook.staticDir);\n try {\n await fs.access(path.join(staticDir, \"index.json\"));\n logger.info(\"Storybook already built at\", staticDir);\n return;\n } catch {\n // need to build\n }\n\n logger.start(\"Building Storybook...\");\n const [command, ...args] = config.storybook.buildCommand.split(\" \");\n const result = await exec(command, args, { cwd });\n if (result.exitCode !== 0) {\n throw new Error(\n `Storybook build failed (exit code ${result.exitCode}):\\n${result.stderr}\\n\\nError code: SW_E_STORYBOOK_BUILD_FAILED`,\n );\n }\n logger.success(\"Storybook built\");\n}\n\nexport async function discoverStories(config: StorywrightConfig, cwd: string): Promise<StoryIndex> {\n const staticDir = path.resolve(cwd, config.storybook.staticDir);\n const indexPath = path.join(staticDir, \"index.json\");\n\n try {\n await fs.access(indexPath);\n } catch {\n throw new Error(\n `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 );\n }\n\n const raw = JSON.parse(await fs.readFile(indexPath, \"utf-8\"));\n const indexJson = normalizeStoryIndex(raw, config.storybook.compatibility);\n\n // Version check\n if (indexJson.v < 4) {\n throw new Error(\n \"Storybook 7.x or earlier is not supported. Storywright requires Storybook 8 or later.\\n\\nError code: SW_E_STORYBOOK_UNSUPPORTED\",\n );\n }\n\n return indexJson;\n}\n\n/**\n * Parse Storybook index.json (v8+).\n */\nfunction normalizeStoryIndex(\n raw: Record<string, unknown>,\n _compatibility: \"auto\" | \"v8\",\n): StoryIndex {\n const version = typeof raw.v === \"number\" ? raw.v : 0;\n const entries = (raw.entries ?? {}) as Record<string, Story>;\n\n return { v: version, entries };\n}\n\nexport function filterStories(storyIndex: StoryIndex, config: StorywrightConfig): StoryIndex {\n const entries: Record<string, Story> = {};\n const includeMatchers = config.include.map((p) => picomatch(p));\n const excludeMatchers = config.exclude.map((p) => picomatch(p));\n\n for (const [id, story] of Object.entries(storyIndex.entries)) {\n // Skip docs entries\n if (story.type === \"docs\") continue;\n if (story.name === \"Docs\") continue;\n\n const fullName = `${story.title}/${story.name}`;\n\n // Check include patterns\n const isIncluded = includeMatchers.some((m) => m(fullName));\n if (!isIncluded) continue;\n\n // Check exclude patterns\n const isExcluded = excludeMatchers.some((m) => m(fullName));\n if (isExcluded) continue;\n\n entries[id] = story;\n }\n\n return { ...storyIndex, entries };\n}\n\nexport function excludeStoriesForBrowser(\n storyIndex: StoryIndex,\n excludePatterns: string[],\n): StoryIndex {\n if (excludePatterns.length === 0) {\n return storyIndex;\n }\n\n const excludeMatchers = excludePatterns.map((p) => picomatch(p));\n const entries: Record<string, Story> = {};\n\n for (const [id, story] of Object.entries(storyIndex.entries)) {\n const fullName = `${story.title}/${story.name}`;\n const isExcluded = excludeMatchers.some((m) => m(fullName));\n if (!isExcluded) {\n entries[id] = story;\n }\n }\n\n return { ...storyIndex, entries };\n}\n"],"mappings":";AAAA,SAAS,cAAc,oBAAoB;;;ACEpC,IAAM,iBAAoC;AAAA,EAC/C,WAAW;AAAA,IACT,WAAW;AAAA,IACX,cAAc;AAAA,IACd,KAAK;AAAA,IACL,eAAe;AAAA,EACjB;AAAA,EAEA,UAAU,CAAC,UAAU;AAAA,EACrB,gBAAgB,CAAC;AAAA,EAEjB,YAAY;AAAA,IACV,UAAU;AAAA,IACV,YAAY;AAAA,IACZ,WAAW;AAAA,IACX,mBAAmB;AAAA,IACnB,YAAY;AAAA,IACZ,UAAU;AAAA,IACV,QAAQ;AAAA,IACR,MAAM;AAAA,EACR;AAAA,EAEA,eAAe;AAAA,IACb,SAAS;AAAA,IACT,YAAY,CAAC,gBAAgB,qBAAqB,iBAAiB;AAAA,IACnE,YAAY;AAAA,IACZ,qBAAqB;AAAA,EACvB;AAAA,EAEA,SAAS;AAAA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AAS,aAAa,OAAO;AAEnC,QAAM,IAAI,QAAc,CAAC,SAAS,WAAW;AAC3C,WAAO,GAAG,SAAS,MAAM;AACzB,WAAO,OAAO,MAAM,MAAM,QAAQ,CAAC;AAAA,EACrC,CAAC;AAED,SAAO,EAAE,MAAM,MAAM,OAAO,MAAM,EAAE;AACtC;","names":["fs","path","picomatch","testMatchLine","escapeBackslash","fs","path","path","path","fs","fs","path","picomatch","path","fs","picomatch","path","fs","picomatch"]}
|