@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.
@@ -1,6 +1,6 @@
1
1
 
2
2
 
3
- > @cappa/plugin-storybook@0.0.13 build /home/tim/code/work/cappa/packages/plugins/plugin-storybook
3
+ > @cappa/plugin-storybook@0.0.15 build /home/tim/code/work/cappa/packages/plugins/plugin-storybook
4
4
  > tsup
5
5
 
6
6
  CLI Building entry: src/index.ts
@@ -25,15 +25,15 @@
25
25
  ESM Build start
26
26
  CLI Cleaning output folder
27
27
  ESM Build start
28
- ESM dist/preview.mjs 1.39 KB
29
- ESM ⚡️ Build success in 7ms
30
- ESM dist/index.mjs 5.81 KB
31
- ESM ⚡️ Build success in 10ms
32
28
  ESM dist/browser.mjs 138.00 B
29
+ ESM ⚡️ Build success in 6ms
30
+ CJS dist/index.js 7.14 KB
31
+ CJS ⚡️ Build success in 9ms
32
+ ESM dist/preview.mjs 1.34 KB
33
33
  ESM ⚡️ Build success in 7ms
34
- CJS dist/index.js 7.17 KB
35
- CJS ⚡️ Build success in 10ms
34
+ ESM dist/index.mjs 5.84 KB
35
+ ESM ⚡️ Build success in 10ms
36
36
  DTS Build start
37
- DTS ⚡️ Build success in 795ms
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
@@ -0,0 +1,5 @@
1
+
2
+
3
+ > @cappa/plugin-storybook@0.0.14 tsc /home/tim/code/work/cappa/packages/plugins/plugin-storybook
4
+ > tsc
5
+
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 | Description | Default |
49
- | ------ | ---------------------------------------------- | --------------- |
50
- | skip | Whether to skip the screenshot | false |
51
- | delay | The delay to wait before taking the screenshot | null (no 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.message
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.message
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.14",
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.14"
33
+ "@cappa/core": "0.0.16"
34
34
  },
35
35
  "devDependencies": {
36
36
  "playwright-core": "^1.55.0",
@@ -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).message,
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) {
@@ -1,7 +1,7 @@
1
- import { describe, it, expect } from "vitest";
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
@@ -39,4 +39,4 @@ export const waitForVisualIdle = async (page: Page) => {
39
39
  */
40
40
  export const buildFilename = (story: StorybookStory) => {
41
41
  return `${story.title.replace(/[^a-zA-Z0-9/]/g, "")}/${story.name.replace(/[^a-zA-Z0-9]/g, "")}.jpeg`;
42
- };
42
+ };
@@ -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;
package/src/tsconfig.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "extends": "@cappa/config-ts/base.json",
3
3
  "compilerOptions": {
4
- "types": ["vitest/globals"],
4
+ "types": ["vitest/globals"]
5
5
  },
6
6
  "include": ["src/**/*.ts"]
7
- }
7
+ }