@elastic/synthetics 1.0.0-beta.3 → 1.0.0-beta.30
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 +99 -162
- package/dist/cli.js.map +1 -1
- package/dist/common_types.d.ts +156 -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/gatherer.d.ts +4 -8
- package/dist/core/gatherer.d.ts.map +1 -1
- package/dist/core/gatherer.js +46 -14
- 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 +211 -93
- package/dist/core/runner.js.map +1 -1
- package/dist/dsl/journey.d.ts +7 -3
- package/dist/dsl/journey.d.ts.map +1 -1
- package/dist/dsl/journey.js +22 -6
- package/dist/dsl/journey.js.map +1 -1
- package/{src/reporters/reporter.ts → dist/dsl/locations.d.ts} +12 -10
- package/dist/dsl/locations.d.ts.map +1 -0
- package/dist/dsl/locations.js +41 -0
- package/dist/dsl/locations.js.map +1 -0
- package/dist/dsl/monitor.d.ts +65 -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 +21 -0
- package/dist/generator/index.d.ts.map +1 -0
- package/dist/generator/index.js +169 -0
- package/dist/generator/index.js.map +1 -0
- package/dist/{reporters/reporter.d.ts → generator/utils.d.ts} +4 -9
- package/dist/generator/utils.d.ts.map +1 -0
- package/dist/generator/utils.js +57 -0
- package/dist/generator/utils.js.map +1 -0
- package/dist/helpers.d.ts +20 -1
- package/dist/helpers.d.ts.map +1 -1
- package/dist/helpers.js +98 -18
- package/dist/helpers.js.map +1 -1
- package/dist/index.d.ts +5 -6
- 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 +144 -0
- package/dist/loader.js.map +1 -0
- package/dist/options.d.ts +34 -0
- package/dist/options.d.ts.map +1 -0
- package/dist/options.js +162 -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/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 +114 -0
- package/dist/push/bundler.js.map +1 -0
- package/dist/{reporters/reporter.js → push/index.d.ts} +4 -3
- package/dist/push/index.d.ts.map +1 -0
- package/dist/push/index.js +55 -0
- package/dist/push/index.js.map +1 -0
- package/dist/push/monitor.d.ts +32 -0
- package/dist/push/monitor.d.ts.map +1 -0
- package/dist/push/monitor.js +62 -0
- package/dist/push/monitor.js.map +1 -0
- package/dist/push/plugin.d.ts +33 -0
- package/dist/push/plugin.d.ts.map +1 -0
- package/dist/push/plugin.js +124 -0
- package/dist/push/plugin.js.map +1 -0
- package/dist/push/request.d.ts +42 -0
- package/dist/push/request.d.ts.map +1 -0
- package/dist/push/request.js +84 -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 +31 -19
- package/src/cli.ts +187 -154
- package/src/common_types.ts +188 -34
- package/src/config.ts +2 -5
- package/src/core/gatherer.ts +55 -27
- package/src/core/index.ts +36 -15
- package/src/core/logger.ts +1 -12
- package/src/core/runner.ts +216 -152
- package/src/dsl/journey.ts +29 -5
- package/src/dsl/locations.ts +38 -0
- package/src/dsl/monitor.ts +87 -0
- package/src/dsl/step.ts +9 -2
- package/src/formatter/javascript.ts +367 -0
- package/src/generator/index.ts +212 -0
- package/src/generator/utils.ts +54 -0
- package/src/helpers.ts +106 -10
- package/src/index.ts +21 -22
- package/src/loader.ts +162 -0
- package/src/options.ts +173 -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 +95 -0
- package/src/push/index.ts +59 -0
- package/src/push/monitor.ts +68 -0
- package/src/push/plugin.ts +114 -0
- package/src/push/request.ts +111 -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 +26 -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,169 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Generator = exports.regularFiles = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* MIT License
|
|
6
|
+
*
|
|
7
|
+
* Copyright (c) 2020-present, Elastic NV
|
|
8
|
+
*
|
|
9
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
10
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
11
|
+
* in the Software without restriction, including without limitation the rights
|
|
12
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
13
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
14
|
+
* furnished to do so, subject to the following conditions:
|
|
15
|
+
*
|
|
16
|
+
* The above copyright notice and this permission notice shall be included in
|
|
17
|
+
* all copies or substantial portions of the Software.
|
|
18
|
+
*
|
|
19
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
20
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
21
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
22
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
23
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
24
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
25
|
+
* THE SOFTWARE.
|
|
26
|
+
*
|
|
27
|
+
*/
|
|
28
|
+
const child_process_1 = require("child_process");
|
|
29
|
+
const fs_1 = require("fs");
|
|
30
|
+
const promises_1 = require("fs/promises");
|
|
31
|
+
const colors_1 = require("kleur/colors");
|
|
32
|
+
const path_1 = require("path");
|
|
33
|
+
const enquirer_1 = require("enquirer");
|
|
34
|
+
const monitor_1 = require("../dsl/monitor");
|
|
35
|
+
const helpers_1 = require("../helpers");
|
|
36
|
+
const utils_1 = require("./utils");
|
|
37
|
+
// Templates that are required for setting up new
|
|
38
|
+
// synthetics project
|
|
39
|
+
const templateDir = (0, path_1.join)(__dirname, '..', '..', 'templates');
|
|
40
|
+
// exported for testing
|
|
41
|
+
exports.regularFiles = [
|
|
42
|
+
'.github/workflows/run-synthetics.yml',
|
|
43
|
+
'README.md',
|
|
44
|
+
'journeys/example.journey.ts',
|
|
45
|
+
'journeys/advanced-example.journey.ts',
|
|
46
|
+
'journeys/advanced-example-helpers.ts',
|
|
47
|
+
];
|
|
48
|
+
class Generator {
|
|
49
|
+
constructor(projectDir) {
|
|
50
|
+
this.projectDir = projectDir;
|
|
51
|
+
this.pkgManager = 'npm';
|
|
52
|
+
}
|
|
53
|
+
async directory() {
|
|
54
|
+
if (!(0, fs_1.existsSync)(this.projectDir)) {
|
|
55
|
+
await (0, promises_1.mkdir)(this.projectDir);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
async questions() {
|
|
59
|
+
if (process.env.TEST_QUESTIONS) {
|
|
60
|
+
return JSON.parse(process.env.TEST_QUESTIONS);
|
|
61
|
+
}
|
|
62
|
+
const question = [
|
|
63
|
+
{
|
|
64
|
+
type: 'select',
|
|
65
|
+
name: 'locations',
|
|
66
|
+
message: 'Select the default location where you want to run monitors.',
|
|
67
|
+
choices: monitor_1.SyntheticsLocations,
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
type: 'numeral',
|
|
71
|
+
name: 'schedule',
|
|
72
|
+
message: 'Set default schedule in minutes for all monitors',
|
|
73
|
+
initial: 10,
|
|
74
|
+
},
|
|
75
|
+
];
|
|
76
|
+
return await (0, enquirer_1.prompt)(question);
|
|
77
|
+
}
|
|
78
|
+
async files(answers) {
|
|
79
|
+
const fileMap = new Map();
|
|
80
|
+
// Setup Synthetics config file
|
|
81
|
+
const configFile = 'synthetics.config.ts';
|
|
82
|
+
fileMap.set(configFile, (0, utils_1.replaceTemplates)(await (0, promises_1.readFile)((0, path_1.join)(templateDir, configFile), 'utf-8'), answers));
|
|
83
|
+
// Setup non-templated files
|
|
84
|
+
Promise.all(exports.regularFiles.map(async (fn) => {
|
|
85
|
+
fileMap.set(fn, await (0, promises_1.readFile)((0, path_1.join)(templateDir, fn), 'utf-8'));
|
|
86
|
+
})).catch(e => {
|
|
87
|
+
throw e;
|
|
88
|
+
});
|
|
89
|
+
// Create files
|
|
90
|
+
for (const [relativePath, content] of fileMap) {
|
|
91
|
+
await this.createFile(relativePath, content);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
async createFile(relativePath, content, override = false) {
|
|
95
|
+
const absolutePath = (0, path_1.join)(this.projectDir, relativePath);
|
|
96
|
+
if (override || !(0, fs_1.existsSync)(absolutePath)) {
|
|
97
|
+
(0, helpers_1.progress)(`Writing ${(0, path_1.relative)(process.cwd(), absolutePath)}.`);
|
|
98
|
+
await (0, promises_1.mkdir)((0, path_1.dirname)(absolutePath), { recursive: true });
|
|
99
|
+
await (0, promises_1.writeFile)(absolutePath, content, 'utf-8');
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
async package() {
|
|
103
|
+
this.pkgManager = await (0, utils_1.getPackageManager)(this.projectDir);
|
|
104
|
+
const commands = new Map();
|
|
105
|
+
commands.set(`Initializing Synthetics project using ${this.pkgManager == 'yarn' ? 'Yarn' : 'NPM'}`, this.pkgManager == 'yarn' ? 'yarn init -y' : 'npm init -y');
|
|
106
|
+
const pkgName = '@elastic/synthetics';
|
|
107
|
+
commands.set(`Installing @elastic/synthetics library`, this.pkgManager == 'yarn'
|
|
108
|
+
? `yarn add -dev ${pkgName}`
|
|
109
|
+
: `npm i -d ${pkgName}`);
|
|
110
|
+
// Execute commands
|
|
111
|
+
for (const [name, command] of commands) {
|
|
112
|
+
(0, helpers_1.progress)(`${name}...`);
|
|
113
|
+
(0, child_process_1.execSync)(command, {
|
|
114
|
+
stdio: 'inherit',
|
|
115
|
+
cwd: this.projectDir,
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
async patchPkgJSON() {
|
|
120
|
+
const filename = 'package.json';
|
|
121
|
+
const pkgJSON = JSON.parse(await (0, promises_1.readFile)((0, path_1.join)(this.projectDir, filename), 'utf-8'));
|
|
122
|
+
if (!pkgJSON.scripts) {
|
|
123
|
+
pkgJSON.scripts = {};
|
|
124
|
+
}
|
|
125
|
+
// Add test command
|
|
126
|
+
pkgJSON.scripts.test = 'npx @elastic/synthetics journeys';
|
|
127
|
+
// Add push command
|
|
128
|
+
const project = (0, path_1.basename)(this.projectDir);
|
|
129
|
+
pkgJSON.scripts.push = `npx @elastic/synthetics push journeys --project ${project} --url http://localhost:5601 --auth apiKey`;
|
|
130
|
+
await this.createFile(filename, JSON.stringify(pkgJSON, null, 2) + '\n', true);
|
|
131
|
+
}
|
|
132
|
+
async patchGitIgnore() {
|
|
133
|
+
const gitIgnorePath = (0, path_1.join)(this.projectDir, '.gitignore');
|
|
134
|
+
let gitIgnore = '';
|
|
135
|
+
if ((0, fs_1.existsSync)(gitIgnorePath)) {
|
|
136
|
+
const contents = await (0, promises_1.readFile)(gitIgnorePath, 'utf-8');
|
|
137
|
+
gitIgnore += contents.trimEnd() + '\n';
|
|
138
|
+
}
|
|
139
|
+
if (!gitIgnore.includes('node_modules')) {
|
|
140
|
+
gitIgnore += 'node_modules/\n';
|
|
141
|
+
}
|
|
142
|
+
gitIgnore += '.synthetics/\n';
|
|
143
|
+
await (0, promises_1.writeFile)(gitIgnorePath, gitIgnore, 'utf-8');
|
|
144
|
+
}
|
|
145
|
+
banner() {
|
|
146
|
+
(0, helpers_1.write)((0, colors_1.bold)(`
|
|
147
|
+
All set, you can run below commands inside: ${this.projectDir}:
|
|
148
|
+
|
|
149
|
+
Run synthetic tests: ${(0, colors_1.cyan)((0, utils_1.runCommand)(this.pkgManager, 'test'))}
|
|
150
|
+
|
|
151
|
+
Push monitors to Kibana: ${(0, colors_1.cyan)((0, utils_1.runCommand)(this.pkgManager, 'push'))}
|
|
152
|
+
|
|
153
|
+
${(0, colors_1.yellow)('Make sure to update the Kibana url and api keys before pushing monitors to Kibana.')}
|
|
154
|
+
|
|
155
|
+
Visit https://www.elastic.co/guide/en/observability/current/synthetic-run-tests.html to learn more.
|
|
156
|
+
`));
|
|
157
|
+
}
|
|
158
|
+
async setup() {
|
|
159
|
+
await this.directory();
|
|
160
|
+
const answers = await this.questions();
|
|
161
|
+
await this.package();
|
|
162
|
+
await this.files(answers);
|
|
163
|
+
await this.patchPkgJSON();
|
|
164
|
+
await this.patchGitIgnore();
|
|
165
|
+
this.banner();
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
exports.Generator = Generator;
|
|
169
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/generator/index.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,iDAAyC;AACzC,2BAAgC;AAChC,0CAAyD;AACzD,yCAAkD;AAClD,+BAAyD;AACzD,uCAAkC;AAClC,4CAAqD;AACrD,wCAAyD;AACzD,mCAA0E;AAE1E,iDAAiD;AACjD,qBAAqB;AACrB,MAAM,WAAW,GAAG,IAAA,WAAI,EAAC,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,WAAW,CAAC,CAAC;AAO7D,uBAAuB;AACV,QAAA,YAAY,GAAG;IAC1B,sCAAsC;IACtC,WAAW;IACX,6BAA6B;IAC7B,sCAAsC;IACtC,sCAAsC;CACvC,CAAC;AAEF,MAAa,SAAS;IAEpB,YAAmB,UAAkB;QAAlB,eAAU,GAAV,UAAU,CAAQ;QADrC,eAAU,GAAG,KAAK,CAAC;IACqB,CAAC;I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|
25
|
-
|
|
26
|
-
export declare
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
};
|
|
30
|
-
export default interface Reporter {
|
|
31
|
-
new (runner: Runner, options: ReporterOptions): any;
|
|
32
|
-
}
|
|
33
|
-
//# sourceMappingURL=reporter.d.ts.map
|
|
25
|
+
export declare function getPackageManager(dir: string): Promise<"yarn" | "npm">;
|
|
26
|
+
export declare function runCommand(pkgManager: string, command: string): string;
|
|
27
|
+
export declare function replaceTemplates(input: string, literals: Record<string, any>): string;
|
|
28
|
+
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/generator/utils.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAKH,wBAAsB,iBAAiB,CAAC,GAAG,EAAE,MAAM,2BAKlD;AAED,wBAAgB,UAAU,CAAC,UAAU,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,UAK7D;AAED,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,UAW5E"}
|
|
@@ -0,0 +1,57 @@
|
|
|
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.replaceTemplates = exports.runCommand = exports.getPackageManager = void 0;
|
|
28
|
+
const fs_1 = require("fs");
|
|
29
|
+
const path_1 = require("path");
|
|
30
|
+
async function getPackageManager(dir) {
|
|
31
|
+
if ((0, fs_1.existsSync)((0, path_1.join)(dir, 'yarn.lock'))) {
|
|
32
|
+
return 'yarn';
|
|
33
|
+
}
|
|
34
|
+
return 'npm';
|
|
35
|
+
}
|
|
36
|
+
exports.getPackageManager = getPackageManager;
|
|
37
|
+
function runCommand(pkgManager, command) {
|
|
38
|
+
if (pkgManager === 'yarn') {
|
|
39
|
+
return `yarn ${command}`;
|
|
40
|
+
}
|
|
41
|
+
return `npm run ${command}`;
|
|
42
|
+
}
|
|
43
|
+
exports.runCommand = runCommand;
|
|
44
|
+
function replaceTemplates(input, literals) {
|
|
45
|
+
for (const key in literals) {
|
|
46
|
+
const finalValue = literals[key];
|
|
47
|
+
input = input.replace(new RegExp(`'{{` + key + `}}'`, 'g'), () => {
|
|
48
|
+
if (typeof finalValue == 'number') {
|
|
49
|
+
return Number(finalValue);
|
|
50
|
+
}
|
|
51
|
+
return finalValue;
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
return input;
|
|
55
|
+
}
|
|
56
|
+
exports.replaceTemplates = replaceTemplates;
|
|
57
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/generator/utils.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;;;AAEH,2BAAgC;AAChC,+BAA4B;AAErB,KAAK,UAAU,iBAAiB,CAAC,GAAW;IACjD,IAAI,IAAA,eAAU,EAAC,IAAA,WAAI,EAAC,GAAG,EAAE,WAAW,CAAC,CAAC,EAAE;QACtC,OAAO,MAAM,CAAC;KACf;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AALD,8CAKC;AAED,SAAgB,UAAU,CAAC,UAAkB,EAAE,OAAe;IAC5D,IAAI,UAAU,KAAK,MAAM,EAAE;QACzB,OAAO,QAAQ,OAAO,EAAE,CAAC;KAC1B;IACD,OAAO,WAAW,OAAO,EAAE,CAAC;AAC9B,CAAC;AALD,gCAKC;AAED,SAAgB,gBAAgB,CAAC,KAAa,EAAE,QAA6B;IAC3E,KAAK,MAAM,GAAG,IAAI,QAAQ,EAAE;QAC1B,MAAM,UAAU,GAAG,QAAQ,CAAC,GAAG,CAAC,CAAC;QACjC,KAAK,GAAG,KAAK,CAAC,OAAO,CAAC,IAAI,MAAM,CAAC,KAAK,GAAG,GAAG,GAAG,KAAK,EAAE,GAAG,CAAC,EAAE,GAAG,EAAE;YAC/D,IAAI,OAAO,UAAU,IAAI,QAAQ,EAAE;gBACjC,OAAO,MAAM,CAAC,UAAU,CAAC,CAAC;aAC3B;YACD,OAAO,UAAU,CAAC;QACpB,CAAC,CAAC,CAAC;KACJ;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAXD,4CAWC"}
|
package/dist/helpers.d.ts
CHANGED
|
@@ -22,15 +22,22 @@
|
|
|
22
22
|
* THE SOFTWARE.
|
|
23
23
|
*
|
|
24
24
|
*/
|
|
25
|
-
|
|
25
|
+
/// <reference types="node" />
|
|
26
|
+
import fs from 'fs';
|
|
27
|
+
import { HooksArgs, HooksCallback, NetworkConditions, Location, ThrottlingOptions } from './common_types';
|
|
28
|
+
export declare const readFileAsync: typeof fs.readFile.__promisify__;
|
|
29
|
+
export declare const writeFileAsync: typeof fs.writeFile.__promisify__;
|
|
30
|
+
export declare const mkdirAsync: typeof fs.mkdir.__promisify__;
|
|
26
31
|
export declare function noop(): void;
|
|
27
32
|
export declare function indent(lines: string, tab?: string): string;
|
|
28
33
|
export declare const symbols: {
|
|
29
34
|
warning: string;
|
|
30
35
|
skipped: string;
|
|
36
|
+
progress: string;
|
|
31
37
|
succeeded: string;
|
|
32
38
|
failed: string;
|
|
33
39
|
};
|
|
40
|
+
export declare function generateUniqueId(): string;
|
|
34
41
|
export declare function generateTempPath(): string;
|
|
35
42
|
/**
|
|
36
43
|
* Get Monotonically increasing time in seconds since
|
|
@@ -94,4 +101,16 @@ export declare function formatError(error: Error): {
|
|
|
94
101
|
*/
|
|
95
102
|
export declare const CACHE_PATH: string;
|
|
96
103
|
export declare function getDurationInUs(duration: number): number;
|
|
104
|
+
export declare function megabitsToBytes(megabytes: number): number;
|
|
105
|
+
export declare const DEFAULT_THROTTLING_OPTIONS: ThrottlingOptions;
|
|
106
|
+
/**
|
|
107
|
+
* Transforms the CLI throttling arguments in to format
|
|
108
|
+
* expected by Chrome devtools protocol NetworkConditions
|
|
109
|
+
*/
|
|
110
|
+
export declare function getNetworkConditions(throttlingOpts: ThrottlingOptions): NetworkConditions;
|
|
111
|
+
export declare function wrapFnWithLocation<A extends unknown[], R>(func: (location: Location, ...args: A) => R): (...args: A) => R;
|
|
112
|
+
export declare function write(message: string): void;
|
|
113
|
+
export declare function progress(message: string): void;
|
|
114
|
+
export declare function error(message: string): void;
|
|
115
|
+
export declare function done(message: string): void;
|
|
97
116
|
//# sourceMappingURL=helpers.d.ts.map
|
package/dist/helpers.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../src/helpers.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG
|
|
1
|
+
{"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../src/helpers.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;;AAKH,OAAO,EAAE,MAAM,IAAI,CAAC;AAIpB,OAAO,EACL,SAAS,EACT,aAAa,EACb,iBAAiB,EACjB,QAAQ,EACR,iBAAiB,EAClB,MAAM,gBAAgB,CAAC;AAKxB,eAAO,MAAM,aAAa,kCAAyB,CAAC;AACpD,eAAO,MAAM,cAAc,mCAA0B,CAAC;AACtD,eAAO,MAAM,UAAU,+BAAsB,CAAC;AAI9C,wBAAgB,IAAI,SAAK;AAEzB,wBAAgB,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,SAAQ,UAEhD;AAOD,eAAO,MAAM,OAAO;;;;;;CAMnB,CAAC;AAEF,wBAAgB,gBAAgB,WAE/B;AAED,wBAAgB,gBAAgB,WAE/B;AAED;;;;;;;GAOG;AACH,wBAAgB,sBAAsB,WAGrC;AAED;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAAC,EAAE,EAAE,MAAM,UAE5C;AAMD,wBAAgB,YAAY,WAE3B;AAED;;GAEG;AACH,wBAAgB,GAAG,WAElB;AAED;;GAEG;AACH,wBAAsB,WAAW,CAC/B,SAAS,EAAE,KAAK,CAAC,aAAa,CAAC,EAC/B,IAAI,EAAE,SAAS,mBAIhB;AAED,wBAAgB,cAAc,CAAC,GAAG,KAAA,kBAMjC;AAED,wBAAgB,WAAW,CAAC,IAAI,KAAA,WAE/B;AAED,wBAAgB,MAAM,CAAC,QAAQ,KAAA,WAE9B;AAED;;;;GAIG;AACH,wBAAgB,uBAAuB,CAAC,WAAW,KAAA,EAAE,GAAG,KAAA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HANGED
|
@@ -27,15 +27,19 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
27
27
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
28
28
|
};
|
|
29
29
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
30
|
-
exports.getDurationInUs = exports.CACHE_PATH = exports.formatError = exports.rewriteErrorStack = exports.rewriteErrorMessage = exports.findPWLogsIndexes = exports.totalist = exports.findPkgJsonByTraversing = exports.isFile = exports.isDirectory = exports.isDepInstalled = exports.runParallel = exports.now = exports.getTimestamp = exports.microSecsToSeconds = exports.monotonicTimeInSeconds = exports.generateTempPath = exports.symbols = exports.indent = exports.noop = void 0;
|
|
30
|
+
exports.done = exports.error = exports.progress = exports.write = exports.wrapFnWithLocation = exports.getNetworkConditions = exports.DEFAULT_THROTTLING_OPTIONS = exports.megabitsToBytes = exports.getDurationInUs = exports.CACHE_PATH = exports.formatError = exports.rewriteErrorStack = exports.rewriteErrorMessage = exports.findPWLogsIndexes = exports.totalist = exports.findPkgJsonByTraversing = exports.isFile = exports.isDirectory = exports.isDepInstalled = exports.runParallel = exports.now = exports.getTimestamp = exports.microSecsToSeconds = exports.monotonicTimeInSeconds = exports.generateTempPath = exports.generateUniqueId = exports.symbols = exports.indent = exports.noop = exports.mkdirAsync = exports.writeFileAsync = exports.readFileAsync = void 0;
|
|
31
31
|
const colors_1 = require("kleur/colors");
|
|
32
32
|
const os_1 = __importDefault(require("os"));
|
|
33
33
|
const path_1 = require("path");
|
|
34
34
|
const fs_1 = __importDefault(require("fs"));
|
|
35
35
|
const util_1 = require("util");
|
|
36
36
|
const perf_hooks_1 = require("perf_hooks");
|
|
37
|
-
const
|
|
38
|
-
const
|
|
37
|
+
const source_map_support_1 = __importDefault(require("@cspotcode/source-map-support"));
|
|
38
|
+
const lstatAsync = (0, util_1.promisify)(fs_1.default.lstat);
|
|
39
|
+
const readdirAsync = (0, util_1.promisify)(fs_1.default.readdir);
|
|
40
|
+
exports.readFileAsync = (0, util_1.promisify)(fs_1.default.readFile);
|
|
41
|
+
exports.writeFileAsync = (0, util_1.promisify)(fs_1.default.writeFile);
|
|
42
|
+
exports.mkdirAsync = (0, util_1.promisify)(fs_1.default.mkdir);
|
|
39
43
|
const SEPARATOR = '\n';
|
|
40
44
|
function noop() { }
|
|
41
45
|
exports.noop = noop;
|
|
@@ -43,14 +47,24 @@ function indent(lines, tab = ' ') {
|
|
|
43
47
|
return lines.replace(/^/gm, tab);
|
|
44
48
|
}
|
|
45
49
|
exports.indent = indent;
|
|
50
|
+
/**
|
|
51
|
+
* Disable unicode symbols for windows, the underlying
|
|
52
|
+
* FS stream has a known issue in windows
|
|
53
|
+
*/
|
|
54
|
+
const NO_UTF8_SUPPORT = process.platform === 'win32';
|
|
46
55
|
exports.symbols = {
|
|
47
|
-
warning: colors_1.yellow('⚠'),
|
|
48
|
-
skipped: colors_1.cyan('-'),
|
|
49
|
-
|
|
50
|
-
|
|
56
|
+
warning: (0, colors_1.yellow)(NO_UTF8_SUPPORT ? '!' : '⚠'),
|
|
57
|
+
skipped: (0, colors_1.cyan)('-'),
|
|
58
|
+
progress: (0, colors_1.cyan)('>'),
|
|
59
|
+
succeeded: (0, colors_1.green)(NO_UTF8_SUPPORT ? 'ok' : '✓'),
|
|
60
|
+
failed: (0, colors_1.red)(NO_UTF8_SUPPORT ? 'x' : '✖'),
|
|
51
61
|
};
|
|
62
|
+
function generateUniqueId() {
|
|
63
|
+
return `${Date.now() + Math.floor(Math.random() * 1e13)}`;
|
|
64
|
+
}
|
|
65
|
+
exports.generateUniqueId = generateUniqueId;
|
|
52
66
|
function generateTempPath() {
|
|
53
|
-
return path_1.join(os_1.default.tmpdir(), `synthetics-${
|
|
67
|
+
return (0, path_1.join)(os_1.default.tmpdir(), `synthetics-${generateUniqueId()}`);
|
|
54
68
|
}
|
|
55
69
|
exports.generateTempPath = generateTempPath;
|
|
56
70
|
/**
|
|
@@ -123,16 +137,16 @@ exports.isFile = isFile;
|
|
|
123
137
|
* from an NPM project.
|
|
124
138
|
*/
|
|
125
139
|
function findPkgJsonByTraversing(resolvePath, cwd) {
|
|
126
|
-
const packageJSON = path_1.resolve(resolvePath, 'package.json');
|
|
140
|
+
const packageJSON = (0, path_1.resolve)(resolvePath, 'package.json');
|
|
127
141
|
if (isFile(packageJSON)) {
|
|
128
142
|
return packageJSON;
|
|
129
143
|
}
|
|
130
|
-
const parentDirectory = path_1.dirname(resolvePath);
|
|
144
|
+
const parentDirectory = (0, path_1.dirname)(resolvePath);
|
|
131
145
|
/**
|
|
132
146
|
* We are in the system root and package.json does not exist
|
|
133
147
|
*/
|
|
134
148
|
if (resolvePath === parentDirectory) {
|
|
135
|
-
throw colors_1.red(`Could not find package.json file in: "${cwd}"\n` +
|
|
149
|
+
throw (0, colors_1.red)(`Could not find package.json file in: "${cwd}"\n` +
|
|
136
150
|
`It is recommended to run the agent in an NPM project.\n` +
|
|
137
151
|
`You can create one by running "npm init -y" in the project folder.`);
|
|
138
152
|
}
|
|
@@ -147,13 +161,13 @@ exports.findPkgJsonByTraversing = findPkgJsonByTraversing;
|
|
|
147
161
|
* https://github.com/lukeed/totalist/blob/44379974e535afe9c38e8d643dd64c59101a14b9/src/async.js#L8
|
|
148
162
|
*/
|
|
149
163
|
async function totalist(dir, callback, pre = '') {
|
|
150
|
-
dir = path_1.resolve('.', dir);
|
|
151
|
-
await
|
|
164
|
+
dir = (0, path_1.resolve)('.', dir);
|
|
165
|
+
await readdirAsync(dir).then(arr => {
|
|
152
166
|
return Promise.all(arr.map(str => {
|
|
153
|
-
const abs = path_1.join(dir, str);
|
|
154
|
-
return
|
|
155
|
-
? totalist(abs, callback, path_1.join(pre, str))
|
|
156
|
-
: callback(path_1.join(pre, str), abs));
|
|
167
|
+
const abs = (0, path_1.join)(dir, str);
|
|
168
|
+
return lstatAsync(abs).then(stats => stats.isDirectory()
|
|
169
|
+
? totalist(abs, callback, (0, path_1.join)(pre, str))
|
|
170
|
+
: callback((0, path_1.join)(pre, str), abs));
|
|
157
171
|
}));
|
|
158
172
|
});
|
|
159
173
|
}
|
|
@@ -227,9 +241,75 @@ const cwd = process.cwd();
|
|
|
227
241
|
* each process does not modify the caching layer used by other process
|
|
228
242
|
* once we move to executing journeys in parallel
|
|
229
243
|
*/
|
|
230
|
-
exports.CACHE_PATH = path_1.join(cwd, '.synthetics', process.pid.toString());
|
|
244
|
+
exports.CACHE_PATH = (0, path_1.join)(cwd, '.synthetics', process.pid.toString());
|
|
231
245
|
function getDurationInUs(duration) {
|
|
232
246
|
return Math.trunc(duration * 1e6);
|
|
233
247
|
}
|
|
234
248
|
exports.getDurationInUs = getDurationInUs;
|
|
249
|
+
function megabitsToBytes(megabytes) {
|
|
250
|
+
return (megabytes * 1024 * 1024) / 8;
|
|
251
|
+
}
|
|
252
|
+
exports.megabitsToBytes = megabitsToBytes;
|
|
253
|
+
exports.DEFAULT_THROTTLING_OPTIONS = {
|
|
254
|
+
download: 5,
|
|
255
|
+
upload: 3,
|
|
256
|
+
latency: 20,
|
|
257
|
+
};
|
|
258
|
+
/**
|
|
259
|
+
* Transforms the CLI throttling arguments in to format
|
|
260
|
+
* expected by Chrome devtools protocol NetworkConditions
|
|
261
|
+
*/
|
|
262
|
+
function getNetworkConditions(throttlingOpts) {
|
|
263
|
+
return {
|
|
264
|
+
downloadThroughput: megabitsToBytes(throttlingOpts.download),
|
|
265
|
+
uploadThroughput: megabitsToBytes(throttlingOpts.upload),
|
|
266
|
+
latency: throttlingOpts.latency,
|
|
267
|
+
offline: false,
|
|
268
|
+
};
|
|
269
|
+
}
|
|
270
|
+
exports.getNetworkConditions = getNetworkConditions;
|
|
271
|
+
const dstackTraceLimit = 10;
|
|
272
|
+
// Uses the V8 Stacktrace API to get the function location
|
|
273
|
+
// information - https://v8.dev/docs/stack-trace-api#customizing-stack-traces
|
|
274
|
+
function wrapFnWithLocation(func) {
|
|
275
|
+
return (...args) => {
|
|
276
|
+
const _prepareStackTrace = Error.prepareStackTrace;
|
|
277
|
+
Error.prepareStackTrace = (_, stackFrames) => {
|
|
278
|
+
// Deafult CallSite would not map to the original transpiled source
|
|
279
|
+
// from ts-node properly, So we wrap it with the library that knows
|
|
280
|
+
// how to retrive those source-map for the transpiled code
|
|
281
|
+
const frame = source_map_support_1.default.wrapCallSite(stackFrames[1]);
|
|
282
|
+
return {
|
|
283
|
+
file: frame.getFileName(),
|
|
284
|
+
line: frame.getLineNumber(),
|
|
285
|
+
column: frame.getColumnNumber(),
|
|
286
|
+
};
|
|
287
|
+
};
|
|
288
|
+
Error.stackTraceLimit = 2;
|
|
289
|
+
const obj = {};
|
|
290
|
+
Error.captureStackTrace(obj);
|
|
291
|
+
const location = obj.stack;
|
|
292
|
+
Error.stackTraceLimit = dstackTraceLimit;
|
|
293
|
+
Error.prepareStackTrace = _prepareStackTrace;
|
|
294
|
+
return func(location, ...args);
|
|
295
|
+
};
|
|
296
|
+
}
|
|
297
|
+
exports.wrapFnWithLocation = wrapFnWithLocation;
|
|
298
|
+
// Console helpers
|
|
299
|
+
function write(message) {
|
|
300
|
+
process.stderr.write(message + '\n');
|
|
301
|
+
}
|
|
302
|
+
exports.write = write;
|
|
303
|
+
function progress(message) {
|
|
304
|
+
write((0, colors_1.cyan)((0, colors_1.bold)(`${exports.symbols.progress} ${message}`)));
|
|
305
|
+
}
|
|
306
|
+
exports.progress = progress;
|
|
307
|
+
function error(message) {
|
|
308
|
+
write((0, colors_1.red)(message));
|
|
309
|
+
}
|
|
310
|
+
exports.error = error;
|
|
311
|
+
function done(message) {
|
|
312
|
+
write((0, colors_1.bold)((0, colors_1.green)(`${exports.symbols['succeeded']} ${message}`)));
|
|
313
|
+
}
|
|
314
|
+
exports.done = done;
|
|
235
315
|
//# sourceMappingURL=helpers.js.map
|
package/dist/helpers.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.js","sourceRoot":"","sources":["../src/helpers.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;;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,eAAO,CAAC,WAAW,CAAC,IAAI,OAAO,EAAE,CAAC,CAAC,CAAC,CAAC;AAC3D,CAAC;AAFD,oBAEC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -22,17 +22,14 @@
|
|
|
22
22
|
* THE SOFTWARE.
|
|
23
23
|
*
|
|
24
24
|
*/
|
|
25
|
-
import { RunOptions } from './
|
|
25
|
+
import { RunOptions } from './common_types';
|
|
26
26
|
export declare function run(options: RunOptions): Promise<{
|
|
27
|
-
[x: string]:
|
|
28
|
-
status: import("./common_types").StatusValue;
|
|
29
|
-
error?: Error;
|
|
30
|
-
};
|
|
27
|
+
[x: string]: import("./common_types").JourneyResult;
|
|
31
28
|
}>;
|
|
32
29
|
/**
|
|
33
30
|
* Export all core module functions
|
|
34
31
|
*/
|
|
35
|
-
export {
|
|
32
|
+
export { journey, step, monitor, beforeAll, afterAll, before, after, } from './core';
|
|
36
33
|
export { expect } from './core/expect';
|
|
37
34
|
/**
|
|
38
35
|
* Export all the driver related types to be consumed
|
|
@@ -44,4 +41,6 @@ export type { Page, ChromiumBrowser, ChromiumBrowserContext, CDPSession, } from
|
|
|
44
41
|
*/
|
|
45
42
|
export type { default as Runner } from './core/runner';
|
|
46
43
|
export type { Reporter, ReporterOptions } from './reporters';
|
|
44
|
+
export type { SyntheticsConfig } from './common_types';
|
|
45
|
+
export type { Action, ActionInContext, Signal, Step, Steps, actionTitle, } from './formatter/javascript';
|
|
47
46
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAGH,OAAO,EAAE,UAAU,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAGH,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAE5C,wBAAsB,GAAG,CAAC,OAAO,EAAE,UAAU;;GAE5C;AAED;;GAEG;AACH,OAAO,EACL,OAAO,EACP,IAAI,EACJ,OAAO,EACP,SAAS,EACT,QAAQ,EACR,MAAM,EACN,KAAK,GACN,MAAM,QAAQ,CAAC;AAChB,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AACvC;;;GAGG;AACH,YAAY,EACV,IAAI,EACJ,eAAe,EACf,sBAAsB,EACtB,UAAU,GACX,MAAM,qBAAqB,CAAC;AAE7B;;GAEG;AACH,YAAY,EAAE,OAAO,IAAI,MAAM,EAAE,MAAM,eAAe,CAAC;AACvD,YAAY,EAAE,QAAQ,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAE7D,YAAY,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AACvD,YAAY,EACV,MAAM,EACN,eAAe,EACf,MAAM,EACN,IAAI,EACJ,KAAK,EACL,WAAW,GACZ,MAAM,wBAAwB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -23,43 +23,22 @@
|
|
|
23
23
|
* THE SOFTWARE.
|
|
24
24
|
*
|
|
25
25
|
*/
|
|
26
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
27
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
28
|
-
};
|
|
29
26
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
30
|
-
exports.expect = exports.after = exports.before = exports.
|
|
27
|
+
exports.expect = exports.after = exports.before = exports.afterAll = exports.beforeAll = exports.monitor = exports.step = exports.journey = exports.run = void 0;
|
|
31
28
|
const core_1 = require("./core");
|
|
32
|
-
const logger_1 = require("./core/logger");
|
|
33
|
-
const source_map_support_1 = __importDefault(require("source-map-support"));
|
|
34
29
|
async function run(options) {
|
|
35
|
-
|
|
36
|
-
* Install source map support
|
|
37
|
-
*/
|
|
38
|
-
source_map_support_1.default.install({
|
|
39
|
-
environment: 'node',
|
|
40
|
-
});
|
|
41
|
-
/**
|
|
42
|
-
* set up logger with appropriate file descriptor
|
|
43
|
-
* to capture all the DEBUG logs when run through heartbeat
|
|
44
|
-
*/
|
|
45
|
-
logger_1.setLogger(options.outfd);
|
|
46
|
-
try {
|
|
47
|
-
return await core_1.runner.run(options);
|
|
48
|
-
}
|
|
49
|
-
catch (e) {
|
|
50
|
-
console.error('Failed to run the test', e);
|
|
51
|
-
process.exit(1);
|
|
52
|
-
}
|
|
30
|
+
return core_1.runner.run(options);
|
|
53
31
|
}
|
|
54
32
|
exports.run = run;
|
|
55
33
|
/**
|
|
56
34
|
* Export all core module functions
|
|
57
35
|
*/
|
|
58
36
|
var core_2 = require("./core");
|
|
59
|
-
Object.defineProperty(exports, "beforeAll", { enumerable: true, get: function () { return core_2.beforeAll; } });
|
|
60
|
-
Object.defineProperty(exports, "afterAll", { enumerable: true, get: function () { return core_2.afterAll; } });
|
|
61
37
|
Object.defineProperty(exports, "journey", { enumerable: true, get: function () { return core_2.journey; } });
|
|
62
38
|
Object.defineProperty(exports, "step", { enumerable: true, get: function () { return core_2.step; } });
|
|
39
|
+
Object.defineProperty(exports, "monitor", { enumerable: true, get: function () { return core_2.monitor; } });
|
|
40
|
+
Object.defineProperty(exports, "beforeAll", { enumerable: true, get: function () { return core_2.beforeAll; } });
|
|
41
|
+
Object.defineProperty(exports, "afterAll", { enumerable: true, get: function () { return core_2.afterAll; } });
|
|
63
42
|
Object.defineProperty(exports, "before", { enumerable: true, get: function () { return core_2.before; } });
|
|
64
43
|
Object.defineProperty(exports, "after", { enumerable: true, get: function () { return core_2.after; } });
|
|
65
44
|
var expect_1 = require("./core/expect");
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;;;AAEH,iCAAgC;AAGzB,KAAK,UAAU,GAAG,CAAC,OAAmB;IAC3C,OAAO,aAAM,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;AAC7B,CAAC;AAFD,kBAEC;AAED;;GAEG;AACH,+BAQgB;AAPd,+FAAA,OAAO,OAAA;AACP,4FAAA,IAAI,OAAA;AACJ,+FAAA,OAAO,OAAA;AACP,iGAAA,SAAS,OAAA;AACT,gGAAA,QAAQ,OAAA;AACR,8FAAA,MAAM,OAAA;AACN,6FAAA,KAAK,OAAA;AAEP,wCAAuC;AAA9B,gGAAA,MAAM,OAAA"}
|
|
@@ -23,8 +23,5 @@
|
|
|
23
23
|
*
|
|
24
24
|
*/
|
|
25
25
|
import { CliArgs } from './common_types';
|
|
26
|
-
declare
|
|
27
|
-
|
|
28
|
-
export { options };
|
|
29
|
-
export default command;
|
|
30
|
-
//# sourceMappingURL=parse_args.d.ts.map
|
|
26
|
+
export declare function loadTestFiles(options: CliArgs, args: string[]): Promise<void>;
|
|
27
|
+
//# sourceMappingURL=loader.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"loader.d.ts","sourceRoot":"","sources":["../src/loader.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAIH,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAazC,wBAAsB,aAAa,CAAC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,iBA6CnE"}
|