@storysnap/cli 2.0.0 → 2.1.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.
@@ -6,6 +6,10 @@ export interface TestRunInput {
6
6
  storybookUrl?: string;
7
7
  branch?: string;
8
8
  commit?: string;
9
+ /** The branch `branch` will merge into; its baselines fill in for missing ones. */
10
+ baseBranch?: string;
11
+ /** The commit `branch` forked from `baseBranch` at. */
12
+ mergeBase?: string;
9
13
  /** pixelmatch per-pixel colour sensitivity (0-1). */
10
14
  threshold?: number;
11
15
  /** Percentage of the image allowed to differ before a story fails (0-100). */
@@ -18,6 +22,8 @@ export interface CreateResultInput {
18
22
  browser: string;
19
23
  viewportWidth: number;
20
24
  viewportHeight: number;
25
+ /** SHA-256 of the PNG, so the server can recognise a screenshot approved on another branch. */
26
+ contentHash?: string;
21
27
  }
22
28
  export interface ResultUploadTarget {
23
29
  resultId: string;
@@ -31,6 +37,12 @@ export interface TestRun {
31
37
  status: 'pending' | 'running' | 'passed' | 'failed' | 'error';
32
38
  branch?: string;
33
39
  commit?: string;
40
+ baseBranch?: string;
41
+ mergeBase?: string;
42
+ /** The branch review this run is a push of; absent on the default branch. */
43
+ reviewId?: string | null;
44
+ /** Its page in the dashboard, when the server knows where that is. Only on creation. */
45
+ reviewUrl?: string | null;
34
46
  totalStories: number;
35
47
  passedStories: number;
36
48
  failedStories: number;
@@ -70,6 +82,7 @@ export interface BaselineUploadUrl {
70
82
  export interface Baseline {
71
83
  id: string;
72
84
  projectId: string;
85
+ branch?: string;
73
86
  storyId: string;
74
87
  browser: string;
75
88
  viewportWidth: number;
@@ -109,7 +122,7 @@ export declare class ApiClient {
109
122
  uploadImage(uploadUrl: string, imageBuffer: Buffer): Promise<void>;
110
123
  getTestRun(id: string): Promise<TestRunWithResults>;
111
124
  listTestRuns(limit?: number, offset?: number): Promise<TestRun[]>;
112
- getBaselineUploadUrl(storyId: string, browser: string, viewportWidth: number, viewportHeight: number): Promise<BaselineUploadUrl>;
125
+ getBaselineUploadUrl(storyId: string, browser: string, viewportWidth: number, viewportHeight: number, branch?: string): Promise<BaselineUploadUrl>;
113
126
  uploadBaseline(uploadUrl: string, imageBuffer: Buffer): Promise<void>;
114
127
  /**
115
128
  * Points the baseline record at an already-uploaded image. Without this the
@@ -121,6 +134,9 @@ export declare class ApiClient {
121
134
  viewportWidth: number;
122
135
  viewportHeight: number;
123
136
  storageKey: string;
137
+ /** Omitted, the server uses the project's default branch. */
138
+ branch?: string;
139
+ contentHash?: string;
124
140
  }): Promise<Baseline>;
125
141
  listBaselines(limit?: number, offset?: number, storyId?: string, browser?: string): Promise<Baseline[]>;
126
142
  approveBaseline(baselineId: string, testResultId?: string): Promise<Baseline>;
@@ -99,12 +99,13 @@ export class ApiClient {
99
99
  const response = await this.request('GET', `/api/v1/test-runs?limit=${limit}&offset=${offset}`);
100
100
  return response.data;
101
101
  }
102
- async getBaselineUploadUrl(storyId, browser, viewportWidth, viewportHeight) {
102
+ async getBaselineUploadUrl(storyId, browser, viewportWidth, viewportHeight, branch) {
103
103
  const response = await this.request('POST', '/api/v1/baselines/upload-url', {
104
104
  storyId,
105
105
  browser,
106
106
  viewportWidth,
107
107
  viewportHeight,
108
+ branch,
108
109
  contentType: 'image/png',
109
110
  });
110
111
  return response.data;
@@ -6,6 +6,7 @@ export interface TestOptions extends StorySelectionOptions {
6
6
  concurrency?: number;
7
7
  branch?: string;
8
8
  commit?: string;
9
+ baseBranch?: string;
9
10
  ci?: boolean;
10
11
  verbose?: boolean;
11
12
  local?: boolean;
@@ -2,10 +2,13 @@ import { loadConfig } from '../../config/loader.js';
2
2
  import { loadCredentials } from '../../config/credentials.js';
3
3
  import { captureScreenshots, getScreenshotKey, parseScreenshotKey } from '../../core/screenshot.js';
4
4
  import { mapWithConcurrency } from '../../core/concurrency.js';
5
+ import { detectGitContext, describeGitContext } from '../../core/git-context.js';
6
+ import { hashScreenshot } from '../../core/hash.js';
5
7
  import { compareAllScreenshots, DEFAULT_MAX_DIFF_PERCENT } from '../../core/compare.js';
6
8
  import { createStorage } from '../../storage/index.js';
7
9
  import { createReporter } from '../reporter.js';
8
10
  import { selectStories } from '../select-stories.js';
11
+ import { describeReview } from '../review.js';
9
12
  import { ApiClient } from '../../api/client.js';
10
13
  function parseBrowsers(browserArg) {
11
14
  if (!browserArg) {
@@ -79,14 +82,17 @@ async function runApiMode(reporter, config, apiUrl, apiToken, options) {
79
82
  reporter.progress(completed, total, `${story.title}/${story.name} (${browser})`);
80
83
  });
81
84
  reporter.succeedSpinner('Screenshots captured');
85
+ const gitContext = await detectGitContext({
86
+ overrides: { branch: options.branch, commit: options.commit, baseBranch: options.baseBranch },
87
+ });
88
+ reporter.info(describeGitContext(gitContext));
82
89
  reporter.startSpinner('Creating test run...');
83
90
  // Only sent when the config actually declares them. Left undefined the server
84
91
  // applies the project's own defaults, which is what makes `PATCH /projects/me`
85
92
  // worth having; a config that does declare them overrides for this run.
86
93
  const testRun = await client.createTestRun({
87
94
  storybookUrl: config.storybookUrl,
88
- branch: options.branch,
89
- commit: options.commit,
95
+ ...gitContext,
90
96
  threshold: config.threshold,
91
97
  maxDiffPercent: config.maxDiffPercent,
92
98
  });
@@ -115,7 +121,7 @@ async function runApiMode(reporter, config, apiUrl, apiToken, options) {
115
121
  });
116
122
  reporter.succeedSpinner('Tests complete');
117
123
  // Report results
118
- reportApiResults(reporter, completedTestRun, options, totalTests - uploaded);
124
+ reportApiResults(reporter, completedTestRun, options, totalTests - uploaded, describeReview(testRun));
119
125
  }
120
126
  /**
121
127
  * Registers each captured screenshot with the API and PUTs the PNG to the
@@ -142,6 +148,7 @@ async function uploadScreenshots(client, testRunId, config, stories, screenshots
142
148
  browser,
143
149
  viewportWidth: config.viewport.width,
144
150
  viewportHeight: config.viewport.height,
151
+ contentHash: hashScreenshot(screenshot.buffer),
145
152
  });
146
153
  await client.uploadImage(target.uploadUrl, screenshot.buffer);
147
154
  uploaded++;
@@ -233,7 +240,7 @@ function reportLocalResult(story, comparison) {
233
240
  break;
234
241
  }
235
242
  }
236
- function reportApiResults(reporter, testRun, options, missing) {
243
+ function reportApiResults(reporter, testRun, options, missing, review) {
237
244
  reporter.header('Results');
238
245
  for (const result of testRun.results) {
239
246
  const storyName = result.storyName || result.storyId;
@@ -289,8 +296,14 @@ function reportApiResults(reporter, testRun, options, missing) {
289
296
  }
290
297
  console.log(` ${parts.join(', ')} of ${testRun.totalStories} stories`);
291
298
  reporter.newLine();
299
+ if (review) {
300
+ console.log(`\x1b[1mReview:\x1b[0m ${review}`);
301
+ reporter.newLine();
302
+ }
292
303
  if (testRun.status === 'failed') {
293
- console.log('\x1b[31mVisual regression tests failed.\x1b[0m', '\x1b[2mReview changes in the dashboard or run "storysnap update" to update baselines.\x1b[0m');
304
+ console.log('\x1b[31mVisual regression tests failed.\x1b[0m', review
305
+ ? '\x1b[2mApprove the changes in the review above, or fix them and push again.\x1b[0m'
306
+ : '\x1b[2mReview changes in the dashboard or run "storysnap update" to update baselines.\x1b[0m');
294
307
  }
295
308
  else if (missing > 0) {
296
309
  console.log(`\x1b[31m${missing} screenshot(s) were not captured or uploaded.\x1b[0m`, '\x1b[2mSee the warnings above.\x1b[0m');
@@ -4,6 +4,7 @@ export interface UpdateOptions extends StorySelectionOptions {
4
4
  browser?: string;
5
5
  storybookUrl?: string;
6
6
  concurrency?: number;
7
+ branch?: string;
7
8
  verbose?: boolean;
8
9
  dryRun?: boolean;
9
10
  local?: boolean;
@@ -3,6 +3,8 @@ import { loadCredentials } from '../../config/credentials.js';
3
3
  import { getStoryKey } from '../../core/storybook.js';
4
4
  import { captureScreenshots, getScreenshotKey } from '../../core/screenshot.js';
5
5
  import { mapWithConcurrency } from '../../core/concurrency.js';
6
+ import { detectGitContext } from '../../core/git-context.js';
7
+ import { hashScreenshot } from '../../core/hash.js';
6
8
  import { createStorage } from '../../storage/index.js';
7
9
  import { createReporter } from '../reporter.js';
8
10
  import { selectStories } from '../select-stories.js';
@@ -71,6 +73,9 @@ async function runApiMode(reporter, config, apiUrl, apiToken, options) {
71
73
  reporter.info(`Browsers: ${config.browsers.join(', ')}`);
72
74
  reporter.newLine();
73
75
  const client = new ApiClient({ apiUrl, apiToken });
76
+ // Baselines land on this branch only; other branches keep theirs.
77
+ const { branch } = await detectGitContext({ overrides: { branch: options.branch } });
78
+ reporter.info(branch ? `Branch: ${branch}` : "Branch: not detected - updating the project's default branch (pass --branch to name one)");
74
79
  // Discover stories
75
80
  const stories = await selectStories(reporter, config, options, 'baselines');
76
81
  if (!stories) {
@@ -99,7 +104,7 @@ async function runApiMode(reporter, config, apiUrl, apiToken, options) {
99
104
  if (!options.dryRun) {
100
105
  try {
101
106
  // Get presigned upload URL from API
102
- const uploadInfo = await client.getBaselineUploadUrl(story.id, browser, config.viewport.width, config.viewport.height);
107
+ const uploadInfo = await client.getBaselineUploadUrl(story.id, browser, config.viewport.width, config.viewport.height, branch);
103
108
  // Upload directly to S3 using presigned URL
104
109
  await client.uploadBaseline(uploadInfo.url, screenshot.buffer);
105
110
  // Record the baseline. The upload alone leaves an orphaned object -
@@ -110,6 +115,8 @@ async function runApiMode(reporter, config, apiUrl, apiToken, options) {
110
115
  viewportWidth: config.viewport.width,
111
116
  viewportHeight: config.viewport.height,
112
117
  storageKey: uploadInfo.storageKey,
118
+ branch,
119
+ contentHash: hashScreenshot(screenshot.buffer),
113
120
  });
114
121
  uploaded++;
115
122
  }
package/dist/cli/index.js CHANGED
@@ -61,8 +61,9 @@ program
61
61
  .option('-b, --browser <browsers>', 'Browsers to test (chromium,firefox,webkit)')
62
62
  .option('--storybook-url <url>', 'Storybook URL, overriding the config file')
63
63
  .option('--concurrency <n>', 'Stories to capture at once (default: 4)', parseConcurrency)
64
- .option('--branch <branch>', 'Branch name to record on the test run (API mode)')
65
- .option('--commit <sha>', 'Commit SHA to record on the test run (API mode)')
64
+ .option('--branch <branch>', 'Branch of the test run (API mode; default: detected from CI or git)')
65
+ .option('--commit <sha>', 'Commit SHA of the test run (API mode; default: detected from CI or git)')
66
+ .option('--base-branch <branch>', 'Branch to compare against where this one has no baseline (API mode; default: the PR/MR target, else the project default branch)')
66
67
  .option('--ci', 'CI mode - fail on any visual diff or new story')
67
68
  .option('-v, --verbose', 'Verbose output')
68
69
  .option('--local', 'Force local-only mode without using the API')
@@ -77,6 +78,7 @@ program
77
78
  concurrency: options.concurrency,
78
79
  branch: options.branch,
79
80
  commit: options.commit,
81
+ baseBranch: options.baseBranch,
80
82
  ci: options.ci,
81
83
  verbose: options.verbose,
82
84
  local: options.local,
@@ -92,6 +94,7 @@ program
92
94
  .option('-b, --browser <browsers>', 'Browsers to test (chromium,firefox,webkit)')
93
95
  .option('--storybook-url <url>', 'Storybook URL, overriding the config file')
94
96
  .option('--concurrency <n>', 'Stories to capture at once (default: 4)', parseConcurrency)
97
+ .option('--branch <branch>', 'Branch whose baselines to update (API mode; default: detected from CI or git)')
95
98
  .option('-v, --verbose', 'Verbose output')
96
99
  .option('--dry-run', 'Show what would be updated without making changes')
97
100
  .option('--local', 'Force local-only mode without using the API')
@@ -104,6 +107,7 @@ program
104
107
  browser: options.browser,
105
108
  storybookUrl: options.storybookUrl,
106
109
  concurrency: options.concurrency,
110
+ branch: options.branch,
107
111
  verbose: options.verbose,
108
112
  dryRun: options.dryRun,
109
113
  local: options.local,
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Where to review this push, for a run on a branch with a review: its
3
+ * dashboard link, or its id when the server has no DASHBOARD_URL to build one.
4
+ */
5
+ export declare function describeReview(run: {
6
+ reviewId?: string | null;
7
+ reviewUrl?: string | null;
8
+ }): string | undefined;
9
+ //# sourceMappingURL=review.d.ts.map
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Where to review this push, for a run on a branch with a review: its
3
+ * dashboard link, or its id when the server has no DASHBOARD_URL to build one.
4
+ */
5
+ export function describeReview(run) {
6
+ if (!run.reviewId)
7
+ return undefined;
8
+ return run.reviewUrl ?? `review ${run.reviewId} (set DASHBOARD_URL on the server for a link)`;
9
+ }
10
+ //# sourceMappingURL=review.js.map
@@ -1,32 +1,11 @@
1
- import { execFile } from 'node:child_process';
2
1
  import { posix } from 'node:path';
3
- import { promisify } from 'node:util';
4
- const execFileAsync = promisify(execFile);
2
+ import { git, findMergeBase } from './git.js';
5
3
  /** Used by `--changed` with no ref. CI checkouts often only have the remote one. */
6
4
  const DEFAULT_REFS = ['main', 'origin/main'];
7
- async function git(args, cwd) {
8
- const { stdout } = await execFileAsync('git', args, { cwd, maxBuffer: 64 * 1024 * 1024 });
9
- return stdout;
10
- }
11
5
  /** Parses `-z` output, which leaves unusual file names unquoted. */
12
6
  function splitNul(output) {
13
7
  return output.split('\0').filter(Boolean);
14
8
  }
15
- async function findMergeBase(refs, cwd) {
16
- for (const ref of refs) {
17
- try {
18
- const base = (await git(['merge-base', ref, 'HEAD'], cwd)).trim();
19
- return { ref, base };
20
- }
21
- catch {
22
- // Try the next candidate
23
- }
24
- }
25
- const tried = refs.map((ref) => `"${ref}"`).join(' or ');
26
- throw new Error(`Could not compare against ${tried}. Make sure this is a git repository and the ref exists - ` +
27
- 'CI checkouts are often shallow, so fetch it first (e.g. "git fetch origin main") ' +
28
- 'or name one explicitly with --changed <ref>.');
29
- }
30
9
  /**
31
10
  * Files that differ from the point where HEAD branched off `ref`: committed,
32
11
  * staged, unstaged and untracked. Comparing against the merge base rather than
@@ -36,7 +15,15 @@ async function findMergeBase(refs, cwd) {
36
15
  * the CLI runs from the directory Storybook runs from.
37
16
  */
38
17
  export async function getChangedFiles(ref, cwd = process.cwd()) {
39
- const { ref: resolvedRef, base } = await findMergeBase(ref ? [ref] : DEFAULT_REFS, cwd);
18
+ const refs = ref ? [ref] : DEFAULT_REFS;
19
+ const found = await findMergeBase(refs, cwd);
20
+ if (!found) {
21
+ const tried = refs.map((r) => `"${r}"`).join(' or ');
22
+ throw new Error(`Could not compare against ${tried}. Make sure this is a git repository and the ref exists - ` +
23
+ 'CI checkouts are often shallow, so fetch it first (e.g. "git fetch origin main") ' +
24
+ 'or name one explicitly with --changed <ref>.');
25
+ }
26
+ const { ref: resolvedRef, base } = found;
40
27
  const [tracked, untracked] = await Promise.all([
41
28
  git(['diff', '--name-only', '--relative', '-z', base], cwd),
42
29
  git(['ls-files', '--others', '--exclude-standard', '-z'], cwd),
@@ -0,0 +1,25 @@
1
+ /** Where a run comes from. Anything left undefined the server fills in. */
2
+ export interface GitContext {
3
+ branch?: string;
4
+ commit?: string;
5
+ /** The branch this one will merge into; the server falls back to its baselines. */
6
+ baseBranch?: string;
7
+ /** The commit `branch` forked from `baseBranch` at. */
8
+ mergeBase?: string;
9
+ }
10
+ export interface GitContextOptions {
11
+ /** Explicit flags, which win over anything detected. */
12
+ overrides?: Pick<GitContext, 'branch' | 'commit' | 'baseBranch'>;
13
+ env?: NodeJS.ProcessEnv;
14
+ cwd?: string;
15
+ }
16
+ /**
17
+ * Works out the branch, commit, base branch and merge base of this run, best
18
+ * effort: flags, then CI variables, then git. Nothing here fails a run - with
19
+ * no git at all every field may come back undefined, and the server treats
20
+ * the run as being on the project's default branch.
21
+ */
22
+ export declare function detectGitContext(options?: GitContextOptions): Promise<GitContext>;
23
+ /** "Branch feature/x (compared against main @ abc1234)", or what was not detected. */
24
+ export declare function describeGitContext(context: GitContext): string;
25
+ //# sourceMappingURL=git-context.d.ts.map
@@ -0,0 +1,75 @@
1
+ import { readFile } from 'node:fs/promises';
2
+ import { git, findMergeBase } from './git.js';
3
+ /** CI providers set some of these to an empty string rather than leaving them out. */
4
+ function first(...values) {
5
+ return values.find((value) => value !== undefined && value.trim() !== '')?.trim();
6
+ }
7
+ async function tryGit(args, cwd) {
8
+ try {
9
+ return first(await git(args, cwd));
10
+ }
11
+ catch {
12
+ return undefined;
13
+ }
14
+ }
15
+ /**
16
+ * The head commit of the pull request that triggered a GitHub Actions run.
17
+ * GITHUB_SHA is a merge commit GitHub made for the run, which nothing outside
18
+ * the run knows about - a status posted on it never shows up on the PR.
19
+ */
20
+ async function githubPullRequestHead(env) {
21
+ if (!env.GITHUB_EVENT_PATH) {
22
+ return undefined;
23
+ }
24
+ try {
25
+ const event = JSON.parse(await readFile(env.GITHUB_EVENT_PATH, 'utf8'));
26
+ return first(event.pull_request?.head?.sha);
27
+ }
28
+ catch {
29
+ return undefined;
30
+ }
31
+ }
32
+ /**
33
+ * Works out the branch, commit, base branch and merge base of this run, best
34
+ * effort: flags, then CI variables, then git. Nothing here fails a run - with
35
+ * no git at all every field may come back undefined, and the server treats
36
+ * the run as being on the project's default branch.
37
+ */
38
+ export async function detectGitContext(options = {}) {
39
+ const { overrides = {}, env = process.env, cwd = process.cwd() } = options;
40
+ const branch = first(overrides.branch,
41
+ // Pull request events check out a detached merge commit; this is the PR's branch.
42
+ env.GITHUB_HEAD_REF, env.CI_MERGE_REQUEST_SOURCE_BRANCH_NAME, env.GITHUB_REF_TYPE === 'branch' ? env.GITHUB_REF_NAME : undefined,
43
+ // Unlike CI_COMMIT_REF_NAME, never a tag.
44
+ env.CI_COMMIT_BRANCH) ?? (await tryGit(['symbolic-ref', '--short', '-q', 'HEAD'], cwd));
45
+ const commit = first(overrides.commit, await githubPullRequestHead(env), env.GITHUB_SHA,
46
+ // Set in merged-results pipelines, where CI_COMMIT_SHA is the merge commit.
47
+ env.CI_MERGE_REQUEST_SOURCE_BRANCH_SHA, env.CI_COMMIT_SHA) ?? (await tryGit(['rev-parse', 'HEAD'], cwd));
48
+ const baseBranch = first(overrides.baseBranch, env.GITHUB_BASE_REF, env.CI_MERGE_REQUEST_TARGET_BRANCH_NAME);
49
+ let mergeBase;
50
+ if (baseBranch && baseBranch !== branch) {
51
+ // The remote first: a local copy of the base is often behind it.
52
+ const refs = [`origin/${baseBranch}`, baseBranch];
53
+ // On a GitHub PR, HEAD is the merge commit, whose merge base with the
54
+ // target is the target itself; the PR's own head gives the fork point.
55
+ const heads = [...new Set([commit, 'HEAD'].filter((h) => Boolean(h)))];
56
+ for (const head of heads) {
57
+ mergeBase = (await findMergeBase(refs, cwd, head))?.base;
58
+ if (mergeBase)
59
+ break;
60
+ }
61
+ }
62
+ return { branch, commit, baseBranch, mergeBase };
63
+ }
64
+ /** "Branch feature/x (compared against main @ abc1234)", or what was not detected. */
65
+ export function describeGitContext(context) {
66
+ if (!context.branch) {
67
+ return "Branch: not detected - using the project's default branch (pass --branch to name one)";
68
+ }
69
+ if (!context.baseBranch || context.baseBranch === context.branch) {
70
+ return `Branch: ${context.branch}`;
71
+ }
72
+ const at = context.mergeBase ? ` @ ${context.mergeBase.slice(0, 7)}` : '';
73
+ return `Branch: ${context.branch} (compared against ${context.baseBranch}${at})`;
74
+ }
75
+ //# sourceMappingURL=git-context.js.map
@@ -0,0 +1,11 @@
1
+ export declare function git(args: string[], cwd: string): Promise<string>;
2
+ /**
3
+ * The commit `head` branched off the first of `refs` that resolves, or
4
+ * undefined when none does (no git, not a repository, or a shallow clone
5
+ * that never fetched the ref).
6
+ */
7
+ export declare function findMergeBase(refs: string[], cwd: string, head?: string): Promise<{
8
+ ref: string;
9
+ base: string;
10
+ } | undefined>;
11
+ //# sourceMappingURL=git.d.ts.map
@@ -0,0 +1,25 @@
1
+ import { execFile } from 'node:child_process';
2
+ import { promisify } from 'node:util';
3
+ const execFileAsync = promisify(execFile);
4
+ export async function git(args, cwd) {
5
+ const { stdout } = await execFileAsync('git', args, { cwd, maxBuffer: 64 * 1024 * 1024 });
6
+ return stdout;
7
+ }
8
+ /**
9
+ * The commit `head` branched off the first of `refs` that resolves, or
10
+ * undefined when none does (no git, not a repository, or a shallow clone
11
+ * that never fetched the ref).
12
+ */
13
+ export async function findMergeBase(refs, cwd, head = 'HEAD') {
14
+ for (const ref of refs) {
15
+ try {
16
+ const base = (await git(['merge-base', ref, head], cwd)).trim();
17
+ return { ref, base };
18
+ }
19
+ catch {
20
+ // Try the next candidate
21
+ }
22
+ }
23
+ return undefined;
24
+ }
25
+ //# sourceMappingURL=git.js.map
@@ -0,0 +1,3 @@
1
+ /** SHA-256 of a screenshot's PNG bytes, hex encoded. */
2
+ export declare function hashScreenshot(buffer: Buffer): string;
3
+ //# sourceMappingURL=hash.d.ts.map
@@ -0,0 +1,6 @@
1
+ import { createHash } from 'node:crypto';
2
+ /** SHA-256 of a screenshot's PNG bytes, hex encoded. */
3
+ export function hashScreenshot(buffer) {
4
+ return createHash('sha256').update(buffer).digest('hex');
5
+ }
6
+ //# sourceMappingURL=hash.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@storysnap/cli",
3
- "version": "2.0.0",
3
+ "version": "2.1.0",
4
4
  "description": "Visual regression testing for Storybook - capture screenshots, detect changes, and maintain baselines",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",