@argos-ci/util 4.0.4 → 4.1.1-alpha.11.sha-4c8577c
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/dist/browser.d.mts +2 -2
- package/dist/browser.mjs +2 -2
- package/dist/index.d.mts +2 -3
- package/dist/index.mjs +4 -3
- package/dist/threshold-CTL5d5N7.d.mts +129 -0
- package/dist/{threshold-5SGmtKTq.mjs → threshold-CTtyBFha.mjs} +12 -1
- package/package.json +3 -2
- package/dist/threshold-MfycRxKY.d.mts +0 -78
package/dist/browser.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export { type ScreenshotMetadata, getMetadataPath, getScreenshotName, validateThreshold };
|
|
1
|
+
import { a as getMetadataPath, i as ScreenshotMetadata, n as getScreenshotName, r as normalizeBaseNames, t as validateThreshold } from "./threshold-CTL5d5N7.mjs";
|
|
2
|
+
export { type ScreenshotMetadata, getMetadataPath, getScreenshotName, normalizeBaseNames, validateThreshold };
|
package/dist/browser.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as getScreenshotName, r as getMetadataPath, t as validateThreshold } from "./threshold-
|
|
2
|
-
export { getMetadataPath, getScreenshotName, validateThreshold };
|
|
1
|
+
import { i as normalizeBaseNames, n as getScreenshotName, r as getMetadataPath, t as validateThreshold } from "./threshold-CTtyBFha.mjs";
|
|
2
|
+
export { getMetadataPath, getScreenshotName, normalizeBaseNames, validateThreshold };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { a as getMetadataPath, i as ScreenshotMetadata, n as getScreenshotName, r as normalizeBaseNames, t as validateThreshold } from "./threshold-CTL5d5N7.mjs";
|
|
3
2
|
//#region src/fs.d.ts
|
|
4
3
|
/**
|
|
5
4
|
* Create a directory if it doesn't exist.
|
|
@@ -40,4 +39,4 @@ declare function readMetadata(screenshotPath: string): Promise<ScreenshotMetadat
|
|
|
40
39
|
*/
|
|
41
40
|
declare function getPlaywrightTracePath(screenshotPath: string): Promise<string | null>;
|
|
42
41
|
//#endregion
|
|
43
|
-
export { ScreenshotMetadata, createDirectory, createTemporaryDirectory, getGitRepositoryPath, getMetadataPath, getPlaywrightTracePath, getScreenshotName, readMetadata, readVersionFromPackage, validateThreshold, writeMetadata };
|
|
42
|
+
export { ScreenshotMetadata, createDirectory, createTemporaryDirectory, getGitRepositoryPath, getMetadataPath, getPlaywrightTracePath, getScreenshotName, normalizeBaseNames, readMetadata, readVersionFromPackage, validateThreshold, writeMetadata };
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as getScreenshotName, r as getMetadataPath, t as validateThreshold } from "./threshold-
|
|
1
|
+
import { i as normalizeBaseNames, n as getScreenshotName, r as getMetadataPath, t as validateThreshold } from "./threshold-CTtyBFha.mjs";
|
|
2
2
|
import { randomBytes } from "node:crypto";
|
|
3
3
|
import { access, mkdir, readFile, writeFile } from "node:fs/promises";
|
|
4
4
|
import { tmpdir } from "node:os";
|
|
@@ -20,7 +20,8 @@ async function createDirectory(pathname) {
|
|
|
20
20
|
* Create temporary directory.
|
|
21
21
|
*/
|
|
22
22
|
async function createTemporaryDirectory() {
|
|
23
|
-
const
|
|
23
|
+
const osTmpDirectory = tmpdir();
|
|
24
|
+
const path = join(osTmpDirectory, "argos." + randomBytes(16).toString("hex"));
|
|
24
25
|
await createDirectory(path);
|
|
25
26
|
return path;
|
|
26
27
|
}
|
|
@@ -100,4 +101,4 @@ async function getPlaywrightTracePath(screenshotPath) {
|
|
|
100
101
|
}
|
|
101
102
|
}
|
|
102
103
|
//#endregion
|
|
103
|
-
export { createDirectory, createTemporaryDirectory, getGitRepositoryPath, getMetadataPath, getPlaywrightTracePath, getScreenshotName, readMetadata, readVersionFromPackage, validateThreshold, writeMetadata };
|
|
104
|
+
export { createDirectory, createTemporaryDirectory, getGitRepositoryPath, getMetadataPath, getPlaywrightTracePath, getScreenshotName, normalizeBaseNames, readMetadata, readVersionFromPackage, validateThreshold, writeMetadata };
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
//#region src/metadata.d.ts
|
|
2
|
+
type ScreenshotMetadata = {
|
|
3
|
+
/** @description The URL of the page that was screenshotted */
|
|
4
|
+
url?: string | null;
|
|
5
|
+
/** @description An URL to an accessible preview of the screenshot */
|
|
6
|
+
previewUrl?: string | null;
|
|
7
|
+
viewport?: {
|
|
8
|
+
/** @description The width of the viewport */
|
|
9
|
+
width: number;
|
|
10
|
+
/** @description The height of the viewport */
|
|
11
|
+
height: number;
|
|
12
|
+
} | null;
|
|
13
|
+
/** @description The color scheme when the screenshot was taken */
|
|
14
|
+
colorScheme?: ("light" | "dark") | null;
|
|
15
|
+
/** @description The media type when the screenshot was taken */
|
|
16
|
+
mediaType?: ("screen" | "print") | null;
|
|
17
|
+
/** @description Tags associated with the screenshot */
|
|
18
|
+
tags?: string[];
|
|
19
|
+
test?: ({
|
|
20
|
+
/** @description The unique identifier of the test */
|
|
21
|
+
id?: string | null;
|
|
22
|
+
/** @description The title of the test */
|
|
23
|
+
title: string;
|
|
24
|
+
/** @description The path of titles leading to the test */
|
|
25
|
+
titlePath: string[];
|
|
26
|
+
/** @description Tags associated with the test */
|
|
27
|
+
tags?: string[];
|
|
28
|
+
/** @description The number of retries for the test */
|
|
29
|
+
retries?: number | null;
|
|
30
|
+
/** @description The current retry count */
|
|
31
|
+
retry?: number | null;
|
|
32
|
+
/** @description The repeat count for the test */
|
|
33
|
+
repeat?: number | null;
|
|
34
|
+
/** @description The location of the test in the source code */
|
|
35
|
+
location?: {
|
|
36
|
+
/** @description The located file */
|
|
37
|
+
file: string;
|
|
38
|
+
/** @description The line number in the file */
|
|
39
|
+
line: number;
|
|
40
|
+
/** @description The column number in the file */
|
|
41
|
+
column: number;
|
|
42
|
+
};
|
|
43
|
+
/** @description Annotations associated to the test */
|
|
44
|
+
annotations?: {
|
|
45
|
+
/** @description The type of annotation */
|
|
46
|
+
type: string;
|
|
47
|
+
/** @description The description of the annotation */
|
|
48
|
+
description?: string;
|
|
49
|
+
/** @description The location of the annotation in the source code */
|
|
50
|
+
location?: {
|
|
51
|
+
/** @description The located file */
|
|
52
|
+
file: string;
|
|
53
|
+
/** @description The line number in the file */
|
|
54
|
+
line: number;
|
|
55
|
+
/** @description The column number in the file */
|
|
56
|
+
column: number;
|
|
57
|
+
};
|
|
58
|
+
}[];
|
|
59
|
+
} | null) | null;
|
|
60
|
+
story?: {
|
|
61
|
+
/** @description Unique ID of the story */
|
|
62
|
+
id: string;
|
|
63
|
+
/** @description Tags attached to the story */
|
|
64
|
+
tags: string[];
|
|
65
|
+
/** @description Story mode */
|
|
66
|
+
mode?: string;
|
|
67
|
+
/** @description True if the story has a play function */
|
|
68
|
+
play?: boolean;
|
|
69
|
+
};
|
|
70
|
+
browser?: {
|
|
71
|
+
/** @description The name of the browser */
|
|
72
|
+
name: string;
|
|
73
|
+
/** @description The version of the browser */
|
|
74
|
+
version: string;
|
|
75
|
+
} | null;
|
|
76
|
+
/** @description The automation library that generated the screenshot */
|
|
77
|
+
automationLibrary: {
|
|
78
|
+
/** @description The name of the automation library */
|
|
79
|
+
name: string;
|
|
80
|
+
/** @description The version of the automation library */
|
|
81
|
+
version: string;
|
|
82
|
+
};
|
|
83
|
+
/** @description The Argos SDK that generated the screenshot */
|
|
84
|
+
sdk: {
|
|
85
|
+
/** @description The name of the Argos SDK */
|
|
86
|
+
name: string;
|
|
87
|
+
/** @description The version of the Argos SDK */
|
|
88
|
+
version: string;
|
|
89
|
+
};
|
|
90
|
+
transient?: {
|
|
91
|
+
/** Threshold configured for this screenshot. */
|
|
92
|
+
threshold?: number;
|
|
93
|
+
/**
|
|
94
|
+
* Name(s) used to find the comparison baseline, instead of the snapshot's
|
|
95
|
+
* own name. Several names are tried in order: the first one that exists in
|
|
96
|
+
* the baseline wins.
|
|
97
|
+
*/
|
|
98
|
+
baseName?: string | string[];
|
|
99
|
+
/** Name of the parent screenshot. */
|
|
100
|
+
parentName?: string;
|
|
101
|
+
};
|
|
102
|
+
};
|
|
103
|
+
/**
|
|
104
|
+
* Get metadata path from snapshot path.
|
|
105
|
+
*/
|
|
106
|
+
declare function getMetadataPath(snapshotPath: string): string;
|
|
107
|
+
//#endregion
|
|
108
|
+
//#region src/base-name.d.ts
|
|
109
|
+
/**
|
|
110
|
+
* Normalize the user-facing `baseName` option — a single name or an ordered
|
|
111
|
+
* list of candidates — into a list, or `null` when nothing was provided.
|
|
112
|
+
*/
|
|
113
|
+
declare function normalizeBaseNames(baseName: string | string[] | undefined | null): string[] | null;
|
|
114
|
+
//#endregion
|
|
115
|
+
//#region src/name.d.ts
|
|
116
|
+
/**
|
|
117
|
+
* Build a screenshot name from a test name and options.
|
|
118
|
+
*/
|
|
119
|
+
declare function getScreenshotName(name: string, options?: {
|
|
120
|
+
viewportWidth?: number;
|
|
121
|
+
}): string;
|
|
122
|
+
//#endregion
|
|
123
|
+
//#region src/threshold.d.ts
|
|
124
|
+
/**
|
|
125
|
+
* Validates the threshold value.
|
|
126
|
+
*/
|
|
127
|
+
declare function validateThreshold(threshold: number): void;
|
|
128
|
+
//#endregion
|
|
129
|
+
export { getMetadataPath as a, ScreenshotMetadata as i, getScreenshotName as n, normalizeBaseNames as r, validateThreshold as t };
|
|
@@ -1,3 +1,14 @@
|
|
|
1
|
+
//#region src/base-name.ts
|
|
2
|
+
/**
|
|
3
|
+
* Normalize the user-facing `baseName` option — a single name or an ordered
|
|
4
|
+
* list of candidates — into a list, or `null` when nothing was provided.
|
|
5
|
+
*/
|
|
6
|
+
function normalizeBaseNames(baseName) {
|
|
7
|
+
if (!baseName) return null;
|
|
8
|
+
const validNames = (Array.isArray(baseName) ? baseName : [baseName]).filter((name) => name !== "");
|
|
9
|
+
return validNames.length > 0 ? validNames : null;
|
|
10
|
+
}
|
|
11
|
+
//#endregion
|
|
1
12
|
//#region src/metadata.ts
|
|
2
13
|
/**
|
|
3
14
|
* Get metadata path from snapshot path.
|
|
@@ -43,4 +54,4 @@ function validateThreshold(threshold) {
|
|
|
43
54
|
if (threshold < 0 || threshold > 1) throw new Error("The threshold must be between 0 and 1.");
|
|
44
55
|
}
|
|
45
56
|
//#endregion
|
|
46
|
-
export { getScreenshotName as n, getMetadataPath as r, validateThreshold as t };
|
|
57
|
+
export { normalizeBaseNames as i, getScreenshotName as n, getMetadataPath as r, validateThreshold as t };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@argos-ci/util",
|
|
3
3
|
"description": "Set of utilities used across all Argos SDKs.",
|
|
4
|
-
"version": "4.
|
|
4
|
+
"version": "4.1.1-alpha.11.sha-4c8577c",
|
|
5
5
|
"author": "Smooth Code",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"repository": {
|
|
@@ -40,6 +40,7 @@
|
|
|
40
40
|
"scripts": {
|
|
41
41
|
"build": "tsdown",
|
|
42
42
|
"check-types": "tsc",
|
|
43
|
+
"test": "vitest run src",
|
|
43
44
|
"check-format": "prettier --check --ignore-unknown --ignore-path=../../.gitignore --ignore-path=../../.prettierignore .",
|
|
44
45
|
"lint": "eslint ."
|
|
45
46
|
},
|
|
@@ -47,5 +48,5 @@
|
|
|
47
48
|
"@types/node": "catalog:",
|
|
48
49
|
"vitest": "catalog:"
|
|
49
50
|
},
|
|
50
|
-
"gitHead": "
|
|
51
|
+
"gitHead": "4c8577c08ff1d9681c5b951dc73665cc8b7955c8"
|
|
51
52
|
}
|
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
//#region src/metadata.d.ts
|
|
2
|
-
type ScreenshotMetadata = {
|
|
3
|
-
/** @description The URL of the page that was screenshotted */url?: string | null; /** @description An URL to an accessible preview of the screenshot */
|
|
4
|
-
previewUrl?: string | null;
|
|
5
|
-
viewport?: {
|
|
6
|
-
/** @description The width of the viewport */width: number; /** @description The height of the viewport */
|
|
7
|
-
height: number;
|
|
8
|
-
} | null; /** @description The color scheme when the screenshot was taken */
|
|
9
|
-
colorScheme?: ("light" | "dark") | null; /** @description The media type when the screenshot was taken */
|
|
10
|
-
mediaType?: ("screen" | "print") | null; /** @description Tags associated with the screenshot */
|
|
11
|
-
tags?: string[];
|
|
12
|
-
test?: ({
|
|
13
|
-
/** @description The unique identifier of the test */id?: string | null; /** @description The title of the test */
|
|
14
|
-
title: string; /** @description The path of titles leading to the test */
|
|
15
|
-
titlePath: string[]; /** @description Tags associated with the test */
|
|
16
|
-
tags?: string[]; /** @description The number of retries for the test */
|
|
17
|
-
retries?: number | null; /** @description The current retry count */
|
|
18
|
-
retry?: number | null; /** @description The repeat count for the test */
|
|
19
|
-
repeat?: number | null; /** @description The location of the test in the source code */
|
|
20
|
-
location?: {
|
|
21
|
-
/** @description The located file */file: string; /** @description The line number in the file */
|
|
22
|
-
line: number; /** @description The column number in the file */
|
|
23
|
-
column: number;
|
|
24
|
-
}; /** @description Annotations associated to the test */
|
|
25
|
-
annotations?: {
|
|
26
|
-
/** @description The type of annotation */type: string; /** @description The description of the annotation */
|
|
27
|
-
description?: string; /** @description The location of the annotation in the source code */
|
|
28
|
-
location?: {
|
|
29
|
-
/** @description The located file */file: string; /** @description The line number in the file */
|
|
30
|
-
line: number; /** @description The column number in the file */
|
|
31
|
-
column: number;
|
|
32
|
-
};
|
|
33
|
-
}[];
|
|
34
|
-
} | null) | null;
|
|
35
|
-
story?: {
|
|
36
|
-
/** @description Unique ID of the story */id: string; /** @description Tags attached to the story */
|
|
37
|
-
tags: string[]; /** @description Story mode */
|
|
38
|
-
mode?: string; /** @description True if the story has a play function */
|
|
39
|
-
play?: boolean;
|
|
40
|
-
};
|
|
41
|
-
browser?: {
|
|
42
|
-
/** @description The name of the browser */name: string; /** @description The version of the browser */
|
|
43
|
-
version: string;
|
|
44
|
-
} | null; /** @description The automation library that generated the screenshot */
|
|
45
|
-
automationLibrary: {
|
|
46
|
-
/** @description The name of the automation library */name: string; /** @description The version of the automation library */
|
|
47
|
-
version: string;
|
|
48
|
-
}; /** @description The Argos SDK that generated the screenshot */
|
|
49
|
-
sdk: {
|
|
50
|
-
/** @description The name of the Argos SDK */name: string; /** @description The version of the Argos SDK */
|
|
51
|
-
version: string;
|
|
52
|
-
};
|
|
53
|
-
transient?: {
|
|
54
|
-
/** Threshold configured for this screenshot. */threshold?: number; /** Override the name to find the comparison baseline. */
|
|
55
|
-
baseName?: string; /** Name of the parent screenshot. */
|
|
56
|
-
parentName?: string;
|
|
57
|
-
};
|
|
58
|
-
};
|
|
59
|
-
/**
|
|
60
|
-
* Get metadata path from snapshot path.
|
|
61
|
-
*/
|
|
62
|
-
declare function getMetadataPath(snapshotPath: string): string;
|
|
63
|
-
//#endregion
|
|
64
|
-
//#region src/name.d.ts
|
|
65
|
-
/**
|
|
66
|
-
* Build a screenshot name from a test name and options.
|
|
67
|
-
*/
|
|
68
|
-
declare function getScreenshotName(name: string, options?: {
|
|
69
|
-
viewportWidth?: number;
|
|
70
|
-
}): string;
|
|
71
|
-
//#endregion
|
|
72
|
-
//#region src/threshold.d.ts
|
|
73
|
-
/**
|
|
74
|
-
* Validates the threshold value.
|
|
75
|
-
*/
|
|
76
|
-
declare function validateThreshold(threshold: number): void;
|
|
77
|
-
//#endregion
|
|
78
|
-
export { getMetadataPath as i, getScreenshotName as n, ScreenshotMetadata as r, validateThreshold as t };
|