@percy/core 1.6.0 → 1.6.3

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/api.js CHANGED
@@ -107,8 +107,9 @@ export function createPercyServer(percy, port) {
107
107
  body = Buffer.isBuffer(body) ? body.toString() : body;
108
108
 
109
109
  if (cmd === 'reset') {
110
- // the reset command will reset testing mode to its default options
110
+ // the reset command will reset testing mode and clear any logs
111
111
  percy.testing = {};
112
+ logger.instance.messages.clear();
112
113
  } else if (cmd === 'version') {
113
114
  // the version command will update the api version header for testing
114
115
  percy.testing.version = body;
package/dist/discovery.js CHANGED
@@ -64,6 +64,7 @@ export function createRequestFinishedHandler(network, {
64
64
  let resource = getResource(url); // process and cache the response and resource
65
65
 
66
66
  if (!((_resource = resource) !== null && _resource !== void 0 && _resource.root) && (!resource || disableCache)) {
67
+ let headers = request.headers;
67
68
  let response = request.response;
68
69
  let capture = response && hostnameMatches(allowedHostnames, url);
69
70
  let body = capture && (await response.buffer());
@@ -85,14 +86,21 @@ export function createRequestFinishedHandler(network, {
85
86
  } // Try to get the proper mimetype if the server or asset discovery browser is sending `text/plain`
86
87
 
87
88
 
88
- let mimeType = response.mimeType === 'text/plain' && mime.lookup(response.url) || response.mimeType;
89
+ let mimeType = response.mimeType === 'text/plain' && mime.lookup(response.url) || response.mimeType; // font responses from the browser may not be properly encoded, so request them directly
89
90
 
90
91
  if (mimeType !== null && mimeType !== void 0 && mimeType.includes('font')) {
91
- // font responses from the browser may not be properly encoded, so request them directly
92
+ var _network$authorizatio;
93
+
92
94
  log.debug('- Requesting asset directly');
95
+
96
+ if (!headers.Authorization && (_network$authorizatio = network.authorization) !== null && _network$authorizatio !== void 0 && _network$authorizatio.username) {
97
+ let token = Buffer.from([network.authorization.username, network.authorization.password || ''].join(':')).toString('base64');
98
+ headers.Authorization = `Basic ${token}`;
99
+ }
100
+
93
101
  body = await makeRequest(response.url, {
94
102
  buffer: true,
95
- headers: request.headers
103
+ headers
96
104
  });
97
105
  }
98
106
 
package/dist/percy.js CHANGED
@@ -25,7 +25,9 @@ export class Percy {
25
25
  constructor({
26
26
  // initial log level
27
27
  loglevel,
28
- // do not eagerly upload snapshots
28
+ // process uploads before the next snapshot
29
+ delayUploads,
30
+ // process uploads after all snapshots
29
31
  deferUploads,
30
32
  // run without uploading anything
31
33
  skipUploads,
@@ -51,7 +53,8 @@ export class Percy {
51
53
  this.testing = testing ? {} : null;
52
54
  this.dryRun = !!testing || !!dryRun;
53
55
  this.skipUploads = this.dryRun || !!skipUploads;
54
- this.deferUploads = this.skipUploads || !!deferUploads;
56
+ this.delayUploads = this.skipUploads || !!delayUploads;
57
+ this.deferUploads = this.delayUploads || !!deferUploads;
55
58
  if (this.deferUploads) this.#uploads.stop();
56
59
  this.config = PercyConfig.load({
57
60
  overrides: options,
@@ -66,6 +69,10 @@ export class Percy {
66
69
  this.#snapshots.concurrency = concurrency;
67
70
  }
68
71
 
72
+ if (this.delayUploads) {
73
+ this.#uploads.concurrency = 1;
74
+ }
75
+
69
76
  this.client = new PercyClient({
70
77
  token,
71
78
  clientInfo,
@@ -166,7 +173,7 @@ export class Percy {
166
173
  };
167
174
  this.build.number = attributes['build-number'];
168
175
  this.build.url = attributes['web-url'];
169
- this.#uploads.run();
176
+ if (!this.delayUploads) this.#uploads.run();
170
177
  });
171
178
  }, 0); // handle deferred build errors
172
179
 
@@ -449,11 +456,13 @@ export class Percy {
449
456
  _scheduleUpload(name, options) {
450
457
  var _this$build4;
451
458
 
452
- if ((_this$build4 = this.build) !== null && _this$build4 !== void 0 && _this$build4.error) {
453
- throw new Error(this.build.error);
454
- }
459
+ if ((_this$build4 = this.build) !== null && _this$build4 !== void 0 && _this$build4.error) throw new Error(this.build.error); // maybe process any existing delayed uploads
455
460
 
461
+ if (!this.skipUploads && this.delayUploads) this.#uploads.run();
456
462
  return this.#uploads.push(`upload/${name}`, async () => {
463
+ // when delayed, stop the queue before other uploads are processed
464
+ if (this.delayUploads) this.#uploads.stop();
465
+
457
466
  try {
458
467
  /* istanbul ignore if: useful for other internal packages */
459
468
  if (typeof options === 'function') options = await options();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@percy/core",
3
- "version": "1.6.0",
3
+ "version": "1.6.3",
4
4
  "license": "MIT",
5
5
  "repository": {
6
6
  "type": "git",
@@ -39,10 +39,10 @@
39
39
  "test:types": "tsd"
40
40
  },
41
41
  "dependencies": {
42
- "@percy/client": "1.6.0",
43
- "@percy/config": "1.6.0",
44
- "@percy/dom": "1.6.0",
45
- "@percy/logger": "1.6.0",
42
+ "@percy/client": "1.6.3",
43
+ "@percy/config": "1.6.3",
44
+ "@percy/dom": "1.6.3",
45
+ "@percy/logger": "1.6.3",
46
46
  "content-disposition": "^0.5.4",
47
47
  "cross-spawn": "^7.0.3",
48
48
  "extract-zip": "^2.0.1",
@@ -53,5 +53,5 @@
53
53
  "rimraf": "^3.0.2",
54
54
  "ws": "^8.0.0"
55
55
  },
56
- "gitHead": "dd03aec4a68a26425cda3afd10fa142011198b5f"
56
+ "gitHead": "ab48a150317a4af36d536a5671701532c669d2d1"
57
57
  }