@percy/client 1.31.12 → 1.31.13-beta.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/dist/client.js +85 -1
- package/package.json +6 -6
package/dist/client.js
CHANGED
|
@@ -40,6 +40,86 @@ function makeRegions(regions, algorithm, algorithmConfiguration) {
|
|
|
40
40
|
}
|
|
41
41
|
}));
|
|
42
42
|
}
|
|
43
|
+
const VISUAL_CONFIG_TOP_LEVEL_KEYS = new Set(['enableLayout', 'percyCssValue', 'compareWithPreviousRun', 'diffIgnoreEnabled', 'diffIgnorePercentage', 'diffSensitivity', 'browsers', 'intelliIgnore']);
|
|
44
|
+
const VISUAL_CONFIG_INTELLI_IGNORE_KEYS = new Set(['enabled', 'dynamic', 'ignoreAds', 'ignoreBanners', 'ignoreCarousels', 'ignoreCustomElementsEnabled', 'ignoreCustomElementsClasses', 'ignoreImages', 'diffIgnorePercentage']);
|
|
45
|
+
function validateBoolean(value, path) {
|
|
46
|
+
if (value != null && typeof value !== 'boolean') {
|
|
47
|
+
throw new Error(`Invalid PERCY_VISUAL_CONFIG: '${path}' must be a boolean`);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
function validateNumberInRange(value, path) {
|
|
51
|
+
if (value == null) return;
|
|
52
|
+
if (typeof value !== 'number' || Number.isNaN(value) || value < 0 || value > 1) {
|
|
53
|
+
throw new Error(`Invalid PERCY_VISUAL_CONFIG: '${path}' must be a number between 0 and 1`);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
function validateIntegerRange(value, path, min, max) {
|
|
57
|
+
if (value == null) return;
|
|
58
|
+
if (!Number.isInteger(value) || value < min || value > max) {
|
|
59
|
+
throw new Error(`Invalid PERCY_VISUAL_CONFIG: '${path}' must be an integer between ${min} and ${max}`);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
function parseVisualConfigFromEnv(log) {
|
|
63
|
+
let rawVisualConfig = process.env.PERCY_VISUAL_CONFIG;
|
|
64
|
+
if (!rawVisualConfig) return;
|
|
65
|
+
let parsed;
|
|
66
|
+
try {
|
|
67
|
+
parsed = JSON.parse(rawVisualConfig);
|
|
68
|
+
} catch {
|
|
69
|
+
throw new Error('Invalid PERCY_VISUAL_CONFIG: value must be valid JSON');
|
|
70
|
+
}
|
|
71
|
+
if (!parsed || typeof parsed !== 'object' || Array.isArray(parsed)) {
|
|
72
|
+
throw new Error('Invalid PERCY_VISUAL_CONFIG: value must be a JSON object');
|
|
73
|
+
}
|
|
74
|
+
let visualConfig = {};
|
|
75
|
+
for (let key of Object.keys(parsed)) {
|
|
76
|
+
if (!VISUAL_CONFIG_TOP_LEVEL_KEYS.has(key)) {
|
|
77
|
+
log.warn(`Ignoring unknown PERCY_VISUAL_CONFIG key: '${key}'`);
|
|
78
|
+
continue;
|
|
79
|
+
}
|
|
80
|
+
visualConfig[key] = parsed[key];
|
|
81
|
+
}
|
|
82
|
+
validateBoolean(visualConfig.enableLayout, 'enableLayout');
|
|
83
|
+
if (visualConfig.percyCssValue != null && typeof visualConfig.percyCssValue !== 'string') {
|
|
84
|
+
throw new Error("Invalid PERCY_VISUAL_CONFIG: 'percyCssValue' must be a string");
|
|
85
|
+
}
|
|
86
|
+
validateBoolean(visualConfig.compareWithPreviousRun, 'compareWithPreviousRun');
|
|
87
|
+
validateBoolean(visualConfig.diffIgnoreEnabled, 'diffIgnoreEnabled');
|
|
88
|
+
validateNumberInRange(visualConfig.diffIgnorePercentage, 'diffIgnorePercentage');
|
|
89
|
+
validateIntegerRange(visualConfig.diffSensitivity, 'diffSensitivity', 1, 5);
|
|
90
|
+
if (visualConfig.browsers != null) {
|
|
91
|
+
if (!Array.isArray(visualConfig.browsers) || !visualConfig.browsers.every(b => typeof b === 'string')) {
|
|
92
|
+
throw new Error("Invalid PERCY_VISUAL_CONFIG: 'browsers' must be an array of strings");
|
|
93
|
+
}
|
|
94
|
+
visualConfig.browsers = normalizeBrowsers(visualConfig.browsers);
|
|
95
|
+
}
|
|
96
|
+
if (visualConfig.intelliIgnore != null) {
|
|
97
|
+
if (!visualConfig.intelliIgnore || typeof visualConfig.intelliIgnore !== 'object' || Array.isArray(visualConfig.intelliIgnore)) {
|
|
98
|
+
throw new Error("Invalid PERCY_VISUAL_CONFIG: 'intelliIgnore' must be an object");
|
|
99
|
+
}
|
|
100
|
+
let sanitizedIntelliIgnore = {};
|
|
101
|
+
for (let key of Object.keys(visualConfig.intelliIgnore)) {
|
|
102
|
+
if (!VISUAL_CONFIG_INTELLI_IGNORE_KEYS.has(key)) {
|
|
103
|
+
log.warn(`Ignoring unknown PERCY_VISUAL_CONFIG intelliIgnore key: '${key}'`);
|
|
104
|
+
continue;
|
|
105
|
+
}
|
|
106
|
+
sanitizedIntelliIgnore[key] = visualConfig.intelliIgnore[key];
|
|
107
|
+
}
|
|
108
|
+
validateBoolean(sanitizedIntelliIgnore.enabled, 'intelliIgnore.enabled');
|
|
109
|
+
validateBoolean(sanitizedIntelliIgnore.dynamic, 'intelliIgnore.dynamic');
|
|
110
|
+
validateBoolean(sanitizedIntelliIgnore.ignoreAds, 'intelliIgnore.ignoreAds');
|
|
111
|
+
validateBoolean(sanitizedIntelliIgnore.ignoreBanners, 'intelliIgnore.ignoreBanners');
|
|
112
|
+
validateBoolean(sanitizedIntelliIgnore.ignoreCarousels, 'intelliIgnore.ignoreCarousels');
|
|
113
|
+
validateBoolean(sanitizedIntelliIgnore.ignoreCustomElementsEnabled, 'intelliIgnore.ignoreCustomElementsEnabled');
|
|
114
|
+
if (sanitizedIntelliIgnore.ignoreCustomElementsClasses != null && typeof sanitizedIntelliIgnore.ignoreCustomElementsClasses !== 'string') {
|
|
115
|
+
throw new Error("Invalid PERCY_VISUAL_CONFIG: 'intelliIgnore.ignoreCustomElementsClasses' must be a string");
|
|
116
|
+
}
|
|
117
|
+
validateBoolean(sanitizedIntelliIgnore.ignoreImages, 'intelliIgnore.ignoreImages');
|
|
118
|
+
validateNumberInRange(sanitizedIntelliIgnore.diffIgnorePercentage, 'intelliIgnore.diffIgnorePercentage');
|
|
119
|
+
visualConfig.intelliIgnore = sanitizedIntelliIgnore;
|
|
120
|
+
}
|
|
121
|
+
return visualConfig;
|
|
122
|
+
}
|
|
43
123
|
|
|
44
124
|
// Validate project path arguments
|
|
45
125
|
function validateProjectPath(path) {
|
|
@@ -185,6 +265,7 @@ export class PercyClient {
|
|
|
185
265
|
} = {}) {
|
|
186
266
|
var _this$config$percy2;
|
|
187
267
|
this.log.debug('Creating a new build...');
|
|
268
|
+
let visualConfig = parseVisualConfigFromEnv(this.log);
|
|
188
269
|
let source = 'user_created';
|
|
189
270
|
if (process.env.PERCY_ORIGINATED_SOURCE) {
|
|
190
271
|
source = 'bstack_sdk_created';
|
|
@@ -216,7 +297,10 @@ export class PercyClient {
|
|
|
216
297
|
source: source,
|
|
217
298
|
'skip-base-build': (_this$config$percy2 = this.config.percy) === null || _this$config$percy2 === void 0 ? void 0 : _this$config$percy2.skipBaseBuild,
|
|
218
299
|
'testhub-build-uuid': this.env.testhubBuildUuid,
|
|
219
|
-
'testhub-build-run-id': this.env.testhubBuildRunId
|
|
300
|
+
'testhub-build-run-id': this.env.testhubBuildRunId,
|
|
301
|
+
...(visualConfig ? {
|
|
302
|
+
'visual-config': visualConfig
|
|
303
|
+
} : {})
|
|
220
304
|
},
|
|
221
305
|
relationships: {
|
|
222
306
|
resources: {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@percy/client",
|
|
3
|
-
"version": "1.31.
|
|
3
|
+
"version": "1.31.13-beta.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
},
|
|
10
10
|
"publishConfig": {
|
|
11
11
|
"access": "public",
|
|
12
|
-
"tag": "
|
|
12
|
+
"tag": "beta"
|
|
13
13
|
},
|
|
14
14
|
"engines": {
|
|
15
15
|
"node": ">=14"
|
|
@@ -33,11 +33,11 @@
|
|
|
33
33
|
"test:coverage": "yarn test --coverage"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@percy/config": "1.31.
|
|
37
|
-
"@percy/env": "1.31.
|
|
38
|
-
"@percy/logger": "1.31.
|
|
36
|
+
"@percy/config": "1.31.13-beta.0",
|
|
37
|
+
"@percy/env": "1.31.13-beta.0",
|
|
38
|
+
"@percy/logger": "1.31.13-beta.0",
|
|
39
39
|
"pac-proxy-agent": "^7.0.2",
|
|
40
40
|
"pako": "^2.1.0"
|
|
41
41
|
},
|
|
42
|
-
"gitHead": "
|
|
42
|
+
"gitHead": "69c6ad10d5724455cebf57f2043adc30559c3b31"
|
|
43
43
|
}
|