@cappa/plugin-storybook 0.0.14 → 0.0.16
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/.turbo/turbo-build.log +8 -8
- package/.turbo/turbo-tsc.log +5 -0
- package/CHANGELOG.md +16 -0
- package/README.md +6 -4
- package/dist/index.js +7 -8
- package/dist/index.mjs +7 -8
- package/dist/preview.mjs +1 -6
- package/package.json +2 -2
- package/src/cappa/plugin.ts +7 -10
- package/src/cappa/util.test.ts +5 -5
- package/src/cappa/util.ts +1 -1
- package/src/storybook/addon/preview.ts +1 -6
- package/src/tsconfig.json +2 -2
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
|
|
2
2
|
|
|
3
|
-
> @cappa/plugin-storybook@0.0.
|
|
3
|
+
> @cappa/plugin-storybook@0.0.15 build /home/tim/code/work/cappa/packages/plugins/plugin-storybook
|
|
4
4
|
> tsup
|
|
5
5
|
|
|
6
6
|
[34mCLI[39m Building entry: src/index.ts
|
|
@@ -25,15 +25,15 @@
|
|
|
25
25
|
[34mESM[39m Build start
|
|
26
26
|
[34mCLI[39m Cleaning output folder
|
|
27
27
|
[34mESM[39m Build start
|
|
28
|
-
[32mESM[39m [1mdist/preview.mjs [22m[32m1.39 KB[39m
|
|
29
|
-
[32mESM[39m ⚡️ Build success in 7ms
|
|
30
|
-
[32mESM[39m [1mdist/index.mjs [22m[32m5.81 KB[39m
|
|
31
|
-
[32mESM[39m ⚡️ Build success in 10ms
|
|
32
28
|
[32mESM[39m [1mdist/browser.mjs [22m[32m138.00 B[39m
|
|
29
|
+
[32mESM[39m ⚡️ Build success in 6ms
|
|
30
|
+
[32mCJS[39m [1mdist/index.js [22m[32m7.14 KB[39m
|
|
31
|
+
[32mCJS[39m ⚡️ Build success in 9ms
|
|
32
|
+
[32mESM[39m [1mdist/preview.mjs [22m[32m1.34 KB[39m
|
|
33
33
|
[32mESM[39m ⚡️ Build success in 7ms
|
|
34
|
-
[
|
|
35
|
-
[
|
|
34
|
+
[32mESM[39m [1mdist/index.mjs [22m[32m5.84 KB[39m
|
|
35
|
+
[32mESM[39m ⚡️ Build success in 10ms
|
|
36
36
|
DTS Build start
|
|
37
|
-
DTS ⚡️ Build success in
|
|
37
|
+
DTS ⚡️ Build success in 777ms
|
|
38
38
|
DTS dist/index.d.ts 593.00 B
|
|
39
39
|
DTS dist/index.d.mts 593.00 B
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# @cappa/plugin-storybook
|
|
2
2
|
|
|
3
|
+
## 0.0.16
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 92d164e: Fix directory creation
|
|
8
|
+
- Updated dependencies [92d164e]
|
|
9
|
+
- @cappa/core@0.0.16
|
|
10
|
+
|
|
11
|
+
## 0.0.15
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- a41a91e: Add fullPage option
|
|
16
|
+
- Updated dependencies [a41a91e]
|
|
17
|
+
- @cappa/core@0.0.15
|
|
18
|
+
|
|
3
19
|
## 0.0.14
|
|
4
20
|
|
|
5
21
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -45,10 +45,11 @@ Cappa uses a storybook addon that allows you to pass options from storybook into
|
|
|
45
45
|
|
|
46
46
|
### Parameters
|
|
47
47
|
|
|
48
|
-
| Option
|
|
49
|
-
|
|
|
50
|
-
| skip
|
|
51
|
-
| delay
|
|
48
|
+
| Option | Description | Default |
|
|
49
|
+
| -------- | ----------------------------------------------- | --------------- |
|
|
50
|
+
| skip | Whether to skip the screenshot | false |
|
|
51
|
+
| delay | The delay to wait before taking the screenshot | null (no delay) |
|
|
52
|
+
| fullPage | Whether to take a full page screenshot | true |
|
|
52
53
|
|
|
53
54
|
#### Example
|
|
54
55
|
|
|
@@ -58,6 +59,7 @@ export const Primary: Story = {
|
|
|
58
59
|
cappa: {
|
|
59
60
|
skip: true,
|
|
60
61
|
delay: 1000,
|
|
62
|
+
fullPage: false,
|
|
61
63
|
},
|
|
62
64
|
},
|
|
63
65
|
};
|
package/dist/index.js
CHANGED
|
@@ -57,8 +57,6 @@ var buildFilename = (story) => {
|
|
|
57
57
|
};
|
|
58
58
|
|
|
59
59
|
// src/cappa/plugin.ts
|
|
60
|
-
var import_path = __toESM(require("path"));
|
|
61
|
-
var import_fs = __toESM(require("fs"));
|
|
62
60
|
function createLatch() {
|
|
63
61
|
let resolve;
|
|
64
62
|
const p = new Promise((r) => resolve = r);
|
|
@@ -145,7 +143,6 @@ var cappaPluginStorybook = (options) => {
|
|
|
145
143
|
await page.waitForTimeout(options2.delay);
|
|
146
144
|
}
|
|
147
145
|
const filename = buildFilename(story);
|
|
148
|
-
import_fs.default.mkdirSync(import_path.default.dirname(filename), { recursive: true });
|
|
149
146
|
const actualFilepath = await screenshotTool.takeScreenshot(page, filename, {
|
|
150
147
|
fullPage: options2.fullPage ?? screenshotOptions.fullPage,
|
|
151
148
|
type: options2.type ?? screenshotOptions.type,
|
|
@@ -154,8 +151,7 @@ var cappaPluginStorybook = (options) => {
|
|
|
154
151
|
});
|
|
155
152
|
results.push({
|
|
156
153
|
storyId: story.id,
|
|
157
|
-
storyName: story.name
|
|
158
|
-
storyTitle: story.title,
|
|
154
|
+
storyName: `${story.title} - ${story.name}`,
|
|
159
155
|
success: true,
|
|
160
156
|
filepath: actualFilepath
|
|
161
157
|
});
|
|
@@ -163,13 +159,16 @@ var cappaPluginStorybook = (options) => {
|
|
|
163
159
|
console.error(`Error taking screenshot of story ${story.title} - ${story.name}:`, error.message);
|
|
164
160
|
results.push({
|
|
165
161
|
storyId: story.id,
|
|
166
|
-
storyName: story.name
|
|
167
|
-
storyTitle: story.title,
|
|
162
|
+
storyName: `${story.title} - ${story.name}`,
|
|
168
163
|
success: false,
|
|
169
|
-
error: error
|
|
164
|
+
error: error?.message ?? "Unknown error"
|
|
170
165
|
});
|
|
171
166
|
}
|
|
172
167
|
}
|
|
168
|
+
if (results.some((r) => !r.success)) {
|
|
169
|
+
console.log(`Error report:
|
|
170
|
+
${results.map((r) => `${r.storyName}: ${r.error}`).join("\n")}`);
|
|
171
|
+
}
|
|
173
172
|
console.log(`Completed screenshots: ${results.filter((r) => r.success).length}/${results.length} successful`);
|
|
174
173
|
return results;
|
|
175
174
|
} catch (error) {
|
package/dist/index.mjs
CHANGED
|
@@ -27,8 +27,6 @@ var buildFilename = (story) => {
|
|
|
27
27
|
};
|
|
28
28
|
|
|
29
29
|
// src/cappa/plugin.ts
|
|
30
|
-
import path from "path";
|
|
31
|
-
import fs from "fs";
|
|
32
30
|
function createLatch() {
|
|
33
31
|
let resolve;
|
|
34
32
|
const p = new Promise((r) => resolve = r);
|
|
@@ -115,7 +113,6 @@ var cappaPluginStorybook = (options) => {
|
|
|
115
113
|
await page.waitForTimeout(options2.delay);
|
|
116
114
|
}
|
|
117
115
|
const filename = buildFilename(story);
|
|
118
|
-
fs.mkdirSync(path.dirname(filename), { recursive: true });
|
|
119
116
|
const actualFilepath = await screenshotTool.takeScreenshot(page, filename, {
|
|
120
117
|
fullPage: options2.fullPage ?? screenshotOptions.fullPage,
|
|
121
118
|
type: options2.type ?? screenshotOptions.type,
|
|
@@ -124,8 +121,7 @@ var cappaPluginStorybook = (options) => {
|
|
|
124
121
|
});
|
|
125
122
|
results.push({
|
|
126
123
|
storyId: story.id,
|
|
127
|
-
storyName: story.name
|
|
128
|
-
storyTitle: story.title,
|
|
124
|
+
storyName: `${story.title} - ${story.name}`,
|
|
129
125
|
success: true,
|
|
130
126
|
filepath: actualFilepath
|
|
131
127
|
});
|
|
@@ -133,13 +129,16 @@ var cappaPluginStorybook = (options) => {
|
|
|
133
129
|
console.error(`Error taking screenshot of story ${story.title} - ${story.name}:`, error.message);
|
|
134
130
|
results.push({
|
|
135
131
|
storyId: story.id,
|
|
136
|
-
storyName: story.name
|
|
137
|
-
storyTitle: story.title,
|
|
132
|
+
storyName: `${story.title} - ${story.name}`,
|
|
138
133
|
success: false,
|
|
139
|
-
error: error
|
|
134
|
+
error: error?.message ?? "Unknown error"
|
|
140
135
|
});
|
|
141
136
|
}
|
|
142
137
|
}
|
|
138
|
+
if (results.some((r) => !r.success)) {
|
|
139
|
+
console.log(`Error report:
|
|
140
|
+
${results.map((r) => `${r.storyName}: ${r.error}`).join("\n")}`);
|
|
141
|
+
}
|
|
143
142
|
console.log(`Completed screenshots: ${results.filter((r) => r.success).length}/${results.length} successful`);
|
|
144
143
|
return results;
|
|
145
144
|
} catch (error) {
|
package/dist/preview.mjs
CHANGED
|
@@ -40,12 +40,7 @@ var withCappaDecorator = makeDecorator({
|
|
|
40
40
|
|
|
41
41
|
// src/storybook/addon/preview.ts
|
|
42
42
|
var decorators = [withCappaDecorator];
|
|
43
|
-
var parameters = {
|
|
44
|
-
layout: "full",
|
|
45
|
-
cappa: {
|
|
46
|
-
enabled: true
|
|
47
|
-
}
|
|
48
|
-
};
|
|
43
|
+
var parameters = {};
|
|
49
44
|
var afterEach = () => {
|
|
50
45
|
window.playAfterEach = true;
|
|
51
46
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cappa/plugin-storybook",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.16",
|
|
4
4
|
"description": "Storybook plugin for Cappa - takes screenshots of Storybook stories",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"dependencies": {
|
|
31
31
|
"@swc/core": "^1.13.5",
|
|
32
32
|
"storybook": "^9.1.5",
|
|
33
|
-
"@cappa/core": "0.0.
|
|
33
|
+
"@cappa/core": "0.0.16"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
36
|
"playwright-core": "^1.55.0",
|
package/src/cappa/plugin.ts
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import type { Plugin, ScreenshotOptions, ScreenshotTool } from "@cappa/core";
|
|
2
2
|
import { buildFilename, freezeUI, waitForVisualIdle } from "./util";
|
|
3
|
-
import path from "path";
|
|
4
|
-
import fs from "fs";
|
|
5
3
|
|
|
6
4
|
export interface StorybookStory {
|
|
7
5
|
id: string;
|
|
@@ -99,7 +97,6 @@ export const cappaPluginStorybook: Plugin<StorybookPluginOptions> = (options) =>
|
|
|
99
97
|
const results: Array<{
|
|
100
98
|
storyId: string;
|
|
101
99
|
storyName: string;
|
|
102
|
-
storyTitle: string;
|
|
103
100
|
success: boolean;
|
|
104
101
|
filepath?: string;
|
|
105
102
|
error?: string;
|
|
@@ -159,8 +156,6 @@ export const cappaPluginStorybook: Plugin<StorybookPluginOptions> = (options) =>
|
|
|
159
156
|
// Take screenshot with story-specific filename
|
|
160
157
|
const filename = buildFilename(story);
|
|
161
158
|
|
|
162
|
-
fs.mkdirSync(path.dirname(filename), { recursive: true });
|
|
163
|
-
|
|
164
159
|
// Actually take the screenshot
|
|
165
160
|
const actualFilepath = await screenshotTool.takeScreenshot(page, filename, {
|
|
166
161
|
fullPage: options.fullPage ?? screenshotOptions.fullPage,
|
|
@@ -171,8 +166,7 @@ export const cappaPluginStorybook: Plugin<StorybookPluginOptions> = (options) =>
|
|
|
171
166
|
|
|
172
167
|
results.push({
|
|
173
168
|
storyId: story.id,
|
|
174
|
-
storyName: story.name
|
|
175
|
-
storyTitle: story.title,
|
|
169
|
+
storyName: `${story.title} - ${story.name}`,
|
|
176
170
|
success: true,
|
|
177
171
|
filepath: actualFilepath,
|
|
178
172
|
});
|
|
@@ -180,14 +174,17 @@ export const cappaPluginStorybook: Plugin<StorybookPluginOptions> = (options) =>
|
|
|
180
174
|
console.error(`Error taking screenshot of story ${story.title} - ${story.name}:`, (error as Error).message);
|
|
181
175
|
results.push({
|
|
182
176
|
storyId: story.id,
|
|
183
|
-
storyName: story.name
|
|
184
|
-
storyTitle: story.title,
|
|
177
|
+
storyName: `${story.title} - ${story.name}`,
|
|
185
178
|
success: false,
|
|
186
|
-
error: (error as Error)
|
|
179
|
+
error: (error as Error)?.message ?? "Unknown error",
|
|
187
180
|
});
|
|
188
181
|
}
|
|
189
182
|
}
|
|
190
183
|
|
|
184
|
+
if (results.some((r) => !r.success)) {
|
|
185
|
+
console.log(`Error report: \n${results.map((r) => `${r.storyName}: ${r.error}`).join("\n")}`);
|
|
186
|
+
}
|
|
187
|
+
|
|
191
188
|
console.log(`Completed screenshots: ${results.filter((r) => r.success).length}/${results.length} successful`);
|
|
192
189
|
return results;
|
|
193
190
|
} catch (error) {
|
package/src/cappa/util.test.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { describe,
|
|
2
|
-
import { buildFilename } from "./util";
|
|
1
|
+
import { describe, expect, it } from "vitest";
|
|
3
2
|
import type { StorybookStory } from "./plugin";
|
|
4
|
-
|
|
3
|
+
import { buildFilename } from "./util";
|
|
4
|
+
|
|
5
5
|
describe("buildFilename", () => {
|
|
6
6
|
it("should build a filename for a story", () => {
|
|
7
7
|
const story: StorybookStory = {
|
|
@@ -26,7 +26,7 @@ describe("buildFilename", () => {
|
|
|
26
26
|
story: "Story",
|
|
27
27
|
type: "story",
|
|
28
28
|
};
|
|
29
|
-
|
|
29
|
+
|
|
30
30
|
const filename = buildFilename(story);
|
|
31
31
|
expect(filename).toBe("Folder/Story/Primary.jpeg");
|
|
32
32
|
});
|
|
@@ -44,4 +44,4 @@ describe("buildFilename", () => {
|
|
|
44
44
|
const filename = buildFilename(story);
|
|
45
45
|
expect(filename).toBe("Story123/Primary123.jpeg");
|
|
46
46
|
});
|
|
47
|
-
});
|
|
47
|
+
});
|
package/src/cappa/util.ts
CHANGED
|
@@ -2,12 +2,7 @@ import { withCappaDecorator } from "./decorator";
|
|
|
2
2
|
|
|
3
3
|
export const decorators = [withCappaDecorator];
|
|
4
4
|
|
|
5
|
-
export const parameters = {
|
|
6
|
-
layout: "full",
|
|
7
|
-
cappa: {
|
|
8
|
-
enabled: true,
|
|
9
|
-
},
|
|
10
|
-
};
|
|
5
|
+
export const parameters = {};
|
|
11
6
|
|
|
12
7
|
export const afterEach = () => {
|
|
13
8
|
(window as any).playAfterEach = true;
|