@argos-ci/util 4.0.1 → 4.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.
@@ -1,2 +1,2 @@
1
- import { i as getMetadataPath, n as getScreenshotName, r as ScreenshotMetadata, t as validateThreshold } from "./threshold-MfycRxKY.mjs";
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-BbcFeciF.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-5SGmtKTq.mjs";
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,4 +1,4 @@
1
- import { i as getMetadataPath, n as getScreenshotName, r as ScreenshotMetadata, t as validateThreshold } from "./threshold-MfycRxKY.mjs";
1
+ import { a as getMetadataPath, i as ScreenshotMetadata, n as getScreenshotName, r as normalizeBaseNames, t as validateThreshold } from "./threshold-BbcFeciF.mjs";
2
2
 
3
3
  //#region src/fs.d.ts
4
4
  /**
@@ -40,4 +40,4 @@ declare function readMetadata(screenshotPath: string): Promise<ScreenshotMetadat
40
40
  */
41
41
  declare function getPlaywrightTracePath(screenshotPath: string): Promise<string | null>;
42
42
  //#endregion
43
- export { ScreenshotMetadata, createDirectory, createTemporaryDirectory, getGitRepositoryPath, getMetadataPath, getPlaywrightTracePath, getScreenshotName, readMetadata, readVersionFromPackage, validateThreshold, writeMetadata };
43
+ 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-5SGmtKTq.mjs";
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";
@@ -100,4 +100,4 @@ async function getPlaywrightTracePath(screenshotPath) {
100
100
  }
101
101
  }
102
102
  //#endregion
103
- export { createDirectory, createTemporaryDirectory, getGitRepositoryPath, getMetadataPath, getPlaywrightTracePath, getScreenshotName, readMetadata, readVersionFromPackage, validateThreshold, writeMetadata };
103
+ export { createDirectory, createTemporaryDirectory, getGitRepositoryPath, getMetadataPath, getPlaywrightTracePath, getScreenshotName, normalizeBaseNames, readMetadata, readVersionFromPackage, validateThreshold, writeMetadata };
@@ -51,8 +51,13 @@ type ScreenshotMetadata = {
51
51
  version: string;
52
52
  };
53
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. */
54
+ /** Threshold configured for this screenshot. */threshold?: number;
55
+ /**
56
+ * Name(s) used to find the comparison baseline, instead of the snapshot's
57
+ * own name. Several names are tried in order: the first one that exists in
58
+ * the baseline wins.
59
+ */
60
+ baseName?: string | string[]; /** Name of the parent screenshot. */
56
61
  parentName?: string;
57
62
  };
58
63
  };
@@ -61,6 +66,13 @@ type ScreenshotMetadata = {
61
66
  */
62
67
  declare function getMetadataPath(snapshotPath: string): string;
63
68
  //#endregion
69
+ //#region src/base-name.d.ts
70
+ /**
71
+ * Normalize the user-facing `baseName` option — a single name or an ordered
72
+ * list of candidates — into a list, or `null` when nothing was provided.
73
+ */
74
+ declare function normalizeBaseNames(baseName: string | string[] | undefined | null): string[] | null;
75
+ //#endregion
64
76
  //#region src/name.d.ts
65
77
  /**
66
78
  * Build a screenshot name from a test name and options.
@@ -75,4 +87,4 @@ declare function getScreenshotName(name: string, options?: {
75
87
  */
76
88
  declare function validateThreshold(threshold: number): void;
77
89
  //#endregion
78
- export { getMetadataPath as i, getScreenshotName as n, ScreenshotMetadata as r, validateThreshold as t };
90
+ 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.0.1",
4
+ "version": "4.1.0",
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": "7fddaad1a6bb251a1f2eecbf8f4ecfa3e84e9b97"
51
+ "gitHead": "a3083087b11004e0b315e2d14f1e9179cbd56da2"
51
52
  }