@cappa/plugin-storybook 0.0.20 → 0.0.22
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/CHANGELOG.md +16 -0
- package/dist/index.js +9 -10
- package/dist/index.mjs +9 -10
- package/package.json +6 -5
- package/src/cappa/plugin.ts +5 -8
- package/src/cappa/util.test.ts +3 -3
- package/src/cappa/util.ts +1 -1
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.21 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.34 KB[39m
|
|
29
|
+
[32mESM[39m ⚡️ Build success in 7ms
|
|
28
30
|
[32mESM[39m [1mdist/browser.mjs [22m[32m138.00 B[39m
|
|
29
|
-
[32mESM[39m ⚡️ Build success in
|
|
30
|
-
[32mESM[39m [1mdist/index.mjs [22m[32m6.
|
|
31
|
+
[32mESM[39m ⚡️ Build success in 7ms
|
|
32
|
+
[32mESM[39m [1mdist/index.mjs [22m[32m6.64 KB[39m
|
|
31
33
|
[32mESM[39m ⚡️ Build success in 10ms
|
|
32
|
-
[
|
|
33
|
-
[
|
|
34
|
-
[32mCJS[39m [1mdist/index.js [22m[32m7.97 KB[39m
|
|
35
|
-
[32mCJS[39m ⚡️ Build success in 11ms
|
|
34
|
+
[32mCJS[39m [1mdist/index.js [22m[32m7.99 KB[39m
|
|
35
|
+
[32mCJS[39m ⚡️ Build success in 10ms
|
|
36
36
|
DTS Build start
|
|
37
|
-
DTS ⚡️ Build success in
|
|
37
|
+
DTS ⚡️ Build success in 826ms
|
|
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.22
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 27a570a: Always use png screenshots
|
|
8
|
+
- Updated dependencies [27a570a]
|
|
9
|
+
- @cappa/core@0.0.22
|
|
10
|
+
|
|
11
|
+
## 0.0.21
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- e01e7c5: Add better report output
|
|
16
|
+
- Updated dependencies [e01e7c5]
|
|
17
|
+
- @cappa/core@0.0.21
|
|
18
|
+
|
|
3
19
|
## 0.0.20
|
|
4
20
|
|
|
5
21
|
### Patch Changes
|
package/dist/index.js
CHANGED
|
@@ -55,10 +55,11 @@ var waitForVisualIdle = async (page) => {
|
|
|
55
55
|
});
|
|
56
56
|
};
|
|
57
57
|
var buildFilename = (story) => {
|
|
58
|
-
return `${story.title.replace(/[^a-zA-Z0-9/]/g, "")}/${story.name.replace(/[^a-zA-Z0-9]/g, "")}.
|
|
58
|
+
return `${story.title.replace(/[^a-zA-Z0-9/]/g, "")}/${story.name.replace(/[^a-zA-Z0-9]/g, "")}.png`;
|
|
59
59
|
};
|
|
60
60
|
|
|
61
61
|
// src/cappa/plugin.ts
|
|
62
|
+
var import_chalk = __toESM(require("chalk"));
|
|
62
63
|
function createLatch() {
|
|
63
64
|
let resolve;
|
|
64
65
|
const p = new Promise((r) => resolve = r);
|
|
@@ -130,9 +131,7 @@ var cappaPluginStorybook = (options) => {
|
|
|
130
131
|
viewport: defaultViewport,
|
|
131
132
|
waitForSelector,
|
|
132
133
|
waitForTimeout,
|
|
133
|
-
fullPage: true
|
|
134
|
-
quality: 90,
|
|
135
|
-
type: "jpeg"
|
|
134
|
+
fullPage: true
|
|
136
135
|
};
|
|
137
136
|
const page = screenshotTool.page;
|
|
138
137
|
if (!page) {
|
|
@@ -168,7 +167,6 @@ var cappaPluginStorybook = (options) => {
|
|
|
168
167
|
filename,
|
|
169
168
|
{
|
|
170
169
|
fullPage: options2.fullPage ?? screenshotOptions.fullPage,
|
|
171
|
-
type: options2.type ?? screenshotOptions.type,
|
|
172
170
|
waitForSelector: options2.waitForSelector ?? screenshotOptions.waitForSelector,
|
|
173
171
|
waitForTimeout: options2.waitForTimeout ?? screenshotOptions.waitForTimeout
|
|
174
172
|
}
|
|
@@ -203,11 +201,12 @@ ${results.filter((r) => r.error).map((r) => `${r.storyName}: ${r.error}`).join("
|
|
|
203
201
|
${results.filter((r) => r.skipped).map((r) => `${r.storyName}`).join("\n")}`
|
|
204
202
|
);
|
|
205
203
|
}
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
204
|
+
logger.box({
|
|
205
|
+
title: "Storybook Report",
|
|
206
|
+
message: `${import_chalk.default.yellow("Skipped stories:")} ${results.filter((r) => r.skipped).length}
|
|
207
|
+
${import_chalk.default.red("Failed stories:")} ${results.filter((r) => r.error).length}
|
|
208
|
+
${import_chalk.default.green("Successful screenshots:")} ${results.length}`
|
|
209
|
+
});
|
|
211
210
|
return results;
|
|
212
211
|
} catch (error) {
|
|
213
212
|
console.error("Error in Storybook plugin:", error.message);
|
package/dist/index.mjs
CHANGED
|
@@ -25,10 +25,11 @@ var waitForVisualIdle = async (page) => {
|
|
|
25
25
|
});
|
|
26
26
|
};
|
|
27
27
|
var buildFilename = (story) => {
|
|
28
|
-
return `${story.title.replace(/[^a-zA-Z0-9/]/g, "")}/${story.name.replace(/[^a-zA-Z0-9]/g, "")}.
|
|
28
|
+
return `${story.title.replace(/[^a-zA-Z0-9/]/g, "")}/${story.name.replace(/[^a-zA-Z0-9]/g, "")}.png`;
|
|
29
29
|
};
|
|
30
30
|
|
|
31
31
|
// src/cappa/plugin.ts
|
|
32
|
+
import chalk from "chalk";
|
|
32
33
|
function createLatch() {
|
|
33
34
|
let resolve;
|
|
34
35
|
const p = new Promise((r) => resolve = r);
|
|
@@ -100,9 +101,7 @@ var cappaPluginStorybook = (options) => {
|
|
|
100
101
|
viewport: defaultViewport,
|
|
101
102
|
waitForSelector,
|
|
102
103
|
waitForTimeout,
|
|
103
|
-
fullPage: true
|
|
104
|
-
quality: 90,
|
|
105
|
-
type: "jpeg"
|
|
104
|
+
fullPage: true
|
|
106
105
|
};
|
|
107
106
|
const page = screenshotTool.page;
|
|
108
107
|
if (!page) {
|
|
@@ -138,7 +137,6 @@ var cappaPluginStorybook = (options) => {
|
|
|
138
137
|
filename,
|
|
139
138
|
{
|
|
140
139
|
fullPage: options2.fullPage ?? screenshotOptions.fullPage,
|
|
141
|
-
type: options2.type ?? screenshotOptions.type,
|
|
142
140
|
waitForSelector: options2.waitForSelector ?? screenshotOptions.waitForSelector,
|
|
143
141
|
waitForTimeout: options2.waitForTimeout ?? screenshotOptions.waitForTimeout
|
|
144
142
|
}
|
|
@@ -173,11 +171,12 @@ ${results.filter((r) => r.error).map((r) => `${r.storyName}: ${r.error}`).join("
|
|
|
173
171
|
${results.filter((r) => r.skipped).map((r) => `${r.storyName}`).join("\n")}`
|
|
174
172
|
);
|
|
175
173
|
}
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
174
|
+
logger.box({
|
|
175
|
+
title: "Storybook Report",
|
|
176
|
+
message: `${chalk.yellow("Skipped stories:")} ${results.filter((r) => r.skipped).length}
|
|
177
|
+
${chalk.red("Failed stories:")} ${results.filter((r) => r.error).length}
|
|
178
|
+
${chalk.green("Successful screenshots:")} ${results.length}`
|
|
179
|
+
});
|
|
181
180
|
return results;
|
|
182
181
|
} catch (error) {
|
|
183
182
|
console.error("Error in Storybook plugin:", error.message);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cappa/plugin-storybook",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.22",
|
|
4
4
|
"description": "Storybook plugin for Cappa - takes screenshots of Storybook stories",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -29,16 +29,17 @@
|
|
|
29
29
|
"license": "MIT",
|
|
30
30
|
"dependencies": {
|
|
31
31
|
"@swc/core": "^1.13.5",
|
|
32
|
+
"chalk": "^5.6.2",
|
|
32
33
|
"storybook": "^9.1.5",
|
|
33
|
-
"@cappa/core": "0.0.
|
|
34
|
+
"@cappa/core": "0.0.22"
|
|
34
35
|
},
|
|
35
36
|
"devDependencies": {
|
|
37
|
+
"@vitest/coverage-v8": "3.2.4",
|
|
38
|
+
"@vitest/ui": "3.2.4",
|
|
36
39
|
"playwright-core": "^1.55.0",
|
|
37
40
|
"tsup": "8.5.0",
|
|
38
41
|
"typescript": "5.7.3",
|
|
39
|
-
"vitest": "3.2.4"
|
|
40
|
-
"@vitest/coverage-v8": "3.2.4",
|
|
41
|
-
"@vitest/ui": "3.2.4"
|
|
42
|
+
"vitest": "3.2.4"
|
|
42
43
|
},
|
|
43
44
|
"scripts": {
|
|
44
45
|
"test": "vitest",
|
package/src/cappa/plugin.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { Plugin, ScreenshotOptions } from "@cappa/core";
|
|
2
2
|
import { buildFilename, freezeUI, waitForVisualIdle } from "./util";
|
|
3
|
+
import chalk from "chalk";
|
|
3
4
|
|
|
4
5
|
export interface StorybookStory {
|
|
5
6
|
id: string;
|
|
@@ -139,8 +140,6 @@ export const cappaPluginStorybook: Plugin<StorybookPluginOptions> = (
|
|
|
139
140
|
waitForSelector: waitForSelector,
|
|
140
141
|
waitForTimeout: waitForTimeout,
|
|
141
142
|
fullPage: true,
|
|
142
|
-
quality: 90,
|
|
143
|
-
type: "jpeg" as const,
|
|
144
143
|
};
|
|
145
144
|
|
|
146
145
|
const page = screenshotTool.page;
|
|
@@ -188,7 +187,6 @@ export const cappaPluginStorybook: Plugin<StorybookPluginOptions> = (
|
|
|
188
187
|
filename,
|
|
189
188
|
{
|
|
190
189
|
fullPage: options.fullPage ?? screenshotOptions.fullPage,
|
|
191
|
-
type: options.type ?? screenshotOptions.type,
|
|
192
190
|
waitForSelector:
|
|
193
191
|
options.waitForSelector ?? screenshotOptions.waitForSelector,
|
|
194
192
|
waitForTimeout:
|
|
@@ -235,11 +233,10 @@ export const cappaPluginStorybook: Plugin<StorybookPluginOptions> = (
|
|
|
235
233
|
);
|
|
236
234
|
}
|
|
237
235
|
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
console.log(`Successful screenshots: ${results.length}`);
|
|
236
|
+
logger.box({
|
|
237
|
+
title: "Storybook Report",
|
|
238
|
+
message: `${chalk.yellow("Skipped stories:")} ${results.filter((r) => r.skipped).length}\n${chalk.red("Failed stories:")} ${results.filter((r) => r.error).length}\n${chalk.green("Successful screenshots:")} ${results.length}`,
|
|
239
|
+
});
|
|
243
240
|
|
|
244
241
|
return results;
|
|
245
242
|
} catch (error) {
|
package/src/cappa/util.test.ts
CHANGED
|
@@ -14,7 +14,7 @@ describe("buildFilename", () => {
|
|
|
14
14
|
};
|
|
15
15
|
|
|
16
16
|
const filename = buildFilename(story);
|
|
17
|
-
expect(filename).toBe("Story/Primary.
|
|
17
|
+
expect(filename).toBe("Story/Primary.png");
|
|
18
18
|
});
|
|
19
19
|
|
|
20
20
|
it("should build a filename for a story with a folder", () => {
|
|
@@ -28,7 +28,7 @@ describe("buildFilename", () => {
|
|
|
28
28
|
};
|
|
29
29
|
|
|
30
30
|
const filename = buildFilename(story);
|
|
31
|
-
expect(filename).toBe("Folder/Story/Primary.
|
|
31
|
+
expect(filename).toBe("Folder/Story/Primary.png");
|
|
32
32
|
});
|
|
33
33
|
|
|
34
34
|
it("should build a filename for a story with special characters", () => {
|
|
@@ -42,6 +42,6 @@ describe("buildFilename", () => {
|
|
|
42
42
|
};
|
|
43
43
|
|
|
44
44
|
const filename = buildFilename(story);
|
|
45
|
-
expect(filename).toBe("Story123/Primary123.
|
|
45
|
+
expect(filename).toBe("Story123/Primary123.png");
|
|
46
46
|
});
|
|
47
47
|
});
|
package/src/cappa/util.ts
CHANGED
|
@@ -40,5 +40,5 @@ export const waitForVisualIdle = async (page: Page) => {
|
|
|
40
40
|
* @returns The filename for the story. Slashes represent folders that should be handled by seperate file system calls.
|
|
41
41
|
*/
|
|
42
42
|
export const buildFilename = (story: StorybookStory) => {
|
|
43
|
-
return `${story.title.replace(/[^a-zA-Z0-9/]/g, "")}/${story.name.replace(/[^a-zA-Z0-9]/g, "")}.
|
|
43
|
+
return `${story.title.replace(/[^a-zA-Z0-9/]/g, "")}/${story.name.replace(/[^a-zA-Z0-9]/g, "")}.png`;
|
|
44
44
|
};
|