@percy/core 1.32.9 → 1.32.10-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/discovery.js +1 -7
- package/dist/snapshot.js +34 -1
- package/dist/utils.js +0 -8
- package/package.json +10 -10
package/dist/discovery.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import logger from '@percy/logger';
|
|
2
2
|
import Queue from './queue.js';
|
|
3
3
|
import Page from './page.js';
|
|
4
|
-
import { normalizeURL, hostnameMatches, createResource, createRootResource, createPercyCSSResource,
|
|
4
|
+
import { normalizeURL, hostnameMatches, createResource, createRootResource, createPercyCSSResource, yieldAll, snapshotLogName, waitForTimeout, withRetries, waitForSelectorInsideBrowser, isGzipped, maybeScrollToBottom, assertNotMetadataTarget } from './utils.js';
|
|
5
5
|
import { ByteLRU, entrySize, DiskSpillStore, createSpillDir } from './cache/byte-lru.js';
|
|
6
6
|
import { sha256hash } from '@percy/client/utils';
|
|
7
7
|
import Pako from 'pako';
|
|
@@ -224,12 +224,6 @@ function processSnapshotResources({
|
|
|
224
224
|
|
|
225
225
|
// For multi dom root resources are stored as array
|
|
226
226
|
resources = resources.flat();
|
|
227
|
-
|
|
228
|
-
// include associated snapshot logs matched by meta information. Redact
|
|
229
|
-
// secrets before egress — this per-snapshot log resource is a parallel
|
|
230
|
-
// egress path to sendBuildLogs and must scrub tokens/credentials too (CWE-532).
|
|
231
|
-
resources.push(createLogResource(redactSecrets(logger.snapshotLogs(snapshot.meta.snapshot))));
|
|
232
|
-
logger.evictSnapshot(snapshot.meta.snapshot);
|
|
233
227
|
if (process.env.PERCY_GZIP) {
|
|
234
228
|
const kept = [];
|
|
235
229
|
for (let index = 0; index < resources.length; index++) {
|
package/dist/snapshot.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import logger from '@percy/logger';
|
|
2
2
|
import PercyConfig from '@percy/config';
|
|
3
3
|
import micromatch from 'micromatch';
|
|
4
|
+
import Pako from 'pako';
|
|
4
5
|
import { configSchema } from './config.js';
|
|
5
6
|
import Queue from './queue.js';
|
|
6
|
-
import { request, hostnameMatches, yieldTo, snapshotLogName, decodeAndEncodeURLWithLogging, compareObjectTypes, normalizeOptions } from './utils.js';
|
|
7
|
+
import { request, hostnameMatches, yieldTo, snapshotLogName, decodeAndEncodeURLWithLogging, compareObjectTypes, normalizeOptions, base64encode, redactSecrets } from './utils.js';
|
|
7
8
|
import { JobData } from './wait-for-job.js';
|
|
8
9
|
|
|
9
10
|
// Throw a better error message for missing or invalid urls
|
|
@@ -426,6 +427,31 @@ async function runDoctorOnFailure(percy) {
|
|
|
426
427
|
}
|
|
427
428
|
}
|
|
428
429
|
|
|
430
|
+
// Uploads a single web snapshot's CLI log to the logs endpoint, keyed by the
|
|
431
|
+
// snapshot id, so it lands directly in the log bucket instead of travelling as a
|
|
432
|
+
// snapshot resource. Best-effort: a failure here must never fail the snapshot.
|
|
433
|
+
export async function uploadSnapshotLog(percy, buildId, snapshotId, meta = {}) {
|
|
434
|
+
try {
|
|
435
|
+
var _meta$snapshot;
|
|
436
|
+
if (!buildId || !snapshotId) return;
|
|
437
|
+
|
|
438
|
+
// Redact secrets before egress (CWE-532) — this per-snapshot log is a
|
|
439
|
+
// parallel egress path to sendBuildLogs and must scrub tokens/credentials.
|
|
440
|
+
let logs = redactSecrets(logger.snapshotLogs(meta.snapshot));
|
|
441
|
+
if (!logs.length) return;
|
|
442
|
+
let content = base64encode(Pako.gzip(JSON.stringify(logs)));
|
|
443
|
+
await percy.client.sendSnapshotLog(buildId, snapshotId, content, meta);
|
|
444
|
+
percy.log.debug(`Snapshot log sent for ${(_meta$snapshot = meta.snapshot) === null || _meta$snapshot === void 0 ? void 0 : _meta$snapshot.name}`, meta);
|
|
445
|
+
} catch (err) {
|
|
446
|
+
var _meta$snapshot2;
|
|
447
|
+
percy.log.debug(`Could not send the snapshot log for ${(_meta$snapshot2 = meta.snapshot) === null || _meta$snapshot2 === void 0 ? void 0 : _meta$snapshot2.name}`, meta);
|
|
448
|
+
percy.log.debug(err);
|
|
449
|
+
} finally {
|
|
450
|
+
// drop this snapshot's cached logs regardless of upload outcome
|
|
451
|
+
logger.evictSnapshot(meta.snapshot);
|
|
452
|
+
}
|
|
453
|
+
}
|
|
454
|
+
|
|
429
455
|
// Creates a snapshots queue that manages a Percy build and uploads snapshots.
|
|
430
456
|
export function createSnapshotsQueue(percy) {
|
|
431
457
|
let {
|
|
@@ -569,6 +595,13 @@ export function createSnapshotsQueue(percy) {
|
|
|
569
595
|
let response = yield percy.client[send](build.id, snapshot);
|
|
570
596
|
if (percy.deferUploads) percy.log.info(`Snapshot uploaded: ${name}`, meta);
|
|
571
597
|
|
|
598
|
+
// upload the per-snapshot CLI log directly to the logs endpoint (web
|
|
599
|
+
// snapshots only; automate/app comparisons carry no snapshot log). For
|
|
600
|
+
// sendSnapshot, response.data.id is the snapshot id. Best-effort.
|
|
601
|
+
if (send === 'sendSnapshot') {
|
|
602
|
+
yield uploadSnapshotLog(percy, build.id, response.data.id, meta);
|
|
603
|
+
}
|
|
604
|
+
|
|
572
605
|
// Pushing to syncQueue, that will check for
|
|
573
606
|
// snapshot processing status, and will resolve once done
|
|
574
607
|
if (snapshot.sync) {
|
package/dist/utils.js
CHANGED
|
@@ -481,14 +481,6 @@ export function createPercyCSSResource(url, css) {
|
|
|
481
481
|
});
|
|
482
482
|
}
|
|
483
483
|
|
|
484
|
-
// Creates a log resource object.
|
|
485
|
-
export function createLogResource(logs) {
|
|
486
|
-
let [url, content] = [`/percy.${Date.now()}.log`, JSON.stringify(logs)];
|
|
487
|
-
return createResource(url, content, 'text/plain', {
|
|
488
|
-
log: true
|
|
489
|
-
});
|
|
490
|
-
}
|
|
491
|
-
|
|
492
484
|
// Returns true or false if the provided object is a generator or not
|
|
493
485
|
export function isGenerator(subject) {
|
|
494
486
|
return typeof (subject === null || subject === void 0 ? void 0 : subject.next) === 'function' && (typeof subject[Symbol.iterator] === 'function' || typeof subject[Symbol.asyncIterator] === 'function');
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@percy/core",
|
|
3
|
-
"version": "1.32.
|
|
3
|
+
"version": "1.32.10-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"
|
|
@@ -46,12 +46,12 @@
|
|
|
46
46
|
"dependencies": {
|
|
47
47
|
"@grpc/grpc-js": "^1.14.3",
|
|
48
48
|
"@grpc/proto-loader": "^0.8.0",
|
|
49
|
-
"@percy/client": "1.32.
|
|
50
|
-
"@percy/config": "1.32.
|
|
51
|
-
"@percy/dom": "1.32.
|
|
52
|
-
"@percy/logger": "1.32.
|
|
53
|
-
"@percy/monitoring": "1.32.
|
|
54
|
-
"@percy/webdriver-utils": "1.32.
|
|
49
|
+
"@percy/client": "1.32.10-beta.0",
|
|
50
|
+
"@percy/config": "1.32.10-beta.0",
|
|
51
|
+
"@percy/dom": "1.32.10-beta.0",
|
|
52
|
+
"@percy/logger": "1.32.10-beta.0",
|
|
53
|
+
"@percy/monitoring": "1.32.10-beta.0",
|
|
54
|
+
"@percy/webdriver-utils": "1.32.10-beta.0",
|
|
55
55
|
"adm-zip": "^0.6.0",
|
|
56
56
|
"busboy": "^1.6.0",
|
|
57
57
|
"content-disposition": "^0.5.4",
|
|
@@ -67,7 +67,7 @@
|
|
|
67
67
|
"yaml": "^2.4.1"
|
|
68
68
|
},
|
|
69
69
|
"optionalDependencies": {
|
|
70
|
-
"@percy/cli-doctor": "1.32.
|
|
70
|
+
"@percy/cli-doctor": "1.32.10-beta.0"
|
|
71
71
|
},
|
|
72
|
-
"gitHead": "
|
|
72
|
+
"gitHead": "601168096f9265a7f538152e7bb37bf2a7ffc8a3"
|
|
73
73
|
}
|