@percy/sdk-utils 1.0.0-beta.70 → 1.0.0-beta.71
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/bundle.js +30 -15
- package/package.json +3 -3
- package/test/client.js +28 -16
package/dist/bundle.js
CHANGED
|
@@ -48,7 +48,8 @@
|
|
|
48
48
|
} // map ansi colors to bound colorize functions
|
|
49
49
|
|
|
50
50
|
|
|
51
|
-
const colors = entries(ANSI_COLORS).reduce((colors,
|
|
51
|
+
const colors = entries(ANSI_COLORS).reduce((colors, _ref) => {
|
|
52
|
+
let [code, name] = _ref;
|
|
52
53
|
return assign(colors, {
|
|
53
54
|
[name]: colorize.bind(null, code)
|
|
54
55
|
});
|
|
@@ -229,7 +230,8 @@
|
|
|
229
230
|
// information to store with the message and other info
|
|
230
231
|
|
|
231
232
|
|
|
232
|
-
log(debug, level, message
|
|
233
|
+
log(debug, level, message) {
|
|
234
|
+
let meta = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
|
|
233
235
|
// message might be an error object
|
|
234
236
|
let isError = typeof message !== 'string' && (level === 'error' || level === 'debug');
|
|
235
237
|
let error = isError && message; // if remote, send logs there
|
|
@@ -300,9 +302,10 @@
|
|
|
300
302
|
}
|
|
301
303
|
})); // attach remote logging handler
|
|
302
304
|
|
|
303
|
-
socket.onmessage =
|
|
304
|
-
|
|
305
|
-
|
|
305
|
+
socket.onmessage = _ref => {
|
|
306
|
+
let {
|
|
307
|
+
data
|
|
308
|
+
} = _ref;
|
|
306
309
|
let {
|
|
307
310
|
log,
|
|
308
311
|
logAll
|
|
@@ -318,7 +321,8 @@
|
|
|
318
321
|
} // Connects to a remote logger
|
|
319
322
|
|
|
320
323
|
|
|
321
|
-
async remote(createSocket
|
|
324
|
+
async remote(createSocket) {
|
|
325
|
+
let timeout = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1000;
|
|
322
326
|
if (this.isRemote) return; // if not already connected, wait until the timeout
|
|
323
327
|
|
|
324
328
|
let err = await new Promise(resolve => {
|
|
@@ -360,9 +364,10 @@
|
|
|
360
364
|
} // attach an incoming message handler
|
|
361
365
|
|
|
362
366
|
|
|
363
|
-
this.socket.onmessage =
|
|
364
|
-
|
|
365
|
-
|
|
367
|
+
this.socket.onmessage = _ref2 => {
|
|
368
|
+
let {
|
|
369
|
+
data
|
|
370
|
+
} = _ref2;
|
|
366
371
|
let {
|
|
367
372
|
env
|
|
368
373
|
} = JSON.parse(data); // update local environment info
|
|
@@ -423,12 +428,21 @@
|
|
|
423
428
|
}
|
|
424
429
|
|
|
425
430
|
Object.assign(logger, {
|
|
426
|
-
format: (
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
431
|
+
format: function () {
|
|
432
|
+
return new Logger().format(...arguments);
|
|
433
|
+
},
|
|
434
|
+
query: function () {
|
|
435
|
+
return new Logger().query(...arguments);
|
|
436
|
+
},
|
|
437
|
+
connect: function () {
|
|
438
|
+
return new Logger().connect(...arguments);
|
|
439
|
+
},
|
|
440
|
+
remote: function () {
|
|
441
|
+
return new Logger().remote(...arguments);
|
|
442
|
+
},
|
|
430
443
|
|
|
431
|
-
loglevel(level
|
|
444
|
+
loglevel(level) {
|
|
445
|
+
let flags = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
432
446
|
if (flags.debug) level = 'debug';else if (flags.verbose) level = 'debug';else if (flags.quiet) level = 'warn';else if (flags.silent) level = 'silent';
|
|
433
447
|
return new Logger().loglevel(level);
|
|
434
448
|
}
|
|
@@ -506,7 +520,8 @@
|
|
|
506
520
|
|
|
507
521
|
};
|
|
508
522
|
|
|
509
|
-
async function request(path
|
|
523
|
+
async function request(path) {
|
|
524
|
+
let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
510
525
|
let response = await request.fetch(`${info.address}${path}`, options); // maybe parse response body as json
|
|
511
526
|
|
|
512
527
|
if (typeof response.body === 'string' && response.headers['content-type'] === 'application/json') {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@percy/sdk-utils",
|
|
3
|
-
"version": "1.0.0-beta.
|
|
3
|
+
"version": "1.0.0-beta.71",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"browser": "dist/bundle.js",
|
|
@@ -46,12 +46,12 @@
|
|
|
46
46
|
}
|
|
47
47
|
},
|
|
48
48
|
"dependencies": {
|
|
49
|
-
"@percy/logger": "1.0.0-beta.
|
|
49
|
+
"@percy/logger": "1.0.0-beta.71"
|
|
50
50
|
},
|
|
51
51
|
"repository": {
|
|
52
52
|
"type": "git",
|
|
53
53
|
"url": "https://github.com/percy/cli",
|
|
54
54
|
"directory": "packages/sdk-utils"
|
|
55
55
|
},
|
|
56
|
-
"gitHead": "
|
|
56
|
+
"gitHead": "364d1df717fb19a26ccb024458df6e78a9c11f99"
|
|
57
57
|
}
|
package/test/client.js
CHANGED
|
@@ -53,7 +53,8 @@
|
|
|
53
53
|
} // map ansi colors to bound colorize functions
|
|
54
54
|
|
|
55
55
|
|
|
56
|
-
const colors = entries(ANSI_COLORS).reduce((colors,
|
|
56
|
+
const colors = entries(ANSI_COLORS).reduce((colors, _ref) => {
|
|
57
|
+
let [code, name] = _ref;
|
|
57
58
|
return assign(colors, {
|
|
58
59
|
[name]: colorize.bind(null, code)
|
|
59
60
|
});
|
|
@@ -79,10 +80,11 @@
|
|
|
79
80
|
const NEWLINE_REG = /\r\n/g;
|
|
80
81
|
const LASTLINE_REG = /\n$/;
|
|
81
82
|
|
|
82
|
-
function sanitizeLog(str
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
83
|
+
function sanitizeLog(str) {
|
|
84
|
+
let {
|
|
85
|
+
ansi,
|
|
86
|
+
elapsed
|
|
87
|
+
} = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
86
88
|
// normalize line endings
|
|
87
89
|
str = str.replace(NEWLINE_REG, '\n'); // strip ansi colors
|
|
88
90
|
|
|
@@ -120,7 +122,11 @@
|
|
|
120
122
|
return object[method];
|
|
121
123
|
}
|
|
122
124
|
|
|
123
|
-
let spy = Object.assign(function spy(
|
|
125
|
+
let spy = Object.assign(function spy() {
|
|
126
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
127
|
+
args[_key] = arguments[_key];
|
|
128
|
+
}
|
|
129
|
+
|
|
124
130
|
spy.calls.push(args);
|
|
125
131
|
if (func) return func.apply(this, args);
|
|
126
132
|
}, {
|
|
@@ -183,12 +189,13 @@
|
|
|
183
189
|
let logs = Array.from(helpers$1.messages);
|
|
184
190
|
logger$1.loglevel('debug');
|
|
185
191
|
write(logger$1.format('--- DUMPING LOGS ---', 'testing', 'warn'));
|
|
186
|
-
logs.reduce((lastlog, {
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
+
logs.reduce((lastlog, _ref) => {
|
|
193
|
+
let {
|
|
194
|
+
debug,
|
|
195
|
+
level,
|
|
196
|
+
message,
|
|
197
|
+
timestamp
|
|
198
|
+
} = _ref;
|
|
192
199
|
write(logger$1.format(message, debug, level, timestamp - lastlog));
|
|
193
200
|
return timestamp;
|
|
194
201
|
}, logs[0].timestamp);
|
|
@@ -225,7 +232,11 @@
|
|
|
225
232
|
};
|
|
226
233
|
|
|
227
234
|
if (process.env.__PERCY_BROWSERIFIED__) {
|
|
228
|
-
helpers.call = async function call(event
|
|
235
|
+
helpers.call = async function call(event) {
|
|
236
|
+
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
237
|
+
args[_key - 1] = arguments[_key];
|
|
238
|
+
}
|
|
239
|
+
|
|
229
240
|
let {
|
|
230
241
|
socket,
|
|
231
242
|
pending = {}
|
|
@@ -249,9 +260,10 @@
|
|
|
249
260
|
socket.onopen = socket.onerror = done;
|
|
250
261
|
});
|
|
251
262
|
|
|
252
|
-
socket.onmessage =
|
|
253
|
-
|
|
254
|
-
|
|
263
|
+
socket.onmessage = _ref => {
|
|
264
|
+
let {
|
|
265
|
+
data
|
|
266
|
+
} = _ref;
|
|
255
267
|
let {
|
|
256
268
|
id,
|
|
257
269
|
resolve,
|