@percy/client 1.28.3-beta.1 → 1.28.4-alpha.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 CHANGED
@@ -2,6 +2,7 @@ import fs from 'fs';
2
2
  import PercyEnv from '@percy/env';
3
3
  import { git } from '@percy/env/utils';
4
4
  import logger from '@percy/logger';
5
+ import Pako from 'pako';
5
6
  import { pool, request, formatBytes, sha256hash, base64encode, getPackageJSON, waitForTimeout, validateTiles } from './utils.js';
6
7
 
7
8
  // Default client API URL can be set with an env var for API development
@@ -187,6 +188,7 @@ export class PercyClient {
187
188
  try {
188
189
  return await this.get(`comparisons/${comparisonId}?sync=true&response_format=sync-cli`);
189
190
  } catch (error) {
191
+ this.log.error(error);
190
192
  if (error.response.statusCode === 403) {
191
193
  throw new Error(INVALID_TOKEN_ERROR_MESSAGE);
192
194
  }
@@ -198,6 +200,7 @@ export class PercyClient {
198
200
  try {
199
201
  return await this.get(`snapshots/${snapshotId}?sync=true&response_format=sync-cli`);
200
202
  } catch (error) {
203
+ this.log.error(error);
201
204
  if (error.response.statusCode === 403) {
202
205
  throw new Error(INVALID_TOKEN_ERROR_MESSAGE);
203
206
  }
@@ -315,7 +318,12 @@ export class PercyClient {
315
318
  content
316
319
  } = {}) {
317
320
  validateId('build', buildId);
318
- if (filepath) content = await fs.promises.readFile(filepath);
321
+ if (filepath) {
322
+ content = await fs.promises.readFile(filepath);
323
+ if (process.env.PERCY_GZIP) {
324
+ content = Pako.gzip(content);
325
+ }
326
+ }
319
327
  let encodedContent = base64encode(content);
320
328
  this.log.debug(`Uploading ${formatBytes(encodedContent.length)} resource: ${url}...`);
321
329
  this.mayBeLogUploadSize(encodedContent.length);
@@ -546,6 +554,7 @@ export class PercyClient {
546
554
  }
547
555
  });
548
556
  } catch (error) {
557
+ this.log.error(error);
549
558
  if (error.response.statusCode === 400) {
550
559
  return false;
551
560
  }
@@ -587,6 +596,12 @@ export class PercyClient {
587
596
  data: body
588
597
  });
589
598
  }
599
+ async sendBuildLogs(body) {
600
+ this.log.debug('Sending Build Logs');
601
+ return this.post('logs', {
602
+ data: body
603
+ });
604
+ }
590
605
  mayBeLogUploadSize(contentSize) {
591
606
  if (contentSize >= 25 * 1024 * 1024) {
592
607
  this.log.error('Uploading resource above 25MB might fail the build...');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@percy/client",
3
- "version": "1.28.3-beta.1",
3
+ "version": "1.28.4-alpha.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": "beta"
12
+ "tag": "alpha"
13
13
  },
14
14
  "engines": {
15
15
  "node": ">=14"
@@ -32,8 +32,9 @@
32
32
  "test:coverage": "yarn test --coverage"
33
33
  },
34
34
  "dependencies": {
35
- "@percy/env": "1.28.3-beta.1",
36
- "@percy/logger": "1.28.3-beta.1"
35
+ "@percy/env": "1.28.4-alpha.0",
36
+ "@percy/logger": "1.28.4-alpha.0",
37
+ "pako": "^2.1.0"
37
38
  },
38
- "gitHead": "3a838eedd0f07f57c6c61cd0cba1c7e20cc95af3"
39
+ "gitHead": "596b98dc0cefdb51602facfc1843a9751be8ed2b"
39
40
  }
package/test/helpers.js CHANGED
@@ -145,7 +145,8 @@ export const api = {
145
145
  }],
146
146
  '/discovery/device-details': () => [201, {
147
147
  data: []
148
- }]
148
+ }],
149
+ '/logs': () => [200, 'random_sha']
149
150
  },
150
151
 
151
152
  async mock({ delay = 10 } = {}) {