found-pixel 0.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.
Files changed (49) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +225 -0
  3. package/bin/found-pixel.js +7 -0
  4. package/dist/bin.d.ts +10 -0
  5. package/dist/bin.d.ts.map +1 -0
  6. package/dist/bin.js +51 -0
  7. package/dist/bin.js.map +1 -0
  8. package/dist/build.d.ts +3 -0
  9. package/dist/build.d.ts.map +1 -0
  10. package/dist/build.js +30 -0
  11. package/dist/build.js.map +1 -0
  12. package/dist/buildkite.d.ts +16 -0
  13. package/dist/buildkite.d.ts.map +1 -0
  14. package/dist/buildkite.js +36 -0
  15. package/dist/buildkite.js.map +1 -0
  16. package/dist/cli.d.ts +2 -0
  17. package/dist/cli.d.ts.map +1 -0
  18. package/dist/cli.js +32 -0
  19. package/dist/cli.js.map +1 -0
  20. package/dist/comment.d.ts +41 -0
  21. package/dist/comment.d.ts.map +1 -0
  22. package/dist/comment.js +114 -0
  23. package/dist/comment.js.map +1 -0
  24. package/dist/config.d.ts +138 -0
  25. package/dist/config.d.ts.map +1 -0
  26. package/dist/config.js +68 -0
  27. package/dist/config.js.map +1 -0
  28. package/dist/github.d.ts +12 -0
  29. package/dist/github.d.ts.map +1 -0
  30. package/dist/github.js +41 -0
  31. package/dist/github.js.map +1 -0
  32. package/dist/index.d.ts +5 -0
  33. package/dist/index.d.ts.map +1 -0
  34. package/dist/index.js +5 -0
  35. package/dist/index.js.map +1 -0
  36. package/dist/review.d.ts +3 -0
  37. package/dist/review.d.ts.map +1 -0
  38. package/dist/review.js +189 -0
  39. package/dist/review.js.map +1 -0
  40. package/dist/storage.d.ts +11 -0
  41. package/dist/storage.d.ts.map +1 -0
  42. package/dist/storage.js +31 -0
  43. package/dist/storage.js.map +1 -0
  44. package/dist/visualRegression.d.ts +14 -0
  45. package/dist/visualRegression.d.ts.map +1 -0
  46. package/dist/visualRegression.js +120 -0
  47. package/dist/visualRegression.js.map +1 -0
  48. package/package.json +62 -0
  49. package/patches/lostPixelWindowApi.cjs +173 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Healthengine
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,225 @@
1
+ # found-pixel
2
+
3
+ Storybook build + visual regression workflow for Buildkite, in one CLI.
4
+
5
+ Each consumer repo drops in a `.storybook/found-pixel.config.json` and one pipeline step instead of copying shell + Node scripts between repos.
6
+
7
+ ## What it does
8
+
9
+ On every build:
10
+
11
+ 1. Runs the configured storybook build command
12
+ 2. Uploads the archive and static site to S3 under `<keyPrefix>/<branch-slug>/`
13
+ 3. Annotates the Buildkite build with a link to the hosted storybook
14
+ 4. If the branch is the default branch, also uploads under the commit SHA for future base resolution
15
+
16
+ On pull requests (additional to the above):
17
+
18
+ 5. Resolves a base storybook from S3 — tries merge-base SHA first (for PRs into the default branch), then the base branch slug, then the default branch
19
+ 6. Runs [storybook-diff](https://www.npmjs.com/package/storybook-diff) between base and head, writing the JSON to `artifacts/`
20
+ 7. Runs [lost-pixel](https://github.com/lost-pixel/lost-pixel) against the changed stories only, capturing visual diffs
21
+ 8. Upserts a PR comment with added / deleted / modified sections, marking stories whose pixels actually changed
22
+ 9. Annotates the Buildkite build with a diff summary and a link to the PR comment
23
+
24
+ ## Install
25
+
26
+ In the consumer repo:
27
+
28
+ ```bash
29
+ npm install --save-dev found-pixel
30
+ # or
31
+ yarn add --dev found-pixel
32
+ ```
33
+
34
+ Runtime requirements on the Buildkite agent:
35
+ - Node 20+
36
+ - `aws` CLI (for S3 reads/writes)
37
+ - `git` (for merge-base resolution)
38
+ - `buildkite-agent` (for annotations and artifact upload)
39
+
40
+ Chromium is installed lazily on first `review` run via `playwright install --with-deps chromium`, using the `playwright-core` copy bundled with `lost-pixel` (so browser revisions match lost-pixel's expectations).
41
+
42
+ ## Configuration
43
+
44
+ Create `found-pixel.config.json` in one of the following locations (searched in order, first match wins):
45
+
46
+ 1. `./found-pixel.config.json` (repo root)
47
+ 2. `./.storybook/found-pixel.config.json`
48
+ 3. `./.github/found-pixel.config.json`
49
+ 4. `./tools/storybook/found-pixel.config.json`
50
+
51
+ Example:
52
+
53
+ ```json
54
+ {
55
+ "defaultBranch": "master",
56
+ "buildCommand": "npm run build-storybook",
57
+ "outputDir": "storybook-static",
58
+ "artifactsDir": "artifacts",
59
+ "s3": {
60
+ "bucket": "my-org-storybook",
61
+ "region": "ap-southeast-2",
62
+ "keyPrefix": "my-app/storybook"
63
+ },
64
+ "github": {
65
+ "repo": "my-org/my-app"
66
+ },
67
+ "storybookDiff": {
68
+ "ignoreModules": [
69
+ "*/generated/*"
70
+ ],
71
+ "maxDepth": 5,
72
+ "autoIgnoreThreshold": 50,
73
+ "useGitattributes": true
74
+ },
75
+ "visualRegression": {
76
+ "enabled": true
77
+ },
78
+ "comment": {
79
+ "heading": "📘 UI Review",
80
+ "marker": "<!-- found-pixel-comment -->",
81
+ "viewerUrl": "https://my-org.github.io/diffy",
82
+ "maxChars": 62000,
83
+ "collapsibleThreshold": 50,
84
+ "codeOnlyStoriesLimit": 25
85
+ }
86
+ }
87
+ ```
88
+
89
+ **Required:** `s3.bucket`, `s3.region`, `s3.keyPrefix`, `github.repo`.
90
+
91
+ **Notable defaults** (all optional):
92
+ - `buildCommand`: `"npm run build-storybook"`
93
+ - `outputDir`: `"storybook-static"`
94
+ - `artifactsDir`: `"artifacts"`
95
+ - `defaultBranch`: `"master"`
96
+ - `visualRegression.enabled`: `true`
97
+ - `comment.heading`: `"📘 Storybook Review"`
98
+ - `comment.marker`: `"<!-- found-pixel-comment -->"`
99
+ - `comment.maxChars`: `62000`
100
+
101
+ `comment.viewerUrl` is optional. When set, modified stories in the PR comment get a "View Changes" link with `?id=<storyId>&compare=<headSlug>&base=<baseSlug>`. When unset, the link is omitted entirely.
102
+
103
+ ### `storybookDiff` options
104
+
105
+ All flags accepted by the [`storybook-diff`](https://www.npmjs.com/package/storybook-diff) CLI:
106
+
107
+ | Key | Type | Default | Maps to |
108
+ |---|---|---|---|
109
+ | `ignoreModules` | `string[]` | `[]` | `--ignore-modules` (repeatable) |
110
+ | `maxDepth` | `number \| null` | `5` | `--max-depth N`, or `--no-depth-limit` when `null` |
111
+ | `autoIgnoreThreshold` | `number` | `50` | `--auto-ignore-threshold N` |
112
+ | `useGitattributes` | `boolean` | `true` | `--no-gitattributes` when `false` |
113
+
114
+ See [src/config.ts](src/config.ts) for the full zod schema.
115
+
116
+ ## Environment variables
117
+
118
+ Read from the Buildkite environment automatically:
119
+
120
+ | Variable | Purpose |
121
+ |---|---|
122
+ | `BUILDKITE_BRANCH` | Current branch (slugified with `/` → `-` unless `BRANCH_SLUG` is set) |
123
+ | `BUILDKITE_COMMIT` | Commit SHA; used as the upload key on default-branch builds |
124
+ | `BUILDKITE_BUILD_URL` | Linked from the PR comment and annotations |
125
+ | `BUILDKITE_PULL_REQUEST` | PR number, or `"false"` for non-PR builds |
126
+ | `BUILDKITE_PULL_REQUEST_BASE_BRANCH` | Target branch; drives base-storybook resolution |
127
+ | `BRANCH_SLUG` | Optional override for the derived slug |
128
+ | `GITHUB_PR_TOKEN` or `GITHUB_TOKEN` | Required to upsert PR comments; if missing, the step logs and skips |
129
+
130
+ ## Pipeline usage
131
+
132
+ Buildkite pipeline step:
133
+
134
+ ```yaml
135
+ steps:
136
+ - label: ":storybook: Visual Regression"
137
+ command: npx found-pixel run
138
+ plugins:
139
+ - docker#v5:
140
+ image: node:20
141
+ ```
142
+
143
+ Or split across steps if you want to parallelise other work:
144
+
145
+ ```yaml
146
+ steps:
147
+ - label: ":storybook: Build"
148
+ command: npx found-pixel build
149
+ key: storybook-build
150
+
151
+ - label: ":mag: Review"
152
+ command: npx found-pixel review
153
+ depends_on: storybook-build
154
+ if: build.pull_request.id != null
155
+ ```
156
+
157
+ ## CLI reference
158
+
159
+ ```
160
+ found-pixel build # build storybook, upload to S3, annotate
161
+ found-pixel review # (PR only) download base, diff, regress, upsert comment
162
+ found-pixel run # build then review
163
+ ```
164
+
165
+ `review` is a no-op when the build isn't a pull request.
166
+
167
+ ## Library usage
168
+
169
+ The comment renderer is a pure function, exported for reuse in custom pipelines:
170
+
171
+ ```ts
172
+ import { renderComment } from "found-pixel/comment";
173
+
174
+ const body = renderComment({
175
+ diff, // storybook-diff JSON output
176
+ visualIds, // string[] | undefined
177
+ baseSlug,
178
+ compareSlug,
179
+ buildUrl,
180
+ storybookUrl: (slug) => `https://.../storybook/${slug}/admin/index.html`,
181
+ comment: {
182
+ marker: "<!-- found-pixel-comment -->",
183
+ maxChars: 62000,
184
+ collapsibleThreshold: 50,
185
+ codeOnlyStoriesLimit: 25,
186
+ viewerUrl: "https://diffy.example.com",
187
+ },
188
+ });
189
+ ```
190
+
191
+ ## Development
192
+
193
+ ```bash
194
+ npm install
195
+ npm test # runs vitest against all fixtures
196
+ npm run build # tsc → dist/
197
+ npm run typecheck # tsc --noEmit
198
+ ```
199
+
200
+ ### Comment format changes
201
+
202
+ The comment generator has snapshot tests that write rendered markdown to `test/snapshots/*.md`. The `.md` files are committed so diffs are reviewable inline when the format changes.
203
+
204
+ Workflow:
205
+
206
+ ```bash
207
+ # 1. Change src/comment.ts
208
+ # 2. Regenerate snapshots
209
+ npm run test:update
210
+ # 3. Inspect the diff in test/snapshots/*.md before committing
211
+ ```
212
+
213
+ To preview a single fixture without running the test suite:
214
+
215
+ ```bash
216
+ npm run preview-comment modified-with-visuals
217
+ ```
218
+
219
+ ### Adding a fixture
220
+
221
+ 1. Create `test/fixtures/<name>/input.json` matching the shape in [test/helpers.ts](test/helpers.ts) (`FixtureInput`)
222
+ 2. Run `npm run test:update` to create the snapshot
223
+ 3. Review the generated `test/snapshots/<name>.md`
224
+
225
+ Size-driven cases (large-diff collapsing, oversized truncation) are programmatic in `test/comment.test.ts` rather than on-disk fixtures, since their scale would make the input JSON unreviewable.
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env node
2
+ import { runCli } from "../dist/cli.js";
3
+
4
+ runCli(process.argv).catch((err) => {
5
+ console.error(err);
6
+ process.exit(1);
7
+ });
package/dist/bin.d.ts ADDED
@@ -0,0 +1,10 @@
1
+ /** Resolve an installed package's CLI entry, accounting for string or object `bin` fields. */
2
+ export declare function resolveBin(pkg: string, binName?: string): string;
3
+ /**
4
+ * Lost-pixel bundles its own `playwright-core` with matching browser revisions.
5
+ * We must use *that* copy's CLI to install browsers, otherwise we'd install
6
+ * browsers for our top-level playwright-core version and lost-pixel would fail
7
+ * at runtime looking for a different chromium build.
8
+ */
9
+ export declare function lostPixelPlaywrightCoreDir(): string;
10
+ //# sourceMappingURL=bin.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bin.d.ts","sourceRoot":"","sources":["../src/bin.ts"],"names":[],"mappings":"AA4BA,8FAA8F;AAC9F,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM,CAchE;AAED;;;;;GAKG;AACH,wBAAgB,0BAA0B,IAAI,MAAM,CAGnD"}
package/dist/bin.js ADDED
@@ -0,0 +1,51 @@
1
+ import { readFileSync } from "node:fs";
2
+ import { dirname, resolve } from "node:path";
3
+ import { fileURLToPath } from "node:url";
4
+ // Some deps are ESM-only with `exports` that block both `./package.json` and
5
+ // the CJS resolution of `.`, so we walk `node_modules` directly instead. Pass
6
+ // `from` to resolve a nested dep (e.g. the playwright-core copy bundled inside
7
+ // lost-pixel) rather than the top-level install.
8
+ function packageRoot(pkg, from) {
9
+ let dir = from ?? dirname(fileURLToPath(import.meta.url));
10
+ while (true) {
11
+ const candidate = resolve(dir, "node_modules", pkg, "package.json");
12
+ try {
13
+ const raw = readFileSync(candidate, "utf8");
14
+ if (JSON.parse(raw).name === pkg) {
15
+ return dirname(candidate);
16
+ }
17
+ }
18
+ catch {
19
+ /* not here */
20
+ }
21
+ const parent = dirname(dir);
22
+ if (parent === dir) {
23
+ throw new Error(`Could not locate package root for '${pkg}'`);
24
+ }
25
+ dir = parent;
26
+ }
27
+ }
28
+ /** Resolve an installed package's CLI entry, accounting for string or object `bin` fields. */
29
+ export function resolveBin(pkg, binName) {
30
+ const root = packageRoot(pkg);
31
+ const pkgJson = JSON.parse(readFileSync(resolve(root, "package.json"), "utf8"));
32
+ if (!pkgJson.bin) {
33
+ throw new Error(`Package '${pkg}' has no bin entry`);
34
+ }
35
+ const binRel = typeof pkgJson.bin === "string" ? pkgJson.bin : pkgJson.bin[binName ?? pkg];
36
+ if (!binRel) {
37
+ throw new Error(`Package '${pkg}' has no bin '${binName ?? pkg}'`);
38
+ }
39
+ return resolve(root, binRel);
40
+ }
41
+ /**
42
+ * Lost-pixel bundles its own `playwright-core` with matching browser revisions.
43
+ * We must use *that* copy's CLI to install browsers, otherwise we'd install
44
+ * browsers for our top-level playwright-core version and lost-pixel would fail
45
+ * at runtime looking for a different chromium build.
46
+ */
47
+ export function lostPixelPlaywrightCoreDir() {
48
+ const lostPixelRoot = packageRoot("lost-pixel");
49
+ return packageRoot("playwright-core", lostPixelRoot);
50
+ }
51
+ //# sourceMappingURL=bin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bin.js","sourceRoot":"","sources":["../src/bin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC7C,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC,6EAA6E;AAC7E,8EAA8E;AAC9E,+EAA+E;AAC/E,iDAAiD;AACjD,SAAS,WAAW,CAAC,GAAW,EAAE,IAAa;IAC7C,IAAI,GAAG,GAAG,IAAI,IAAI,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;IAC1D,OAAO,IAAI,EAAE,CAAC;QACZ,MAAM,SAAS,GAAG,OAAO,CAAC,GAAG,EAAE,cAAc,EAAE,GAAG,EAAE,cAAc,CAAC,CAAC;QACpE,IAAI,CAAC;YACH,MAAM,GAAG,GAAG,YAAY,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC;YAC5C,IAAK,IAAI,CAAC,KAAK,CAAC,GAAG,CAAuB,CAAC,IAAI,KAAK,GAAG,EAAE,CAAC;gBACxD,OAAO,OAAO,CAAC,SAAS,CAAC,CAAC;YAC5B,CAAC;QACH,CAAC;QAAC,MAAM,CAAC;YACP,cAAc;QAChB,CAAC;QACD,MAAM,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC;QAC5B,IAAI,MAAM,KAAK,GAAG,EAAE,CAAC;YACnB,MAAM,IAAI,KAAK,CAAC,sCAAsC,GAAG,GAAG,CAAC,CAAC;QAChE,CAAC;QACD,GAAG,GAAG,MAAM,CAAC;IACf,CAAC;AACH,CAAC;AAED,8FAA8F;AAC9F,MAAM,UAAU,UAAU,CAAC,GAAW,EAAE,OAAgB;IACtD,MAAM,IAAI,GAAG,WAAW,CAAC,GAAG,CAAC,CAAC;IAC9B,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,OAAO,CAAC,IAAI,EAAE,cAAc,CAAC,EAAE,MAAM,CAAC,CAE7E,CAAC;IACF,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC;QACjB,MAAM,IAAI,KAAK,CAAC,YAAY,GAAG,oBAAoB,CAAC,CAAC;IACvD,CAAC;IACD,MAAM,MAAM,GACV,OAAO,OAAO,CAAC,GAAG,KAAK,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,OAAO,IAAI,GAAG,CAAC,CAAC;IAC9E,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,MAAM,IAAI,KAAK,CAAC,YAAY,GAAG,iBAAiB,OAAO,IAAI,GAAG,GAAG,CAAC,CAAC;IACrE,CAAC;IACD,OAAO,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;AAC/B,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,0BAA0B;IACxC,MAAM,aAAa,GAAG,WAAW,CAAC,YAAY,CAAC,CAAC;IAChD,OAAO,WAAW,CAAC,iBAAiB,EAAE,aAAa,CAAC,CAAC;AACvD,CAAC"}
@@ -0,0 +1,3 @@
1
+ import type { Config } from "./config.js";
2
+ export declare function build(cfg: Config): Promise<void>;
3
+ //# sourceMappingURL=build.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../src/build.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAO1C,wBAAsB,KAAK,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CA+CtD"}
package/dist/build.js ADDED
@@ -0,0 +1,30 @@
1
+ import { execa } from "execa";
2
+ import { rmSync } from "node:fs";
3
+ import { archiveUrl, storybookUrl } from "./config.js";
4
+ import { readContext, annotate } from "./buildkite.js";
5
+ import { archiveKey, branchKey, createS3 } from "./storage.js";
6
+ const ARCHIVE_FILE = "storybook.tar.gz";
7
+ export async function build(cfg) {
8
+ const ctx = readContext();
9
+ const s3 = createS3(cfg.s3);
10
+ console.log(`--- :storybook: Build Storybook`);
11
+ await execa(cfg.buildCommand, { shell: true, stdio: "inherit" });
12
+ console.log(`~~~ :package: Compress ${ARCHIVE_FILE}`);
13
+ rmSync(ARCHIVE_FILE, { force: true });
14
+ await execa("tar", ["-czf", ARCHIVE_FILE, "-C", cfg.outputDir, "."], { stdio: "inherit" });
15
+ console.log(`--- :s3: Upload ${ARCHIVE_FILE} (against ${ctx.branchSlug})`);
16
+ await s3.cp(ARCHIVE_FILE, `s3://${cfg.s3.bucket}/${archiveKey(cfg, ctx.branchSlug)}`);
17
+ console.log(`--- :s3: Upload storybook static (against ${ctx.branchSlug})`);
18
+ await s3.cp(`./${cfg.outputDir}`, `s3://${cfg.s3.bucket}/${branchKey(cfg, ctx.branchSlug)}/admin/`, { recursive: true });
19
+ if (ctx.branch === cfg.defaultBranch && ctx.commitSha) {
20
+ console.log(`--- :s3: Upload ${ARCHIVE_FILE} (against ${ctx.commitSha})`);
21
+ await s3.cp(ARCHIVE_FILE, `s3://${cfg.s3.bucket}/${archiveKey(cfg, ctx.commitSha)}`);
22
+ console.log(`--- :s3: Upload storybook static (against ${ctx.commitSha})`);
23
+ await s3.cp(`./${cfg.outputDir}`, `s3://${cfg.s3.bucket}/${branchKey(cfg, ctx.commitSha)}/admin/`, { recursive: true });
24
+ }
25
+ console.log(`~~~ :checkered_flag: Completed upload`);
26
+ const url = storybookUrl(cfg, ctx.branchSlug);
27
+ const archive = archiveUrl(cfg, ctx.branchSlug);
28
+ await annotate(`:storybook: Storybook: [View Storybook (${ctx.branchSlug})](${url}) ([Download archive](${archive}))`, { context: "host-storybook" });
29
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AM,QAAQ,CACZ,2CAA2C,GAAG,CAAC,UAAU,MAAM,GAAG,yBAAyB,OAAO,IAAI,EACtG,EAAE,OAAO,EAAE,gBAAgB,EAAE,CAC9B,CAAC;AACJ,CAAC"}
@@ -0,0 +1,16 @@
1
+ export interface BuildkiteContext {
2
+ commitSha: string;
3
+ branch: string;
4
+ branchSlug: string;
5
+ buildUrl: string;
6
+ pullRequest: string | null;
7
+ pullRequestBaseBranch: string | null;
8
+ }
9
+ export declare function slugify(branch: string): string;
10
+ export declare function readContext(env?: NodeJS.ProcessEnv): BuildkiteContext;
11
+ export declare function annotate(body: string, opts: {
12
+ context: string;
13
+ style?: "info" | "success" | "warning" | "error";
14
+ }): Promise<void>;
15
+ export declare function uploadArtifact(pattern: string): Promise<void>;
16
+ //# sourceMappingURL=buildkite.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"buildkite.d.ts","sourceRoot":"","sources":["../src/buildkite.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,gBAAgB;IAC/B,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,qBAAqB,EAAE,MAAM,GAAG,IAAI,CAAC;CACtC;AAED,wBAAgB,OAAO,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAE9C;AAED,wBAAgB,WAAW,CAAC,GAAG,GAAE,MAAM,CAAC,UAAwB,GAAG,gBAAgB,CAWlF;AAED,wBAAsB,QAAQ,CAC5B,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,GAAG,SAAS,GAAG,SAAS,GAAG,OAAO,CAAA;CAAE,GAC1E,OAAO,CAAC,IAAI,CAAC,CASf;AAED,wBAAsB,cAAc,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAMnE"}
@@ -0,0 +1,36 @@
1
+ import { execa } from "execa";
2
+ export function slugify(branch) {
3
+ return branch.replaceAll("/", "-");
4
+ }
5
+ export function readContext(env = process.env) {
6
+ const pr = env.BUILDKITE_PULL_REQUEST;
7
+ const branch = env.BUILDKITE_BRANCH ?? "";
8
+ return {
9
+ commitSha: env.BUILDKITE_COMMIT ?? "",
10
+ branch,
11
+ branchSlug: env.BRANCH_SLUG ?? slugify(branch),
12
+ buildUrl: env.BUILDKITE_BUILD_URL ?? "",
13
+ pullRequest: pr && pr !== "false" ? pr : null,
14
+ pullRequestBaseBranch: env.BUILDKITE_PULL_REQUEST_BASE_BRANCH ?? null,
15
+ };
16
+ }
17
+ export async function annotate(body, opts) {
18
+ const style = opts.style ?? "info";
19
+ try {
20
+ await execa("buildkite-agent", ["annotate", "--context", opts.context, "--style", style, body], {
21
+ stdio: "inherit",
22
+ });
23
+ }
24
+ catch (err) {
25
+ console.warn(`buildkite-agent annotate failed (context=${opts.context}):`, err);
26
+ }
27
+ }
28
+ export async function uploadArtifact(pattern) {
29
+ try {
30
+ await execa("buildkite-agent", ["artifact", "upload", pattern], { stdio: "inherit" });
31
+ }
32
+ catch (err) {
33
+ console.warn(`buildkite-agent artifact upload failed (pattern=${pattern}):`, err);
34
+ }
35
+ }
36
+ //# sourceMappingURL=buildkite.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"buildkite.js","sourceRoot":"","sources":["../src/buildkite.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,OAAO,CAAC;AAW9B,MAAM,UAAU,OAAO,CAAC,MAAc;IACpC,OAAO,MAAM,CAAC,UAAU,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;AACrC,CAAC;AAED,MAAM,UAAU,WAAW,CAAC,MAAyB,OAAO,CAAC,GAAG;IAC9D,MAAM,EAAE,GAAG,GAAG,CAAC,sBAAsB,CAAC;IACtC,MAAM,M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ts ADDED
@@ -0,0 +1,2 @@
1
+ export declare function runCli(argv: string[]): Promise<void>;
2
+ //# sourceMappingURL=cli.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":"AAKA,wBAAsB,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CA8B1D"}
package/dist/cli.js ADDED
@@ -0,0 +1,32 @@
1
+ import { Command } from "commander";
2
+ import { build } from "./build.js";
3
+ import { loadConfig } from "./config.js";
4
+ import { review } from "./review.js";
5
+ export async function runCli(argv) {
6
+ const program = new Command();
7
+ program
8
+ .name("found-pixel")
9
+ .description("Storybook build + visual regression workflow for Buildkite");
10
+ program
11
+ .command("build")
12
+ .description("Build storybook, upload archive + static site to S3, annotate build")
13
+ .action(async () => {
14
+ await build(loadConfig());
15
+ });
16
+ program
17
+ .command("review")
18
+ .description("PR review: download base, run diff + lost-pixel, upsert PR comment")
19
+ .action(async () => {
20
+ await review(loadConfig());
21
+ });
22
+ program
23
+ .command("run")
24
+ .description("build then review (no-op review if not a PR)")
25
+ .action(async () => {
26
+ const cfg = loadConfig();
27
+ await build(cfg);
28
+ await review(cfg);
29
+ });
30
+ await program.parseAsync(argv);
31
+ }
32
+ //# sourceMappingURL=cli.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACnC,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAErC,MAAM,CAAC,KAAK,UAAU,MAAM,CAAC,IAAc;IACzC,MAAM,OAAO,GAAG,IAAI,OAAO,EAAE,CAAC;IAC9B,OAAO;SACJ,IAAI,CAAC,aAAa,CAAC;SACnB,WAAW,CAAC,4DAA4D,CAAC,CAAC;IAE7E,OAAO;SACJ,OAAO,CAAC,OAAO,CAAC;SAChB,WAAW,CAAC,qEAAqE,CAAC;SAClF,MAAM,CAAC,KAAK,IAAI,EAAE;QACjB,MAAM,KAAK,CAAC,UAAU,EAAE,CAAC,CAAC;IAC5B,CAAC,CAAC,CAAC;IAEL,OAAO;SACJ,OAAO,CAAC,QAAQ,CAAC;SACjB,WAAW,CAAC,oEAAoE,CAAC;SACjF,MAAM,CAAC,KAAK,IAAI,EAAE;QACjB,MAAM,MAAM,CAAC,UAAU,EAAE,CAAC,CAAC;IAC7B,CAAC,CAAC,CAAC;IAEL,OAAO;SACJ,OAAO,CAAC,KAAK,CAAC;SACd,WAAW,CAAC,8CAA8C,CAAC;SAC3D,MAAM,CAAC,KAAK,IAAI,EAAE;QACjB,MAAM,GAAG,GAAG,UAAU,EAAE,CAAC;QACzB,MAAM,KAAK,CAAC,GAAG,CAAC,CAAC;QACjB,MAAM,MAAM,CAAC,GAAG,CAAC,CAAC;IACpB,CAAC,CAAC,CAAC;IAEL,MAAM,OAAO,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;AACjC,CAAC"}
@@ -0,0 +1,41 @@
1
+ export interface Story {
2
+ id: string;
3
+ title: string;
4
+ name: string;
5
+ }
6
+ export interface ChangeSource {
7
+ ignored?: boolean;
8
+ affectedStoryCount: number;
9
+ }
10
+ export interface StorybookDiff {
11
+ summary?: {
12
+ created?: number;
13
+ deleted?: number;
14
+ modified?: number;
15
+ };
16
+ created?: Story[];
17
+ deleted?: Story[];
18
+ modified?: Story[];
19
+ changeSources?: ChangeSource[];
20
+ }
21
+ export interface CommentConfig {
22
+ heading: string;
23
+ marker: string;
24
+ viewerUrl?: string;
25
+ maxChars: number;
26
+ collapsibleThreshold: number;
27
+ codeOnlyStoriesLimit: number;
28
+ }
29
+ export interface RenderInput {
30
+ diff: StorybookDiff;
31
+ /** `undefined` = no visual-regression data available; fall back to showing all modified stories. */
32
+ visualIds?: string[];
33
+ baseSlug: string;
34
+ compareSlug: string;
35
+ repoName: string;
36
+ buildUrl: string;
37
+ storybookUrl: (slug: string) => string;
38
+ comment: CommentConfig;
39
+ }
40
+ export declare function renderComment(input: RenderInput): string;
41
+ //# sourceMappingURL=comment.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"comment.d.ts","sourceRoot":"","sources":["../src/comment.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,KAAK;IACpB,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,YAAY;IAC3B,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,kBAAkB,EAAE,MAAM,CAAC;CAC5B;AAED,MAAM,WAAW,aAAa;IAC5B,OAAO,CAAC,EAAE;QACR,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;KACnB,CAAC;IACF,OAAO,CAAC,EAAE,KAAK,EAAE,CAAC;IAClB,OAAO,CAAC,EAAE,KAAK,EAAE,CAAC;IAClB,QAAQ,CAAC,EAAE,KAAK,EAAE,CAAC;IACnB,aAAa,CAAC,EAAE,YAAY,EAAE,CAAC;CAChC;AAED,MAAM,WAAW,aAAa;IAC5B,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,oBAAoB,EAAE,MAAM,CAAC;IAC7B,oBAAoB,EAAE,MAAM,CAAC;CAC9B;AAED,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,aAAa,CAAC;IACpB,oGAAoG;IACpG,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;IACrB,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,CAAC;IACvC,OAAO,EAAE,aAAa,CAAC;CACxB;AAID,wBAAgB,aAAa,CAAC,KAAK,EAAE,WAAW,GAAG,MAAM,CA+IxD"}
@@ -0,0 +1,114 @@
1
+ export function renderComment(input) {
2
+ const { diff, visualIds, baseSlug, compareSlug, repoName, buildUrl, storybookUrl, comment } = input;
3
+ const summary = diff.summary ?? {};
4
+ const allMod = diff.modified ?? [];
5
+ const cre = diff.created ?? [];
6
+ const del = diff.deleted ?? [];
7
+ let mod;
8
+ let codeOnlyStories;
9
+ if (visualIds !== undefined) {
10
+ const visualSet = new Set(visualIds);
11
+ mod = allMod.filter((s) => visualSet.has(s.id) || visualIds.some((vid) => vid.startsWith(s.id)));
12
+ codeOnlyStories = allMod.filter((s) => !mod.includes(s));
13
+ }
14
+ else {
15
+ mod = allMod;
16
+ codeOnlyStories = [];
17
+ }
18
+ const modifiedCount = mod.length;
19
+ const totalChanged = modifiedCount + (summary.created ?? 0) + (summary.deleted ?? 0);
20
+ const ignoredStoryCount = (diff.changeSources ?? [])
21
+ .filter((s) => s.ignored)
22
+ .reduce((sum, s) => sum + s.affectedStoryCount, 0);
23
+ const buildStoryUrl = (storyId, slug) => `${storybookUrl(slug)}?path=/story/${storyId}`;
24
+ const buildViewerUrl = (storyId) => {
25
+ if (!comment.viewerUrl)
26
+ return null;
27
+ const params = new URLSearchParams({
28
+ id: storyId,
29
+ r: repoName,
30
+ a: baseSlug,
31
+ b: compareSlug,
32
+ });
33
+ return `${comment.viewerUrl}?${params.toString()}`;
34
+ };
35
+ const renderSection = (heading, stories, totalInSection, collapsible) => {
36
+ if (!totalInSection)
37
+ return "";
38
+ if (!stories.length) {
39
+ return [
40
+ `#### ${heading} (${totalInSection})`,
41
+ `_All ${totalInSection} omitted here (size limit); see [Buildkite artifacts](${buildUrl}#artifacts)._`,
42
+ "",
43
+ ].join("\n");
44
+ }
45
+ const lines = stories.map((story) => {
46
+ const displayName = `${story.title} - ${story.name}`;
47
+ const storyUrlRef = heading === "Deleted" ? baseSlug : compareSlug;
48
+ const storyUrl = buildStoryUrl(story.id, storyUrlRef);
49
+ const lineItem = `- [ ] [${displayName}](${storyUrl})`;
50
+ if (heading === "Modified") {
51
+ const viewerUrl = buildViewerUrl(story.id);
52
+ return viewerUrl ? `${lineItem} | [View Changes](${viewerUrl})` : lineItem;
53
+ }
54
+ return lineItem;
55
+ });
56
+ let block = [`#### ${heading} (${totalInSection})`, ...lines, ""].join("\n");
57
+ if (totalInSection > stories.length) {
58
+ block += `_…and ${totalInSection - stories.length} more — see [Buildkite artifacts](${buildUrl}#artifacts)._\n\n`;
59
+ }
60
+ if (collapsible) {
61
+ block = `<details>\n<summary><strong>${heading} (${totalInSection})</strong></summary>\n\n${block}</details>\n\n`;
62
+ }
63
+ return block;
64
+ };
65
+ const buildBody = (limitPerSection) => {
66
+ const collapsible = totalChanged > comment.collapsibleThreshold;
67
+ const sections = [
68
+ renderSection("Added", cre.slice(0, limitPerSection), summary.created ?? cre.length, collapsible),
69
+ renderSection("Deleted", del.slice(0, limitPerSection), summary.deleted ?? del.length, collapsible),
70
+ renderSection("Modified", mod.slice(0, limitPerSection), modifiedCount, collapsible),
71
+ ].filter(Boolean);
72
+ const footerParts = [];
73
+ if (codeOnlyStories.length > 0) {
74
+ const codeOnlyBody = codeOnlyStories.length > comment.codeOnlyStoriesLimit
75
+ ? `_All ${codeOnlyStories.length} omitted here (size limit); see [Buildkite artifacts](${buildUrl}#artifacts)._`
76
+ : codeOnlyStories.map((s) => `- ${s.id}`).join("\n");
77
+ footerParts.push(`<details>\n<summary><sub>${codeOnlyStories.length} modified ${codeOnlyStories.length === 1 ? "story" : "stories"} with code changes but no visual difference</sub></summary>\n\n${codeOnlyBody}\n</details>`);
78
+ }
79
+ if (totalChanged > 0 && ignoredStoryCount > 0) {
80
+ footerParts.push("", `<sub><i>Ignored ${ignoredStoryCount} other stories with dependency graph changes ([artifacts](${buildUrl}#artifacts))</i></sub>`);
81
+ }
82
+ return [
83
+ comment.marker,
84
+ `### ${comment.heading}`,
85
+ "",
86
+ ...(sections.length > 0 ? sections : ["_No story changes detected._"]),
87
+ ...(footerParts.length > 0 ? ["", ...footerParts] : []),
88
+ ].join("\n");
89
+ };
90
+ const maxStories = Math.max(mod.length, cre.length, del.length);
91
+ let body = buildBody(maxStories);
92
+ if (body.length > comment.maxChars) {
93
+ let lo = 0;
94
+ let hi = maxStories;
95
+ while (lo < hi) {
96
+ const mid = Math.ceil((lo + hi) / 2);
97
+ if (buildBody(mid).length <= comment.maxChars) {
98
+ lo = mid;
99
+ }
100
+ else {
101
+ hi = mid - 1;
102
+ }
103
+ }
104
+ body = buildBody(lo);
105
+ }
106
+ if (body.length > comment.maxChars) {
107
+ const fullLen = body.length;
108
+ body =
109
+ body.slice(0, comment.maxChars - 200) +
110
+ `\n\n_…comment truncated (${fullLen} chars); full list in [Buildkite artifacts](${buildUrl}#artifacts)._`;
111
+ }
112
+ return body;
113
+ }
114
+ //# sourceMappingURL=comment.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"comment.js","sourceRoot":"","sources":["../src/comment.ts"],"names":[],"mappings":"AA8CA,MAAM,UAAU,aAAa,CAAC,KAAkB;IAC9C,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE,QAAQ,EAAE,WAAW,EAAE,QAAQ,EAAE,QAAQ,EAAE,YAAY,EAAE,OAAO,EAAE,GAAG,KAAK,CAAC;IAEpG,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,IAAI,EAAE,CAAC;IACnC,MAAM,MAAM,GAAG,IAAI,CAAC,QAAQ,IAAI,EAAE,CAAC;IACnC,MAAM,GAAG,GAAG,IAAI,CAAC,OAAO,IAAI,EAAE,CAAC;IAC/B,MAAM,GAAG,GAAG,IAAI,CAAC,OAAO,IAAI,EAAE,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