@percy/core 1.29.1-beta.1 → 1.29.2-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/network.js +1 -12
- package/dist/percy.js +3 -3
- package/dist/snapshot.js +4 -21
- package/dist/utils.js +0 -29
- package/package.json +7 -7
package/dist/network.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { request as makeRequest } from '@percy/client/utils';
|
|
2
2
|
import logger from '@percy/logger';
|
|
3
3
|
import mime from 'mime-types';
|
|
4
|
-
import { DefaultMap, createResource,
|
|
4
|
+
import { DefaultMap, createResource, hostnameMatches, normalizeURL, waitFor } from './utils.js';
|
|
5
5
|
const MAX_RESOURCE_SIZE = 25 * 1024 ** 2; // 25MB
|
|
6
6
|
const ALLOWED_STATUSES = [200, 201, 301, 302, 304, 307, 308];
|
|
7
7
|
const ALLOWED_RESOURCES = ['Document', 'Stylesheet', 'Image', 'Media', 'Font', 'Other'];
|
|
@@ -213,17 +213,6 @@ export class Network {
|
|
|
213
213
|
|
|
214
214
|
// do not handle data urls
|
|
215
215
|
if (request.url.startsWith('data:')) return;
|
|
216
|
-
|
|
217
|
-
// Browsers handle URL encoding leniently, but invalid characters can break tools like Jackproxy.
|
|
218
|
-
// This code checks for issues such as `%` and leading spaces and warns the user accordingly.
|
|
219
|
-
decodeAndEncodeURLWithLogging(request.url, this.log, {
|
|
220
|
-
meta: {
|
|
221
|
-
...this.meta,
|
|
222
|
-
url: request.url
|
|
223
|
-
},
|
|
224
|
-
shouldLogWarning: true,
|
|
225
|
-
warningMessage: `An invalid URL was detected for url: ${request.url} - the snapshot may fail on Percy. Please verify that your asset URL is valid.`
|
|
226
|
-
});
|
|
227
216
|
if (this.intercept) {
|
|
228
217
|
this.#pending.set(requestId, event);
|
|
229
218
|
if (this.captureMockedServiceWorker) {
|
package/dist/percy.js
CHANGED
|
@@ -146,7 +146,7 @@ export class Percy {
|
|
|
146
146
|
|
|
147
147
|
// validate provided config options
|
|
148
148
|
let errors = PercyConfig.validate(config);
|
|
149
|
-
if (errors) {
|
|
149
|
+
if ((errors === null || errors === void 0 ? void 0 : errors.length) > 0) {
|
|
150
150
|
this.log.warn('Invalid config:');
|
|
151
151
|
for (let e of errors) this.log.warn(`- ${e.path}: ${e.message}`);
|
|
152
152
|
}
|
|
@@ -177,7 +177,7 @@ export class Percy {
|
|
|
177
177
|
this.readyState = 0;
|
|
178
178
|
try {
|
|
179
179
|
if (process.env.PERCY_CLIENT_ERROR_LOGS !== 'false') {
|
|
180
|
-
this.log.warn('Notice: Percy collects CI logs
|
|
180
|
+
this.log.warn('Notice: Percy collects CI logs to improve service and enhance your experience. These logs help us debug issues and provide insights on your dashboards, making it easier to optimize the product experience. Logs are stored securely for 30 days. You can opt out anytime with export PERCY_CLIENT_ERROR_LOGS=false, but keeping this enabled helps us offer the best support and features.');
|
|
181
181
|
}
|
|
182
182
|
// Not awaiting proxy check as this can be asyncronous when not enabled
|
|
183
183
|
const detectProxy = detectSystemProxyAndLog(this.config.percy.useSystemProxy);
|
|
@@ -417,7 +417,7 @@ export class Percy {
|
|
|
417
417
|
...comparison
|
|
418
418
|
} = options;
|
|
419
419
|
let errors = PercyConfig.validate(comparison, '/comparison');
|
|
420
|
-
if (errors) {
|
|
420
|
+
if ((errors === null || errors === void 0 ? void 0 : errors.length) > 0) {
|
|
421
421
|
this.log.warn('Invalid upload options:');
|
|
422
422
|
for (let e of errors) this.log.warn(`- ${e.path}: ${e.message}`);
|
|
423
423
|
}
|
package/dist/snapshot.js
CHANGED
|
@@ -3,7 +3,7 @@ import PercyConfig from '@percy/config';
|
|
|
3
3
|
import micromatch from 'micromatch';
|
|
4
4
|
import { configSchema } from './config.js';
|
|
5
5
|
import Queue from './queue.js';
|
|
6
|
-
import { request, hostnameMatches, yieldTo, snapshotLogName
|
|
6
|
+
import { request, hostnameMatches, yieldTo, snapshotLogName } from './utils.js';
|
|
7
7
|
import { JobData } from './wait-for-job.js';
|
|
8
8
|
|
|
9
9
|
// Throw a better error message for missing or invalid urls
|
|
@@ -17,23 +17,6 @@ function validURL(url, base) {
|
|
|
17
17
|
throw new Error(`Invalid snapshot URL: ${e.input}`);
|
|
18
18
|
}
|
|
19
19
|
}
|
|
20
|
-
function validateAndFixSnapshotUrl(snapshot) {
|
|
21
|
-
let log = logger('core:snapshot');
|
|
22
|
-
// encoding snapshot url, if contians invalid URI characters/syntax
|
|
23
|
-
let modifiedURL = decodeAndEncodeURLWithLogging(snapshot.url, log, {
|
|
24
|
-
meta: {
|
|
25
|
-
snapshot: {
|
|
26
|
-
name: snapshot.name || snapshot.url
|
|
27
|
-
}
|
|
28
|
-
},
|
|
29
|
-
shouldLogWarning: true,
|
|
30
|
-
warningMessage: `Invalid URL detected for url: ${snapshot.url} - the snapshot may fail on Percy. Please confirm that your website URL is valid.`
|
|
31
|
-
});
|
|
32
|
-
if (modifiedURL !== snapshot.url) {
|
|
33
|
-
log.debug(`Snapshot URL modified to: ${modifiedURL}`);
|
|
34
|
-
snapshot.url = modifiedURL;
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
20
|
|
|
38
21
|
// used to deserialize regular expression strings
|
|
39
22
|
const RE_REGEXP = /^\/(.+)\/(\w+)?$/;
|
|
@@ -103,9 +86,9 @@ function mapSnapshotOptions(snapshots, context) {
|
|
|
103
86
|
if (typeof snapshot === 'string') snapshot = {
|
|
104
87
|
url: snapshot
|
|
105
88
|
};
|
|
106
|
-
|
|
107
|
-
let url = validURL(snapshot.url, context === null || context === void 0 ? void 0 : context.baseUrl);
|
|
89
|
+
|
|
108
90
|
// normalize the snapshot url and use it for the default name
|
|
91
|
+
let url = validURL(snapshot.url, context === null || context === void 0 ? void 0 : context.baseUrl);
|
|
109
92
|
(_snapshot = snapshot).name || (_snapshot.name = `${url.pathname}${url.search}${url.hash}`);
|
|
110
93
|
snapshot.url = url.href;
|
|
111
94
|
|
|
@@ -226,7 +209,7 @@ export function validateSnapshotOptions(options) {
|
|
|
226
209
|
|
|
227
210
|
// warn on validation errors
|
|
228
211
|
let errors = PercyConfig.validate(migrated, schema);
|
|
229
|
-
if (errors) {
|
|
212
|
+
if ((errors === null || errors === void 0 ? void 0 : errors.length) > 0) {
|
|
230
213
|
log.warn('Invalid snapshot options:');
|
|
231
214
|
for (let e of errors) log.warn(`- ${e.path}: ${e.message}`);
|
|
232
215
|
}
|
package/dist/utils.js
CHANGED
|
@@ -379,35 +379,6 @@ export function redactSecrets(data) {
|
|
|
379
379
|
export function base64encode(content) {
|
|
380
380
|
return Buffer.from(content).toString('base64');
|
|
381
381
|
}
|
|
382
|
-
|
|
383
|
-
// This function replaces invalid character that are not the
|
|
384
|
-
// part of valid URI syntax with there correct encoded value.
|
|
385
|
-
// Also, if a character is a part of valid URI syntax, those characters
|
|
386
|
-
// are not encoded
|
|
387
|
-
// Eg: [abc] -> gets encoded to %5Babc%5D
|
|
388
|
-
// ab c -> ab%20c
|
|
389
|
-
export function decodeAndEncodeURLWithLogging(url, logger, options = {}) {
|
|
390
|
-
// In case the url is partially encoded, then directly using encodeURI()
|
|
391
|
-
// will encode those characters again. Therefore decodeURI once helps is decoding
|
|
392
|
-
// partially encoded URL and then after encoding it again, full URL get encoded
|
|
393
|
-
// correctly.
|
|
394
|
-
const {
|
|
395
|
-
meta,
|
|
396
|
-
shouldLogWarning,
|
|
397
|
-
warningMessage
|
|
398
|
-
} = options;
|
|
399
|
-
try {
|
|
400
|
-
let decodedURL = decodeURI(url); // This can throw error, so handle it will trycatch
|
|
401
|
-
let encodedURL = encodeURI(decodedURL);
|
|
402
|
-
return encodedURL;
|
|
403
|
-
} catch (error) {
|
|
404
|
-
logger.debug(error, meta);
|
|
405
|
-
if (error.name === 'URIError' && shouldLogWarning) {
|
|
406
|
-
logger.warn(warningMessage);
|
|
407
|
-
}
|
|
408
|
-
return url;
|
|
409
|
-
}
|
|
410
|
-
}
|
|
411
382
|
export function snapshotLogName(name, meta) {
|
|
412
383
|
var _meta$snapshot;
|
|
413
384
|
if (meta !== null && meta !== void 0 && (_meta$snapshot = meta.snapshot) !== null && _meta$snapshot !== void 0 && _meta$snapshot.testCase) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@percy/core",
|
|
3
|
-
"version": "1.29.
|
|
3
|
+
"version": "1.29.2-beta.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -43,11 +43,11 @@
|
|
|
43
43
|
"test:types": "tsd"
|
|
44
44
|
},
|
|
45
45
|
"dependencies": {
|
|
46
|
-
"@percy/client": "1.29.
|
|
47
|
-
"@percy/config": "1.29.
|
|
48
|
-
"@percy/dom": "1.29.
|
|
49
|
-
"@percy/logger": "1.29.
|
|
50
|
-
"@percy/webdriver-utils": "1.29.
|
|
46
|
+
"@percy/client": "1.29.2-beta.0",
|
|
47
|
+
"@percy/config": "1.29.2-beta.0",
|
|
48
|
+
"@percy/dom": "1.29.2-beta.0",
|
|
49
|
+
"@percy/logger": "1.29.2-beta.0",
|
|
50
|
+
"@percy/webdriver-utils": "1.29.2-beta.0",
|
|
51
51
|
"content-disposition": "^0.5.4",
|
|
52
52
|
"cross-spawn": "^7.0.3",
|
|
53
53
|
"extract-zip": "^2.0.1",
|
|
@@ -60,5 +60,5 @@
|
|
|
60
60
|
"ws": "^8.17.1",
|
|
61
61
|
"yaml": "^2.4.1"
|
|
62
62
|
},
|
|
63
|
-
"gitHead": "
|
|
63
|
+
"gitHead": "5e1526d9d9b3e08f3f667de97f340c3ac8c3809c"
|
|
64
64
|
}
|