@percy/client 1.28.8-beta.4 → 1.28.8
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 +10 -3
- package/dist/utils.js +13 -0
- package/package.json +5 -5
package/dist/client.js
CHANGED
|
@@ -3,7 +3,7 @@ import PercyEnv from '@percy/env';
|
|
|
3
3
|
import { git } from '@percy/env/utils';
|
|
4
4
|
import logger from '@percy/logger';
|
|
5
5
|
import Pako from 'pako';
|
|
6
|
-
import { pool, request, formatBytes, sha256hash, base64encode, getPackageJSON, waitForTimeout, validateTiles } from './utils.js';
|
|
6
|
+
import { pool, request, formatBytes, sha256hash, base64encode, getPackageJSON, waitForTimeout, validateTiles, tagsList } from './utils.js';
|
|
7
7
|
|
|
8
8
|
// Default client API URL can be set with an env var for API development
|
|
9
9
|
const {
|
|
@@ -45,13 +45,15 @@ export class PercyClient {
|
|
|
45
45
|
clientInfo,
|
|
46
46
|
environmentInfo,
|
|
47
47
|
config,
|
|
48
|
+
labels,
|
|
48
49
|
// versioned api url
|
|
49
50
|
apiUrl = PERCY_CLIENT_API_URL
|
|
50
51
|
} = {}) {
|
|
51
52
|
Object.assign(this, {
|
|
52
53
|
token,
|
|
53
54
|
config: config || {},
|
|
54
|
-
apiUrl
|
|
55
|
+
apiUrl,
|
|
56
|
+
labels: labels
|
|
55
57
|
});
|
|
56
58
|
this.addClientInfo(clientInfo);
|
|
57
59
|
this.addEnvironmentInfo(environmentInfo);
|
|
@@ -129,6 +131,7 @@ export class PercyClient {
|
|
|
129
131
|
projectType
|
|
130
132
|
} = {}) {
|
|
131
133
|
this.log.debug('Creating a new build...');
|
|
134
|
+
let tagsArr = tagsList(this.labels);
|
|
132
135
|
return this.post('builds', {
|
|
133
136
|
data: {
|
|
134
137
|
type: 'builds',
|
|
@@ -147,7 +150,8 @@ export class PercyClient {
|
|
|
147
150
|
'pull-request-number': this.env.pullRequest,
|
|
148
151
|
'parallel-nonce': this.env.parallel.nonce,
|
|
149
152
|
'parallel-total-shards': this.env.parallel.total,
|
|
150
|
-
partial: this.env.partial
|
|
153
|
+
partial: this.env.partial,
|
|
154
|
+
tags: tagsArr
|
|
151
155
|
},
|
|
152
156
|
relationships: {
|
|
153
157
|
resources: {
|
|
@@ -362,6 +366,7 @@ export class PercyClient {
|
|
|
362
366
|
environmentInfo,
|
|
363
367
|
sync,
|
|
364
368
|
testCase,
|
|
369
|
+
labels,
|
|
365
370
|
thTestCaseExecutionId,
|
|
366
371
|
resources = []
|
|
367
372
|
} = {}) {
|
|
@@ -371,6 +376,7 @@ export class PercyClient {
|
|
|
371
376
|
if (!this.clientInfo.size || !this.environmentInfo.size) {
|
|
372
377
|
this.log.warn('Warning: Missing `clientInfo` and/or `environmentInfo` properties');
|
|
373
378
|
}
|
|
379
|
+
let tagsArr = tagsList(labels);
|
|
374
380
|
this.log.debug(`Creating snapshot: ${name}...`);
|
|
375
381
|
for (let resource of resources) {
|
|
376
382
|
if (resource.sha || resource.content || !resource.filepath) continue;
|
|
@@ -385,6 +391,7 @@ export class PercyClient {
|
|
|
385
391
|
scope: scope || null,
|
|
386
392
|
sync: !!sync,
|
|
387
393
|
'test-case': testCase || null,
|
|
394
|
+
tags: tagsArr,
|
|
388
395
|
'scope-options': scopeOptions || {},
|
|
389
396
|
'minimum-height': minHeight || null,
|
|
390
397
|
'enable-javascript': enableJavaScript || null,
|
package/dist/utils.js
CHANGED
|
@@ -233,4 +233,17 @@ export function validateTiles(tiles) {
|
|
|
233
233
|
}
|
|
234
234
|
return true;
|
|
235
235
|
}
|
|
236
|
+
|
|
237
|
+
// convert tags comma-separated-names to array of objects for POST request
|
|
238
|
+
export function tagsList(tags) {
|
|
239
|
+
let tagsArr = [];
|
|
240
|
+
if (typeof tags !== 'undefined' && tags !== null && typeof tags === 'string') {
|
|
241
|
+
let tagNamesArray = tags.split(',');
|
|
242
|
+
tagsArr = tagNamesArray.map(name => ({
|
|
243
|
+
id: null,
|
|
244
|
+
name: name.trim()
|
|
245
|
+
}));
|
|
246
|
+
}
|
|
247
|
+
return tagsArr;
|
|
248
|
+
}
|
|
236
249
|
export { hostnameMatches, ProxyHttpAgent, ProxyHttpsAgent, proxyAgentFor } from './proxy.js';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@percy/client",
|
|
3
|
-
"version": "1.28.8
|
|
3
|
+
"version": "1.28.8",
|
|
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": "latest"
|
|
13
13
|
},
|
|
14
14
|
"engines": {
|
|
15
15
|
"node": ">=14"
|
|
@@ -32,9 +32,9 @@
|
|
|
32
32
|
"test:coverage": "yarn test --coverage"
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@percy/env": "1.28.8
|
|
36
|
-
"@percy/logger": "1.28.8
|
|
35
|
+
"@percy/env": "1.28.8",
|
|
36
|
+
"@percy/logger": "1.28.8",
|
|
37
37
|
"pako": "^2.1.0"
|
|
38
38
|
},
|
|
39
|
-
"gitHead": "
|
|
39
|
+
"gitHead": "1b93761a01b608afadf8d4efccacc11f925396bd"
|
|
40
40
|
}
|