@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
package/package.json
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@elastic/synthetics",
|
|
3
|
-
"version": "1.0.0-beta.
|
|
3
|
+
"version": "1.0.0-beta.32",
|
|
4
4
|
"description": "Elastic synthetic monitoring agent",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
7
7
|
"scripts": {
|
|
8
|
-
"clean": "
|
|
8
|
+
"clean": "rimraf dist",
|
|
9
9
|
"prepublish": "npm run clean && npm run build",
|
|
10
10
|
"build": "tsc",
|
|
11
|
+
"build:locations": "sh utils/update_locations.sh",
|
|
11
12
|
"watch": "tsc -w",
|
|
12
13
|
"lint": "eslint . --rulesdir utils/eslint-rules",
|
|
13
14
|
"lint:fix": "npm run lint -- --fix",
|
|
@@ -22,7 +23,8 @@
|
|
|
22
23
|
},
|
|
23
24
|
"files": [
|
|
24
25
|
"dist",
|
|
25
|
-
"src"
|
|
26
|
+
"src",
|
|
27
|
+
"templates"
|
|
26
28
|
],
|
|
27
29
|
"lint-staged": {
|
|
28
30
|
"*.{js,ts}": [
|
|
@@ -38,32 +40,42 @@
|
|
|
38
40
|
"author": "",
|
|
39
41
|
"license": "MIT",
|
|
40
42
|
"dependencies": {
|
|
41
|
-
"
|
|
43
|
+
"@cspotcode/source-map-support": "^0.8.1",
|
|
44
|
+
"archiver": "^5.3.0",
|
|
45
|
+
"commander": "^9.0.0",
|
|
42
46
|
"deepmerge": "^4.2.2",
|
|
43
|
-
"
|
|
47
|
+
"enquirer": "^2.3.6",
|
|
48
|
+
"esbuild": "^0.14.27",
|
|
49
|
+
"expect": "^28.1.3",
|
|
44
50
|
"http-proxy": "^1.18.1",
|
|
45
|
-
"kleur": "^4.1.
|
|
51
|
+
"kleur": "^4.1.4",
|
|
46
52
|
"micromatch": "^4.0.4",
|
|
47
|
-
"playwright-chromium": "=1.
|
|
48
|
-
"
|
|
53
|
+
"playwright-chromium": "=1.20.1",
|
|
54
|
+
"playwright-core": "=1.20.1",
|
|
55
|
+
"sharp": "^0.30.6",
|
|
49
56
|
"snakecase-keys": "^3.2.1",
|
|
50
|
-
"sonic-boom": "^
|
|
51
|
-
"
|
|
52
|
-
"
|
|
53
|
-
"
|
|
57
|
+
"sonic-boom": "^2.6.0",
|
|
58
|
+
"ts-node": "^10.9.0",
|
|
59
|
+
"typescript": "^4.7.4",
|
|
60
|
+
"undici": "^5.7.0"
|
|
54
61
|
},
|
|
55
62
|
"devDependencies": {
|
|
56
|
-
"@types/jest": "^
|
|
63
|
+
"@types/jest": "^28.1.3",
|
|
57
64
|
"@types/micromatch": "^4.0.1",
|
|
58
|
-
"@types/node": "^
|
|
65
|
+
"@types/node": "^16.11.44",
|
|
59
66
|
"@types/sharp": "^0.28.2",
|
|
60
|
-
"@typescript-eslint/eslint-plugin": "^
|
|
61
|
-
"@typescript-eslint/parser": "^
|
|
62
|
-
"eslint": "^
|
|
67
|
+
"@typescript-eslint/eslint-plugin": "^5.0.0",
|
|
68
|
+
"@typescript-eslint/parser": "^5.0.0",
|
|
69
|
+
"eslint": "^8.0.1",
|
|
63
70
|
"husky": "^4.3.6",
|
|
64
|
-
"jest": "^
|
|
71
|
+
"jest": "^28.1.3",
|
|
65
72
|
"lint-staged": "^10.5.3",
|
|
66
|
-
"prettier": "^2.
|
|
67
|
-
"
|
|
73
|
+
"prettier": "^2.4.1",
|
|
74
|
+
"rimraf": "^3.0.2",
|
|
75
|
+
"ts-jest": "^28.0.5",
|
|
76
|
+
"unzipper": "^0.10.11"
|
|
77
|
+
},
|
|
78
|
+
"engines": {
|
|
79
|
+
"node": ">14.14.0"
|
|
68
80
|
}
|
|
69
81
|
}
|
package/src/cli.ts
CHANGED
|
@@ -25,169 +25,222 @@
|
|
|
25
25
|
*
|
|
26
26
|
*/
|
|
27
27
|
|
|
28
|
-
import {
|
|
29
|
-
import {
|
|
30
|
-
import
|
|
31
|
-
import {
|
|
32
|
-
import { log } from './core/logger';
|
|
33
|
-
import program, { options } from './parse_args';
|
|
28
|
+
import { program, Option } from 'commander';
|
|
29
|
+
import { cwd } from 'process';
|
|
30
|
+
import { CliArgs, PushOptions } from './common_types';
|
|
31
|
+
import { reporters } from './reporters';
|
|
34
32
|
import {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
} from './
|
|
33
|
+
normalizeOptions,
|
|
34
|
+
parseThrottling,
|
|
35
|
+
getCommonCommandOpts,
|
|
36
|
+
} from './options';
|
|
37
|
+
import { loadTestFiles } from './loader';
|
|
40
38
|
import { run } from './';
|
|
41
|
-
import {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
};
|
|
59
|
-
|
|
60
|
-
async function readStdin() {
|
|
61
|
-
const chunks = [];
|
|
62
|
-
stdin.resume();
|
|
63
|
-
stdin.setEncoding('utf-8');
|
|
64
|
-
for await (const chunk of stdin) {
|
|
65
|
-
chunks.push(chunk);
|
|
66
|
-
}
|
|
67
|
-
return chunks.join();
|
|
68
|
-
}
|
|
39
|
+
import { runner } from './core';
|
|
40
|
+
import { SyntheticsLocations } from './dsl/monitor';
|
|
41
|
+
import {
|
|
42
|
+
push,
|
|
43
|
+
loadSettings,
|
|
44
|
+
validateSettings,
|
|
45
|
+
catchIncorrectSettings,
|
|
46
|
+
} from './push';
|
|
47
|
+
import {
|
|
48
|
+
formatLocations,
|
|
49
|
+
getLocations,
|
|
50
|
+
renderLocations,
|
|
51
|
+
LocationCmdOptions,
|
|
52
|
+
} from './locations';
|
|
53
|
+
import { resolve } from 'path';
|
|
54
|
+
import { Generator } from './generator';
|
|
55
|
+
import { error } from './helpers';
|
|
56
|
+
import { LocationsMap } from './locations/public-locations';
|
|
69
57
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
require(suite);
|
|
73
|
-
}
|
|
74
|
-
}
|
|
58
|
+
/* eslint-disable-next-line @typescript-eslint/no-var-requires */
|
|
59
|
+
const { name, version } = require('../package.json');
|
|
75
60
|
|
|
76
|
-
|
|
77
|
-
* Handle both directory and files that are passed through TTY
|
|
78
|
-
* and add them to suites
|
|
79
|
-
*/
|
|
80
|
-
async function prepareSuites(inputs: string[]) {
|
|
81
|
-
const suites = new Set<string>();
|
|
82
|
-
const addSuite = absPath => {
|
|
83
|
-
log(`Processing file: ${absPath}`);
|
|
84
|
-
suites.add(require.resolve(absPath));
|
|
85
|
-
};
|
|
86
|
-
/**
|
|
87
|
-
* Match all files inside the directory with the
|
|
88
|
-
* .journey.{mjs|cjs|js|ts) extensions
|
|
89
|
-
*/
|
|
90
|
-
const pattern = options.pattern
|
|
91
|
-
? new RegExp(options.pattern, 'i')
|
|
92
|
-
: /.+\.journey\.([mc]js|[jt]s?)$/;
|
|
93
|
-
/**
|
|
94
|
-
* Ignore node_modules by default when running suites
|
|
95
|
-
*/
|
|
96
|
-
const ignored = /node_modules/i;
|
|
61
|
+
const { params, pattern, tags, match, playwrightOpts } = getCommonCommandOpts();
|
|
97
62
|
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
63
|
+
program
|
|
64
|
+
.name(`npx ${name}`)
|
|
65
|
+
.usage('[options] [dir] [files] file')
|
|
66
|
+
.option(
|
|
67
|
+
'-c, --config <path>',
|
|
68
|
+
'configuration path (default: synthetics.config.js)'
|
|
69
|
+
)
|
|
70
|
+
.addOption(pattern)
|
|
71
|
+
.addOption(tags)
|
|
72
|
+
.addOption(match)
|
|
73
|
+
.addOption(params)
|
|
74
|
+
.addOption(
|
|
75
|
+
new Option('--reporter <value>', `output repoter format`).choices(
|
|
76
|
+
Object.keys(reporters)
|
|
77
|
+
)
|
|
78
|
+
)
|
|
79
|
+
.option('--inline', 'Run inline journeys from heartbeat')
|
|
80
|
+
.option('-r, --require <modules...>', 'module(s) to preload')
|
|
81
|
+
.option('--no-headless', 'run browser in headful mode')
|
|
82
|
+
.option('--sandbox', 'enable chromium sandboxing')
|
|
83
|
+
.option('--rich-events', 'Mimics a heartbeat run')
|
|
84
|
+
.option(
|
|
85
|
+
'--capability <features...>',
|
|
86
|
+
'Enable capabilities through feature flags'
|
|
87
|
+
)
|
|
88
|
+
.addOption(
|
|
89
|
+
new Option('--screenshots [flag]', 'take screenshots at end of each step')
|
|
90
|
+
.choices(['on', 'off', 'only-on-failure'])
|
|
91
|
+
.default('on')
|
|
92
|
+
)
|
|
93
|
+
.option(
|
|
94
|
+
'--dry-run',
|
|
95
|
+
"don't actually execute anything, report only registered journeys"
|
|
96
|
+
)
|
|
97
|
+
.option(
|
|
98
|
+
'--outfd <fd>',
|
|
99
|
+
'specify a file descriptor for logs. Default is stdout',
|
|
100
|
+
parseInt
|
|
101
|
+
)
|
|
102
|
+
.option(
|
|
103
|
+
'--ws-endpoint <endpoint>',
|
|
104
|
+
'Browser WebSocket endpoint to connect to'
|
|
105
|
+
)
|
|
106
|
+
.option(
|
|
107
|
+
'--pause-on-error',
|
|
108
|
+
'pause on error until a keypress is made in the console. Useful during development'
|
|
109
|
+
)
|
|
110
|
+
.option(
|
|
111
|
+
'--ignore-https-errors',
|
|
112
|
+
'ignores any HTTPS errors in sites being tested, including ones related to unrecognized certs or signatures. This can be insecure!'
|
|
113
|
+
)
|
|
114
|
+
.option(
|
|
115
|
+
'--quiet-exit-code',
|
|
116
|
+
'always return 0 as an exit code status, regardless of test pass / fail. Only return > 0 exit codes on internal errors where the suite could not be run'
|
|
117
|
+
)
|
|
118
|
+
.option(
|
|
119
|
+
'--throttling <config>',
|
|
120
|
+
'JSON object to throttle network conditions for download and upload throughput in megabits/second and latency in milliseconds. Ex: { "download": 10, "upload": 5, "latency": 200 }.',
|
|
121
|
+
parseThrottling,
|
|
122
|
+
{}
|
|
123
|
+
)
|
|
124
|
+
.option('--no-throttling', 'Turns off default network throttling.')
|
|
125
|
+
.addOption(playwrightOpts)
|
|
126
|
+
.version(version)
|
|
127
|
+
.description('Run synthetic tests')
|
|
128
|
+
.action(async (cliArgs: CliArgs) => {
|
|
129
|
+
try {
|
|
130
|
+
await loadTestFiles(cliArgs, program.args);
|
|
131
|
+
const options = normalizeOptions(cliArgs);
|
|
132
|
+
const results = await run(options);
|
|
133
|
+
/**
|
|
134
|
+
* Exit with error status if any journey fails
|
|
135
|
+
*/
|
|
136
|
+
if (!options.quietExitCode) {
|
|
137
|
+
for (const result of Object.values(results)) {
|
|
138
|
+
if (result.status === 'failed') {
|
|
139
|
+
process.exit(1);
|
|
140
|
+
}
|
|
109
141
|
}
|
|
110
|
-
});
|
|
111
|
-
} else {
|
|
112
|
-
addSuite(absPath);
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
return suites.values();
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
(async () => {
|
|
119
|
-
if (options.inline) {
|
|
120
|
-
const source = await readStdin();
|
|
121
|
-
loadInlineScript(source);
|
|
122
|
-
} else {
|
|
123
|
-
/**
|
|
124
|
-
* Preload modules before running the suites
|
|
125
|
-
*/
|
|
126
|
-
const modules = [].concat(options.require || []).filter(Boolean);
|
|
127
|
-
for (const name of modules) {
|
|
128
|
-
if (isDepInstalled(name)) {
|
|
129
|
-
require(name);
|
|
130
|
-
} else {
|
|
131
|
-
throw new Error(`cannot find module '${name}'`);
|
|
132
142
|
}
|
|
143
|
+
} catch (e) {
|
|
144
|
+
console.error(e);
|
|
145
|
+
process.exit(1);
|
|
133
146
|
}
|
|
134
|
-
|
|
135
|
-
* Transform `.ts` files out of the box by invoking
|
|
136
|
-
* the `ts-node` via `transpile-only` mode that compiles
|
|
137
|
-
* TS files without doing any extensive type checks
|
|
138
|
-
*/
|
|
139
|
-
/* eslint-disable-next-line @typescript-eslint/no-var-requires */
|
|
140
|
-
require('ts-node').register({
|
|
141
|
-
transpileOnly: true,
|
|
142
|
-
compilerOptions: {
|
|
143
|
-
esModuleInterop: true,
|
|
144
|
-
allowJs: true,
|
|
145
|
-
target: 'es2018',
|
|
146
|
-
},
|
|
147
|
-
});
|
|
148
|
-
/**
|
|
149
|
-
* Handle piped files by reading the STDIN
|
|
150
|
-
* ex: ls example/suites/*.js | npx @elastic/synthetics
|
|
151
|
-
*/
|
|
152
|
-
const files =
|
|
153
|
-
program.args.length > 0
|
|
154
|
-
? program.args
|
|
155
|
-
: (await readStdin()).split('\n').filter(Boolean);
|
|
156
|
-
const suites = await prepareSuites(files);
|
|
157
|
-
requireSuites(suites);
|
|
158
|
-
}
|
|
147
|
+
});
|
|
159
148
|
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
149
|
+
// Push command
|
|
150
|
+
program
|
|
151
|
+
.command('push')
|
|
152
|
+
.description(
|
|
153
|
+
'Push all journeys in the current directory to create monitors within the Kibana monitor management UI'
|
|
154
|
+
)
|
|
155
|
+
.requiredOption(
|
|
156
|
+
'--auth <auth>',
|
|
157
|
+
'API key used for Kibana authentication(https://www.elastic.co/guide/en/kibana/master/api-keys.html).'
|
|
158
|
+
)
|
|
159
|
+
.option(
|
|
160
|
+
'--schedule <time-in-minutes>',
|
|
161
|
+
"schedule in minutes for the pushed monitors. Setting `10`, for example, configures monitors which don't have an interval defined to run every 10 minutes.",
|
|
162
|
+
parseInt
|
|
163
|
+
)
|
|
164
|
+
.addOption(
|
|
165
|
+
new Option(
|
|
166
|
+
'--locations <locations...>',
|
|
167
|
+
'default list of locations from which your monitors will run.'
|
|
168
|
+
).choices(SyntheticsLocations)
|
|
169
|
+
)
|
|
170
|
+
.option(
|
|
171
|
+
'--private-locations <locations...>',
|
|
172
|
+
'default list of private locations from which your monitors will run.'
|
|
173
|
+
)
|
|
174
|
+
.option('--url <url>', 'Kibana URL to upload the monitors')
|
|
175
|
+
.option(
|
|
176
|
+
'--project <id>',
|
|
177
|
+
'id that will be used for logically grouping monitors'
|
|
178
|
+
)
|
|
179
|
+
.option(
|
|
180
|
+
'--space <space>',
|
|
181
|
+
'the target Kibana spaces for the pushed monitors — spaces help you organise pushed monitors.'
|
|
182
|
+
)
|
|
183
|
+
.addOption(pattern)
|
|
184
|
+
.addOption(tags)
|
|
185
|
+
.addOption(match)
|
|
186
|
+
.addOption(params)
|
|
187
|
+
.addOption(playwrightOpts)
|
|
188
|
+
.action(async (cmdOpts: PushOptions) => {
|
|
189
|
+
try {
|
|
190
|
+
const settings = await loadSettings();
|
|
191
|
+
await loadTestFiles({ inline: false }, [cwd()]);
|
|
192
|
+
const options = normalizeOptions({
|
|
193
|
+
...program.opts(),
|
|
194
|
+
...settings,
|
|
195
|
+
...cmdOpts,
|
|
196
|
+
}) as PushOptions;
|
|
197
|
+
validateSettings(options);
|
|
198
|
+
await catchIncorrectSettings(settings, options);
|
|
199
|
+
const monitors = runner.buildMonitors(options);
|
|
200
|
+
await push(monitors, options);
|
|
201
|
+
} catch (e) {
|
|
202
|
+
e && console.error(e);
|
|
203
|
+
process.exit(1);
|
|
204
|
+
}
|
|
205
|
+
});
|
|
174
206
|
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
207
|
+
// Init command
|
|
208
|
+
program
|
|
209
|
+
.command('init [dir]')
|
|
210
|
+
.description('Initialize Elastic synthetics project')
|
|
211
|
+
.action(async (dir = '') => {
|
|
212
|
+
try {
|
|
213
|
+
const generator = await new Generator(resolve(process.cwd(), dir));
|
|
214
|
+
await generator.setup();
|
|
215
|
+
} catch (e) {
|
|
216
|
+
e && error(e);
|
|
217
|
+
process.exit(1);
|
|
218
|
+
}
|
|
180
219
|
});
|
|
181
220
|
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
221
|
+
// Locations command
|
|
222
|
+
program
|
|
223
|
+
.command('locations')
|
|
224
|
+
.description(
|
|
225
|
+
`List all locations to run the synthetics monitors. Pass optional '--url' and '--auth' to list private locations.`
|
|
226
|
+
)
|
|
227
|
+
.option('--url <url>', 'Kibana URL to fetch all public and private locations')
|
|
228
|
+
.option(
|
|
229
|
+
'--auth <auth>',
|
|
230
|
+
'API key used for Kibana authentication(https://www.elastic.co/guide/en/kibana/master/api-keys.html).'
|
|
231
|
+
)
|
|
232
|
+
.action(async (cmdOpts: LocationCmdOptions) => {
|
|
233
|
+
try {
|
|
234
|
+
let locations = Object.keys(LocationsMap);
|
|
235
|
+
if (cmdOpts.auth && cmdOpts.url) {
|
|
236
|
+
const allLocations = await getLocations(cmdOpts);
|
|
237
|
+
locations = formatLocations(allLocations);
|
|
238
|
+
}
|
|
239
|
+
renderLocations(locations);
|
|
240
|
+
} catch (e) {
|
|
241
|
+
e && error(e);
|
|
187
242
|
process.exit(1);
|
|
188
243
|
}
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
process.exit(1);
|
|
193
|
-
});
|
|
244
|
+
});
|
|
245
|
+
|
|
246
|
+
program.parse(process.argv);
|