@storysnap/cli 2.0.0 → 2.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api/client.d.ts +34 -1
- package/dist/api/client.js +3 -1
- package/dist/cli/commands/test.d.ts +1 -0
- package/dist/cli/commands/test.js +119 -62
- package/dist/cli/commands/update.d.ts +1 -0
- package/dist/cli/commands/update.js +62 -30
- package/dist/cli/environment-warning.d.ts +17 -0
- package/dist/cli/environment-warning.js +42 -0
- package/dist/cli/index.js +11 -3
- package/dist/cli/review.d.ts +9 -0
- package/dist/cli/review.js +10 -0
- package/dist/cli/select-stories.d.ts +6 -1
- package/dist/cli/select-stories.js +16 -0
- package/dist/cli/verdict.d.ts +17 -0
- package/dist/cli/verdict.js +22 -0
- package/dist/config/schema.d.ts +11 -0
- package/dist/config/schema.js +18 -0
- package/dist/core/capture-environment.d.ts +19 -0
- package/dist/core/capture-environment.js +102 -0
- package/dist/core/changed.js +10 -23
- package/dist/core/compare.d.ts +3 -1
- package/dist/core/compare.js +30 -10
- package/dist/core/git-context.d.ts +25 -0
- package/dist/core/git-context.js +75 -0
- package/dist/core/git.d.ts +11 -0
- package/dist/core/git.js +25 -0
- package/dist/core/hash.d.ts +7 -0
- package/dist/core/hash.js +11 -0
- package/dist/core/modes.d.ts +50 -0
- package/dist/core/modes.js +124 -0
- package/dist/core/screenshot.d.ts +91 -4
- package/dist/core/screenshot.js +266 -47
- package/dist/core/story-parameters.d.ts +48 -0
- package/dist/core/story-parameters.js +122 -0
- package/dist/core/story-render.d.ts +31 -0
- package/dist/core/story-render.js +75 -0
- package/dist/core/storybook.d.ts +16 -2
- package/dist/core/storybook.js +18 -6
- package/dist/core/viewports.d.ts +14 -0
- package/dist/core/viewports.js +27 -0
- package/package.json +9 -10
package/dist/core/storybook.d.ts
CHANGED
|
@@ -1,6 +1,20 @@
|
|
|
1
|
-
import type { Story, StorySnapConfig, Browser } from '@storysnap/shared';
|
|
1
|
+
import type { Story, StorySnapConfig, Browser, Viewport } from '@storysnap/shared';
|
|
2
2
|
export declare function discoverStories(config: StorySnapConfig): Promise<Story[]>;
|
|
3
3
|
export declare function filterStories(stories: Story[], include?: string[], exclude?: string[]): Story[];
|
|
4
4
|
export declare function getStoryUrl(baseUrl: string, storyId: string): string;
|
|
5
|
-
|
|
5
|
+
/**
|
|
6
|
+
* A local baseline's file name: the story ID made filename-safe, then the
|
|
7
|
+
* browser, then the viewport. The viewport is only given for a capture at a
|
|
8
|
+
* viewport other than the configured `viewport`, so the baselines written
|
|
9
|
+
* before stories could have several keep their names.
|
|
10
|
+
*/
|
|
11
|
+
export declare function getStoryKey(storyId: string, browser?: Browser, viewport?: Viewport, mode?: string): string;
|
|
12
|
+
/** The local baseline file name for a capture, given the configured viewport. */
|
|
13
|
+
export declare function getCaptureKey(capture: {
|
|
14
|
+
storyId: string;
|
|
15
|
+
browser: Browser;
|
|
16
|
+
width: number;
|
|
17
|
+
height: number;
|
|
18
|
+
mode?: string;
|
|
19
|
+
}, configured: Viewport | undefined): string;
|
|
6
20
|
//# sourceMappingURL=storybook.d.ts.map
|
package/dist/core/storybook.js
CHANGED
|
@@ -113,12 +113,24 @@ export function getStoryUrl(baseUrl, storyId) {
|
|
|
113
113
|
const cleanBaseUrl = baseUrl.replace(/\/$/, '');
|
|
114
114
|
return `${cleanBaseUrl}/iframe.html?id=${encodeURIComponent(storyId)}&viewMode=story`;
|
|
115
115
|
}
|
|
116
|
-
|
|
117
|
-
|
|
116
|
+
/**
|
|
117
|
+
* A local baseline's file name: the story ID made filename-safe, then the
|
|
118
|
+
* browser, then the viewport. The viewport is only given for a capture at a
|
|
119
|
+
* viewport other than the configured `viewport`, so the baselines written
|
|
120
|
+
* before stories could have several keep their names.
|
|
121
|
+
*/
|
|
122
|
+
export function getStoryKey(storyId, browser, viewport, mode) {
|
|
118
123
|
const safeId = storyId.replace(/[^a-zA-Z0-9-]/g, '-');
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
124
|
+
const browserPart = browser ? `-${browser}` : '';
|
|
125
|
+
const viewportPart = viewport ? `-${viewport.width}x${viewport.height}` : '';
|
|
126
|
+
// As on the server: '@' and the URI-encoded name, so any mode name is one
|
|
127
|
+
// safe file name, and nothing at all without a mode.
|
|
128
|
+
const modePart = mode ? `@${encodeURIComponent(mode)}` : '';
|
|
129
|
+
return `${safeId}${browserPart}${viewportPart}${modePart}.png`;
|
|
130
|
+
}
|
|
131
|
+
/** The local baseline file name for a capture, given the configured viewport. */
|
|
132
|
+
export function getCaptureKey(capture, configured) {
|
|
133
|
+
const atConfigured = !configured || (capture.width === configured.width && capture.height === configured.height);
|
|
134
|
+
return getStoryKey(capture.storyId, capture.browser, atConfigured ? undefined : { width: capture.width, height: capture.height }, capture.mode);
|
|
123
135
|
}
|
|
124
136
|
//# sourceMappingURL=storybook.js.map
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { Viewport, ViewportInput } from '@storysnap/shared';
|
|
2
|
+
/**
|
|
3
|
+
* The viewports a story is captured at: its own from its parameters, else the
|
|
4
|
+
* configured list, else the one configured `viewport`. A bare number is a
|
|
5
|
+
* width at the configured viewport's height, as in Chromatic's `viewports`.
|
|
6
|
+
* Duplicates are dropped and the order is kept.
|
|
7
|
+
*/
|
|
8
|
+
export declare function resolveViewports(config: {
|
|
9
|
+
viewport: Viewport;
|
|
10
|
+
viewports?: ViewportInput[];
|
|
11
|
+
}, storyViewports?: ViewportInput[]): Viewport[];
|
|
12
|
+
export declare function sameViewport(a: Viewport, b: Viewport): boolean;
|
|
13
|
+
export declare function describeViewport(viewport: Viewport): string;
|
|
14
|
+
//# sourceMappingURL=viewports.d.ts.map
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The viewports a story is captured at: its own from its parameters, else the
|
|
3
|
+
* configured list, else the one configured `viewport`. A bare number is a
|
|
4
|
+
* width at the configured viewport's height, as in Chromatic's `viewports`.
|
|
5
|
+
* Duplicates are dropped and the order is kept.
|
|
6
|
+
*/
|
|
7
|
+
export function resolveViewports(config, storyViewports) {
|
|
8
|
+
const list = storyViewports ?? config.viewports ?? [config.viewport];
|
|
9
|
+
const seen = new Set();
|
|
10
|
+
const viewports = [];
|
|
11
|
+
for (const entry of list) {
|
|
12
|
+
const viewport = typeof entry === 'number' ? { width: entry, height: config.viewport.height } : entry;
|
|
13
|
+
const label = describeViewport(viewport);
|
|
14
|
+
if (!seen.has(label)) {
|
|
15
|
+
seen.add(label);
|
|
16
|
+
viewports.push({ width: viewport.width, height: viewport.height });
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
return viewports;
|
|
20
|
+
}
|
|
21
|
+
export function sameViewport(a, b) {
|
|
22
|
+
return a.width === b.width && a.height === b.height;
|
|
23
|
+
}
|
|
24
|
+
export function describeViewport(viewport) {
|
|
25
|
+
return `${viewport.width}x${viewport.height}`;
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=viewports.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@storysnap/cli",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.2.0",
|
|
4
4
|
"description": "Visual regression testing for Storybook - capture screenshots, detect changes, and maintain baselines",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -53,23 +53,22 @@
|
|
|
53
53
|
},
|
|
54
54
|
"homepage": "https://github.com/Kosai106/storysnap#readme",
|
|
55
55
|
"dependencies": {
|
|
56
|
-
"@aws-sdk/client-s3": "^3.
|
|
56
|
+
"@aws-sdk/client-s3": "^3.1164.0",
|
|
57
57
|
"chalk": "^6.0.1",
|
|
58
|
-
"commander": "^15.
|
|
59
|
-
"
|
|
60
|
-
"ora": "^9.4.1",
|
|
58
|
+
"commander": "^15.1.0",
|
|
59
|
+
"ora": "^10.0.0",
|
|
61
60
|
"pixelmatch": "^8.0.0",
|
|
62
|
-
"playwright": "^1.
|
|
61
|
+
"playwright": "^1.65.0",
|
|
63
62
|
"pngjs": "^7.0.0",
|
|
64
|
-
"zod": "^4.6.
|
|
63
|
+
"zod": "^4.6.7"
|
|
65
64
|
},
|
|
66
65
|
"devDependencies": {
|
|
67
66
|
"@storysnap/shared": "1.0.0",
|
|
68
|
-
"@types/node": "^22.
|
|
67
|
+
"@types/node": "^22.20.5",
|
|
69
68
|
"@types/pngjs": "^6.0.5",
|
|
70
|
-
"@vitest/coverage-v8": "^5.0
|
|
69
|
+
"@vitest/coverage-v8": "^5.1.0",
|
|
71
70
|
"typescript": "^7.0.2",
|
|
72
|
-
"vitest": "^5.0
|
|
71
|
+
"vitest": "^5.1.0"
|
|
73
72
|
},
|
|
74
73
|
"engines": {
|
|
75
74
|
"node": ">=22.12.0"
|