@percy/core 1.28.3 → 1.28.4-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/timing.js ADDED
@@ -0,0 +1,21 @@
1
+ import logger from '@percy/logger';
2
+ export default class TimeIt {
3
+ log = logger('timer');
4
+ // returns a singleton instance
5
+ constructor() {
6
+ let {
7
+ instance = this
8
+ } = this.constructor;
9
+ this.constructor.instance = instance;
10
+ return instance;
11
+ }
12
+ async measure(name, identifier, callback) {
13
+ const startTime = Date.now();
14
+ try {
15
+ return await callback();
16
+ } finally {
17
+ const duration = Date.now() - startTime;
18
+ this.log.info(`${name} - ${identifier} - ${duration / 1000}s`);
19
+ }
20
+ }
21
+ }
package/dist/utils.js CHANGED
@@ -1,6 +1,10 @@
1
1
  import EventEmitter from 'events';
2
2
  import { sha256hash } from '@percy/client/utils';
3
3
  import { camelcase, merge } from '@percy/config/utils';
4
+ import YAML from 'yaml';
5
+ import path from 'path';
6
+ import url from 'url';
7
+ import { readFileSync } from 'fs';
4
8
  export { request, getPackageJSON, hostnameMatches } from '@percy/client/utils';
5
9
  export { Server, createServer } from './server.js';
6
10
 
@@ -351,6 +355,28 @@ export async function withRetries(fn, {
351
355
  }
352
356
  }
353
357
  }
358
+ export function redactSecrets(data) {
359
+ const filepath = path.resolve(url.fileURLToPath(import.meta.url), '../secretPatterns.yml');
360
+ const secretPatterns = YAML.parse(readFileSync(filepath, 'utf-8'));
361
+ if (Array.isArray(data)) {
362
+ // Process each item in the array
363
+ return data.map(item => redactSecrets(item));
364
+ } else if (typeof data === 'object' && data !== null) {
365
+ // Process each key-value pair in the object
366
+ data.message = redactSecrets(data.message);
367
+ }
368
+ if (typeof data === 'string') {
369
+ for (const pattern of secretPatterns.patterns) {
370
+ data = data.replace(new RegExp(pattern.pattern.regex, 'g'), '[REDACTED]');
371
+ }
372
+ }
373
+ return data;
374
+ }
375
+
376
+ // Returns a base64 encoding of a string or buffer.
377
+ export function base64encode(content) {
378
+ return Buffer.from(content).toString('base64');
379
+ }
354
380
  export function snapshotLogName(name, meta) {
355
381
  var _meta$snapshot;
356
382
  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.28.3",
3
+ "version": "1.28.4-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": "latest"
12
+ "tag": "beta"
13
13
  },
14
14
  "engines": {
15
15
  "node": ">=14"
@@ -43,11 +43,11 @@
43
43
  "test:types": "tsd"
44
44
  },
45
45
  "dependencies": {
46
- "@percy/client": "1.28.3",
47
- "@percy/config": "1.28.3",
48
- "@percy/dom": "1.28.3",
49
- "@percy/logger": "1.28.3",
50
- "@percy/webdriver-utils": "1.28.3",
46
+ "@percy/client": "1.28.4-beta.0",
47
+ "@percy/config": "1.28.4-beta.0",
48
+ "@percy/dom": "1.28.4-beta.0",
49
+ "@percy/logger": "1.28.4-beta.0",
50
+ "@percy/webdriver-utils": "1.28.4-beta.0",
51
51
  "content-disposition": "^0.5.4",
52
52
  "cross-spawn": "^7.0.3",
53
53
  "extract-zip": "^2.0.1",
@@ -57,7 +57,8 @@
57
57
  "pako": "^2.1.0",
58
58
  "path-to-regexp": "^6.2.0",
59
59
  "rimraf": "^3.0.2",
60
- "ws": "^8.0.0"
60
+ "ws": "^8.0.0",
61
+ "yaml": "^2.4.1"
61
62
  },
62
- "gitHead": "5d41045921c7ac06329c4b72caaf291d34e3f699"
63
+ "gitHead": "fe4d7e944acd2081d901eb2eed202ccb64098576"
63
64
  }
@@ -10,6 +10,7 @@ export function mockfs(initial) {
10
10
 
11
11
  $bypass: [
12
12
  path.resolve(url.fileURLToPath(import.meta.url), '/../../../dom/dist/bundle.js'),
13
+ path.resolve(url.fileURLToPath(import.meta.url), '../secretPatterns.yml'),
13
14
  p => p.includes?.('.local-chromium'),
14
15
  ...(initial?.$bypass ?? [])
15
16
  ]