@recursica/adapter-tester 2.2.0 → 4.0.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.
- package/README.md +69 -23
- package/dist/adapter-tester.schema.json.d.ts +24 -11
- package/dist/cli.cjs +32 -23
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +296 -4853
- package/dist/cli.js.map +1 -1
- package/dist/config.d.ts +57 -6
- package/dist/config.d.ts.map +1 -1
- package/dist/fileConfig.d.ts +21 -5
- package/dist/fileConfig.d.ts.map +1 -1
- package/dist/golden/diffPng.d.ts +13 -0
- package/dist/golden/diffPng.d.ts.map +1 -0
- package/dist/golden/manifest.schema.json.d.ts +27 -0
- package/dist/golden/manifestStore.d.ts +33 -0
- package/dist/golden/manifestStore.d.ts.map +1 -0
- package/dist/golden/resolveSourceOfTruthGolden.d.ts +29 -0
- package/dist/golden/resolveSourceOfTruthGolden.d.ts.map +1 -0
- package/dist/golden/validateManifest.d.ts +7 -0
- package/dist/golden/validateManifest.d.ts.map +1 -0
- package/dist/index-C6uYPRmx.cjs +9 -0
- package/dist/index-C6uYPRmx.cjs.map +1 -0
- package/dist/index-DqQzFSAH.js +4667 -0
- package/dist/index-DqQzFSAH.js.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +21 -6
- package/dist/index.js.map +1 -1
- package/dist/testing/runVisualRegression.d.ts +48 -6
- package/dist/testing/runVisualRegression.d.ts.map +1 -1
- package/dist/testing.cjs +4 -1
- package/dist/testing.cjs.map +1 -1
- package/dist/testing.d.ts +1 -1
- package/dist/testing.d.ts.map +1 -1
- package/dist/testing.js +311 -155
- package/dist/testing.js.map +1 -1
- package/package.json +4 -7
- package/src/adapter-tester.schema.json +24 -11
- package/src/golden/manifest.schema.json +24 -0
- package/dist/config-B0Eop8Az.cjs +0 -2
- package/dist/config-B0Eop8Az.cjs.map +0 -1
- package/dist/config-CDxTeSAY.js +0 -21
- package/dist/config-CDxTeSAY.js.map +0 -1
package/dist/config.d.ts
CHANGED
|
@@ -9,18 +9,53 @@ export interface AdapterTarget {
|
|
|
9
9
|
*/
|
|
10
10
|
sourceOfTruth?: boolean;
|
|
11
11
|
}
|
|
12
|
+
/** How `resolveVisualRegressionPlan` reaches the source-of-truth adapter's (mantine)
|
|
13
|
+
* own golden images, for the divergence check. Never involves booting a
|
|
14
|
+
* Storybook — both `readImage` targets are plain files on disk. */
|
|
15
|
+
export type SourceOfTruthGoldenLocation = {
|
|
16
|
+
/** Sibling package already checked out locally (this monorepo's own
|
|
17
|
+
* `sourceOfTruth.type: "url"` mode) — read its `test/golden/` directly. */
|
|
18
|
+
type: "local";
|
|
19
|
+
/** Absolute path to the source-of-truth adapter's `test/golden/` directory. */
|
|
20
|
+
dir: string;
|
|
21
|
+
} | {
|
|
22
|
+
/** No local checkout (the default, standalone-repo mode) — resolve the
|
|
23
|
+
* installed version against the npm registry, then fetch that git tag's
|
|
24
|
+
* `test/golden/` from the public GitHub repo, caching what's downloaded. */
|
|
25
|
+
type: "npm";
|
|
26
|
+
packageName: string;
|
|
27
|
+
/** npm version/dist-tag to resolve, e.g. "latest" or a pinned version. */
|
|
28
|
+
versionSpec: string;
|
|
29
|
+
/** Directory downloaded manifest/images are cached in between runs. */
|
|
30
|
+
cacheDir: string;
|
|
31
|
+
};
|
|
32
|
+
export type GoldenMode = "check" | "update-golden" | "approve-divergence";
|
|
33
|
+
/**
|
|
34
|
+
* Which check(s) a run performs. `"own"` (the default) is what a normal,
|
|
35
|
+
* fast, no-network run does: this project's own live render vs. its own
|
|
36
|
+
* committed golden images. `"divergence"` is the separate, opt-in check
|
|
37
|
+
* against the source-of-truth adapter's published golden images.
|
|
38
|
+
*/
|
|
39
|
+
export type CheckMode = "own" | "divergence";
|
|
40
|
+
export interface StoryOverride {
|
|
41
|
+
/** Diff threshold override for this story. Overrides `diffThresholdPixels`
|
|
42
|
+
* for components with acceptable cross-library structural variation (e.g.
|
|
43
|
+
* native control widgets). */
|
|
44
|
+
threshold?: number;
|
|
45
|
+
/** Skip this story entirely — no own-drift check, no divergence check, no
|
|
46
|
+
* golden captured. For stories with no meaningful cross-adapter counterpart. */
|
|
47
|
+
exclude?: boolean;
|
|
48
|
+
}
|
|
12
49
|
export interface AdapterTesterConfig {
|
|
13
50
|
targets: AdapterTarget[];
|
|
14
51
|
/** Global pixel-diff threshold applied to every story comparison. */
|
|
15
52
|
diffThresholdPixels: number;
|
|
16
53
|
/**
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
54
|
+
* Per-story overrides, keyed by story id prefix (a story matches if its id
|
|
55
|
+
* equals the key or starts with it). When more than one key matches, the
|
|
56
|
+
* longest (most specific) key wins.
|
|
20
57
|
*/
|
|
21
|
-
|
|
22
|
-
/** Pixel-diff threshold applied to `relaxedThresholdStoryIds`. */
|
|
23
|
-
relaxedThresholdPixels?: number;
|
|
58
|
+
stories?: Record<string, StoryOverride>;
|
|
24
59
|
/**
|
|
25
60
|
* Storybook entry title categories excluded from the comparison — an
|
|
26
61
|
* entry is excluded if its title equals one of these or starts with
|
|
@@ -31,6 +66,22 @@ export interface AdapterTesterConfig {
|
|
|
31
66
|
* cross-adapter counterpart to diff against.
|
|
32
67
|
*/
|
|
33
68
|
excludeTitlePrefixes?: string[];
|
|
69
|
+
/** Absolute path to this project's own `test/golden/` directory — where
|
|
70
|
+
* golden PNGs and `manifest.json` are stored, committed to git. */
|
|
71
|
+
goldenDir: string;
|
|
72
|
+
/**
|
|
73
|
+
* True only for the source-of-truth adapter's own config (mantine). It has
|
|
74
|
+
* nothing above it to diverge from, so the divergence check is skipped
|
|
75
|
+
* entirely and `sourceOfTruthGolden` is ignored.
|
|
76
|
+
*/
|
|
77
|
+
isSourceOfTruthAdapter: boolean;
|
|
78
|
+
/** How to reach the source-of-truth's golden images. Required unless
|
|
79
|
+
* `isSourceOfTruthAdapter` is true. */
|
|
80
|
+
sourceOfTruthGolden?: SourceOfTruthGoldenLocation;
|
|
81
|
+
/** Set by the CLI from `--update-golden`/`--approve-divergence`. Defaults to `"check"`. */
|
|
82
|
+
goldenMode: GoldenMode;
|
|
83
|
+
/** Set by the CLI from `--divergence-only`. Defaults to `"own"`. */
|
|
84
|
+
checkMode: CheckMode;
|
|
34
85
|
}
|
|
35
86
|
export declare function defineAdapterTesterConfig(config: AdapterTesterConfig): AdapterTesterConfig;
|
|
36
87
|
export declare function getSourceOfTruth(config: AdapterTesterConfig): AdapterTarget;
|
package/dist/config.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,aAAa;IAC5B,sFAAsF;IACtF,IAAI,EAAE,MAAM,CAAC;IACb,+DAA+D;IAC/D,GAAG,EAAE,MAAM,CAAC;IACZ;;;OAGG;IACH,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB;AAED,MAAM,WAAW,mBAAmB;IAClC,OAAO,EAAE,aAAa,EAAE,CAAC;IACzB,qEAAqE;IACrE,mBAAmB,EAAE,MAAM,CAAC;IAC5B;;;;OAIG;IACH,
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,aAAa;IAC5B,sFAAsF;IACtF,IAAI,EAAE,MAAM,CAAC;IACb,+DAA+D;IAC/D,GAAG,EAAE,MAAM,CAAC;IACZ;;;OAGG;IACH,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB;AAED;;mEAEmE;AACnE,MAAM,MAAM,2BAA2B,GACnC;IACE;+EAC2E;IAC3E,IAAI,EAAE,OAAO,CAAC;IACd,+EAA+E;IAC/E,GAAG,EAAE,MAAM,CAAC;CACb,GACD;IACE;;gFAE4E;IAC5E,IAAI,EAAE,KAAK,CAAC;IACZ,WAAW,EAAE,MAAM,CAAC;IACpB,0EAA0E;IAC1E,WAAW,EAAE,MAAM,CAAC;IACpB,uEAAuE;IACvE,QAAQ,EAAE,MAAM,CAAC;CAClB,CAAC;AAEN,MAAM,MAAM,UAAU,GAAG,OAAO,GAAG,eAAe,GAAG,oBAAoB,CAAC;AAE1E;;;;;GAKG;AACH,MAAM,MAAM,SAAS,GAAG,KAAK,GAAG,YAAY,CAAC;AAE7C,MAAM,WAAW,aAAa;IAC5B;;kCAE8B;IAC9B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;oFACgF;IAChF,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED,MAAM,WAAW,mBAAmB;IAClC,OAAO,EAAE,aAAa,EAAE,CAAC;IACzB,qEAAqE;IACrE,mBAAmB,EAAE,MAAM,CAAC;IAC5B;;;;OAIG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC;IACxC;;;;;;;;OAQG;IACH,oBAAoB,CAAC,EAAE,MAAM,EAAE,CAAC;IAChC;uEACmE;IACnE,SAAS,EAAE,MAAM,CAAC;IAClB;;;;OAIG;IACH,sBAAsB,EAAE,OAAO,CAAC;IAChC;2CACuC;IACvC,mBAAmB,CAAC,EAAE,2BAA2B,CAAC;IAClD,2FAA2F;IAC3F,UAAU,EAAE,UAAU,CAAC;IACvB,oEAAoE;IACpE,SAAS,EAAE,SAAS,CAAC;CACtB;AAED,wBAAgB,yBAAyB,CACvC,MAAM,EAAE,mBAAmB,GAC1B,mBAAmB,CAUrB;AAED,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,mBAAmB,GAAG,aAAa,CAM3E"}
|
package/dist/fileConfig.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AdapterTesterConfig } from './config.js';
|
|
1
|
+
import { AdapterTesterConfig, StoryOverride } from './config.js';
|
|
2
2
|
import { HarnessWebServerConfig } from './harness/mantineSourceOfTruth.js';
|
|
3
3
|
export declare const CONFIG_FILE_NAME = "adapter-tester.config.json";
|
|
4
4
|
interface StorybookTargetFileConfig {
|
|
@@ -36,25 +36,41 @@ export interface AdapterTesterFileConfig {
|
|
|
36
36
|
storybook?: StorybookTargetFileConfig;
|
|
37
37
|
sourceOfTruth?: SourceOfTruthFileConfig;
|
|
38
38
|
diffThresholdPixels?: number;
|
|
39
|
-
|
|
40
|
-
relaxedThresholdPixels?: number;
|
|
39
|
+
stories?: Record<string, StoryOverride>;
|
|
41
40
|
excludeTitlePrefixes?: string[];
|
|
41
|
+
/**
|
|
42
|
+
* True only for the source-of-truth adapter's own config (mantine-adapter).
|
|
43
|
+
* Skips `sourceOfTruth` entirely — there's nothing above it to diverge
|
|
44
|
+
* from — and runs the own-drift golden check standalone, against just this
|
|
45
|
+
* project's own Storybook. Defaults to false.
|
|
46
|
+
*/
|
|
47
|
+
isSourceOfTruthAdapter?: boolean;
|
|
42
48
|
}
|
|
43
49
|
export interface ResolvedAdapterTesterConfig {
|
|
44
50
|
engineConfig: AdapterTesterConfig;
|
|
45
51
|
webServers: HarnessWebServerConfig[];
|
|
46
52
|
}
|
|
53
|
+
export interface ResolveConfigOverrides {
|
|
54
|
+
/** From `--source-of-truth-version`. Overrides `sourceOfTruth.mantineAdapterVersion`. */
|
|
55
|
+
mantineAdapterVersion?: string;
|
|
56
|
+
}
|
|
47
57
|
/**
|
|
48
58
|
* Loads `adapter-tester.config.json` from `cwd` (or falls back to defaults
|
|
49
59
|
* when the file doesn't exist) and resolves it into the engine config
|
|
50
|
-
* `
|
|
60
|
+
* `resolveVisualRegressionPlan` consumes plus the Playwright `webServer` entries
|
|
51
61
|
* needed to boot both sides of the comparison.
|
|
52
62
|
*
|
|
53
63
|
* Default mode (no `sourceOfTruth`/`storybook` set): compares this project's
|
|
54
64
|
* own Storybook against a throwaway Mantine harness — no monorepo checkout
|
|
55
65
|
* required. Set `sourceOfTruth.type: "url"` for the non-standard mode used
|
|
56
66
|
* to compare sibling workspace packages inside this monorepo.
|
|
67
|
+
*
|
|
68
|
+
* `overrides.mantineAdapterVersion` (from `--source-of-truth-version`) pins
|
|
69
|
+
* the mantine-harness install/golden-fetch version for this run, overriding
|
|
70
|
+
* `sourceOfTruth.mantineAdapterVersion`. Throws if passed together with
|
|
71
|
+
* `isSourceOfTruthAdapter` or `sourceOfTruth.type: "url"` — neither has a
|
|
72
|
+
* version to pin.
|
|
57
73
|
*/
|
|
58
|
-
export declare function resolveConfig(cwd: string): ResolvedAdapterTesterConfig;
|
|
74
|
+
export declare function resolveConfig(cwd: string, overrides?: ResolveConfigOverrides): ResolvedAdapterTesterConfig;
|
|
59
75
|
export {};
|
|
60
76
|
//# sourceMappingURL=fileConfig.d.ts.map
|
package/dist/fileConfig.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fileConfig.d.ts","sourceRoot":"","sources":["../src/fileConfig.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"fileConfig.d.ts","sourceRoot":"","sources":["../src/fileConfig.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,mBAAmB,EAEnB,aAAa,EACd,MAAM,aAAa,CAAC;AACrB,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,mCAAmC,CAAC;AAMhF,eAAO,MAAM,gBAAgB,+BAA+B,CAAC;AAO7D,UAAU,yBAAyB;IACjC;;wEAEoE;IACpE,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,kFAAkF;IAClF,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,kFAAkF;IAClF,GAAG,CAAC,EAAE,MAAM,CAAC;CACd;AAED,UAAU,qCAAqC;IAC7C;gFAC4E;IAC5E,IAAI,CAAC,EAAE,iBAAiB,CAAC;IACzB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,qBAAqB,CAAC,EAAE,MAAM,CAAC;IAC/B,wBAAwB,CAAC,EAAE,MAAM,CAAC;CACnC;AAED,UAAU,0BAA0B;IAClC;yEACqE;IACrE,IAAI,EAAE,KAAK,CAAC;IACZ,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,GAAG,CAAC,EAAE,MAAM,CAAC;CACd;AAED,KAAK,uBAAuB,GACxB,qCAAqC,GACrC,0BAA0B,CAAC;AAE/B,MAAM,WAAW,uBAAuB;IACtC;uFACmF;IACnF,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,yBAAyB,CAAC;IACtC,aAAa,CAAC,EAAE,uBAAuB,CAAC;IACxC,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC;IACxC,oBAAoB,CAAC,EAAE,MAAM,EAAE,CAAC;IAChC;;;;;OAKG;IACH,sBAAsB,CAAC,EAAE,OAAO,CAAC;CAClC;AAED,MAAM,WAAW,2BAA2B;IAC1C,YAAY,EAAE,mBAAmB,CAAC;IAClC,UAAU,EAAE,sBAAsB,EAAE,CAAC;CACtC;AAED,MAAM,WAAW,sBAAsB;IACrC,yFAAyF;IACzF,qBAAqB,CAAC,EAAE,MAAM,CAAC;CAChC;AAmCD;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,aAAa,CAC3B,GAAG,EAAE,MAAM,EACX,SAAS,GAAE,sBAA2B,GACrC,2BAA2B,CA8H7B"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export interface PngDiffResult {
|
|
2
|
+
/** Mismatched-pixel count, or `Infinity` if the two images aren't even the
|
|
3
|
+
* same dimensions — pixelmatch itself throws on a size mismatch, and a size
|
|
4
|
+
* mismatch is itself a real difference, not something to swallow. */
|
|
5
|
+
diffPixels: number;
|
|
6
|
+
/** Visual highlight of the mismatched pixels, encoded as a PNG buffer.
|
|
7
|
+
* `null` when `diffPixels` is `Infinity` — there's no pixel-aligned diff to
|
|
8
|
+
* render across two different-sized images. */
|
|
9
|
+
diffImage: Buffer | null;
|
|
10
|
+
}
|
|
11
|
+
/** Pixel-diffs two PNG buffers. */
|
|
12
|
+
export declare function diffPngBuffers(a: Buffer, b: Buffer): PngDiffResult;
|
|
13
|
+
//# sourceMappingURL=diffPng.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"diffPng.d.ts","sourceRoot":"","sources":["../../src/golden/diffPng.ts"],"names":[],"mappings":"AAGA,MAAM,WAAW,aAAa;IAC5B;;yEAEqE;IACrE,UAAU,EAAE,MAAM,CAAC;IACnB;;mDAE+C;IAC/C,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;CAC1B;AAED,mCAAmC;AACnC,wBAAgB,cAAc,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,aAAa,CAgBlE"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
declare const _default: {
|
|
2
|
+
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
3
|
+
"$id": "https://github.com/borderux/recursica/tree/main/packages/adapter-tester/src/golden/manifest.schema.json",
|
|
4
|
+
"title": "test/golden/manifest.json",
|
|
5
|
+
"description": "Tracks golden (baseline) image metadata for @recursica/adapter-tester's golden-image visual regression checks. One manifest lives alongside its adapter's test/golden/<story-id>.png files, keyed by story id.",
|
|
6
|
+
"type": "object",
|
|
7
|
+
"additionalProperties": {
|
|
8
|
+
"type": "object",
|
|
9
|
+
"additionalProperties": false,
|
|
10
|
+
"required": ["createdAt"],
|
|
11
|
+
"properties": {
|
|
12
|
+
"createdAt": {
|
|
13
|
+
"type": "string",
|
|
14
|
+
"format": "date-time",
|
|
15
|
+
"description": "When this story's own golden PNG was last captured, via --update-golden, --approve-divergence, or first-run auto-create."
|
|
16
|
+
},
|
|
17
|
+
"sourceOfTruthCreatedAt": {
|
|
18
|
+
"type": "string",
|
|
19
|
+
"format": "date-time",
|
|
20
|
+
"description": "The source-of-truth adapter's (mantine) manifest `createdAt` for this story at the time this adapter's divergence from it was last reviewed via --approve-divergence. Omitted on the source-of-truth adapter's own manifest, and omitted here until the first approval. If mantine's current `createdAt` for this story is newer than this value, the divergence is flagged again for re-review."
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
;
|
|
26
|
+
|
|
27
|
+
export default _default;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
export interface GoldenManifestEntry {
|
|
2
|
+
createdAt: string;
|
|
3
|
+
sourceOfTruthCreatedAt?: string;
|
|
4
|
+
}
|
|
5
|
+
export type GoldenManifest = Record<string, GoldenManifestEntry>;
|
|
6
|
+
export declare function manifestPath(goldenDir: string): string;
|
|
7
|
+
export declare function goldenImagePath(goldenDir: string, storyId: string): string;
|
|
8
|
+
/** Returns `{}` if no manifest exists yet — a fresh adapter with no goldens
|
|
9
|
+
* captured is the normal starting state, not an error. */
|
|
10
|
+
export declare function loadManifest(goldenDir: string): GoldenManifest;
|
|
11
|
+
/** Validates before writing, and sorts keys so the diff on a reviewed PR is
|
|
12
|
+
* stable regardless of the order stories happened to run in. Writes to a
|
|
13
|
+
* temp file and renames over the real one — `rename` is atomic, so a
|
|
14
|
+
* concurrent `loadManifest` (running in another Playwright worker) never
|
|
15
|
+
* observes a half-written file. */
|
|
16
|
+
export declare function saveManifest(goldenDir: string, manifest: GoldenManifest): void;
|
|
17
|
+
/** Runs `updater` against this story's manifest entry under an exclusive
|
|
18
|
+
* lock on `manifest.json`: reloads the manifest fresh, applies `updater`,
|
|
19
|
+
* and saves it back, all before releasing the lock. Concurrent Playwright
|
|
20
|
+
* workers each own a different story, so this is the only section that
|
|
21
|
+
* needs to serialize — everything else about a story (its screenshot, its
|
|
22
|
+
* golden image file, its diff) is independent of every other story. */
|
|
23
|
+
export declare function updateManifestEntry(goldenDir: string, storyId: string, updater: (entry: GoldenManifestEntry | undefined) => GoldenManifestEntry | undefined): Promise<GoldenManifestEntry | undefined>;
|
|
24
|
+
export declare function saveGoldenImage(goldenDir: string, storyId: string, buffer: Buffer): void;
|
|
25
|
+
/** Removes the golden `.png` + manifest entry for every story id in the
|
|
26
|
+
* manifest that isn't in `currentStoryIds` (e.g. a story renamed or deleted
|
|
27
|
+
* from Storybook) — otherwise those never get cleaned up on their own,
|
|
28
|
+
* since a run only ever adds/updates entries for stories it actually saw.
|
|
29
|
+
* Returns the pruned ids, for the caller to report. Both the file removal
|
|
30
|
+
* and the manifest delete are idempotent, so it's safe for this to run
|
|
31
|
+
* redundantly from more than one Playwright worker. */
|
|
32
|
+
export declare function pruneOrphanedGoldens(goldenDir: string, currentStoryIds: ReadonlySet<string>): Promise<string[]>;
|
|
33
|
+
//# sourceMappingURL=manifestStore.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"manifestStore.d.ts","sourceRoot":"","sources":["../../src/golden/manifestStore.ts"],"names":[],"mappings":"AAcA,MAAM,WAAW,mBAAmB;IAClC,SAAS,EAAE,MAAM,CAAC;IAClB,sBAAsB,CAAC,EAAE,MAAM,CAAC;CACjC;AAED,MAAM,MAAM,cAAc,GAAG,MAAM,CAAC,MAAM,EAAE,mBAAmB,CAAC,CAAC;AAEjE,wBAAgB,YAAY,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAEtD;AAMD,wBAAgB,eAAe,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,CAE1E;AAED;0DAC0D;AAC1D,wBAAgB,YAAY,CAAC,SAAS,EAAE,MAAM,GAAG,cAAc,CAM9D;AAED;;;;mCAImC;AACnC,wBAAgB,YAAY,CAC1B,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,cAAc,GACvB,IAAI,CAWN;AAqCD;;;;;uEAKuE;AACvE,wBAAsB,mBAAmB,CACvC,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,CACP,KAAK,EAAE,mBAAmB,GAAG,SAAS,KACnC,mBAAmB,GAAG,SAAS,GACnC,OAAO,CAAC,mBAAmB,GAAG,SAAS,CAAC,CAe1C;AAED,wBAAgB,eAAe,CAC7B,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,MAAM,GACb,IAAI,CAGN;AAED;;;;;;uDAMuD;AACvD,wBAAsB,oBAAoB,CACxC,SAAS,EAAE,MAAM,EACjB,eAAe,EAAE,WAAW,CAAC,MAAM,CAAC,GACnC,OAAO,CAAC,MAAM,EAAE,CAAC,CAWnB"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { SourceOfTruthGoldenLocation } from '../config.js';
|
|
2
|
+
import { GoldenManifest } from './manifestStore.js';
|
|
3
|
+
export interface SourceOfTruthGolden {
|
|
4
|
+
manifest: GoldenManifest;
|
|
5
|
+
/** Returns the golden PNG bytes for a story, or `null` if the source of
|
|
6
|
+
* truth has no golden captured for it yet. */
|
|
7
|
+
readImage(storyId: string): Promise<Buffer | null>;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Resolves the source-of-truth adapter's golden images for the divergence
|
|
11
|
+
* check. Never boots a Storybook — both location types resolve to plain
|
|
12
|
+
* files, fetched once and cached, not re-diffed per pixel over the wire.
|
|
13
|
+
*
|
|
14
|
+
* `location.type === "local"`: a sibling package already checked out (this
|
|
15
|
+
* monorepo's own `sourceOfTruth.type: "url"` mode) — read its
|
|
16
|
+
* `test/golden/` directly, including any uncommitted local changes.
|
|
17
|
+
*
|
|
18
|
+
* `location.type === "npm"`: no local checkout (the default, standalone-repo
|
|
19
|
+
* mode) — resolve the installed version against the npm registry, then fetch
|
|
20
|
+
* that exact version's `test/golden/` from the public GitHub repo at the
|
|
21
|
+
* matching release tag (changesets tags every release as
|
|
22
|
+
* `<packageName>@<version>`), caching what's downloaded under `cacheDir`.
|
|
23
|
+
*
|
|
24
|
+
* Returns `null` — degrading the divergence check to a skip, not a failure —
|
|
25
|
+
* when no golden baseline exists yet for this version, or the registry/repo
|
|
26
|
+
* is unreachable.
|
|
27
|
+
*/
|
|
28
|
+
export declare function resolveSourceOfTruthGolden(location: SourceOfTruthGoldenLocation): Promise<SourceOfTruthGolden | null>;
|
|
29
|
+
//# sourceMappingURL=resolveSourceOfTruthGolden.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolveSourceOfTruthGolden.d.ts","sourceRoot":"","sources":["../../src/golden/resolveSourceOfTruthGolden.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,cAAc,CAAC;AAChE,OAAO,EAIL,KAAK,cAAc,EACpB,MAAM,oBAAoB,CAAC;AAK5B,MAAM,WAAW,mBAAmB;IAClC,QAAQ,EAAE,cAAc,CAAC;IACzB;kDAC8C;IAC9C,SAAS,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;CACpD;AAkCD;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAsB,0BAA0B,CAC9C,QAAQ,EAAE,2BAA2B,GACpC,OAAO,CAAC,mBAAmB,GAAG,IAAI,CAAC,CA8ErC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Validates a parsed `test/golden/manifest.json` against `manifest.schema.json`.
|
|
3
|
+
* Throws with every violation listed — callers must not silently coerce or
|
|
4
|
+
* drop invalid entries.
|
|
5
|
+
*/
|
|
6
|
+
export declare function validateGoldenManifest(data: unknown, path: string): void;
|
|
7
|
+
//# sourceMappingURL=validateManifest.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validateManifest.d.ts","sourceRoot":"","sources":["../../src/golden/validateManifest.ts"],"names":[],"mappings":"AAaA;;;;GAIG;AACH,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI,CAYxE"}
|