Socket
Socket
Sign inDemoInstall

@percy/client

Package Overview
Dependencies
Maintainers
6
Versions
238
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@percy/client - npm Package Compare versions

Comparing version 1.17.0 to 1.18.0

47

dist/client.js

@@ -5,3 +5,3 @@ import fs from 'fs';

import logger from '@percy/logger';
import { pool, request, sha256hash, base64encode, getPackageJSON } from './utils.js';
import { pool, request, sha256hash, base64encode, getPackageJSON, waitForTimeout } from './utils.js';

@@ -116,3 +116,4 @@ // Default client API URL can be set with an env var for API development

async createBuild({
resources = []
resources = [],
projectType
} = {}) {

@@ -124,2 +125,3 @@ this.log.debug('Creating a new build...');

attributes: {
type: projectType,
branch: this.env.git.branch,

@@ -410,3 +412,4 @@ 'target-branch': this.env.target.branch,

filepath,
content
content,
sha
} = {}) {

@@ -416,2 +419,5 @@ validateId('comparison', comparisonId);

if (filepath) content = await fs.promises.readFile(filepath);
if (sha) {
return await this.verify(comparisonId, sha);
}
return this.post(`comparisons/${comparisonId}/tiles`, {

@@ -427,2 +433,37 @@ data: {

}
// Convenience method for verifying if tile is present
async verify(comparisonId, sha) {
let retries = 10;
let success = null;
do {
await waitForTimeout(500);
success = await this.verifyComparisonTile(comparisonId, sha);
retries -= 1;
} while (retries > 0 && !success);
if (!success) {
this.log.error('Uploading comparison tile failed');
return false;
}
return true;
}
async verifyComparisonTile(comparisonId, sha) {
validateId('comparison', comparisonId);
this.log.debug(`Verifying comparison tile with sha: ${sha}`);
try {
return await this.get(`comparisons/${comparisonId}/tiles/verify`, {
data: {
type: 'tiles',
attributes: {
sha: sha
}
}
});
} catch (error) {
if (error.message.includes('409')) {
return false;
}
throw error;
}
}
async uploadComparisonTiles(comparisonId, tiles) {

@@ -429,0 +470,0 @@ validateId('comparison', comparisonId);

@@ -16,2 +16,5 @@ import os from 'os';

}
export function waitForTimeout() {
return new Promise(resolve => setTimeout(resolve, ...arguments));
}

@@ -18,0 +21,0 @@ // Returns the package.json content at the package path.

8

package.json
{
"name": "@percy/client",
"version": "1.17.0",
"version": "1.18.0",
"license": "MIT",

@@ -34,6 +34,6 @@ "repository": {

"dependencies": {
"@percy/env": "1.17.0",
"@percy/logger": "1.17.0"
"@percy/env": "1.18.0",
"@percy/logger": "1.18.0"
},
"gitHead": "b7b2403047ea6208de71c73232df8a5375781a30"
"gitHead": "8aeb759653765fea11e8ebeb96c53a4c4ea616b2"
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc