@cappa/plugin-storybook 0.6.3 → 0.7.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/dist/index.cjs +13 -24
- package/dist/index.cjs.d.cts +21 -27
- package/dist/index.esm.d.ts +21 -27
- package/dist/index.js +13 -24
- package/package.json +7 -8
package/dist/index.cjs
CHANGED
|
@@ -37,7 +37,6 @@ module.exports = __toCommonJS(index_cjs_exports);
|
|
|
37
37
|
|
|
38
38
|
// src/cappa/plugin.ts
|
|
39
39
|
var import_logger = require("@cappa/logger");
|
|
40
|
-
var import_minimatch = require("minimatch");
|
|
41
40
|
|
|
42
41
|
// src/cappa/storybook-url.ts
|
|
43
42
|
function encodePairs(obj) {
|
|
@@ -177,23 +176,13 @@ async function waitForPlayFunctionCompletion(page, storyName) {
|
|
|
177
176
|
});
|
|
178
177
|
}
|
|
179
178
|
}
|
|
180
|
-
function
|
|
181
|
-
return
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
}
|
|
188
|
-
if ((0, import_minimatch.minimatch)(story.name, pattern)) {
|
|
189
|
-
return true;
|
|
190
|
-
}
|
|
191
|
-
const fullPath = `${story.title}/${story.name}`;
|
|
192
|
-
if ((0, import_minimatch.minimatch)(fullPath, pattern)) {
|
|
193
|
-
return true;
|
|
194
|
-
}
|
|
195
|
-
return false;
|
|
196
|
-
});
|
|
179
|
+
function toFilterContext(story) {
|
|
180
|
+
return {
|
|
181
|
+
id: story.id,
|
|
182
|
+
title: story.title,
|
|
183
|
+
name: story.name,
|
|
184
|
+
filePath: `${story.title}/${story.name}`
|
|
185
|
+
};
|
|
197
186
|
}
|
|
198
187
|
function createLatch() {
|
|
199
188
|
let resolve;
|
|
@@ -216,8 +205,8 @@ var cappaPluginStorybook = (options) => {
|
|
|
216
205
|
const logger = (0, import_logger.getLogger)();
|
|
217
206
|
const {
|
|
218
207
|
storybookUrl,
|
|
219
|
-
includeStories
|
|
220
|
-
excludeStories
|
|
208
|
+
includeStories,
|
|
209
|
+
excludeStories,
|
|
221
210
|
storybook: defaultStorybookOptions
|
|
222
211
|
} = options;
|
|
223
212
|
const storiesUrl = `${storybookUrl}/index.json`;
|
|
@@ -231,14 +220,14 @@ var cappaPluginStorybook = (options) => {
|
|
|
231
220
|
const data = await response.json();
|
|
232
221
|
const stories = Object.values(data.entries);
|
|
233
222
|
let filteredStories = stories;
|
|
234
|
-
if (includeStories
|
|
223
|
+
if (includeStories) {
|
|
235
224
|
filteredStories = filteredStories.filter(
|
|
236
|
-
(story) =>
|
|
225
|
+
(story) => includeStories(toFilterContext(story))
|
|
237
226
|
);
|
|
238
227
|
}
|
|
239
|
-
if (excludeStories
|
|
228
|
+
if (excludeStories) {
|
|
240
229
|
filteredStories = filteredStories.filter(
|
|
241
|
-
(story) => !
|
|
230
|
+
(story) => !excludeStories(toFilterContext(story))
|
|
242
231
|
);
|
|
243
232
|
}
|
|
244
233
|
filteredStories = filteredStories.filter(
|
package/dist/index.cjs.d.cts
CHANGED
|
@@ -36,37 +36,31 @@ interface ScreenshotOptionsStorybook extends ScreenshotVariantOverrideStorybook
|
|
|
36
36
|
variants?: ScreenshotVariantOptionsStorybook[];
|
|
37
37
|
}
|
|
38
38
|
|
|
39
|
+
/**
|
|
40
|
+
* Context passed to includeStories and excludeStories predicate functions.
|
|
41
|
+
* Use these fields to decide which stories to include or exclude.
|
|
42
|
+
*/
|
|
43
|
+
interface StoryFilterContext {
|
|
44
|
+
id: string;
|
|
45
|
+
title: string;
|
|
46
|
+
name: string;
|
|
47
|
+
/** Full story path: `${title}/${name}` (e.g. "Button/Primary") */
|
|
48
|
+
filePath: string;
|
|
49
|
+
}
|
|
39
50
|
interface StorybookPluginOptions {
|
|
40
51
|
storybookUrl: string;
|
|
41
52
|
/**
|
|
42
|
-
*
|
|
43
|
-
*
|
|
44
|
-
*
|
|
45
|
-
* - Story title (e.g., "Button")
|
|
46
|
-
* - Story name (e.g., "Primary")
|
|
47
|
-
* - Full story path (e.g., "Button/Primary")
|
|
48
|
-
*
|
|
49
|
-
* Examples:
|
|
50
|
-
* - ["button--*"] - Include all button stories
|
|
51
|
-
* - ["*--primary"] - Include all primary stories
|
|
52
|
-
* - ["Button/*"] - Include all stories under Button title
|
|
53
|
-
* - ["*--*"] - Include all stories
|
|
53
|
+
* Optional predicate to include stories. If provided, only stories for which
|
|
54
|
+
* it returns true are included. Example: (s) => s.id === 'button--primary'
|
|
55
|
+
* or (s) => s.title === 'Button'.
|
|
54
56
|
*/
|
|
55
|
-
includeStories?:
|
|
57
|
+
includeStories?: (story: StoryFilterContext) => boolean;
|
|
56
58
|
/**
|
|
57
|
-
*
|
|
58
|
-
*
|
|
59
|
-
*
|
|
60
|
-
* - Story title (e.g., "Button")
|
|
61
|
-
* - Story name (e.g., "Primary")
|
|
62
|
-
* - Full story path (e.g., "Button/Primary")
|
|
63
|
-
*
|
|
64
|
-
* Examples:
|
|
65
|
-
* - ["button--*"] - Exclude all button stories
|
|
66
|
-
* - ["*--secondary"] - Exclude all secondary stories
|
|
67
|
-
* - ["Input/*"] - Exclude all stories under Input title
|
|
59
|
+
* Optional predicate to exclude stories. If provided, stories for which it
|
|
60
|
+
* returns true are excluded (applied after includeStories). Example:
|
|
61
|
+
* (s) => s.title === 'Input'.
|
|
68
62
|
*/
|
|
69
|
-
excludeStories?:
|
|
63
|
+
excludeStories?: (story: StoryFilterContext) => boolean;
|
|
70
64
|
defaultViewport?: {
|
|
71
65
|
width: number;
|
|
72
66
|
height: number;
|
|
@@ -78,10 +72,10 @@ interface StorybookPluginOptions {
|
|
|
78
72
|
/**
|
|
79
73
|
* Storybook Plugin for Cappa
|
|
80
74
|
* Fetches stories from a running Storybook server and takes screenshots of each story.
|
|
81
|
-
* Supports
|
|
75
|
+
* Supports includeStories and excludeStories predicate functions for filtering.
|
|
82
76
|
*/
|
|
83
77
|
declare const cappaPluginStorybook: Plugin<StorybookPluginOptions>;
|
|
84
78
|
|
|
85
79
|
declare const previewAnnotations: string[];
|
|
86
80
|
|
|
87
|
-
export { type ScreenshotOptionsStorybook as CappaStorybookOptions, type StorybookPluginOptions, cappaPluginStorybook, previewAnnotations };
|
|
81
|
+
export { type ScreenshotOptionsStorybook as CappaStorybookOptions, type StoryFilterContext, type StorybookPluginOptions, cappaPluginStorybook, previewAnnotations };
|
package/dist/index.esm.d.ts
CHANGED
|
@@ -36,37 +36,31 @@ interface ScreenshotOptionsStorybook extends ScreenshotVariantOverrideStorybook
|
|
|
36
36
|
variants?: ScreenshotVariantOptionsStorybook[];
|
|
37
37
|
}
|
|
38
38
|
|
|
39
|
+
/**
|
|
40
|
+
* Context passed to includeStories and excludeStories predicate functions.
|
|
41
|
+
* Use these fields to decide which stories to include or exclude.
|
|
42
|
+
*/
|
|
43
|
+
interface StoryFilterContext {
|
|
44
|
+
id: string;
|
|
45
|
+
title: string;
|
|
46
|
+
name: string;
|
|
47
|
+
/** Full story path: `${title}/${name}` (e.g. "Button/Primary") */
|
|
48
|
+
filePath: string;
|
|
49
|
+
}
|
|
39
50
|
interface StorybookPluginOptions {
|
|
40
51
|
storybookUrl: string;
|
|
41
52
|
/**
|
|
42
|
-
*
|
|
43
|
-
*
|
|
44
|
-
*
|
|
45
|
-
* - Story title (e.g., "Button")
|
|
46
|
-
* - Story name (e.g., "Primary")
|
|
47
|
-
* - Full story path (e.g., "Button/Primary")
|
|
48
|
-
*
|
|
49
|
-
* Examples:
|
|
50
|
-
* - ["button--*"] - Include all button stories
|
|
51
|
-
* - ["*--primary"] - Include all primary stories
|
|
52
|
-
* - ["Button/*"] - Include all stories under Button title
|
|
53
|
-
* - ["*--*"] - Include all stories
|
|
53
|
+
* Optional predicate to include stories. If provided, only stories for which
|
|
54
|
+
* it returns true are included. Example: (s) => s.id === 'button--primary'
|
|
55
|
+
* or (s) => s.title === 'Button'.
|
|
54
56
|
*/
|
|
55
|
-
includeStories?:
|
|
57
|
+
includeStories?: (story: StoryFilterContext) => boolean;
|
|
56
58
|
/**
|
|
57
|
-
*
|
|
58
|
-
*
|
|
59
|
-
*
|
|
60
|
-
* - Story title (e.g., "Button")
|
|
61
|
-
* - Story name (e.g., "Primary")
|
|
62
|
-
* - Full story path (e.g., "Button/Primary")
|
|
63
|
-
*
|
|
64
|
-
* Examples:
|
|
65
|
-
* - ["button--*"] - Exclude all button stories
|
|
66
|
-
* - ["*--secondary"] - Exclude all secondary stories
|
|
67
|
-
* - ["Input/*"] - Exclude all stories under Input title
|
|
59
|
+
* Optional predicate to exclude stories. If provided, stories for which it
|
|
60
|
+
* returns true are excluded (applied after includeStories). Example:
|
|
61
|
+
* (s) => s.title === 'Input'.
|
|
68
62
|
*/
|
|
69
|
-
excludeStories?:
|
|
63
|
+
excludeStories?: (story: StoryFilterContext) => boolean;
|
|
70
64
|
defaultViewport?: {
|
|
71
65
|
width: number;
|
|
72
66
|
height: number;
|
|
@@ -78,10 +72,10 @@ interface StorybookPluginOptions {
|
|
|
78
72
|
/**
|
|
79
73
|
* Storybook Plugin for Cappa
|
|
80
74
|
* Fetches stories from a running Storybook server and takes screenshots of each story.
|
|
81
|
-
* Supports
|
|
75
|
+
* Supports includeStories and excludeStories predicate functions for filtering.
|
|
82
76
|
*/
|
|
83
77
|
declare const cappaPluginStorybook: Plugin<StorybookPluginOptions>;
|
|
84
78
|
|
|
85
79
|
declare const previewAnnotations: string[];
|
|
86
80
|
|
|
87
|
-
export { type ScreenshotOptionsStorybook as CappaStorybookOptions, type StorybookPluginOptions, cappaPluginStorybook, previewAnnotations };
|
|
81
|
+
export { type ScreenshotOptionsStorybook as CappaStorybookOptions, type StoryFilterContext, type StorybookPluginOptions, cappaPluginStorybook, previewAnnotations };
|
package/dist/index.js
CHANGED
|
@@ -3,7 +3,6 @@ import { fileURLToPath } from "url";
|
|
|
3
3
|
|
|
4
4
|
// src/cappa/plugin.ts
|
|
5
5
|
import { getLogger } from "@cappa/logger";
|
|
6
|
-
import { minimatch } from "minimatch";
|
|
7
6
|
|
|
8
7
|
// src/cappa/storybook-url.ts
|
|
9
8
|
function encodePairs(obj) {
|
|
@@ -143,23 +142,13 @@ async function waitForPlayFunctionCompletion(page, storyName) {
|
|
|
143
142
|
});
|
|
144
143
|
}
|
|
145
144
|
}
|
|
146
|
-
function
|
|
147
|
-
return
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
}
|
|
154
|
-
if (minimatch(story.name, pattern)) {
|
|
155
|
-
return true;
|
|
156
|
-
}
|
|
157
|
-
const fullPath = `${story.title}/${story.name}`;
|
|
158
|
-
if (minimatch(fullPath, pattern)) {
|
|
159
|
-
return true;
|
|
160
|
-
}
|
|
161
|
-
return false;
|
|
162
|
-
});
|
|
145
|
+
function toFilterContext(story) {
|
|
146
|
+
return {
|
|
147
|
+
id: story.id,
|
|
148
|
+
title: story.title,
|
|
149
|
+
name: story.name,
|
|
150
|
+
filePath: `${story.title}/${story.name}`
|
|
151
|
+
};
|
|
163
152
|
}
|
|
164
153
|
function createLatch() {
|
|
165
154
|
let resolve;
|
|
@@ -182,8 +171,8 @@ var cappaPluginStorybook = (options) => {
|
|
|
182
171
|
const logger = getLogger();
|
|
183
172
|
const {
|
|
184
173
|
storybookUrl,
|
|
185
|
-
includeStories
|
|
186
|
-
excludeStories
|
|
174
|
+
includeStories,
|
|
175
|
+
excludeStories,
|
|
187
176
|
storybook: defaultStorybookOptions
|
|
188
177
|
} = options;
|
|
189
178
|
const storiesUrl = `${storybookUrl}/index.json`;
|
|
@@ -197,14 +186,14 @@ var cappaPluginStorybook = (options) => {
|
|
|
197
186
|
const data = await response.json();
|
|
198
187
|
const stories = Object.values(data.entries);
|
|
199
188
|
let filteredStories = stories;
|
|
200
|
-
if (includeStories
|
|
189
|
+
if (includeStories) {
|
|
201
190
|
filteredStories = filteredStories.filter(
|
|
202
|
-
(story) =>
|
|
191
|
+
(story) => includeStories(toFilterContext(story))
|
|
203
192
|
);
|
|
204
193
|
}
|
|
205
|
-
if (excludeStories
|
|
194
|
+
if (excludeStories) {
|
|
206
195
|
filteredStories = filteredStories.filter(
|
|
207
|
-
(story) => !
|
|
196
|
+
(story) => !excludeStories(toFilterContext(story))
|
|
208
197
|
);
|
|
209
198
|
}
|
|
210
199
|
filteredStories = filteredStories.filter(
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cappa/plugin-storybook",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.1",
|
|
4
4
|
"description": "Storybook plugin for Cappa - takes screenshots of Storybook stories",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -63,20 +63,19 @@
|
|
|
63
63
|
"dependencies": {
|
|
64
64
|
"@swc/core": "^1.15.18",
|
|
65
65
|
"chalk": "^5.6.2",
|
|
66
|
-
"
|
|
67
|
-
"@cappa/core": "0.7.2",
|
|
66
|
+
"@cappa/core": "0.7.3",
|
|
68
67
|
"@cappa/logger": "0.0.10"
|
|
69
68
|
},
|
|
70
69
|
"devDependencies": {
|
|
71
70
|
"@arethetypeswrong/cli": "0.18.2",
|
|
72
|
-
"@types/node": "25.
|
|
73
|
-
"@vitest/coverage-v8": "4.0
|
|
74
|
-
"@vitest/ui": "4.0
|
|
71
|
+
"@types/node": "25.5.0",
|
|
72
|
+
"@vitest/coverage-v8": "4.1.0",
|
|
73
|
+
"@vitest/ui": "4.1.0",
|
|
75
74
|
"playwright-core": "^1.58.2",
|
|
76
|
-
"storybook": "^10.
|
|
75
|
+
"storybook": "^10.3.1",
|
|
77
76
|
"tsup": "8.5.1",
|
|
78
77
|
"typescript": "5.9.3",
|
|
79
|
-
"vitest": "4.0
|
|
78
|
+
"vitest": "4.1.0"
|
|
80
79
|
},
|
|
81
80
|
"scripts": {
|
|
82
81
|
"test": "vitest",
|