@elastic/synthetics 1.0.0-beta.3 → 1.0.0-beta.32
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/README.md +4 -3
- package/dist/cli.js +123 -161
- package/dist/cli.js.map +1 -1
- package/dist/common_types.d.ts +159 -34
- package/dist/common_types.d.ts.map +1 -1
- package/dist/config.d.ts +2 -5
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +5 -5
- package/dist/config.js.map +1 -1
- package/dist/core/browser-service.js +5 -5
- package/dist/core/browser-service.js.map +1 -1
- package/dist/core/expect.d.ts +25 -25
- package/dist/core/expect.d.ts.map +1 -1
- package/dist/core/expect.js.map +1 -1
- package/dist/core/gatherer.d.ts +4 -8
- package/dist/core/gatherer.d.ts.map +1 -1
- package/dist/core/gatherer.js +49 -15
- package/dist/core/gatherer.js.map +1 -1
- package/dist/core/index.d.ts +5 -1
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js +23 -11
- package/dist/core/index.js.map +1 -1
- package/dist/core/logger.d.ts +0 -1
- package/dist/core/logger.d.ts.map +1 -1
- package/dist/core/logger.js +3 -16
- package/dist/core/logger.js.map +1 -1
- package/dist/core/runner.d.ts +21 -65
- package/dist/core/runner.d.ts.map +1 -1
- package/dist/core/runner.js +212 -93
- package/dist/core/runner.js.map +1 -1
- package/dist/dsl/index.js +5 -1
- package/dist/dsl/index.js.map +1 -1
- package/dist/dsl/journey.d.ts +9 -4
- package/dist/dsl/journey.d.ts.map +1 -1
- package/dist/dsl/journey.js +27 -7
- package/dist/dsl/journey.js.map +1 -1
- package/dist/dsl/monitor.d.ts +66 -0
- package/dist/dsl/monitor.d.ts.map +1 -0
- package/dist/dsl/monitor.js +63 -0
- package/dist/dsl/monitor.js.map +1 -0
- package/dist/dsl/step.d.ts +3 -2
- package/dist/dsl/step.d.ts.map +1 -1
- package/dist/dsl/step.js +2 -1
- package/dist/dsl/step.js.map +1 -1
- package/dist/formatter/javascript.d.ts +98 -0
- package/dist/formatter/javascript.d.ts.map +1 -0
- package/dist/formatter/javascript.js +295 -0
- package/dist/formatter/javascript.js.map +1 -0
- package/dist/generator/index.d.ts +29 -0
- package/dist/generator/index.d.ts.map +1 -0
- package/dist/generator/index.js +240 -0
- package/dist/generator/index.js.map +1 -0
- package/dist/{reporters/reporter.js → generator/utils.d.ts} +5 -3
- package/dist/generator/utils.d.ts.map +1 -0
- package/dist/generator/utils.js +80 -0
- package/dist/generator/utils.js.map +1 -0
- package/dist/helpers.d.ts +24 -1
- package/dist/helpers.d.ts.map +1 -1
- package/dist/helpers.js +126 -19
- package/dist/helpers.js.map +1 -1
- package/dist/index.d.ts +6 -7
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -26
- package/dist/index.js.map +1 -1
- package/dist/{parse_args.d.ts → loader.d.ts} +2 -5
- package/dist/loader.d.ts.map +1 -0
- package/dist/loader.js +152 -0
- package/dist/loader.js.map +1 -0
- package/dist/locations/index.d.ts +45 -0
- package/dist/locations/index.d.ts.map +1 -0
- package/dist/locations/index.js +90 -0
- package/dist/locations/index.js.map +1 -0
- package/dist/{reporters/reporter.d.ts → locations/public-locations.d.ts} +12 -8
- package/dist/locations/public-locations.d.ts.map +1 -0
- package/dist/locations/public-locations.js +41 -0
- package/dist/locations/public-locations.js.map +1 -0
- package/dist/options.d.ts +41 -0
- package/dist/options.d.ts.map +1 -0
- package/dist/options.js +182 -0
- package/dist/options.js.map +1 -0
- package/dist/plugins/browser-console.d.ts +5 -4
- package/dist/plugins/browser-console.d.ts.map +1 -1
- package/dist/plugins/browser-console.js +27 -8
- package/dist/plugins/browser-console.js.map +1 -1
- package/dist/plugins/index.js +5 -1
- package/dist/plugins/index.js.map +1 -1
- package/dist/plugins/network.d.ts +20 -33
- package/dist/plugins/network.d.ts.map +1 -1
- package/dist/plugins/network.js +173 -214
- package/dist/plugins/network.js.map +1 -1
- package/dist/plugins/performance.d.ts +4 -19
- package/dist/plugins/performance.d.ts.map +1 -1
- package/dist/plugins/performance.js +5 -5
- package/dist/plugins/performance.js.map +1 -1
- package/dist/plugins/plugin-manager.d.ts +9 -5
- package/dist/plugins/plugin-manager.d.ts.map +1 -1
- package/dist/plugins/plugin-manager.js +44 -29
- package/dist/plugins/plugin-manager.js.map +1 -1
- package/dist/plugins/tracing.d.ts +6 -6
- package/dist/plugins/tracing.d.ts.map +1 -1
- package/dist/plugins/tracing.js +8 -7
- package/dist/plugins/tracing.js.map +1 -1
- package/dist/push/bundler.d.ts +34 -0
- package/dist/push/bundler.d.ts.map +1 -0
- package/dist/push/bundler.js +123 -0
- package/dist/push/bundler.js.map +1 -0
- package/dist/push/index.d.ts +33 -0
- package/dist/push/index.d.ts.map +1 -0
- package/dist/push/index.js +174 -0
- package/dist/push/index.js.map +1 -0
- package/dist/push/monitor.d.ts +34 -0
- package/dist/push/monitor.d.ts.map +1 -0
- package/dist/push/monitor.js +78 -0
- package/dist/push/monitor.js.map +1 -0
- package/{src/reporters/reporter.ts → dist/push/plugin.d.ts} +8 -10
- package/dist/push/plugin.d.ts.map +1 -0
- package/dist/push/plugin.js +133 -0
- package/dist/push/plugin.js.map +1 -0
- package/dist/push/request.d.ts +43 -0
- package/dist/push/request.d.ts.map +1 -0
- package/dist/push/request.js +83 -0
- package/dist/push/request.js.map +1 -0
- package/dist/reporters/base.d.ts +14 -6
- package/dist/reporters/base.d.ts.map +1 -1
- package/dist/reporters/base.js +54 -48
- package/dist/reporters/base.js.map +1 -1
- package/dist/reporters/index.d.ts +18 -8
- package/dist/reporters/index.d.ts.map +1 -1
- package/dist/reporters/index.js.map +1 -1
- package/dist/reporters/json.d.ts +18 -67
- package/dist/reporters/json.d.ts.map +1 -1
- package/dist/reporters/json.js +153 -175
- package/dist/reporters/json.js.map +1 -1
- package/dist/reporters/junit.d.ts +7 -1
- package/dist/reporters/junit.d.ts.map +1 -1
- package/dist/reporters/junit.js +94 -89
- package/dist/reporters/junit.js.map +1 -1
- package/dist/sdk/lh-trace-processor.d.ts +35 -9
- package/dist/sdk/lh-trace-processor.d.ts.map +1 -1
- package/dist/sdk/lh-trace-processor.js +114 -53
- package/dist/sdk/lh-trace-processor.js.map +1 -1
- package/dist/sdk/trace-metrics.d.ts +4 -4
- package/dist/sdk/trace-metrics.d.ts.map +1 -1
- package/dist/sdk/trace-metrics.js +5 -6
- package/dist/sdk/trace-metrics.js.map +1 -1
- package/dist/sdk/trace-processor.d.ts +11 -3
- package/dist/sdk/trace-processor.d.ts.map +1 -1
- package/dist/sdk/trace-processor.js +17 -9
- package/dist/sdk/trace-processor.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1888
- package/package.json +32 -20
- package/src/cli.ts +205 -152
- package/src/common_types.ts +192 -34
- package/src/config.ts +2 -5
- package/src/core/expect.ts +58 -24
- package/src/core/gatherer.ts +59 -24
- package/src/core/index.ts +36 -15
- package/src/core/logger.ts +1 -12
- package/src/core/runner.ts +215 -152
- package/src/dsl/journey.ts +37 -6
- package/src/dsl/monitor.ts +88 -0
- package/src/dsl/step.ts +9 -2
- package/src/formatter/javascript.ts +367 -0
- package/src/generator/index.ts +316 -0
- package/src/generator/utils.ts +80 -0
- package/src/helpers.ts +132 -12
- package/src/index.ts +22 -22
- package/src/loader.ts +171 -0
- package/src/locations/index.ts +108 -0
- package/src/locations/public-locations.ts +38 -0
- package/src/options.ts +211 -0
- package/src/plugins/browser-console.ts +30 -8
- package/src/plugins/network.ts +208 -267
- package/src/plugins/performance.ts +6 -22
- package/src/plugins/plugin-manager.ts +49 -31
- package/src/plugins/tracing.ts +8 -9
- package/src/push/bundler.ts +100 -0
- package/src/push/index.ts +202 -0
- package/src/push/monitor.ts +96 -0
- package/src/push/plugin.ts +119 -0
- package/src/push/request.ts +103 -0
- package/src/reporters/base.ts +63 -52
- package/src/reporters/index.ts +26 -3
- package/src/reporters/json.ts +203 -206
- package/src/reporters/junit.ts +98 -93
- package/src/sdk/lh-trace-processor.ts +132 -68
- package/src/sdk/trace-metrics.ts +10 -6
- package/src/sdk/trace-processor.ts +28 -13
- package/templates/.github/workflows/run-synthetics.yml +26 -0
- package/templates/README.md +21 -0
- package/templates/journeys/advanced-example-helpers.ts +54 -0
- package/templates/journeys/advanced-example.journey.ts +43 -0
- package/templates/journeys/example.journey.ts +18 -0
- package/templates/synthetics.config.ts +27 -0
- package/CHANGELOG.md +0 -102
- package/NOTICE.txt +0 -221
- package/dist/parse_args.d.ts.map +0 -1
- package/dist/parse_args.js +0 -89
- package/dist/parse_args.js.map +0 -1
- package/dist/reporters/reporter.d.ts.map +0 -1
- package/dist/reporters/reporter.js.map +0 -1
- package/src/parse_args.ts +0 -127
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* MIT License
|
|
4
|
+
*
|
|
5
|
+
* Copyright (c) 2020-present, Elastic NV
|
|
6
|
+
*
|
|
7
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
8
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
9
|
+
* in the Software without restriction, including without limitation the rights
|
|
10
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
11
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
12
|
+
* furnished to do so, subject to the following conditions:
|
|
13
|
+
*
|
|
14
|
+
* The above copyright notice and this permission notice shall be included in
|
|
15
|
+
* all copies or substantial portions of the Software.
|
|
16
|
+
*
|
|
17
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
18
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
19
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
20
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
21
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
22
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
23
|
+
* THE SOFTWARE.
|
|
24
|
+
*
|
|
25
|
+
*/
|
|
26
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
27
|
+
exports.createMonitors = exports.buildMonitorSchema = void 0;
|
|
28
|
+
const promises_1 = require("fs/promises");
|
|
29
|
+
const path_1 = require("path");
|
|
30
|
+
const bundler_1 = require("./bundler");
|
|
31
|
+
const request_1 = require("./request");
|
|
32
|
+
const helpers_1 = require("../helpers");
|
|
33
|
+
const public_locations_1 = require("../locations/public-locations");
|
|
34
|
+
function translateLocation(locations) {
|
|
35
|
+
if (!locations)
|
|
36
|
+
return [];
|
|
37
|
+
return locations.map(loc => public_locations_1.LocationsMap[loc] || loc).filter(Boolean);
|
|
38
|
+
}
|
|
39
|
+
async function buildMonitorSchema(monitors) {
|
|
40
|
+
/**
|
|
41
|
+
* Set up the bundle artifacts path which can be used to
|
|
42
|
+
* create the bundles required for uploading journeys
|
|
43
|
+
*/
|
|
44
|
+
const bundlePath = (0, path_1.join)(helpers_1.SYNTHETICS_PATH, 'bundles');
|
|
45
|
+
await (0, promises_1.mkdir)(bundlePath, { recursive: true });
|
|
46
|
+
const bundler = new bundler_1.Bundler();
|
|
47
|
+
const schemas = [];
|
|
48
|
+
for (const monitor of monitors) {
|
|
49
|
+
const { source, config, filter } = monitor;
|
|
50
|
+
const outPath = (0, path_1.join)(bundlePath, config.name + '.zip');
|
|
51
|
+
const content = await bundler.build(source.file, outPath);
|
|
52
|
+
schemas.push({
|
|
53
|
+
...config,
|
|
54
|
+
content,
|
|
55
|
+
locations: translateLocation(config.locations),
|
|
56
|
+
filter: filter,
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
await (0, promises_1.rm)(bundlePath, { recursive: true });
|
|
60
|
+
return schemas;
|
|
61
|
+
}
|
|
62
|
+
exports.buildMonitorSchema = buildMonitorSchema;
|
|
63
|
+
async function createMonitors(monitors, options) {
|
|
64
|
+
const schema = {
|
|
65
|
+
project: options.project,
|
|
66
|
+
keep_stale: false,
|
|
67
|
+
monitors,
|
|
68
|
+
};
|
|
69
|
+
return await (0, request_1.sendRequest)({
|
|
70
|
+
url: (0, helpers_1.removeTrailingSlash)(options.url) +
|
|
71
|
+
`/s/${options.space}/api/synthetics/service/project/monitors`,
|
|
72
|
+
method: 'PUT',
|
|
73
|
+
auth: options.auth,
|
|
74
|
+
body: JSON.stringify(schema),
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
exports.createMonitors = createMonitors;
|
|
78
|
+
//# sourceMappingURL=monitor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"monitor.js","sourceRoot":"","sources":["../../src/push/monitor.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;;;AAEH,0CAAwC;AACxC,+BAA4B;AAC5B,uCAAoC;AACpC,uCAAwC;AACxC,wCAAkE;AAClE,oEAA6D;AAgB7D,SAAS,iBAAiB,CAAC,SAAsC;IAC/D,IAAI,CAAC,SAAS;QAAE,OAAO,EAAE,CAAC;IAC1B,OAAO,SAAS,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,+BAAY,CAAC,GAAG,CAAC,IAAI,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;AACxE,CAAC;AAEM,KAAK,UAAU,kBAAkB,CAAC,QAAmB;IAC1D;;;OAGG;IACH,MAAM,UAAU,GAAG,IAAA,WAAI,EAAC,yBAAe,EAAE,SAAS,CAAC,CAAC;IACpD,MAAM,IAAA,gBAAK,EAAC,UAAU,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IAC7C,MAAM,OAAO,GAAG,IAAI,iBAAO,EAAE,CAAC;IAC9B,MAAM,OAAO,GAAoB,EAAE,CAAC;IAEpC,KAAK,MAAM,OAAO,IAAI,QAA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|
|
26
|
+
export declare function commonOptions(): esbuild.BuildOptions;
|
|
27
|
+
export declare type PluginData = {
|
|
28
|
+
path: string;
|
|
29
|
+
contents: string;
|
|
31
30
|
};
|
|
32
|
-
|
|
33
|
-
export
|
|
34
|
-
|
|
35
|
-
}
|
|
31
|
+
export declare type PluginCallback = (data: PluginData) => void;
|
|
32
|
+
export declare function MultiAssetPlugin(callback: PluginCallback): esbuild.Plugin;
|
|
33
|
+
//# sourceMappingURL=plugin.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../src/push/plugin.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAIH,OAAO,KAAK,OAAO,MAAM,SAAS,CAAC;AAEnC,wBAAgB,aAAa,IAAI,OAAO,CAAC,YAAY,CAapD;AAED,oBAAY,UAAU,GAAG;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;CAClB,CAAC;AACF,oBAAY,cAAc,GAAG,CAAC,IAAI,EAAE,UAAU,KAAK,IAAI,CAAC;AAExD,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,cAAc,GAAG,OAAO,CAAC,MAAM,CAoEzE"}
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* MIT License
|
|
4
|
+
*
|
|
5
|
+
* Copyright (c) 2020-present, Elastic NV
|
|
6
|
+
*
|
|
7
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
8
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
9
|
+
* in the Software without restriction, including without limitation the rights
|
|
10
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
11
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
12
|
+
* furnished to do so, subject to the following conditions:
|
|
13
|
+
*
|
|
14
|
+
* The above copyright notice and this permission notice shall be included in
|
|
15
|
+
* all copies or substantial portions of the Software.
|
|
16
|
+
*
|
|
17
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
18
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
19
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
20
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
21
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
22
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
23
|
+
* THE SOFTWARE.
|
|
24
|
+
*
|
|
25
|
+
*/
|
|
26
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
27
|
+
if (k2 === undefined) k2 = k;
|
|
28
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
29
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
30
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
31
|
+
}
|
|
32
|
+
Object.defineProperty(o, k2, desc);
|
|
33
|
+
}) : (function(o, m, k, k2) {
|
|
34
|
+
if (k2 === undefined) k2 = k;
|
|
35
|
+
o[k2] = m[k];
|
|
36
|
+
}));
|
|
37
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
38
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
39
|
+
}) : function(o, v) {
|
|
40
|
+
o["default"] = v;
|
|
41
|
+
});
|
|
42
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
43
|
+
if (mod && mod.__esModule) return mod;
|
|
44
|
+
var result = {};
|
|
45
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
46
|
+
__setModuleDefault(result, mod);
|
|
47
|
+
return result;
|
|
48
|
+
};
|
|
49
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
50
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
51
|
+
};
|
|
52
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
53
|
+
exports.MultiAssetPlugin = exports.commonOptions = void 0;
|
|
54
|
+
const path_1 = __importDefault(require("path"));
|
|
55
|
+
const promises_1 = __importDefault(require("fs/promises"));
|
|
56
|
+
const esbuild = __importStar(require("esbuild"));
|
|
57
|
+
function commonOptions() {
|
|
58
|
+
return {
|
|
59
|
+
bundle: true,
|
|
60
|
+
external: ['node_modules', '@elastic/synthetics'],
|
|
61
|
+
minify: false,
|
|
62
|
+
platform: 'node',
|
|
63
|
+
logLevel: 'silent',
|
|
64
|
+
format: 'esm',
|
|
65
|
+
write: false,
|
|
66
|
+
outExtension: {
|
|
67
|
+
'.js': '.js',
|
|
68
|
+
},
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
exports.commonOptions = commonOptions;
|
|
72
|
+
function MultiAssetPlugin(callback) {
|
|
73
|
+
// Check that the path isn't in an external package by making sure it's at a standard
|
|
74
|
+
// local filesystem location
|
|
75
|
+
const isBare = (str) => {
|
|
76
|
+
// Note that we use `isAbsolute` to handle UNC/windows style paths like C:\path\to\thing
|
|
77
|
+
// This is not necessary for relative directories since `.\file` is not supported as an import
|
|
78
|
+
// nor is `~/path/to/file`.
|
|
79
|
+
if (path_1.default.isAbsolute(str) || str.startsWith('./') || str.startsWith('../')) {
|
|
80
|
+
return true;
|
|
81
|
+
}
|
|
82
|
+
return false;
|
|
83
|
+
};
|
|
84
|
+
return {
|
|
85
|
+
name: 'esbuild-multiasset-plugin',
|
|
86
|
+
setup(build) {
|
|
87
|
+
build.onResolve({ filter: /.*?/ }, async (args) => {
|
|
88
|
+
// External and other packages need be marked external to
|
|
89
|
+
// be removed from the bundle
|
|
90
|
+
if (build.initialOptions.external?.includes(args.path) ||
|
|
91
|
+
!isBare(args.path)) {
|
|
92
|
+
return {
|
|
93
|
+
external: true,
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
if (args.kind === 'entry-point') {
|
|
97
|
+
return {
|
|
98
|
+
path: args.path,
|
|
99
|
+
namespace: 'asset',
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
// If the modules are resolved locally, then
|
|
103
|
+
// use the imported path to get full path
|
|
104
|
+
const entryPath = path_1.default.join(path_1.default.dirname(args.importer), args.path) +
|
|
105
|
+
path_1.default.extname(args.importer);
|
|
106
|
+
// Spin off another build to copy over the imported modules without bundling
|
|
107
|
+
const result = await esbuild.build({
|
|
108
|
+
...commonOptions(),
|
|
109
|
+
entryPoints: {
|
|
110
|
+
[entryPath]: entryPath,
|
|
111
|
+
},
|
|
112
|
+
bundle: false,
|
|
113
|
+
external: [],
|
|
114
|
+
});
|
|
115
|
+
callback({
|
|
116
|
+
path: entryPath,
|
|
117
|
+
contents: result.outputFiles[0].text,
|
|
118
|
+
});
|
|
119
|
+
return {
|
|
120
|
+
errors: result.errors,
|
|
121
|
+
external: true,
|
|
122
|
+
};
|
|
123
|
+
});
|
|
124
|
+
build.onLoad({ filter: /.*?/, namespace: 'asset' }, async (args) => {
|
|
125
|
+
const contents = await promises_1.default.readFile(args.path, 'utf-8');
|
|
126
|
+
callback({ path: args.path, contents });
|
|
127
|
+
return { contents };
|
|
128
|
+
});
|
|
129
|
+
},
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
exports.MultiAssetPlugin = MultiAssetPlugin;
|
|
133
|
+
//# sourceMappingURL=plugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin.js","sourceRoot":"","sources":["../../src/push/plugin.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;;;;;;;;;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+
*
|
|
4
|
+
* Copyright (c) 2020-present, Elastic NV
|
|
5
|
+
*
|
|
6
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
* in the Software without restriction, including without limitation the rights
|
|
9
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
* furnished to do so, subject to the following conditions:
|
|
12
|
+
*
|
|
13
|
+
* The above copyright notice and this permission notice shall be included in
|
|
14
|
+
* all copies or substantial portions of the Software.
|
|
15
|
+
*
|
|
16
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
22
|
+
* THE SOFTWARE.
|
|
23
|
+
*
|
|
24
|
+
*/
|
|
25
|
+
import { Dispatcher } from 'undici';
|
|
26
|
+
export declare type APIRequestOptions = {
|
|
27
|
+
url: string;
|
|
28
|
+
method: Dispatcher.HttpMethod;
|
|
29
|
+
auth: string;
|
|
30
|
+
body?: string;
|
|
31
|
+
};
|
|
32
|
+
export declare function sendRequest(options: APIRequestOptions): Promise<Dispatcher.ResponseData>;
|
|
33
|
+
export declare function ok(statusCode: number): boolean;
|
|
34
|
+
export declare type APIMonitorError = {
|
|
35
|
+
id?: string;
|
|
36
|
+
reason: string;
|
|
37
|
+
details: string;
|
|
38
|
+
};
|
|
39
|
+
export declare function formatNotFoundError(message: string): string;
|
|
40
|
+
export declare function formatAPIError(statuCode: number, error: string, message: string): string;
|
|
41
|
+
export declare function formatFailedMonitors(errors: APIMonitorError[]): string;
|
|
42
|
+
export declare function formatStaleMonitors(errors: APIMonitorError[]): string;
|
|
43
|
+
//# sourceMappingURL=request.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"request.d.ts","sourceRoot":"","sources":["../../src/push/request.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAGH,OAAO,EAAE,UAAU,EAAW,MAAM,QAAQ,CAAC;AAM7C,oBAAY,iBAAiB,GAAG;IAC9B,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,UAAU,CAAC,UAAU,CAAC;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,wBAAsB,WAAW,CAAC,OAAO,EAAE,iBAAiB,oCAW3D;AAED,wBAAgB,EAAE,CAAC,UAAU,EAAE,MAAM,WAEpC;AAED,oBAAY,eAAe,GAAG;IAC5B,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,MAAM,UAIlD;AAED,wBAAgB,cAAc,CAC5B,SAAS,EAAE,MAAM,EACjB,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,MAAM,UAShB;AAcD,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,eAAe,EAAE,UAG7D;AAED,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,eAAe,EAAE,UAG5D"}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* MIT License
|
|
4
|
+
*
|
|
5
|
+
* Copyright (c) 2020-present, Elastic NV
|
|
6
|
+
*
|
|
7
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
8
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
9
|
+
* in the Software without restriction, including without limitation the rights
|
|
10
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
11
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
12
|
+
* furnished to do so, subject to the following conditions:
|
|
13
|
+
*
|
|
14
|
+
* The above copyright notice and this permission notice shall be included in
|
|
15
|
+
* all copies or substantial portions of the Software.
|
|
16
|
+
*
|
|
17
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
18
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
19
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
20
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
21
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
22
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
23
|
+
* THE SOFTWARE.
|
|
24
|
+
*
|
|
25
|
+
*/
|
|
26
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
27
|
+
exports.formatStaleMonitors = exports.formatFailedMonitors = exports.formatAPIError = exports.formatNotFoundError = exports.ok = exports.sendRequest = void 0;
|
|
28
|
+
const colors_1 = require("kleur/colors");
|
|
29
|
+
const undici_1 = require("undici");
|
|
30
|
+
const helpers_1 = require("../helpers");
|
|
31
|
+
/* eslint-disable @typescript-eslint/no-var-requires */
|
|
32
|
+
const { version } = require('../../package.json');
|
|
33
|
+
async function sendRequest(options) {
|
|
34
|
+
return await (0, undici_1.request)(options.url, {
|
|
35
|
+
method: options.method,
|
|
36
|
+
body: options.body,
|
|
37
|
+
headers: {
|
|
38
|
+
authorization: `ApiKey ${options.auth}`,
|
|
39
|
+
'content-type': 'application/json',
|
|
40
|
+
'user-agent': `Elastic/Synthetics ${version}`,
|
|
41
|
+
'kbn-xsrf': 'true',
|
|
42
|
+
},
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
exports.sendRequest = sendRequest;
|
|
46
|
+
function ok(statusCode) {
|
|
47
|
+
return statusCode >= 200 && statusCode <= 299;
|
|
48
|
+
}
|
|
49
|
+
exports.ok = ok;
|
|
50
|
+
function formatNotFoundError(message) {
|
|
51
|
+
return (0, colors_1.bold)(`${helpers_1.symbols['failed']} Please check your kibana url and try again - 404:${message}`);
|
|
52
|
+
}
|
|
53
|
+
exports.formatNotFoundError = formatNotFoundError;
|
|
54
|
+
function formatAPIError(statuCode, error, message) {
|
|
55
|
+
let outer = (0, colors_1.bold)(`${helpers_1.symbols['failed']} Error\n`);
|
|
56
|
+
let inner = (0, colors_1.bold)(`${helpers_1.symbols['failed']} monitor creation failed - ${statuCode}:${error}\n`);
|
|
57
|
+
inner += (0, helpers_1.indent)(message, ' ');
|
|
58
|
+
outer += (0, helpers_1.indent)(inner);
|
|
59
|
+
return outer;
|
|
60
|
+
}
|
|
61
|
+
exports.formatAPIError = formatAPIError;
|
|
62
|
+
function formatMonitorError(errors) {
|
|
63
|
+
let outer = '';
|
|
64
|
+
for (const error of errors) {
|
|
65
|
+
const monitorId = error.id ? `: monitor(${error.id})` : '';
|
|
66
|
+
let inner = (0, colors_1.bold)(`> ${error.reason}${monitorId}\n`);
|
|
67
|
+
inner += (0, helpers_1.indent)(error.details, ' ');
|
|
68
|
+
outer += (0, helpers_1.indent)(inner) + '\n';
|
|
69
|
+
outer += '\n';
|
|
70
|
+
}
|
|
71
|
+
return outer;
|
|
72
|
+
}
|
|
73
|
+
function formatFailedMonitors(errors) {
|
|
74
|
+
const heading = (0, colors_1.bold)(`${helpers_1.symbols['failed']} Error\n`);
|
|
75
|
+
return heading + formatMonitorError(errors);
|
|
76
|
+
}
|
|
77
|
+
exports.formatFailedMonitors = formatFailedMonitors;
|
|
78
|
+
function formatStaleMonitors(errors) {
|
|
79
|
+
const heading = (0, colors_1.bold)(`${helpers_1.symbols['warning']} Warnings\n`);
|
|
80
|
+
return heading + formatMonitorError(errors);
|
|
81
|
+
}
|
|
82
|
+
exports.formatStaleMonitors = formatStaleMonitors;
|
|
83
|
+
//# sourceMappingURL=request.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"request.js","sourceRoot":"","sources":["../../src/push/request.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;;;AAEH,yCAAoC;AACpC,mCAA6C;AAC7C,wCAA6C;AAE7C,uDAAuD;AACvD,MAAM,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAAC;AAS3C,KAAK,UAAU,WAAW,CAAC,OAA0B;IAC1D,OAAO,MAAM,IAAA,gBAAO,EAAC,OAAO,CAAC,GAAG,EAAE;QAChC,MAAM,EAAE,OAAO,CAAC,MAAM;QACtB,IAAI,EAAE,OAAO,CAAC,IAAI;QAClB,OAAO,EAAE;YACP,aAAa,EAAE,UAAU,OAAO,CAAC,IAAI,EAAE;YACvC,cAAc,EAAE,kBAAkB;YAClC,YAAY,EAAE,sBAAsB,OAAO,EAAE;YAC7C,UAAU,EAAE,MAAM;SACnB;KACF,CAAC,CAAC;AACL,CAAC;AAXD,kCAWC;AAED,SAAgB,EAAE,CAAC,UAAkB;IACnC,OAAO,UAAU,IAAI,GAAG,IAAI,UAAU,IAAI,GAAG,CAAC;AAChD,CAAC;AAFD,gBAEC;AAQD,SAAgB,mBAAmB,CAAC,OAAe;IACjD,OAAO,IAAA,aAAI,EACT,GAAG,iBAAO,CAAC,QAAQ,CAAC,qDAAqD,OAAO,EAAE,CACnF,CAAC;AACJ,CAAC;AAJD,kDAIC;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MAAM,OAAO,GAAG,IAAA,aAAI,EAAC,GAAG,iBAAO,CAAC,SAAS,CAAC,aAAa,CAAC,CAAC;IACzD,OAAO,OAAO,GAAG,kBAAkB,CAAC,MAAM,CAAC,CAAC;AAC9C,CAAC;AAHD,kDAGC"}
|
package/dist/reporters/base.d.ts
CHANGED
|
@@ -23,14 +23,22 @@
|
|
|
23
23
|
*
|
|
24
24
|
*/
|
|
25
25
|
import SonicBoom from 'sonic-boom';
|
|
26
|
-
import
|
|
27
|
-
import {
|
|
28
|
-
|
|
29
|
-
|
|
26
|
+
import { Reporter, ReporterOptions } from '.';
|
|
27
|
+
import { JourneyEndResult, JourneyStartResult, StepEndResult } from '../common_types';
|
|
28
|
+
import { Journey, Step } from '../dsl';
|
|
29
|
+
export default class BaseReporter implements Reporter {
|
|
30
30
|
stream: SonicBoom;
|
|
31
31
|
fd: number;
|
|
32
|
-
|
|
33
|
-
|
|
32
|
+
metrics: {
|
|
33
|
+
succeeded: number;
|
|
34
|
+
failed: number;
|
|
35
|
+
skipped: number;
|
|
36
|
+
};
|
|
37
|
+
constructor(options?: ReporterOptions);
|
|
38
|
+
onJourneyStart(journey: Journey, {}: JourneyStartResult): void;
|
|
39
|
+
onStepEnd(journey: Journey, step: Step, result: StepEndResult): void;
|
|
40
|
+
onJourneyEnd(journey: Journey, { error }: JourneyEndResult): void;
|
|
41
|
+
onEnd(): void;
|
|
34
42
|
write(message: any): void;
|
|
35
43
|
}
|
|
36
44
|
//# sourceMappingURL=base.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base.d.ts","sourceRoot":"","sources":["../../src/reporters/base.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,OAAO,SAAS,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"base.d.ts","sourceRoot":"","sources":["../../src/reporters/base.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,OAAO,SAAS,MAAM,YAAY,CAAC;AASnC,OAAO,EAAE,QAAQ,EAAE,eAAe,EAAE,MAAM,GAAG,CAAC;AAC9C,OAAO,EACL,gBAAgB,EAChB,kBAAkB,EAClB,aAAa,EACd,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAyBvC,MAAM,CAAC,OAAO,OAAO,YAAa,YAAW,QAAQ;IACnD,MAAM,EAAE,SAAS,CAAC;IAClB,EAAE,EAAE,MAAM,CAAC;IACX,OAAO;;;;MAIL;gBAEU,OAAO,GAAE,eAAoB;IAUzC,cAAc,CAAC,OAAO,EAAE,OAAO,EAAE,EAAE,EAAE,kBAAkB;IAIvD,SAAS,CAAC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,aAAa;IAW7D,YAAY,CAAC,OAAO,EAAE,OAAO,EAAE,EAAE,KAAK,EAAE,EAAE,gBAAgB;IAY1D,KAAK;IAwBL,KAAK,CAAC,OAAO,KAAA;CAMd"}
|
package/dist/reporters/base.js
CHANGED
|
@@ -32,75 +32,81 @@ const colors_1 = require("kleur/colors");
|
|
|
32
32
|
const helpers_1 = require("../helpers");
|
|
33
33
|
function renderError(error) {
|
|
34
34
|
let output = '';
|
|
35
|
-
const outer = helpers_1.indent('');
|
|
36
|
-
const inner = helpers_1.indent(outer);
|
|
35
|
+
const outer = (0, helpers_1.indent)('');
|
|
36
|
+
const inner = (0, helpers_1.indent)(outer);
|
|
37
37
|
const container = outer + '---\n';
|
|
38
38
|
output += container;
|
|
39
39
|
let stack = error.stack;
|
|
40
40
|
if (stack) {
|
|
41
41
|
output += inner + 'stack: |-\n';
|
|
42
|
-
stack = helpers_1.rewriteErrorStack(stack, helpers_1.findPWLogsIndexes(stack));
|
|
42
|
+
stack = (0, helpers_1.rewriteErrorStack)(stack, (0, helpers_1.findPWLogsIndexes)(stack));
|
|
43
43
|
const lines = String(stack).split('\n');
|
|
44
44
|
for (const line of lines) {
|
|
45
45
|
output += inner + ' ' + line + '\n';
|
|
46
46
|
}
|
|
47
47
|
}
|
|
48
48
|
output += container;
|
|
49
|
-
return colors_1.red(output);
|
|
49
|
+
return (0, colors_1.red)(output);
|
|
50
50
|
}
|
|
51
51
|
function renderDuration(durationMs) {
|
|
52
52
|
return parseInt(durationMs);
|
|
53
53
|
}
|
|
54
54
|
class BaseReporter {
|
|
55
|
-
constructor(
|
|
56
|
-
this.
|
|
57
|
-
this.fd = options.fd || process.stdout.fd;
|
|
58
|
-
this.stream = new sonic_boom_1.default({ fd: this.fd, sync: true });
|
|
59
|
-
this._registerListeners();
|
|
60
|
-
this.runner.on('end', () => this.stream.flush());
|
|
61
|
-
}
|
|
62
|
-
_registerListeners() {
|
|
63
|
-
const result = {
|
|
55
|
+
constructor(options = {}) {
|
|
56
|
+
this.metrics = {
|
|
64
57
|
succeeded: 0,
|
|
65
58
|
failed: 0,
|
|
66
59
|
skipped: 0,
|
|
67
60
|
};
|
|
68
|
-
this.
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
this.
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
61
|
+
this.fd = options.fd || process.stdout.fd;
|
|
62
|
+
/**
|
|
63
|
+
* minLength is set to 1 byte to make sure we flush the
|
|
64
|
+
* content even if its the last byte on the stream buffer
|
|
65
|
+
* before destroying the pipe with underlying file descriptor
|
|
66
|
+
*/
|
|
67
|
+
this.stream = new sonic_boom_1.default({ fd: this.fd, sync: true, minLength: 1 });
|
|
68
|
+
}
|
|
69
|
+
onJourneyStart(journey, {}) {
|
|
70
|
+
this.write(`\nJourney: ${journey.name}`);
|
|
71
|
+
}
|
|
72
|
+
onStepEnd(journey, step, result) {
|
|
73
|
+
const { status, end, start, error } = result;
|
|
74
|
+
const message = `${helpers_1.symbols[status]} Step: '${step.name}' ${status} (${renderDuration((end - start) * 1000)} ms)`;
|
|
75
|
+
this.write((0, helpers_1.indent)(message));
|
|
76
|
+
error && this.write(renderError(error));
|
|
77
|
+
this.metrics[status]++;
|
|
78
|
+
}
|
|
79
|
+
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
80
|
+
onJourneyEnd(journey, { error }) {
|
|
81
|
+
const { failed, succeeded, skipped } = this.metrics;
|
|
82
|
+
const total = failed + succeeded + skipped;
|
|
83
|
+
/**
|
|
84
|
+
* Render the error on the terminal only when no steps could
|
|
85
|
+
* be executed which means the error happened in one of the hooks
|
|
86
|
+
*/
|
|
87
|
+
if (total === 0 && error) {
|
|
88
|
+
this.write(renderError(error));
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
onEnd() {
|
|
92
|
+
const { failed, succeeded, skipped } = this.metrics;
|
|
93
|
+
const total = failed + succeeded + skipped;
|
|
94
|
+
let message = '\n';
|
|
95
|
+
if (total === 0) {
|
|
96
|
+
message = 'No tests found!';
|
|
97
|
+
message += ` (${renderDuration((0, helpers_1.now)())} ms) \n`;
|
|
102
98
|
this.write(message);
|
|
103
|
-
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
message += succeeded > 0 ? (0, colors_1.green)(` ${succeeded} passed`) : '';
|
|
102
|
+
message += failed > 0 ? (0, colors_1.red)(` ${failed} failed`) : '';
|
|
103
|
+
message += skipped > 0 ? (0, colors_1.cyan)(` ${skipped} skipped`) : '';
|
|
104
|
+
message += ` (${renderDuration((0, helpers_1.now)())} ms) \n`;
|
|
105
|
+
this.write(message);
|
|
106
|
+
// flushSync is used here to make sure all the data from the underlying
|
|
107
|
+
// SonicBoom stream buffer is completely written to the fd before closing
|
|
108
|
+
// the process
|
|
109
|
+
this.stream.flushSync();
|
|
104
110
|
}
|
|
105
111
|
write(message) {
|
|
106
112
|
if (typeof message == 'object') {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base.js","sourceRoot":"","sources":["../../src/reporters/base.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;;;;;AAEH,4DAAmC;AACnC,yCAAgD;
|
|
1
|
+
{"version":3,"file":"base.js","sourceRoot":"","sources":["../../src/reporters/base.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;;;;;AAEH,4DAAmC;AACnC,yCAAgD;AAChD,wCAMoB;AASpB,SAAS,WAAW,CAAC,KAAK;IACxB,IAAI,MAAM,GAAG,EAAE,CAAC;IAChB,MAAM,KAAK,GAAG,IAAA,gBAAM,EAAC,EAAE,CAAC,CAAC;IACzB,MAAM,KAAK,GAAG,IAAA,gBAAM,EAAC,KAAK,CAAC,CAAC;IAC5B,MAAM,SAAS,GAAG,KAAK,GAAG,OAAO,CAAC;IAClC,MAAM,IAAI,SAAS,CAAC;IACpB,IAAI,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC;IACxB,IAAI,KAAK,EAAE;QACT,MAAM,IAAI,KAAK,GAAG,aAAa,CAAC;QAChC,KAAK,GAAG,IAAA,2BAAiB,EAAC,KAAK,EAAE,IAAA,2BAAiB,EAAC,KAAK,CAAC,CAAC,CAAC;QAC3D,MAAM,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QACxC,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE;YACxB,MAAM,IAAI,KAAK,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;SACtC;KACF;IACD,MAAM,IAAI,SAAS,CAAC;IACpB,OA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E;QACvE,yEAAyE;QACzE,cAAc;QACd,IAAI,CAAC,MAAM,CAAC,SAAS,EAAE,CAAC;IAC1B,CAAC;IAED,KAAK,CAAC,OAAO;QACX,IAAI,OAAO,OAAO,IAAI,QAAQ,EAAE;YAC9B,OAAO,GAAG,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;SACnC;QACD,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,OAAO,GAAG,IAAI,CAAC,CAAC;IACpC,CAAC;CACF;AA5ED,+BA4EC"}
|
|
@@ -22,14 +22,24 @@
|
|
|
22
22
|
* THE SOFTWARE.
|
|
23
23
|
*
|
|
24
24
|
*/
|
|
25
|
-
import
|
|
26
|
-
import
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
25
|
+
import { Journey, Step } from '../dsl';
|
|
26
|
+
import { StartEvent, JourneyEndResult, JourneyStartResult, StepEndResult } from '../common_types';
|
|
27
|
+
export declare type ReporterOptions = {
|
|
28
|
+
fd?: number;
|
|
29
|
+
colors?: boolean;
|
|
30
|
+
};
|
|
31
|
+
export declare type BuiltInReporterName = 'default' | 'json' | 'junit';
|
|
32
|
+
export declare type ReporterInstance = new (opts: ReporterOptions) => Reporter;
|
|
30
33
|
export declare const reporters: {
|
|
31
|
-
|
|
32
|
-
json: typeof JSONReporter;
|
|
33
|
-
junit: typeof JUnitReporter;
|
|
34
|
+
[key in BuiltInReporterName]: ReporterInstance;
|
|
34
35
|
};
|
|
36
|
+
export interface Reporter {
|
|
37
|
+
onStart?(params: StartEvent): void;
|
|
38
|
+
onJourneyRegister?(journey: Journey): void;
|
|
39
|
+
onJourneyStart?(journey: Journey, result: JourneyStartResult): void;
|
|
40
|
+
onStepStart?(journey: Journey, step: Step): void;
|
|
41
|
+
onStepEnd?(journey: Journey, step: Step, result: StepEndResult): void;
|
|
42
|
+
onJourneyEnd?(journey: Journey, result: JourneyEndResult): void | Promise<void>;
|
|
43
|
+
onEnd?(): void | Promise<void>;
|
|
44
|
+
}
|
|
35
45
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/reporters/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/reporters/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAKH,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AACvC,OAAO,EACL,UAAU,EACV,gBAAgB,EAChB,kBAAkB,EAClB,aAAa,EACd,MAAM,iBAAiB,CAAC;AAEzB,oBAAY,eAAe,GAAG;IAAE,EAAE,CAAC,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,OAAO,CAAA;CAAE,CAAC;AAChE,oBAAY,mBAAmB,GAAG,SAAS,GAAG,MAAM,GAAG,OAAO,CAAC;AAC/D,oBAAY,gBAAgB,GAAG,KAAK,IAAI,EAAE,eAAe,KAAK,QAAQ,CAAC;AACvE,eAAO,MAAM,SAAS,EAAE;KACrB,GAAG,IAAI,mBAAmB,GAAG,gBAAgB;CAK/C,CAAC;AAEF,MAAM,WAAW,QAAQ;IACvB,OAAO,CAAC,CAAC,MAAM,EAAE,UAAU,GAAG,IAAI,CAAC;IACnC,iBAAiB,CAAC,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAAC;IAC3C,cAAc,CAAC,CAAC,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,kBAAkB,GAAG,IAAI,CAAC;IACpE,WAAW,CAAC,CAAC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,GAAG,IAAI,CAAC;IACjD,SAAS,CAAC,CAAC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,aAAa,GAAG,IAAI,CAAC;IACtE,YAAY,CAAC,CACX,OAAO,EAAE,OAAO,EAChB,MAAM,EAAE,gBAAgB,GACvB,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACxB,KAAK,CAAC,IAAI,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAChC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/reporters/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;;;;;;AAEH,kDAAkC;AAClC,kDAAkC;AAClC,oDAAoC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/reporters/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;;;;;;AAEH,kDAAkC;AAClC,kDAAkC;AAClC,oDAAoC;AAYvB,QAAA,SAAS,GAElB;IACF,OAAO,EAAE,cAAY;IACrB,IAAI,EAAE,cAAY;IAClB,KAAK,EAAE,eAAa;CACrB,CAAC"}
|