varsnap 1.8.1 → 1.8.4
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/built/varsnap/core.d.ts +2 -4
- package/dist/built/varsnap/core.js +16 -7
- package/dist/built/varsnap/gitbranchenv.d.ts +1 -1
- package/dist/built/varsnap/gitbranchenv.js +2 -1
- package/dist/varsnap.js +1556 -754
- package/dist/varsnap.min.js +2 -2
- package/package.json +7 -7
- package/CHANGELOG.md +0 -371
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
import querystring = require('querystring');
|
|
3
|
-
export declare const version = "1.8.1";
|
|
1
|
+
export declare const version = "1.8.4";
|
|
4
2
|
export declare const clientName: string;
|
|
5
3
|
export interface Config {
|
|
6
4
|
varsnap: boolean;
|
|
@@ -11,7 +9,7 @@ export interface Config {
|
|
|
11
9
|
logger?: Logger;
|
|
12
10
|
}
|
|
13
11
|
declare type ConfigKeys = keyof Config;
|
|
14
|
-
declare type rawJSONObject = ConsumeSnapResponse | ProduceTrialResponse | TrialGroupRequest | TrialGroupResponse |
|
|
12
|
+
declare type rawJSONObject = ConsumeSnapResponse | ProduceTrialResponse | TrialGroupRequest | TrialGroupResponse | Record<string, string>;
|
|
15
13
|
export interface Logger {
|
|
16
14
|
debug(s: string): void;
|
|
17
15
|
log(s: string): void;
|
|
@@ -2,13 +2,12 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.runTests = exports.varsnap = exports.Consumer = exports.Producer = exports.Util = exports.clientName = exports.version = void 0;
|
|
4
4
|
const axios_1 = require("axios");
|
|
5
|
-
const querystring = require("querystring");
|
|
6
5
|
const child_process_1 = require("child_process");
|
|
7
6
|
const produceURL = 'https://www.varsnap.com/api/snap/produce/';
|
|
8
7
|
const consumeURL = 'https://www.varsnap.com/api/snap/consume/';
|
|
9
8
|
const produceTrialURL = 'https://www.varsnap.com/api/trial/produce/';
|
|
10
9
|
const trialGroupURL = 'https://www.varsnap.com/api/trial_group/';
|
|
11
|
-
exports.version = '1.8.
|
|
10
|
+
exports.version = '1.8.4';
|
|
12
11
|
exports.clientName = 'javascript.' + exports.version;
|
|
13
12
|
const defaultConfig = {
|
|
14
13
|
varsnap: true,
|
|
@@ -63,13 +62,15 @@ class Util {
|
|
|
63
62
|
return 'javascript.' + exports.version + '.' + signature;
|
|
64
63
|
}
|
|
65
64
|
static ajax(url, requestData) {
|
|
65
|
+
const requestParams = new URLSearchParams(requestData);
|
|
66
|
+
const data = requestParams.toString();
|
|
66
67
|
const options = {
|
|
67
68
|
method: 'POST',
|
|
68
69
|
url: url,
|
|
69
70
|
headers: {
|
|
70
71
|
'Content-Type': 'application/x-www-form-urlencoded',
|
|
71
72
|
},
|
|
72
|
-
data:
|
|
73
|
+
data: data,
|
|
73
74
|
responseType: 'json',
|
|
74
75
|
};
|
|
75
76
|
if (Util.isNode() && options.headers) {
|
|
@@ -77,6 +78,8 @@ class Util {
|
|
|
77
78
|
}
|
|
78
79
|
const ajaxPromise = (0, axios_1.default)(options).then((response) => {
|
|
79
80
|
return response.data;
|
|
81
|
+
}).catch((error) => {
|
|
82
|
+
return error;
|
|
80
83
|
});
|
|
81
84
|
return ajaxPromise;
|
|
82
85
|
}
|
|
@@ -279,7 +282,6 @@ class Consumer {
|
|
|
279
282
|
});
|
|
280
283
|
trialPromises.push(trialPromise);
|
|
281
284
|
}
|
|
282
|
-
this.reportTrialGroup(trialGroup);
|
|
283
285
|
return trialPromises;
|
|
284
286
|
}).then((trialPromises) => {
|
|
285
287
|
return Promise.all(trialPromises).then((results) => {
|
|
@@ -298,7 +300,7 @@ class Consumer {
|
|
|
298
300
|
'consumer_token': Util.getConfig(this.config, 'consumerToken'),
|
|
299
301
|
'snap_id': snap.id,
|
|
300
302
|
'test_outputs': Producer.serialize(localOutputs),
|
|
301
|
-
'matches': matches,
|
|
303
|
+
'matches': matches.toString(),
|
|
302
304
|
'snap_outputs_formatted': Producer.serialize_formatted(prodOutputs),
|
|
303
305
|
'test_outputs_formatted': Producer.serialize_formatted(localOutputs),
|
|
304
306
|
};
|
|
@@ -317,6 +319,9 @@ class Consumer {
|
|
|
317
319
|
return report;
|
|
318
320
|
}
|
|
319
321
|
reportLog(snapID, inputs, prodOutputs, localOutputs, matches, trialURL) {
|
|
322
|
+
if (matches) {
|
|
323
|
+
return;
|
|
324
|
+
}
|
|
320
325
|
Util.log(this.config, '');
|
|
321
326
|
Util.log(this.config, 'Testing with Varsnap uuid: ' + snapID);
|
|
322
327
|
Util.log(this.config, 'Signature: ' + this.signature);
|
|
@@ -396,8 +401,9 @@ function getTrialGroup(consumerConfig) {
|
|
|
396
401
|
return response;
|
|
397
402
|
}).catch((error) => {
|
|
398
403
|
let errorMessage = '';
|
|
399
|
-
if (error && error.response && error.response.data
|
|
400
|
-
|
|
404
|
+
if (error && error.response && error.response.data) {
|
|
405
|
+
const response = error.response.data;
|
|
406
|
+
errorMessage = response.error;
|
|
401
407
|
}
|
|
402
408
|
else {
|
|
403
409
|
errorMessage = error.toString();
|
|
@@ -424,6 +430,9 @@ function runTests() {
|
|
|
424
430
|
const testPromise = consumer.consume(trialGroup);
|
|
425
431
|
testPromises.push(testPromise);
|
|
426
432
|
}
|
|
433
|
+
if (consumers.length > 0) {
|
|
434
|
+
consumers[0].reportTrialGroup(trialGroup);
|
|
435
|
+
}
|
|
427
436
|
return Promise.all(testPromises);
|
|
428
437
|
}).then((results) => {
|
|
429
438
|
const allPass = results.every((result) => result);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare function setGitBranchEnv():
|
|
1
|
+
export declare function setGitBranchEnv(): Promise<string>;
|
|
@@ -11,9 +11,10 @@ function setGitBranchEnv() {
|
|
|
11
11
|
env: 'none',
|
|
12
12
|
branch: '',
|
|
13
13
|
};
|
|
14
|
-
core_1.Util.getBranch(config)
|
|
14
|
+
return core_1.Util.getBranch(config)
|
|
15
15
|
.then((branch) => {
|
|
16
16
|
process.env.GIT_BRANCH = branch;
|
|
17
|
+
return branch;
|
|
17
18
|
});
|
|
18
19
|
}
|
|
19
20
|
exports.setGitBranchEnv = setGitBranchEnv;
|