viewev 0.0.0-stage → 0.1.0-beta.1
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/LICENSE +21 -0
- package/README.md +148 -2
- package/assets/logo/Logo-horizontal.png +0 -0
- package/dist/adapters/storybook/index.d.ts +5 -0
- package/dist/adapters/storybook/index.js +4 -0
- package/dist/adapters/storybook/index.js.map +1 -0
- package/dist/adapters/storybook/provider.d.ts +24 -0
- package/dist/adapters/storybook/provider.js +114 -0
- package/dist/adapters/storybook/provider.js.map +1 -0
- package/dist/adapters/storybook/scenarios.d.ts +30 -0
- package/dist/adapters/storybook/scenarios.js +64 -0
- package/dist/adapters/storybook/scenarios.js.map +1 -0
- package/dist/adapters/storybook/static-server.d.ts +10 -0
- package/dist/adapters/storybook/static-server.js +105 -0
- package/dist/adapters/storybook/static-server.js.map +1 -0
- package/dist/adapters/storybook/storybook-index.d.ts +32 -0
- package/dist/adapters/storybook/storybook-index.js +35 -0
- package/dist/adapters/storybook/storybook-index.js.map +1 -0
- package/dist/baselines/environment-check.d.ts +7 -0
- package/dist/baselines/environment-check.js +24 -0
- package/dist/baselines/environment-check.js.map +1 -0
- package/dist/baselines/environment-key.d.ts +8 -0
- package/dist/baselines/environment-key.js +12 -0
- package/dist/baselines/environment-key.js.map +1 -0
- package/dist/baselines/file-store.d.ts +12 -0
- package/dist/baselines/file-store.js +81 -0
- package/dist/baselines/file-store.js.map +1 -0
- package/dist/baselines/git-store.d.ts +16 -0
- package/dist/baselines/git-store.js +150 -0
- package/dist/baselines/git-store.js.map +1 -0
- package/dist/baselines/memory-store.d.ts +3 -0
- package/dist/baselines/memory-store.js +15 -0
- package/dist/baselines/memory-store.js.map +1 -0
- package/dist/baselines/metadata.d.ts +16 -0
- package/dist/baselines/metadata.js +84 -0
- package/dist/baselines/metadata.js.map +1 -0
- package/dist/baselines/types.d.ts +33 -0
- package/dist/baselines/types.js +2 -0
- package/dist/baselines/types.js.map +1 -0
- package/dist/browser/playwright/capturer.d.ts +2 -0
- package/dist/browser/playwright/capturer.js +142 -0
- package/dist/browser/playwright/capturer.js.map +1 -0
- package/dist/browser/playwright/environment.d.ts +4 -0
- package/dist/browser/playwright/environment.js +36 -0
- package/dist/browser/playwright/environment.js.map +1 -0
- package/dist/browser/playwright/index.d.ts +1 -0
- package/dist/browser/playwright/index.js +2 -0
- package/dist/browser/playwright/index.js.map +1 -0
- package/dist/browser/types.d.ts +43 -0
- package/dist/browser/types.js +2 -0
- package/dist/browser/types.js.map +1 -0
- package/dist/ci/github-summary.d.ts +5 -0
- package/dist/ci/github-summary.js +110 -0
- package/dist/ci/github-summary.js.map +1 -0
- package/dist/cli/baseline-ref.d.ts +6 -0
- package/dist/cli/baseline-ref.js +11 -0
- package/dist/cli/baseline-ref.js.map +1 -0
- package/dist/cli/bin.d.ts +2 -0
- package/dist/cli/bin.js +13 -0
- package/dist/cli/bin.js.map +1 -0
- package/dist/cli/commands/baseline.d.ts +3 -0
- package/dist/cli/commands/baseline.js +90 -0
- package/dist/cli/commands/baseline.js.map +1 -0
- package/dist/cli/commands/capture.d.ts +3 -0
- package/dist/cli/commands/capture.js +42 -0
- package/dist/cli/commands/capture.js.map +1 -0
- package/dist/cli/commands/config.d.ts +3 -0
- package/dist/cli/commands/config.js +25 -0
- package/dist/cli/commands/config.js.map +1 -0
- package/dist/cli/commands/doctor.d.ts +3 -0
- package/dist/cli/commands/doctor.js +19 -0
- package/dist/cli/commands/doctor.js.map +1 -0
- package/dist/cli/commands/report.d.ts +3 -0
- package/dist/cli/commands/report.js +16 -0
- package/dist/cli/commands/report.js.map +1 -0
- package/dist/cli/commands/scenarios.d.ts +3 -0
- package/dist/cli/commands/scenarios.js +30 -0
- package/dist/cli/commands/scenarios.js.map +1 -0
- package/dist/cli/commands/test.d.ts +3 -0
- package/dist/cli/commands/test.js +285 -0
- package/dist/cli/commands/test.js.map +1 -0
- package/dist/cli/context.d.ts +21 -0
- package/dist/cli/context.js +22 -0
- package/dist/cli/context.js.map +1 -0
- package/dist/cli/doctor.d.ts +12 -0
- package/dist/cli/doctor.js +113 -0
- package/dist/cli/doctor.js.map +1 -0
- package/dist/cli/format.d.ts +17 -0
- package/dist/cli/format.js +128 -0
- package/dist/cli/format.js.map +1 -0
- package/dist/cli/impact.d.ts +16 -0
- package/dist/cli/impact.js +63 -0
- package/dist/cli/impact.js.map +1 -0
- package/dist/cli/program.d.ts +11 -0
- package/dist/cli/program.js +70 -0
- package/dist/cli/program.js.map +1 -0
- package/dist/cli/session.d.ts +27 -0
- package/dist/cli/session.js +53 -0
- package/dist/cli/session.js.map +1 -0
- package/dist/comparison/compare.d.ts +11 -0
- package/dist/comparison/compare.js +41 -0
- package/dist/comparison/compare.js.map +1 -0
- package/dist/comparison/types.d.ts +34 -0
- package/dist/comparison/types.js +2 -0
- package/dist/comparison/types.js.map +1 -0
- package/dist/config/load.d.ts +23 -0
- package/dist/config/load.js +93 -0
- package/dist/config/load.js.map +1 -0
- package/dist/config/schema.d.ts +473 -0
- package/dist/config/schema.js +157 -0
- package/dist/config/schema.js.map +1 -0
- package/dist/core/artifacts.d.ts +6 -0
- package/dist/core/artifacts.js +2 -0
- package/dist/core/artifacts.js.map +1 -0
- package/dist/core/baseline-run.d.ts +37 -0
- package/dist/core/baseline-run.js +85 -0
- package/dist/core/baseline-run.js.map +1 -0
- package/dist/core/capture-settings.d.ts +6 -0
- package/dist/core/capture-settings.js +21 -0
- package/dist/core/capture-settings.js.map +1 -0
- package/dist/core/discovery.d.ts +3 -0
- package/dist/core/discovery.js +17 -0
- package/dist/core/discovery.js.map +1 -0
- package/dist/core/impact.d.ts +19 -0
- package/dist/core/impact.js +28 -0
- package/dist/core/impact.js.map +1 -0
- package/dist/core/pool.d.ts +5 -0
- package/dist/core/pool.js +21 -0
- package/dist/core/pool.js.map +1 -0
- package/dist/core/result.d.ts +117 -0
- package/dist/core/result.js +53 -0
- package/dist/core/result.js.map +1 -0
- package/dist/core/selection.d.ts +8 -0
- package/dist/core/selection.js +8 -0
- package/dist/core/selection.js.map +1 -0
- package/dist/core/test-run.d.ts +40 -0
- package/dist/core/test-run.js +141 -0
- package/dist/core/test-run.js.map +1 -0
- package/dist/impact/git.d.ts +17 -0
- package/dist/impact/git.js +55 -0
- package/dist/impact/git.js.map +1 -0
- package/dist/impact/storybook.d.ts +16 -0
- package/dist/impact/storybook.js +324 -0
- package/dist/impact/storybook.js.map +1 -0
- package/dist/impact/types.d.ts +28 -0
- package/dist/impact/types.js +23 -0
- package/dist/impact/types.js.map +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -0
- package/dist/reference/build.d.ts +10 -0
- package/dist/reference/build.js +36 -0
- package/dist/reference/build.js.map +1 -0
- package/dist/reference/git-worktree.d.ts +8 -0
- package/dist/reference/git-worktree.js +77 -0
- package/dist/reference/git-worktree.js.map +1 -0
- package/dist/reference/open.d.ts +13 -0
- package/dist/reference/open.js +66 -0
- package/dist/reference/open.js.map +1 -0
- package/dist/reporting/artifacts.d.ts +8 -0
- package/dist/reporting/artifacts.js +23 -0
- package/dist/reporting/artifacts.js.map +1 -0
- package/dist/reporting/html.d.ts +4 -0
- package/dist/reporting/html.js +251 -0
- package/dist/reporting/html.js.map +1 -0
- package/dist/reporting/report.d.ts +12 -0
- package/dist/reporting/report.js +55 -0
- package/dist/reporting/report.js.map +1 -0
- package/dist/reporting/results-json.d.ts +36 -0
- package/dist/reporting/results-json.js +38 -0
- package/dist/reporting/results-json.js.map +1 -0
- package/dist/scenarios/glob.d.ts +7 -0
- package/dist/scenarios/glob.js +21 -0
- package/dist/scenarios/glob.js.map +1 -0
- package/dist/scenarios/model.d.ts +61 -0
- package/dist/scenarios/model.js +31 -0
- package/dist/scenarios/model.js.map +1 -0
- package/dist/scenarios/schema.d.ts +8 -0
- package/dist/scenarios/schema.js +70 -0
- package/dist/scenarios/schema.js.map +1 -0
- package/dist/shared/environment.d.ts +23 -0
- package/dist/shared/environment.js +2 -0
- package/dist/shared/environment.js.map +1 -0
- package/dist/shared/errors.d.ts +23 -0
- package/dist/shared/errors.js +29 -0
- package/dist/shared/errors.js.map +1 -0
- package/dist/shared/png.d.ts +3 -0
- package/dist/shared/png.js +14 -0
- package/dist/shared/png.js.map +1 -0
- package/dist/shared/size.d.ts +4 -0
- package/dist/shared/size.js +2 -0
- package/dist/shared/size.js.map +1 -0
- package/docs/architecture.md +176 -0
- package/docs/ci.md +86 -0
- package/docs/impact.md +61 -0
- package/docs/publishing.md +35 -0
- package/package.json +58 -4
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"git-worktree.js","sourceRoot":"","sources":["../../src/reference/git-worktree.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,EAAE,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACjC,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAElD,MAAM,aAAa,GAAG,SAAS,CAAC,QAAQ,CAAC,CAAC;AAE1C,KAAK,UAAU,GAAG,CAAC,GAAW,EAAE,IAAuB;IACrD,IAAI,CAAC;QACH,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,aAAa,CAAC,KAAK,EAAE,CAAC,GAAG,IAAI,CAAC,EAAE;YACvD,GAAG;YACH,SAAS,EAAE,EAAE,GAAG,IAAI,GAAG,IAAI;SAC5B,CAAC,CAAC;QACH,OAAO,MAAM,CAAC,IAAI,EAAE,CAAC;IACvB,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,MAAM,GAAI,KAA8B,CAAC,MAAM,CAAC;QACtD,MAAM,MAAM,GACV,OAAO,MAAM,KAAK,QAAQ,IAAI,MAAM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AAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { StorybookSource } from '../adapters/storybook/index.js';
|
|
2
|
+
import type { LoadedConfig } from '../config/load.js';
|
|
3
|
+
import type { CliIO } from '../cli/context.js';
|
|
4
|
+
import type { GitWorktree } from './git-worktree.js';
|
|
5
|
+
export interface OpenReference {
|
|
6
|
+
readonly source: StorybookSource;
|
|
7
|
+
readonly worktree: GitWorktree;
|
|
8
|
+
readonly commit: string;
|
|
9
|
+
readonly storyRoot: string;
|
|
10
|
+
close(): Promise<void>;
|
|
11
|
+
}
|
|
12
|
+
/** Checks out, builds and opens the target branch's configured Storybook. */
|
|
13
|
+
export declare function openReference(loaded: LoadedConfig, ref: string, io: CliIO): Promise<OpenReference>;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import path from 'node:path';
|
|
2
|
+
import { realpath } from 'node:fs/promises';
|
|
3
|
+
import { openStorybook } from '../adapters/storybook/index.js';
|
|
4
|
+
import { ConfigError } from '../shared/errors.js';
|
|
5
|
+
import { buildReference } from './build.js';
|
|
6
|
+
import { createGitWorktree } from './git-worktree.js';
|
|
7
|
+
/** Checks out, builds and opens the target branch's configured Storybook. */
|
|
8
|
+
export async function openReference(loaded, ref, io) {
|
|
9
|
+
const reference = loaded.config.reference;
|
|
10
|
+
if (reference === undefined) {
|
|
11
|
+
throw new ConfigError('Dynamic branch comparison needs a "reference.build" command list in viewev.config. ' +
|
|
12
|
+
'See the branch comparison configuration in the Viewev documentation.');
|
|
13
|
+
}
|
|
14
|
+
const staticDir = loaded.config.provider.staticDir;
|
|
15
|
+
if (staticDir === undefined) {
|
|
16
|
+
throw new ConfigError('Dynamic branch comparison needs provider.staticDir so Viewev can open the target branch Storybook.');
|
|
17
|
+
}
|
|
18
|
+
const worktree = await createGitWorktree(loaded.rootDir, ref);
|
|
19
|
+
let source;
|
|
20
|
+
try {
|
|
21
|
+
io.stdout(`[viewev] Preparing ${ref} (${worktree.commit.slice(0, 12)}) in ${worktree.directory}\n`);
|
|
22
|
+
await buildReference(reference.build, {
|
|
23
|
+
directory: worktree.directory,
|
|
24
|
+
ref,
|
|
25
|
+
commit: worktree.commit,
|
|
26
|
+
stdout: io.stdout,
|
|
27
|
+
stderr: io.stderr,
|
|
28
|
+
});
|
|
29
|
+
const [repoRoot, configRoot] = await Promise.all([
|
|
30
|
+
realpath(worktree.repoRoot),
|
|
31
|
+
realpath(loaded.rootDir),
|
|
32
|
+
]);
|
|
33
|
+
const configRelative = path.relative(repoRoot, configRoot);
|
|
34
|
+
const referenceConfigRoot = path.join(worktree.directory, configRelative);
|
|
35
|
+
const referenceStaticDir = path.resolve(referenceConfigRoot, staticDir);
|
|
36
|
+
source = await openStorybook({
|
|
37
|
+
staticDir: referenceStaticDir,
|
|
38
|
+
viewport: loaded.config.viewport,
|
|
39
|
+
variants: loaded.config.variants,
|
|
40
|
+
});
|
|
41
|
+
let closed = false;
|
|
42
|
+
return {
|
|
43
|
+
source,
|
|
44
|
+
worktree,
|
|
45
|
+
commit: worktree.commit,
|
|
46
|
+
storyRoot: path.dirname(referenceStaticDir),
|
|
47
|
+
close: async () => {
|
|
48
|
+
if (closed)
|
|
49
|
+
return;
|
|
50
|
+
closed = true;
|
|
51
|
+
try {
|
|
52
|
+
await source?.close();
|
|
53
|
+
}
|
|
54
|
+
finally {
|
|
55
|
+
await worktree.close();
|
|
56
|
+
}
|
|
57
|
+
},
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
catch (error) {
|
|
61
|
+
await source?.close().catch(() => undefined);
|
|
62
|
+
await worktree.close().catch(() => undefined);
|
|
63
|
+
throw error;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
//# sourceMappingURL=open.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"open.js","sourceRoot":"","sources":["../../src/reference/open.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO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CAAC,SAAS,CAAC,CAAC;QAC9C,MAAM,KAAK,CAAC;IACd,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { ArtifactWriter } from '../core/artifacts.js';
|
|
2
|
+
/**
|
|
3
|
+
* Prepares the report directory for a new run. Only the `artifacts` folder inside it is
|
|
4
|
+
* removed, never the report directory itself, so a mistyped path cannot delete anything else.
|
|
5
|
+
*/
|
|
6
|
+
export declare function prepareReportDir(reportDir: string): Promise<void>;
|
|
7
|
+
/** Writes report images as `artifacts/<scenario-id>.<kind>.png` inside the report directory. */
|
|
8
|
+
export declare function createArtifactWriter(reportDir: string): ArtifactWriter;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { mkdir, rm, writeFile } from 'node:fs/promises';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
const ARTIFACTS_DIR = 'artifacts';
|
|
4
|
+
/**
|
|
5
|
+
* Prepares the report directory for a new run. Only the `artifacts` folder inside it is
|
|
6
|
+
* removed, never the report directory itself, so a mistyped path cannot delete anything else.
|
|
7
|
+
*/
|
|
8
|
+
export async function prepareReportDir(reportDir) {
|
|
9
|
+
await rm(path.join(reportDir, ARTIFACTS_DIR), { recursive: true, force: true });
|
|
10
|
+
await mkdir(path.join(reportDir, ARTIFACTS_DIR), { recursive: true });
|
|
11
|
+
}
|
|
12
|
+
/** Writes report images as `artifacts/<scenario-id>.<kind>.png` inside the report directory. */
|
|
13
|
+
export function createArtifactWriter(reportDir) {
|
|
14
|
+
return {
|
|
15
|
+
async write(id, kind, png) {
|
|
16
|
+
const fileName = `${id}.${kind}.png`;
|
|
17
|
+
await writeFile(path.join(reportDir, ARTIFACTS_DIR, fileName), png);
|
|
18
|
+
// Always forward slashes, so the same path works in JSON and HTML on every platform.
|
|
19
|
+
return path.posix.join(ARTIFACTS_DIR, fileName);
|
|
20
|
+
},
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=artifacts.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"artifacts.js","sourceRoot":"","sources":["../../src/reporting/artifacts.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,EAAE,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AACxD,OAAO,IAAI,MAAM,WAAW,CAAC;AAG7B,MAAM,aAAa,GAAG,WAAW,CAAC;AAElC;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,gBAAgB,CAAC,SAAiB;IACtD,MAAM,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,aAAa,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;IAChF,MAAM,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,aAAa,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;AACxE,CAAC;AAED,gGAAgG;AAChG,MAAM,UAAU,oBAAoB,CAAC,SAAiB;IACpD,OAAO;QACL,KAAK,CAAC,KAAK,CAAC,EAAE,EAAE,IAAkB,EAAE,GAAG;YACrC,MAAM,QAAQ,GAAG,GAAG,EAAE,IAAI,IAAI,MAAM,CAAC;YACrC,MAAM,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,aAAa,EAAE,QAAQ,CAAC,EAAE,GAAG,CAAC,CAAC;YACpE,qFAAqF;YACrF,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,aAAa,EAAE,QAAQ,CAAC,CAAC;QAClD,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { ResultsFile } from './results-json.js';
|
|
2
|
+
export declare function escapeHtml(value: string): string;
|
|
3
|
+
/** Renders the whole report as one self-contained HTML document (no external requests). */
|
|
4
|
+
export declare function renderReportHtml(file: ResultsFile): string;
|
|
@@ -0,0 +1,251 @@
|
|
|
1
|
+
export function escapeHtml(value) {
|
|
2
|
+
return value
|
|
3
|
+
.replace(/&/g, '&')
|
|
4
|
+
.replace(/</g, '<')
|
|
5
|
+
.replace(/>/g, '>')
|
|
6
|
+
.replace(/"/g, '"')
|
|
7
|
+
.replace(/'/g, ''');
|
|
8
|
+
}
|
|
9
|
+
const e = escapeHtml;
|
|
10
|
+
const STATUS_ORDER = ['error', 'regression', 'changed', 'missing-baseline', 'passed'];
|
|
11
|
+
const STATUS_LABELS = {
|
|
12
|
+
error: 'Error',
|
|
13
|
+
regression: 'Regression',
|
|
14
|
+
changed: 'Changed in this PR',
|
|
15
|
+
'missing-baseline': 'No baseline',
|
|
16
|
+
passed: 'Passed',
|
|
17
|
+
};
|
|
18
|
+
function percent(ratio) {
|
|
19
|
+
const value = ratio * 100;
|
|
20
|
+
return value > 0 && value < 0.01 ? '<0.01%' : `${value.toFixed(2)}%`;
|
|
21
|
+
}
|
|
22
|
+
function figure(label, source, id) {
|
|
23
|
+
if (source === undefined)
|
|
24
|
+
return '';
|
|
25
|
+
return (`<figure><figcaption>${e(label)}</figcaption>` +
|
|
26
|
+
`<a href="${e(source)}" target="_blank" rel="noopener">` +
|
|
27
|
+
`<img src="${e(source)}" loading="lazy" alt="${e(`${label} screenshot of ${id}`)}"></a></figure>`);
|
|
28
|
+
}
|
|
29
|
+
function blink(expected, actual, id) {
|
|
30
|
+
if (expected === undefined || actual === undefined)
|
|
31
|
+
return '';
|
|
32
|
+
return ('<div class="blink" data-state="expected">' +
|
|
33
|
+
'<button type="button" class="blink-toggle">Switch expected / actual</button> ' +
|
|
34
|
+
'<span class="blink-label muted">showing expected</span>' +
|
|
35
|
+
`<div class="blink-stack"><img class="b-expected" src="${e(expected)}" loading="lazy" alt="Expected screenshot of ${e(id)}">` +
|
|
36
|
+
`<img class="b-actual" src="${e(actual)}" loading="lazy" alt="Actual screenshot of ${e(id)}"></div></div>`);
|
|
37
|
+
}
|
|
38
|
+
function details(scenario) {
|
|
39
|
+
const rows = [
|
|
40
|
+
['Viewport', `${scenario.viewport.width}x${scenario.viewport.height}`],
|
|
41
|
+
['Source', `${scenario.origin.provider}: ${scenario.origin.ref}`],
|
|
42
|
+
['Duration', `${scenario.durationMs} ms`],
|
|
43
|
+
];
|
|
44
|
+
if (scenario.variant !== undefined) {
|
|
45
|
+
rows.push([
|
|
46
|
+
'Variant',
|
|
47
|
+
Object.entries(scenario.variant)
|
|
48
|
+
.map(([k, v]) => `${k}=${v}`)
|
|
49
|
+
.join(', '),
|
|
50
|
+
]);
|
|
51
|
+
}
|
|
52
|
+
if (scenario.clipped === true) {
|
|
53
|
+
rows.push(['Note', 'The page is larger than the viewport, so only part of it is captured.']);
|
|
54
|
+
}
|
|
55
|
+
return ('<table class="meta">' +
|
|
56
|
+
rows.map(([name, value]) => `<tr><th>${e(name)}</th><td>${e(value)}</td></tr>`).join('') +
|
|
57
|
+
'</table>');
|
|
58
|
+
}
|
|
59
|
+
function summaryText(scenario, hasReference) {
|
|
60
|
+
const { outcome } = scenario;
|
|
61
|
+
switch (outcome.status) {
|
|
62
|
+
case 'passed':
|
|
63
|
+
return `${percent(outcome.stats.diffRatio)} different`;
|
|
64
|
+
case 'regression':
|
|
65
|
+
return outcome.cause === 'dimensions'
|
|
66
|
+
? `size changed ${outcome.expected.width}x${outcome.expected.height} → ${outcome.actual.width}x${outcome.actual.height}`
|
|
67
|
+
: `${percent(outcome.stats.diffRatio)} different (${outcome.stats.diffPixels} of ${outcome.stats.totalPixels} px)`;
|
|
68
|
+
case 'missing-baseline':
|
|
69
|
+
return hasReference
|
|
70
|
+
? 'no matching scenario on the target branch'
|
|
71
|
+
: 'no approved baseline yet';
|
|
72
|
+
case 'changed':
|
|
73
|
+
if (outcome.change === 'added')
|
|
74
|
+
return 'new baseline proposed by this change';
|
|
75
|
+
return outcome.cause === 'dimensions'
|
|
76
|
+
? `baseline update proposed: size ${outcome.expected.width}x${outcome.expected.height} → ${outcome.actual.width}x${outcome.actual.height}`
|
|
77
|
+
: `baseline update proposed: ${percent(outcome.stats.diffRatio)} different from the approved baseline`;
|
|
78
|
+
case 'error':
|
|
79
|
+
return `[${outcome.error.phase}] ${outcome.error.message}`;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
function body(scenario, hasReference) {
|
|
83
|
+
const { outcome, id } = scenario;
|
|
84
|
+
switch (outcome.status) {
|
|
85
|
+
case 'passed':
|
|
86
|
+
return '';
|
|
87
|
+
case 'error':
|
|
88
|
+
return `<p class="error-text">${e(outcome.error.message)}</p>`;
|
|
89
|
+
case 'missing-baseline':
|
|
90
|
+
return `<div class="images">${figure(hasReference ? 'Current UI' : 'Actual', outcome.artifacts.actual, id)}</div>`;
|
|
91
|
+
case 'changed': {
|
|
92
|
+
const { expected, actual, diff } = outcome.artifacts;
|
|
93
|
+
return (`<p class="muted">The approved baseline differs, but this change proposes a matching one. ` +
|
|
94
|
+
`Review the baseline images in the pull request.</p>` +
|
|
95
|
+
`<div class="images">${figure('Approved', expected, id)}${figure('New', actual, id)}` +
|
|
96
|
+
`${figure('Difference', diff, id)}</div>${blink(expected, actual, id)}`);
|
|
97
|
+
}
|
|
98
|
+
case 'regression': {
|
|
99
|
+
const { expected, actual, diff } = outcome.artifacts;
|
|
100
|
+
return (`<div class="images">${figure('Expected', expected, id)}${figure('Actual', actual, id)}` +
|
|
101
|
+
`${figure('Difference', diff, id)}</div>${blink(expected, actual, id)}`);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
function scenarioHtml(scenario, hasReference) {
|
|
106
|
+
const { status } = scenario.outcome;
|
|
107
|
+
const statusLabel = status === 'missing-baseline' && hasReference ? 'New scenario' : STATUS_LABELS[status];
|
|
108
|
+
const label = `<span class="badge ${status}">${statusLabel}</span>`;
|
|
109
|
+
const title = `${label} <span class="id">${e(scenario.id)}</span> ` +
|
|
110
|
+
`<span class="muted">${e(scenario.name)}</span> <span class="muted">— ${e(summaryText(scenario, hasReference))}</span>`;
|
|
111
|
+
if (status === 'passed') {
|
|
112
|
+
return `<div class="scenario row" data-status="${status}">${title}</div>`;
|
|
113
|
+
}
|
|
114
|
+
return (`<details class="scenario" data-status="${status}" open><summary>${title}</summary>` +
|
|
115
|
+
`${body(scenario, hasReference)}${details(scenario)}</details>`);
|
|
116
|
+
}
|
|
117
|
+
const STYLE = `
|
|
118
|
+
:root{color-scheme:light dark;--bg:#fff;--fg:#161616;--muted:#6f6f6f;--line:#d0d0d0;--card:#f4f4f4;
|
|
119
|
+
--ok:#198038;--bad:#da1e28;--warn:#b28600;--info:#0f62fe}
|
|
120
|
+
@media (prefers-color-scheme:dark){:root{--bg:#161616;--fg:#f4f4f4;--muted:#a8a8a8;--line:#393939;--card:#262626;
|
|
121
|
+
--ok:#42be65;--bad:#fa4d56;--warn:#f1c21b;--info:#78a9ff}}
|
|
122
|
+
*{box-sizing:border-box}
|
|
123
|
+
body{margin:0;background:var(--bg);color:var(--fg);font:14px/1.5 system-ui,-apple-system,Segoe UI,sans-serif}
|
|
124
|
+
header,main,footer{max-width:1200px;margin:0 auto;padding:16px 24px}
|
|
125
|
+
h1{margin:0 0 4px;font-size:22px}h2{font-size:16px;margin:24px 0 8px}
|
|
126
|
+
.muted{color:var(--muted)}.id{font-family:ui-monospace,Menlo,Consolas,monospace;font-weight:600}
|
|
127
|
+
.counts{display:flex;gap:8px;flex-wrap:wrap;margin:12px 0}
|
|
128
|
+
.counts button{border:1px solid var(--line);background:var(--card);color:var(--fg);border-radius:6px;padding:6px 12px;cursor:pointer;font:inherit}
|
|
129
|
+
.counts button[aria-pressed=true]{border-color:var(--info);outline:1px solid var(--info)}
|
|
130
|
+
.badge{display:inline-block;border-radius:4px;padding:0 8px;font-size:12px;font-weight:600;color:#fff}
|
|
131
|
+
.badge.passed{background:var(--ok)}.badge.changed{background:var(--info)}.badge.regression,.badge.error{background:var(--bad)}.badge.missing-baseline{background:var(--warn);color:#161616}
|
|
132
|
+
.scenario{border:1px solid var(--line);border-radius:6px;margin:8px 0;background:var(--card)}
|
|
133
|
+
.scenario.row{padding:6px 12px}details.scenario>summary{padding:8px 12px;cursor:pointer}
|
|
134
|
+
details.scenario>*:not(summary){margin:8px 12px 12px}
|
|
135
|
+
.images{display:flex;gap:12px;flex-wrap:wrap}figure{margin:0;flex:1 1 280px;min-width:0}
|
|
136
|
+
figcaption{font-weight:600;margin-bottom:4px}img{max-width:100%;height:auto;border:1px solid var(--line);background:#fff}
|
|
137
|
+
.blink{margin-top:12px}.blink-stack{margin-top:6px}.blink[data-state=expected] .b-actual,.blink[data-state=actual] .b-expected{display:none}
|
|
138
|
+
.meta{border-collapse:collapse}.meta th{text-align:left;padding:2px 16px 2px 0;color:var(--muted);font-weight:500}
|
|
139
|
+
.error-text{color:var(--bad);font-family:ui-monospace,Menlo,Consolas,monospace}
|
|
140
|
+
.warnings{border-left:4px solid var(--warn);padding:4px 12px;background:var(--card)}
|
|
141
|
+
.notice{border-left:4px solid var(--info);padding:6px 12px;margin:12px 0;background:var(--card)}
|
|
142
|
+
ul.plain{padding-left:20px}
|
|
143
|
+
`;
|
|
144
|
+
const FILTERS = ['all', ...STATUS_ORDER];
|
|
145
|
+
function filterRules() {
|
|
146
|
+
return FILTERS.filter((f) => f !== 'all')
|
|
147
|
+
.map((f) => `main[data-filter="${f}"] .scenario:not([data-status="${f}"]){display:none}`)
|
|
148
|
+
.join('\n');
|
|
149
|
+
}
|
|
150
|
+
const SCRIPT = `
|
|
151
|
+
document.addEventListener('click', function (event) {
|
|
152
|
+
var target = event.target;
|
|
153
|
+
if (!(target instanceof Element)) return;
|
|
154
|
+
var filter = target.closest('[data-set-filter]');
|
|
155
|
+
if (filter) {
|
|
156
|
+
document.querySelector('main').setAttribute('data-filter', filter.getAttribute('data-set-filter'));
|
|
157
|
+
document.querySelectorAll('[data-set-filter]').forEach(function (button) {
|
|
158
|
+
button.setAttribute('aria-pressed', String(button === filter));
|
|
159
|
+
});
|
|
160
|
+
return;
|
|
161
|
+
}
|
|
162
|
+
var toggle = target.closest('.blink-toggle');
|
|
163
|
+
if (toggle) {
|
|
164
|
+
var blink = toggle.closest('.blink');
|
|
165
|
+
var next = blink.getAttribute('data-state') === 'expected' ? 'actual' : 'expected';
|
|
166
|
+
blink.setAttribute('data-state', next);
|
|
167
|
+
blink.querySelector('.blink-label').textContent = 'showing ' + next;
|
|
168
|
+
}
|
|
169
|
+
});
|
|
170
|
+
`;
|
|
171
|
+
/** Renders the whole report as one self-contained HTML document (no external requests). */
|
|
172
|
+
export function renderReportHtml(file) {
|
|
173
|
+
const { summary } = file;
|
|
174
|
+
const counts = {
|
|
175
|
+
all: summary.total,
|
|
176
|
+
error: summary.errors,
|
|
177
|
+
regression: summary.regressions,
|
|
178
|
+
changed: summary.changed,
|
|
179
|
+
'missing-baseline': summary.missingBaselines,
|
|
180
|
+
passed: summary.passed,
|
|
181
|
+
};
|
|
182
|
+
const filterLabels = {
|
|
183
|
+
all: 'All',
|
|
184
|
+
...STATUS_LABELS,
|
|
185
|
+
'missing-baseline': file.reference !== undefined ? 'New scenario' : 'No baseline',
|
|
186
|
+
};
|
|
187
|
+
const buttons = FILTERS.map((f) => `<button type="button" data-set-filter="${f}" aria-pressed="${f === 'all'}">` +
|
|
188
|
+
`${filterLabels[f]} (${counts[f]})</button>`).join('');
|
|
189
|
+
const sorted = [...file.scenarios].sort((a, b) => STATUS_ORDER.indexOf(a.outcome.status) - STATUS_ORDER.indexOf(b.outcome.status) ||
|
|
190
|
+
a.id.localeCompare(b.id));
|
|
191
|
+
const environment = file.environment === undefined
|
|
192
|
+
? ''
|
|
193
|
+
: `Chromium ${e(file.environment.browser.version)} on ${e(file.environment.os.platform)}/` +
|
|
194
|
+
`${e(file.environment.os.arch)} (${e(file.environment.automation.name)} ` +
|
|
195
|
+
`${e(file.environment.automation.version)})`;
|
|
196
|
+
const selection = file.selection;
|
|
197
|
+
const selectionHtml = selection === undefined
|
|
198
|
+
? ''
|
|
199
|
+
: selection.mode === 'all'
|
|
200
|
+
? `<div class="notice">Impact analysis: every scenario ran. ${e(selection.reason ?? '')}</div>`
|
|
201
|
+
: `<div class="notice">Selective run: ${selection.selected} of ${selection.total} scenarios were selected` +
|
|
202
|
+
`${selection.baseRef !== undefined ? ` for the changes since ${e(selection.baseRef)}` : ''}` +
|
|
203
|
+
` (${selection.changedFileCount ?? 0} changed files). Scenarios that were not selected were ` +
|
|
204
|
+
'not tested, so this report is not full visual coverage.</div>';
|
|
205
|
+
const warnings = file.warnings.length > 0
|
|
206
|
+
? `<h2>Warnings</h2><div class="warnings">${file.warnings.map((w) => `<p>${e(w)}</p>`).join('')}</div>`
|
|
207
|
+
: '';
|
|
208
|
+
const removed = file.removed ?? [];
|
|
209
|
+
const removedHtml = removed.length > 0
|
|
210
|
+
? `<h2>Baselines removed by this change (${removed.length})</h2>` +
|
|
211
|
+
'<p class="muted">Their scenarios no longer exist and this change deletes the baselines too.</p>' +
|
|
212
|
+
`<ul class="plain">${removed.map((id) => `<li class="id">${e(id)}</li>`).join('')}</ul>`
|
|
213
|
+
: '';
|
|
214
|
+
const obsolete = file.obsolete.length > 0
|
|
215
|
+
? `<h2>${file.reference !== undefined ? 'Scenarios removed since reference' : 'Obsolete baselines'} (${file.obsolete.length})</h2>` +
|
|
216
|
+
(file.reference !== undefined
|
|
217
|
+
? `<p class="muted">These scenarios exist on ${e(file.reference.ref)} but not in the current UI.</p>`
|
|
218
|
+
: '<p class="muted">These baselines have no matching scenario. Remove them with <code>viewev baseline prune --yes</code>.</p>') +
|
|
219
|
+
`<ul class="plain">${file.obsolete.map((id) => `<li class="id">${e(id)}</li>`).join('')}</ul>`
|
|
220
|
+
: '';
|
|
221
|
+
return `<!doctype html>
|
|
222
|
+
<html lang="en">
|
|
223
|
+
<head>
|
|
224
|
+
<meta charset="utf-8">
|
|
225
|
+
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
226
|
+
<title>Viewev report</title>
|
|
227
|
+
<style>${STYLE}${filterRules()}</style>
|
|
228
|
+
</head>
|
|
229
|
+
<body>
|
|
230
|
+
<header>
|
|
231
|
+
<h1>Viewev report</h1>
|
|
232
|
+
<div class="muted"><time datetime="${e(file.startedAt)}">${e(file.startedAt)}</time> · ${file.durationMs} ms</div>
|
|
233
|
+
<div class="muted">${environment}</div>
|
|
234
|
+
${file.reference !== undefined ? `<div class="muted">Reference UI: ${e(file.reference.ref)} (${e(file.reference.commit.slice(0, 12))})</div>` : ''}
|
|
235
|
+
${selectionHtml}
|
|
236
|
+
<div class="counts">${buttons}</div>
|
|
237
|
+
</header>
|
|
238
|
+
<main data-filter="all">
|
|
239
|
+
${warnings}
|
|
240
|
+
<h2>Scenarios</h2>
|
|
241
|
+
${sorted.length > 0 ? sorted.map((scenario) => scenarioHtml(scenario, file.reference !== undefined)).join('\n') : '<p class="muted">No scenarios were run.</p>'}
|
|
242
|
+
${obsolete}
|
|
243
|
+
${removedHtml}
|
|
244
|
+
</main>
|
|
245
|
+
<footer class="muted">${file.reference !== undefined ? `Generated by Viewev. Expected images are fresh captures from ${e(file.reference.ref)} (${e(file.reference.commit.slice(0, 12))}).` : 'Generated by Viewev. Approve intended changes with <code>viewev baseline update</code> and review the changed images in Git.'}</footer>
|
|
246
|
+
<script>${SCRIPT}</script>
|
|
247
|
+
</body>
|
|
248
|
+
</html>
|
|
249
|
+
`;
|
|
250
|
+
}
|
|
251
|
+
//# sourceMappingURL=html.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"html.js","sourceRoot":"","sources":["../../src/reporting/html.ts"],"names":[],"mappings":"AAIA,MAAM,UAAU,UAAU,CAAC,KAAa;IACtC,OAAO,KAAK;SACT,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC;SACtB,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC;SACrB,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC;SACrB,OAAO,CAAC,IAAI,EAAE,QAAQ,CAAC;SACvB,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;AAC5B,CAAC;AAED,M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AChJ,aAAa;sBACO,OAAO;;;EAG3B,QAAQ;;EAER,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,YAAY,CAAC,QAAQ,EAAE,IAAI,CAAC,SAAS,KAAK,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,6CAA6C;EAC7J,QAAQ;EACR,WAAW;;wBAEW,IAAI,CAAC,SAAS,KAAK,SAAS,CAAC,CAAC,CAAC,gEAAgE,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,8HAA8H;UACjT,MAAM;;;CAGf,CAAC;AACF,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { RunResult } from '../core/result.js';
|
|
2
|
+
import type { ResultsFile } from './results-json.js';
|
|
3
|
+
export declare const REPORT_FILE_NAME = "index.html";
|
|
4
|
+
export interface ReportPaths {
|
|
5
|
+
readonly resultsPath: string;
|
|
6
|
+
readonly reportPath: string;
|
|
7
|
+
}
|
|
8
|
+
export declare function writeHtmlReport(reportDir: string, file: ResultsFile): Promise<string>;
|
|
9
|
+
/** Writes results.json and the HTML report for a finished run. */
|
|
10
|
+
export declare function writeReport(reportDir: string, result: RunResult): Promise<ReportPaths>;
|
|
11
|
+
/** Reads the results of the last run so the report can be rendered again. */
|
|
12
|
+
export declare function readResultsFile(reportDir: string): Promise<ResultsFile>;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { mkdir, readFile, writeFile } from 'node:fs/promises';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import { ConfigError } from '../shared/errors.js';
|
|
4
|
+
import { renderReportHtml } from './html.js';
|
|
5
|
+
import { RESULTS_FILE_NAME, toResultsFile, writeResultsFile } from './results-json.js';
|
|
6
|
+
export const REPORT_FILE_NAME = 'index.html';
|
|
7
|
+
export async function writeHtmlReport(reportDir, file) {
|
|
8
|
+
await mkdir(reportDir, { recursive: true });
|
|
9
|
+
const reportPath = path.join(reportDir, REPORT_FILE_NAME);
|
|
10
|
+
await writeFile(reportPath, renderReportHtml(file));
|
|
11
|
+
return reportPath;
|
|
12
|
+
}
|
|
13
|
+
/** Writes results.json and the HTML report for a finished run. */
|
|
14
|
+
export async function writeReport(reportDir, result) {
|
|
15
|
+
const resultsPath = await writeResultsFile(reportDir, result);
|
|
16
|
+
const reportPath = await writeHtmlReport(reportDir, toResultsFile(result));
|
|
17
|
+
return { resultsPath, reportPath };
|
|
18
|
+
}
|
|
19
|
+
function isResultsFile(value) {
|
|
20
|
+
if (typeof value !== 'object' || value === null)
|
|
21
|
+
return false;
|
|
22
|
+
const candidate = value;
|
|
23
|
+
return (candidate['schemaVersion'] === 1 &&
|
|
24
|
+
Array.isArray(candidate['scenarios']) &&
|
|
25
|
+
Array.isArray(candidate['obsolete']) &&
|
|
26
|
+
Array.isArray(candidate['warnings']) &&
|
|
27
|
+
typeof candidate['summary'] === 'object' &&
|
|
28
|
+
candidate['summary'] !== null);
|
|
29
|
+
}
|
|
30
|
+
/** Reads the results of the last run so the report can be rendered again. */
|
|
31
|
+
export async function readResultsFile(reportDir) {
|
|
32
|
+
const file = path.join(reportDir, RESULTS_FILE_NAME);
|
|
33
|
+
let text;
|
|
34
|
+
try {
|
|
35
|
+
text = await readFile(file, 'utf8');
|
|
36
|
+
}
|
|
37
|
+
catch (error) {
|
|
38
|
+
if (error.code === 'ENOENT') {
|
|
39
|
+
throw new ConfigError(`No results found at ${file}. Run "viewev test" first.`);
|
|
40
|
+
}
|
|
41
|
+
throw error;
|
|
42
|
+
}
|
|
43
|
+
let json;
|
|
44
|
+
try {
|
|
45
|
+
json = JSON.parse(text);
|
|
46
|
+
}
|
|
47
|
+
catch (error) {
|
|
48
|
+
throw new ConfigError(`${file} is not valid JSON.`, { cause: error });
|
|
49
|
+
}
|
|
50
|
+
if (!isResultsFile(json)) {
|
|
51
|
+
throw new ConfigError(`${file} is not a Viewev results file, or its version is not supported.`);
|
|
52
|
+
}
|
|
53
|
+
return json;
|
|
54
|
+
}
|
|
55
|
+
//# sourceMappingURL=report.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"report.js","sourceRoot":"","sources":["../../src/reporting/report.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC9D,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAC7C,OAAO,EAAE,iBAAiB,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAGvF,MAAM,CAAC,MAAM,gBAAgB,GAAG,YAAY,CAAC;AAO7C,MAAM,CAAC,KAAK,UAAU,eAAe,CAAC,SAAiB,EAAE,IAAiB;IACxE,MAAM,KAAK,CAAC,SAAS,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IAC5C,MAAM,UAAU,GAAG,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,gBAAgB,CAAC,CAAC;IAC1D,MAAM,SAAS,CAAC,UAAU,EAAE,gBAAgB,CAAC,IAAI,CAAC,CAAC,CAAC;IACpD,OAAO,UAAU,CAAC;AACpB,CAAC;AAED,kEAAkE;AAClE,MAAM,CAAC,KAAK,UAAU,WAAW,CAAC,SAAiB,EAAE,MAAiB;IACpE,MAAM,WAAW,GAAG,MAAM,gBAAgB,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC;IAC9D,MAAM,UAAU,GAAG,MAAM,eAAe,CAAC,SAAS,EAAE,aAAa,CAAC,MAAM,C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B,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,CAAC;IACxE,CAAC;IACD,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,EAAE,CAAC;QACzB,MAAM,IAAI,WAAW,CAAC,GAAG,IAAI,iEAAiE,CAAC,CAAC;IAClG,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { ReferenceInfo, RunResult, RunSummary, ScenarioOutcome, SelectionInfo } from '../core/result.js';
|
|
2
|
+
import type { EnvironmentInfo } from '../shared/environment.js';
|
|
3
|
+
import type { Size } from '../shared/size.js';
|
|
4
|
+
export declare const RESULTS_FILE_NAME = "results.json";
|
|
5
|
+
export interface ResultsFile {
|
|
6
|
+
readonly schemaVersion: 1;
|
|
7
|
+
readonly startedAt: string;
|
|
8
|
+
readonly durationMs: number;
|
|
9
|
+
readonly environment?: EnvironmentInfo;
|
|
10
|
+
readonly reference?: ReferenceInfo;
|
|
11
|
+
readonly summary: RunSummary;
|
|
12
|
+
readonly warnings: readonly string[];
|
|
13
|
+
readonly scenarios: ReadonlyArray<{
|
|
14
|
+
readonly id: string;
|
|
15
|
+
readonly name: string;
|
|
16
|
+
readonly group?: readonly string[];
|
|
17
|
+
readonly origin: {
|
|
18
|
+
readonly provider: string;
|
|
19
|
+
readonly ref: string;
|
|
20
|
+
};
|
|
21
|
+
readonly viewport: Size;
|
|
22
|
+
readonly variant?: Readonly<Record<string, string>>;
|
|
23
|
+
readonly tags?: readonly string[];
|
|
24
|
+
readonly durationMs: number;
|
|
25
|
+
readonly clipped?: boolean;
|
|
26
|
+
readonly outcome: ScenarioOutcome;
|
|
27
|
+
}>;
|
|
28
|
+
readonly obsolete: readonly string[];
|
|
29
|
+
/** Baselines that the change under test removes together with their scenario. */
|
|
30
|
+
readonly removed: readonly string[];
|
|
31
|
+
/** Present when impact analysis chose the scenarios. */
|
|
32
|
+
readonly selection?: SelectionInfo;
|
|
33
|
+
}
|
|
34
|
+
/** The machine-readable result of a run; the HTML report is rendered from it. */
|
|
35
|
+
export declare function toResultsFile(result: RunResult): ResultsFile;
|
|
36
|
+
export declare function writeResultsFile(reportDir: string, result: RunResult): Promise<string>;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { mkdir, writeFile } from 'node:fs/promises';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import { summarize } from '../core/result.js';
|
|
4
|
+
export const RESULTS_FILE_NAME = 'results.json';
|
|
5
|
+
/** The machine-readable result of a run; the HTML report is rendered from it. */
|
|
6
|
+
export function toResultsFile(result) {
|
|
7
|
+
return {
|
|
8
|
+
schemaVersion: 1,
|
|
9
|
+
startedAt: result.startedAt,
|
|
10
|
+
durationMs: result.durationMs,
|
|
11
|
+
...(result.environment !== undefined ? { environment: result.environment } : {}),
|
|
12
|
+
...(result.reference !== undefined ? { reference: result.reference } : {}),
|
|
13
|
+
summary: summarize(result),
|
|
14
|
+
warnings: result.warnings ?? [],
|
|
15
|
+
scenarios: result.scenarios.map(({ scenario, outcome, durationMs, clipped }) => ({
|
|
16
|
+
id: scenario.id,
|
|
17
|
+
name: scenario.name,
|
|
18
|
+
...(scenario.group !== undefined ? { group: scenario.group } : {}),
|
|
19
|
+
origin: scenario.origin,
|
|
20
|
+
viewport: scenario.viewport,
|
|
21
|
+
...(scenario.variant !== undefined ? { variant: scenario.variant } : {}),
|
|
22
|
+
...(scenario.tags !== undefined ? { tags: scenario.tags } : {}),
|
|
23
|
+
durationMs,
|
|
24
|
+
...(clipped === true ? { clipped } : {}),
|
|
25
|
+
outcome,
|
|
26
|
+
})),
|
|
27
|
+
obsolete: result.obsolete,
|
|
28
|
+
removed: result.removed ?? [],
|
|
29
|
+
...(result.selection !== undefined ? { selection: result.selection } : {}),
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
export async function writeResultsFile(reportDir, result) {
|
|
33
|
+
await mkdir(reportDir, { recursive: true });
|
|
34
|
+
const file = path.join(reportDir, RESULTS_FILE_NAME);
|
|
35
|
+
await writeFile(file, `${JSON.stringify(toResultsFile(result), null, 2)}\n`);
|
|
36
|
+
return file;
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=results-json.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"results-json.js","sourceRoot":"","sources":["../../src/reporting/results-json.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAW9C,MAAM,CAAC,MAAM,iBAAiB,GAAG,cAAc,CAAC;AA6BhD,iFAAiF;AACjF,MAAM,UAAU,aAAa,CAAC,MAAiB;IAC7C,OAAO;QACL,aAAa,EAAE,CAAC;QAChB,SAAS,EAAE,MAAM,CAAC,SAAS;QAC3B,UAAU,EAAE,MAAM,CAAC,UAAU;QAC7B,GAAG,CAAC,MAAM,CAAC,WAAW,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,WAAW,EAAE,MAAM,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QAChF,GAAG,CAAC,MAAM,CAAC,SAAS,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,MAAM,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QAC1E,OAAO,EAAE,SAAS,CAAC,MAAM,CAAC;QAC1B,QAAQ,EAAE,MAAM,CAAC,QAAQ,IAAI,EAAE;QAC/B,SAAS,EAAE,MAAM,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,EAAE,QAAQ,EAAE,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC,CAAC;YAC/E,EAAE,EAAE,QAAQ,CAAC,EAAE;YACf,IAAI,EAAE,QAAQ,CAAC,IAAI;YACnB,GAAG,CAAC,QAAQ,CAAC,KAAK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,IAAI,CAAC;AACd,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Minimal glob matching for scenario ids: `*` matches any run of characters and `?` matches
|
|
3
|
+
* exactly one. Matching is case-insensitive and must cover the whole id. Scenario ids never
|
|
4
|
+
* contain path separators, so no other glob syntax is needed.
|
|
5
|
+
*/
|
|
6
|
+
export declare function globToRegExp(pattern: string): RegExp;
|
|
7
|
+
export declare function matchesAnyGlob(value: string, patterns: readonly string[]): boolean;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Minimal glob matching for scenario ids: `*` matches any run of characters and `?` matches
|
|
3
|
+
* exactly one. Matching is case-insensitive and must cover the whole id. Scenario ids never
|
|
4
|
+
* contain path separators, so no other glob syntax is needed.
|
|
5
|
+
*/
|
|
6
|
+
export function globToRegExp(pattern) {
|
|
7
|
+
const source = Array.from(pattern)
|
|
8
|
+
.map((char) => {
|
|
9
|
+
if (char === '*')
|
|
10
|
+
return '.*';
|
|
11
|
+
if (char === '?')
|
|
12
|
+
return '.';
|
|
13
|
+
return char.replace(/[\\^$.*+?()[\]{}|/-]/g, '\\$&');
|
|
14
|
+
})
|
|
15
|
+
.join('');
|
|
16
|
+
return new RegExp(`^${source}$`, 'i');
|
|
17
|
+
}
|
|
18
|
+
export function matchesAnyGlob(value, patterns) {
|
|
19
|
+
return patterns.some((pattern) => globToRegExp(pattern).test(value));
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=glob.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"glob.js","sourceRoot":"","sources":["../../src/scenarios/glob.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,UAAU,YAAY,CAAC,OAAe;IAC1C,MAAM,MAAM,GAAG,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC;SAC/B,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE;QACZ,IAAI,IAAI,KAAK,GAAG;YAAE,OAAO,IAAI,CAAC;QAC9B,IAAI,IAAI,KAAK,GAAG;YAAE,OAAO,GAAG,CAAC;QAC7B,OAAO,IAAI,CAAC,OAAO,CAAC,uBAAuB,EAAE,MAAM,CAAC,CAAC;IACvD,CAAC,CAAC;SACD,IAAI,CAAC,EAAE,CAAC,CAAC;IACZ,OAAO,IAAI,MAAM,CAAC,IAAI,MAAM,GAAG,EAAE,GAAG,CAAC,CAAC;AACxC,CAAC;AAED,MAAM,UAAU,cAAc,CAAC,KAAa,EAAE,QAA2B;IACvE,OAAO,QAAQ,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;AACvE,CAAC"}
|