@gatling.io/cli 3.11.7 → 3.13.1
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/package.json +8 -6
- package/polyfills/crypto.js +87 -0
- package/polyfills/global.js +13 -0
- package/src/bundle/index.ts +43 -0
- package/src/bundle/polyfill.ts +91 -0
- package/src/commands/build.ts +34 -0
- package/src/commands/enterpriseDeploy.ts +97 -0
- package/src/commands/enterprisePackage.ts +45 -0
- package/src/commands/enterpriseStart.ts +122 -0
- package/src/commands/index.ts +25 -0
- package/src/commands/install.ts +19 -0
- package/src/commands/options.ts +308 -0
- package/src/commands/recorder.ts +41 -0
- package/src/commands/run.ts +82 -0
- package/src/commands/runOnly.ts +56 -0
- package/src/dependencies/coursier.ts +84 -0
- package/src/dependencies/download.ts +11 -0
- package/src/dependencies/graalVm.ts +74 -0
- package/src/dependencies/index.ts +45 -0
- package/src/dependencies/os.ts +24 -0
- package/src/dependencies/versions.ts +15 -0
- package/src/enterprise.ts +227 -0
- package/src/index.ts +5 -0
- package/src/java.ts +48 -0
- package/src/log.ts +19 -0
- package/src/readline.ts +39 -0
- package/src/run.ts +67 -0
- package/src/simulations.ts +29 -0
- package/target/{bundle.d.ts → bundle/index.d.ts} +2 -1
- package/target/{bundle.js → bundle/index.js} +7 -1
- package/target/bundle/polyfill.d.ts +2 -0
- package/target/bundle/polyfill.js +83 -0
- package/target/commands/build.d.ts +3 -0
- package/target/commands/build.js +22 -0
- package/target/commands/enterpriseDeploy.d.ts +3 -0
- package/target/commands/enterpriseDeploy.js +64 -0
- package/target/commands/enterprisePackage.d.ts +3 -0
- package/target/commands/enterprisePackage.js +28 -0
- package/target/commands/enterpriseStart.d.ts +3 -0
- package/target/commands/enterpriseStart.js +80 -0
- package/target/commands/index.d.ts +2 -0
- package/target/commands/index.js +28 -0
- package/target/commands/install.d.ts +3 -0
- package/target/commands/install.js +18 -0
- package/target/commands/options.d.ts +50 -0
- package/target/commands/options.js +214 -0
- package/target/commands/recorder.d.ts +3 -0
- package/target/commands/recorder.js +28 -0
- package/target/commands/run.d.ts +3 -0
- package/target/commands/run.js +53 -0
- package/target/commands/runOnly.d.ts +3 -0
- package/target/commands/runOnly.js +37 -0
- package/target/dependencies/coursier.d.ts +1 -1
- package/target/dependencies/coursier.js +11 -6
- package/target/dependencies/index.d.ts +2 -0
- package/target/dependencies/index.js +4 -2
- package/target/dependencies/versions.d.ts +3 -0
- package/target/dependencies/versions.js +9 -6
- package/target/enterprise.d.ts +2 -1
- package/target/enterprise.js +7 -6
- package/target/index.js +2 -337
- package/target/run.js +4 -2
- package/tsconfig.json +18 -0
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const options_1 = require("./options");
|
|
4
|
+
const simulations_1 = require("../simulations");
|
|
5
|
+
const dependencies_1 = require("../dependencies");
|
|
6
|
+
const bundle_1 = require("../bundle");
|
|
7
|
+
const enterprise_1 = require("../enterprise");
|
|
8
|
+
exports.default = (program) => {
|
|
9
|
+
program
|
|
10
|
+
.command("enterprise-deploy")
|
|
11
|
+
.description("Deploy a package and configured simulations")
|
|
12
|
+
.addOption(options_1.sourcesFolderOption)
|
|
13
|
+
.addOption(options_1.resourcesFolderOption)
|
|
14
|
+
.addOption(options_1.bundleFileOption)
|
|
15
|
+
.addOption(options_1.resultsFolderOption)
|
|
16
|
+
.addOption(options_1.postmanOption)
|
|
17
|
+
.addOption(options_1.typescriptOption)
|
|
18
|
+
.addOption(options_1.gatlingHomeOption)
|
|
19
|
+
// Base
|
|
20
|
+
.addOption(options_1.apiUrlOption)
|
|
21
|
+
.addOption(options_1.webAppUrlOption)
|
|
22
|
+
.addOption(options_1.apiTokenOption)
|
|
23
|
+
// Plugin configuration
|
|
24
|
+
.addOption(options_1.controlPlaneUrlOption)
|
|
25
|
+
.addOption(options_1.nonInteractiveOption)
|
|
26
|
+
// Descriptor file
|
|
27
|
+
.addOption(options_1.packageDescriptorFilenameOption)
|
|
28
|
+
// Deployment info
|
|
29
|
+
.addOption(options_1.packageFileOption)
|
|
30
|
+
.action(async (options) => {
|
|
31
|
+
const sourcesFolder = (0, options_1.sourcesFolderOptionValue)(options);
|
|
32
|
+
const simulations = await (0, simulations_1.findSimulations)(sourcesFolder);
|
|
33
|
+
const postman = (0, options_1.postmanOptionValueWithDefaults)(options);
|
|
34
|
+
const typescript = (0, options_1.typescriptOptionValueWithDefaults)(options, simulations);
|
|
35
|
+
const resourcesFolder = (0, options_1.resourcesFolderOptionValue)(options);
|
|
36
|
+
const bundleFile = (0, options_1.bundleFileOptionValue)(options);
|
|
37
|
+
const resultsFolder = (0, options_1.resultsFolderOptionValue)(options);
|
|
38
|
+
const gatlingHome = (0, options_1.gatlingHomeOptionValueWithDefaults)(options);
|
|
39
|
+
const apiUrl = (0, options_1.apiUrlOptionValue)(options);
|
|
40
|
+
const webAppUrl = (0, options_1.webAppUrlOptionValue)(options);
|
|
41
|
+
const apiToken = (0, options_1.apiTokenOptionValue)(options);
|
|
42
|
+
const controlPlaneUrl = (0, options_1.controlPlaneUrlOptionValue)(options);
|
|
43
|
+
const nonInteractive = (0, options_1.nonInteractiveOptionValue)(options);
|
|
44
|
+
const packageDescriptorFilename = (0, options_1.packageDescriptorFilenameOptionValue)(options);
|
|
45
|
+
const packageFile = (0, options_1.packageFileOptionValue)(options);
|
|
46
|
+
const { graalvmHome, jvmClasspath } = await (0, dependencies_1.installGatlingJs)({ gatlingHome });
|
|
47
|
+
await (0, bundle_1.bundle)({ sourcesFolder, bundleFile, postman, typescript, simulations });
|
|
48
|
+
await (0, enterprise_1.enterprisePackage)({ bundleFile, resourcesFolder, packageFile, simulations });
|
|
49
|
+
await (0, enterprise_1.enterpriseDeploy)({
|
|
50
|
+
graalvmHome,
|
|
51
|
+
jvmClasspath,
|
|
52
|
+
bundleFile,
|
|
53
|
+
resourcesFolder,
|
|
54
|
+
resultsFolder,
|
|
55
|
+
apiUrl,
|
|
56
|
+
webAppUrl,
|
|
57
|
+
apiToken,
|
|
58
|
+
controlPlaneUrl,
|
|
59
|
+
nonInteractive,
|
|
60
|
+
packageDescriptorFilename,
|
|
61
|
+
packageFile
|
|
62
|
+
});
|
|
63
|
+
});
|
|
64
|
+
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const options_1 = require("./options");
|
|
4
|
+
const simulations_1 = require("../simulations");
|
|
5
|
+
const bundle_1 = require("../bundle");
|
|
6
|
+
const enterprise_1 = require("../enterprise");
|
|
7
|
+
exports.default = (program) => {
|
|
8
|
+
program
|
|
9
|
+
.command("enterprise-package")
|
|
10
|
+
.description("Build Gatling simulations and package them for Gatling Enterprise")
|
|
11
|
+
.addOption(options_1.sourcesFolderOption)
|
|
12
|
+
.addOption(options_1.resourcesFolderOption)
|
|
13
|
+
.addOption(options_1.bundleFileOption)
|
|
14
|
+
.addOption(options_1.packageFileOption)
|
|
15
|
+
.addOption(options_1.postmanOption)
|
|
16
|
+
.addOption(options_1.typescriptOption)
|
|
17
|
+
.action(async (options) => {
|
|
18
|
+
const sourcesFolder = (0, options_1.sourcesFolderOptionValue)(options);
|
|
19
|
+
const resourcesFolder = (0, options_1.resourcesFolderOptionValue)(options);
|
|
20
|
+
const bundleFile = (0, options_1.bundleFileOptionValue)(options);
|
|
21
|
+
const packageFile = (0, options_1.packageFileOptionValue)(options);
|
|
22
|
+
const simulations = await (0, simulations_1.findSimulations)(sourcesFolder);
|
|
23
|
+
const postman = (0, options_1.postmanOptionValueWithDefaults)(options);
|
|
24
|
+
const typescript = (0, options_1.typescriptOptionValueWithDefaults)(options, simulations);
|
|
25
|
+
await (0, bundle_1.bundle)({ sourcesFolder, bundleFile, postman, typescript, simulations });
|
|
26
|
+
await (0, enterprise_1.enterprisePackage)({ bundleFile, resourcesFolder, packageFile, simulations });
|
|
27
|
+
});
|
|
28
|
+
};
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const options_1 = require("./options");
|
|
4
|
+
const simulations_1 = require("../simulations");
|
|
5
|
+
const dependencies_1 = require("../dependencies");
|
|
6
|
+
const bundle_1 = require("../bundle");
|
|
7
|
+
const enterprise_1 = require("../enterprise");
|
|
8
|
+
exports.default = (program) => {
|
|
9
|
+
program
|
|
10
|
+
.command("enterprise-start")
|
|
11
|
+
.description("Start a simulation deployed with `enterprise-deploy`")
|
|
12
|
+
.addOption(options_1.sourcesFolderOption)
|
|
13
|
+
.addOption(options_1.resourcesFolderOption)
|
|
14
|
+
.addOption(options_1.bundleFileOption)
|
|
15
|
+
.addOption(options_1.resultsFolderOption)
|
|
16
|
+
.addOption(options_1.postmanOption)
|
|
17
|
+
.addOption(options_1.typescriptOption)
|
|
18
|
+
.addOption(options_1.gatlingHomeOption)
|
|
19
|
+
// Base
|
|
20
|
+
.addOption(options_1.apiUrlOption)
|
|
21
|
+
.addOption(options_1.webAppUrlOption)
|
|
22
|
+
.addOption(options_1.apiTokenOption)
|
|
23
|
+
// Plugin configuration
|
|
24
|
+
.addOption(options_1.controlPlaneUrlOption)
|
|
25
|
+
.addOption(options_1.nonInteractiveOption)
|
|
26
|
+
// Descriptor file
|
|
27
|
+
.addOption(options_1.packageDescriptorFilenameOption)
|
|
28
|
+
// Deployment info
|
|
29
|
+
.addOption(options_1.packageFileOption)
|
|
30
|
+
// Start
|
|
31
|
+
.addOption(options_1.enterpriseSimulationOption)
|
|
32
|
+
.addOption(options_1.runTitleOption)
|
|
33
|
+
.addOption(options_1.runDescriptionOption)
|
|
34
|
+
.addOption(options_1.waitForRunEndOption)
|
|
35
|
+
.action(async (options) => {
|
|
36
|
+
const sourcesFolder = (0, options_1.sourcesFolderOptionValue)(options);
|
|
37
|
+
const simulations = await (0, simulations_1.findSimulations)(sourcesFolder);
|
|
38
|
+
const postman = (0, options_1.postmanOptionValueWithDefaults)(options);
|
|
39
|
+
const typescript = (0, options_1.typescriptOptionValueWithDefaults)(options, simulations);
|
|
40
|
+
const resourcesFolder = (0, options_1.resourcesFolderOptionValue)(options);
|
|
41
|
+
const bundleFile = (0, options_1.bundleFileOptionValue)(options);
|
|
42
|
+
const resultsFolder = (0, options_1.resultsFolderOptionValue)(options);
|
|
43
|
+
const gatlingHome = (0, options_1.gatlingHomeOptionValueWithDefaults)(options);
|
|
44
|
+
const apiUrl = (0, options_1.apiUrlOptionValue)(options);
|
|
45
|
+
const webAppUrl = (0, options_1.webAppUrlOptionValue)(options);
|
|
46
|
+
const apiToken = (0, options_1.apiTokenOptionValue)(options);
|
|
47
|
+
const controlPlaneUrl = (0, options_1.controlPlaneUrlOptionValue)(options);
|
|
48
|
+
const nonInteractive = (0, options_1.nonInteractiveOptionValue)(options);
|
|
49
|
+
const packageDescriptorFilename = (0, options_1.packageDescriptorFilenameOptionValue)(options);
|
|
50
|
+
const packageFile = (0, options_1.packageFileOptionValue)(options);
|
|
51
|
+
const enterpriseSimulation = (0, options_1.enterpriseSimulationOptionValue)(options);
|
|
52
|
+
const runTitle = (0, options_1.runTitleOptionValue)(options);
|
|
53
|
+
const runDescription = (0, options_1.runDescriptionOptionValue)(options);
|
|
54
|
+
const waitForRunEnd = (0, options_1.waitForRunEndOptionValue)(options);
|
|
55
|
+
if ((0, options_1.nonInteractiveOptionValue)(options) && enterpriseSimulation === undefined) {
|
|
56
|
+
throw new Error(`No simulation specified when using non-interactive mode`);
|
|
57
|
+
}
|
|
58
|
+
const { graalvmHome, jvmClasspath } = await (0, dependencies_1.installGatlingJs)({ gatlingHome });
|
|
59
|
+
await (0, bundle_1.bundle)({ sourcesFolder, bundleFile, postman, typescript, simulations });
|
|
60
|
+
await (0, enterprise_1.enterprisePackage)({ bundleFile, resourcesFolder, packageFile, simulations });
|
|
61
|
+
await (0, enterprise_1.enterpriseStart)({
|
|
62
|
+
graalvmHome,
|
|
63
|
+
jvmClasspath,
|
|
64
|
+
bundleFile,
|
|
65
|
+
resourcesFolder,
|
|
66
|
+
resultsFolder,
|
|
67
|
+
apiUrl,
|
|
68
|
+
webAppUrl,
|
|
69
|
+
apiToken,
|
|
70
|
+
controlPlaneUrl,
|
|
71
|
+
nonInteractive,
|
|
72
|
+
packageDescriptorFilename,
|
|
73
|
+
packageFile,
|
|
74
|
+
enterpriseSimulation,
|
|
75
|
+
runTitle,
|
|
76
|
+
runDescription,
|
|
77
|
+
waitForRunEnd
|
|
78
|
+
});
|
|
79
|
+
});
|
|
80
|
+
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.program = void 0;
|
|
7
|
+
const commander_1 = require("commander");
|
|
8
|
+
const install_1 = __importDefault(require("./install"));
|
|
9
|
+
const build_1 = __importDefault(require("./build"));
|
|
10
|
+
const runOnly_1 = __importDefault(require("./runOnly"));
|
|
11
|
+
const run_1 = __importDefault(require("./run"));
|
|
12
|
+
const recorder_1 = __importDefault(require("./recorder"));
|
|
13
|
+
const enterprisePackage_1 = __importDefault(require("./enterprisePackage"));
|
|
14
|
+
const enterpriseDeploy_1 = __importDefault(require("./enterpriseDeploy"));
|
|
15
|
+
const enterpriseStart_1 = __importDefault(require("./enterpriseStart"));
|
|
16
|
+
const dependencies_1 = require("../dependencies");
|
|
17
|
+
exports.program = new commander_1.Command()
|
|
18
|
+
.name("gatling-js-cli")
|
|
19
|
+
.version(dependencies_1.versions.gatling.jsAdapter)
|
|
20
|
+
.description("The Gatling Javascript run & packaging tool");
|
|
21
|
+
(0, install_1.default)(exports.program);
|
|
22
|
+
(0, build_1.default)(exports.program);
|
|
23
|
+
(0, runOnly_1.default)(exports.program);
|
|
24
|
+
(0, run_1.default)(exports.program);
|
|
25
|
+
(0, recorder_1.default)(exports.program);
|
|
26
|
+
(0, enterprisePackage_1.default)(exports.program);
|
|
27
|
+
(0, enterpriseDeploy_1.default)(exports.program);
|
|
28
|
+
(0, enterpriseStart_1.default)(exports.program);
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const options_1 = require("./options");
|
|
4
|
+
const dependencies_1 = require("../dependencies");
|
|
5
|
+
const log_1 = require("../log");
|
|
6
|
+
exports.default = (program) => {
|
|
7
|
+
program
|
|
8
|
+
.command("install")
|
|
9
|
+
.description("Install all required components and dependencies for Gatling")
|
|
10
|
+
.addOption(options_1.gatlingHomeOption)
|
|
11
|
+
.action(async (options) => {
|
|
12
|
+
const gatlingHome = (0, options_1.gatlingHomeOptionValueWithDefaults)(options);
|
|
13
|
+
const { graalvmHome, coursierBinary, jvmClasspath } = await (0, dependencies_1.installGatlingJs)({ gatlingHome });
|
|
14
|
+
log_1.logger.info(`graalvmHome=${graalvmHome}`);
|
|
15
|
+
log_1.logger.info(`coursierBinary=${coursierBinary}`);
|
|
16
|
+
log_1.logger.info(`jvmClasspath=${jvmClasspath}`);
|
|
17
|
+
});
|
|
18
|
+
};
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { Option, Argument } from "commander";
|
|
2
|
+
import { SimulationFile } from "../simulations";
|
|
3
|
+
export declare const gatlingHomeOption: Option;
|
|
4
|
+
export declare const gatlingHomeOptionValueWithDefaults: (options: any) => string;
|
|
5
|
+
export declare const sourcesFolderOption: Option;
|
|
6
|
+
export declare const sourcesFolderOptionValue: (options: any) => string;
|
|
7
|
+
export declare const simulationOption: Option;
|
|
8
|
+
export declare const simulationOptionValueWithDefaults: (options: any, simulationsFound: SimulationFile[], interactive: boolean) => string;
|
|
9
|
+
export declare const simulationMandatoryOption: Option;
|
|
10
|
+
export declare const simulationMandatoryOptionValue: (options: any) => string;
|
|
11
|
+
export declare const bundleFileOption: Option;
|
|
12
|
+
export declare const bundleFileOptionValue: (options: any) => string;
|
|
13
|
+
export declare const packageFileOption: Option;
|
|
14
|
+
export declare const packageFileOptionValue: (options: any) => string;
|
|
15
|
+
export declare const resourcesFolderOption: Option;
|
|
16
|
+
export declare const resourcesFolderOptionValue: (options: any) => string;
|
|
17
|
+
export declare const resultsFolderOption: Option;
|
|
18
|
+
export declare const resultsFolderOptionValue: (options: any) => string;
|
|
19
|
+
export declare const typescriptOption: Option;
|
|
20
|
+
export declare const typescriptOptionValueWithDefaults: (options: any, simulationsFound: SimulationFile[]) => boolean;
|
|
21
|
+
export declare const graalvmHomeMandatoryOption: Option;
|
|
22
|
+
export declare const graalvmHomeMandatoryOptionValue: (options: any) => string;
|
|
23
|
+
export declare const jvmClasspathMandatoryOption: Option;
|
|
24
|
+
export declare const jvmClasspathMandatoryOptionValue: (options: any) => string;
|
|
25
|
+
export declare const memoryOption: Option;
|
|
26
|
+
export declare const memoryOptionValue: (options: any) => number | undefined;
|
|
27
|
+
export declare const nonInteractiveOption: Option;
|
|
28
|
+
export declare const nonInteractiveOptionValue: (options: any) => boolean;
|
|
29
|
+
export declare const postmanOption: Option;
|
|
30
|
+
export declare const postmanOptionValueWithDefaults: (options: any) => string | undefined;
|
|
31
|
+
export declare const runParametersArgument: Argument;
|
|
32
|
+
export declare const parseRunParametersArgument: (args: string[]) => Record<string, string>;
|
|
33
|
+
export declare const apiUrlOption: Option;
|
|
34
|
+
export declare const apiUrlOptionValue: (options: any) => string;
|
|
35
|
+
export declare const webAppUrlOption: Option;
|
|
36
|
+
export declare const webAppUrlOptionValue: (options: any) => string;
|
|
37
|
+
export declare const apiTokenOption: Option;
|
|
38
|
+
export declare const apiTokenOptionValue: (options: any) => string | undefined;
|
|
39
|
+
export declare const controlPlaneUrlOption: Option;
|
|
40
|
+
export declare const controlPlaneUrlOptionValue: (options: any) => string | undefined;
|
|
41
|
+
export declare const packageDescriptorFilenameOption: Option;
|
|
42
|
+
export declare const packageDescriptorFilenameOptionValue: (options: any) => string;
|
|
43
|
+
export declare const enterpriseSimulationOption: Option;
|
|
44
|
+
export declare const enterpriseSimulationOptionValue: (options: any) => string | undefined;
|
|
45
|
+
export declare const runTitleOption: Option;
|
|
46
|
+
export declare const runTitleOptionValue: (options: any) => string | undefined;
|
|
47
|
+
export declare const runDescriptionOption: Option;
|
|
48
|
+
export declare const runDescriptionOptionValue: (options: any) => string | undefined;
|
|
49
|
+
export declare const waitForRunEndOption: Option;
|
|
50
|
+
export declare const waitForRunEndOptionValue: (options: any) => boolean;
|
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.waitForRunEndOptionValue = exports.waitForRunEndOption = exports.runDescriptionOptionValue = exports.runDescriptionOption = exports.runTitleOptionValue = exports.runTitleOption = exports.enterpriseSimulationOptionValue = exports.enterpriseSimulationOption = exports.packageDescriptorFilenameOptionValue = exports.packageDescriptorFilenameOption = exports.controlPlaneUrlOptionValue = exports.controlPlaneUrlOption = exports.apiTokenOptionValue = exports.apiTokenOption = exports.webAppUrlOptionValue = exports.webAppUrlOption = exports.apiUrlOptionValue = exports.apiUrlOption = exports.parseRunParametersArgument = exports.runParametersArgument = exports.postmanOptionValueWithDefaults = exports.postmanOption = exports.nonInteractiveOptionValue = exports.nonInteractiveOption = exports.memoryOptionValue = exports.memoryOption = exports.jvmClasspathMandatoryOptionValue = exports.jvmClasspathMandatoryOption = exports.graalvmHomeMandatoryOptionValue = exports.graalvmHomeMandatoryOption = exports.typescriptOptionValueWithDefaults = exports.typescriptOption = exports.resultsFolderOptionValue = exports.resultsFolderOption = exports.resourcesFolderOptionValue = exports.resourcesFolderOption = exports.packageFileOptionValue = exports.packageFileOption = exports.bundleFileOptionValue = exports.bundleFileOption = exports.simulationMandatoryOptionValue = exports.simulationMandatoryOption = exports.simulationOptionValueWithDefaults = exports.simulationOption = exports.sourcesFolderOptionValue = exports.sourcesFolderOption = exports.gatlingHomeOptionValueWithDefaults = exports.gatlingHomeOption = void 0;
|
|
7
|
+
const commander_1 = require("commander");
|
|
8
|
+
const fs_1 = __importDefault(require("fs"));
|
|
9
|
+
const os_1 = __importDefault(require("os"));
|
|
10
|
+
const path_1 = __importDefault(require("path"));
|
|
11
|
+
const readline_1 = require("../readline");
|
|
12
|
+
const log_1 = require("../log");
|
|
13
|
+
const getStringValueOptional = (option) => (options) => {
|
|
14
|
+
const value = options[option.attributeName()];
|
|
15
|
+
if (typeof value === "string" || typeof value === "undefined") {
|
|
16
|
+
return value;
|
|
17
|
+
}
|
|
18
|
+
else {
|
|
19
|
+
throw Error(`Expected type string|undefined for attribute ${option.attributeName()}, got ${typeof value} - please report this as a bug.`);
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
const getStringValueMandatory = (option) => (options) => {
|
|
23
|
+
const value = options[option.attributeName()];
|
|
24
|
+
if (typeof value === "string") {
|
|
25
|
+
return value;
|
|
26
|
+
}
|
|
27
|
+
else {
|
|
28
|
+
throw Error(`Expected type string for attribute ${option.attributeName()}, got ${typeof value} - please report this as a bug.`);
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
const getBooleanValueOptional = (option) => (options) => {
|
|
32
|
+
const value = options[option.attributeName()];
|
|
33
|
+
if (typeof value === "boolean" || typeof value === "undefined") {
|
|
34
|
+
return value;
|
|
35
|
+
}
|
|
36
|
+
else {
|
|
37
|
+
throw Error(`Expected type boolean|undefined for attribute ${option.attributeName()}, got ${typeof value} - please report this as a bug.`);
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
const getBooleanValueMandatory = (option) => (options) => {
|
|
41
|
+
const value = options[option.attributeName()];
|
|
42
|
+
if (typeof value === "boolean") {
|
|
43
|
+
return value;
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
throw Error(`Expected type boolean for attribute ${option.attributeName()}, got ${typeof value} - please report this as a bug.`);
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
const getNumberValueOptional = (option) => (options) => {
|
|
50
|
+
const value = options[option.attributeName()];
|
|
51
|
+
if (typeof value === "number" || typeof value === "undefined") {
|
|
52
|
+
return value;
|
|
53
|
+
}
|
|
54
|
+
else {
|
|
55
|
+
throw Error(`Expected type number|undefined for attribute ${option.attributeName()}, got ${typeof value} - please report this as a bug.`);
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
exports.gatlingHomeOption = new commander_1.Option("--gatling-home <value>", 'The folder used to download and install Gatling components (default: "~/.gatling")');
|
|
59
|
+
const gatlingHomeOptionValueWithDefaults = (options) => getStringValueOptional(exports.gatlingHomeOption)(options) || `${os_1.default.homedir()}/.gatling`;
|
|
60
|
+
exports.gatlingHomeOptionValueWithDefaults = gatlingHomeOptionValueWithDefaults;
|
|
61
|
+
exports.sourcesFolderOption = new commander_1.Option("--sources-folder <value>", "The sources folder path").default("src");
|
|
62
|
+
exports.sourcesFolderOptionValue = getStringValueMandatory(exports.sourcesFolderOption);
|
|
63
|
+
exports.simulationOption = new commander_1.Option("--simulation <value>", "The simulation entry point function name (default: if only one *.gatling.js or *.gatling.ts file is found, will execute that simulation)");
|
|
64
|
+
const simulationOptionValueWithDefaults = (options, simulationsFound, interactive) => {
|
|
65
|
+
const declaredSimulation = getStringValueOptional(exports.simulationOption)(options);
|
|
66
|
+
if (declaredSimulation !== undefined) {
|
|
67
|
+
return declaredSimulation;
|
|
68
|
+
}
|
|
69
|
+
else if (simulationsFound.length === 1) {
|
|
70
|
+
return simulationsFound[0].name;
|
|
71
|
+
}
|
|
72
|
+
else if (simulationsFound.length === 0) {
|
|
73
|
+
throw new Error("No simulation found, simulations must be defined in a <simulation name>.gatling.js or <simulation name>.gatling.ts file)");
|
|
74
|
+
}
|
|
75
|
+
else if (interactive) {
|
|
76
|
+
const sortedSimulations = simulationsFound.sort((a, b) => a.name.localeCompare(b.name));
|
|
77
|
+
const idx = (0, readline_1.keyInSelectPaginated)(sortedSimulations.map((s) => s.name), "Choose a simulation to run");
|
|
78
|
+
if (idx >= 0) {
|
|
79
|
+
const simulation = sortedSimulations[idx].name;
|
|
80
|
+
log_1.logger.info(`Simulation '${simulation}' was chosen.`);
|
|
81
|
+
return simulation;
|
|
82
|
+
}
|
|
83
|
+
else {
|
|
84
|
+
throw new Error("Simulation choice was cancelled.");
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
else {
|
|
88
|
+
throw new Error(`Several simulations found, specify one using the --simulation option (available simulations: ${simulationsFound.map((s) => s.name)})`);
|
|
89
|
+
}
|
|
90
|
+
};
|
|
91
|
+
exports.simulationOptionValueWithDefaults = simulationOptionValueWithDefaults;
|
|
92
|
+
exports.simulationMandatoryOption = new commander_1.Option("--simulation <value>", "The simulation entry point function name").makeOptionMandatory(true);
|
|
93
|
+
exports.simulationMandatoryOptionValue = getStringValueMandatory(exports.simulationMandatoryOption);
|
|
94
|
+
exports.bundleFileOption = new commander_1.Option("--bundle-file <value>", "The target bundle file path when building simulations (must have a .js extension)")
|
|
95
|
+
.default("target/bundle.js")
|
|
96
|
+
.argParser((value) => {
|
|
97
|
+
if (!value.endsWith(".js")) {
|
|
98
|
+
throw Error(`'${value}' is not a valid bundle file path: should have a .js extension`);
|
|
99
|
+
}
|
|
100
|
+
return value;
|
|
101
|
+
});
|
|
102
|
+
exports.bundleFileOptionValue = getStringValueMandatory(exports.bundleFileOption);
|
|
103
|
+
exports.packageFileOption = new commander_1.Option("--package-file <value>", "The target package file path when packaging simulations for Gatling Enterprise (must have a .zip extension)")
|
|
104
|
+
.default("target/package.zip")
|
|
105
|
+
.argParser((value) => {
|
|
106
|
+
if (!value.endsWith(".zip")) {
|
|
107
|
+
throw Error(`'${value}' is not a valid package file path: should have a .zip extension`);
|
|
108
|
+
}
|
|
109
|
+
return value;
|
|
110
|
+
});
|
|
111
|
+
exports.packageFileOptionValue = getStringValueMandatory(exports.packageFileOption);
|
|
112
|
+
exports.resourcesFolderOption = new commander_1.Option("--resources-folder <value>", "The resources folder path").default("resources");
|
|
113
|
+
exports.resourcesFolderOptionValue = getStringValueMandatory(exports.resourcesFolderOption);
|
|
114
|
+
exports.resultsFolderOption = new commander_1.Option("--results-folder <value>", "The results folder path").default("target/gatling");
|
|
115
|
+
exports.resultsFolderOptionValue = getStringValueMandatory(exports.resultsFolderOption);
|
|
116
|
+
exports.typescriptOption = new commander_1.Option("--typescript", "Use the typescript compiler to compile your code (default: true if the sourcesFolder contains any *.gatling.ts file, false otherwise)");
|
|
117
|
+
const typescriptOptionValueWithDefaults = (options, simulationsFound) => {
|
|
118
|
+
const value = getBooleanValueOptional(exports.typescriptOption)(options);
|
|
119
|
+
return value !== undefined ? value : simulationsFound.findIndex((s) => s.type === "typescript") >= 0;
|
|
120
|
+
};
|
|
121
|
+
exports.typescriptOptionValueWithDefaults = typescriptOptionValueWithDefaults;
|
|
122
|
+
exports.graalvmHomeMandatoryOption = new commander_1.Option("--graalvm-home <value>", "Path to the GraalVM home").makeOptionMandatory(true);
|
|
123
|
+
exports.graalvmHomeMandatoryOptionValue = getStringValueMandatory(exports.graalvmHomeMandatoryOption);
|
|
124
|
+
exports.jvmClasspathMandatoryOption = new commander_1.Option("--jvm-classpath <value>", "The classpath containing all Gatling JVM components").makeOptionMandatory(true);
|
|
125
|
+
exports.jvmClasspathMandatoryOptionValue = getStringValueMandatory(exports.jvmClasspathMandatoryOption);
|
|
126
|
+
exports.memoryOption = new commander_1.Option("--memory <value>", "Heap space memory size in MiB for Gatling. Half the total available memory is usually a good default, as the Gatling process will use more memory than just the heap space.").argParser((value) => {
|
|
127
|
+
const parsedValue = parseInt(value, 10);
|
|
128
|
+
if (isNaN(parsedValue)) {
|
|
129
|
+
throw new Error(`${value} is not a valid memory size, must be an integer number`);
|
|
130
|
+
}
|
|
131
|
+
return parsedValue;
|
|
132
|
+
});
|
|
133
|
+
exports.memoryOptionValue = getNumberValueOptional(exports.memoryOption);
|
|
134
|
+
exports.nonInteractiveOption = new commander_1.Option("--non-interactive", "Switch to non-interactive mode and fail if no simulation is explicitly specified").default(false);
|
|
135
|
+
exports.nonInteractiveOptionValue = getBooleanValueMandatory(exports.nonInteractiveOption);
|
|
136
|
+
exports.postmanOption = new commander_1.Option("--postman <version>", "Postman compatibility option: adds polyfills, etc.").hideHelp();
|
|
137
|
+
const postmanOptionValueWithDefaults = (options) => {
|
|
138
|
+
const postmanOptionValue = getStringValueOptional(exports.postmanOption)(options);
|
|
139
|
+
if (postmanOptionValue !== undefined) {
|
|
140
|
+
return postmanOptionValue;
|
|
141
|
+
}
|
|
142
|
+
else {
|
|
143
|
+
try {
|
|
144
|
+
const conf = JSON.parse(fs_1.default.readFileSync("package.json", { encoding: "utf-8", flag: "r" }));
|
|
145
|
+
const withPostman = conf.dependencies?.["@gatling.io/postman"] !== undefined ||
|
|
146
|
+
conf.devDependencies?.["@gatling.io/postman"] !== undefined;
|
|
147
|
+
if (withPostman) {
|
|
148
|
+
let directory = path_1.default.normalize(path_1.default.dirname("package.json"));
|
|
149
|
+
const root = path_1.default.parse(directory).root;
|
|
150
|
+
while (true) {
|
|
151
|
+
const file = path_1.default.join(directory, "node_modules", "@gatling.io", "postman", "package.json");
|
|
152
|
+
if (fs_1.default.existsSync(file)) {
|
|
153
|
+
const installedPackage = JSON.parse(fs_1.default.readFileSync(file, { encoding: "utf-8", flag: "r" }));
|
|
154
|
+
return installedPackage.version;
|
|
155
|
+
}
|
|
156
|
+
else if (directory === root) {
|
|
157
|
+
return undefined;
|
|
158
|
+
}
|
|
159
|
+
else {
|
|
160
|
+
directory = path_1.default.normalize(path_1.default.join(directory, ".."));
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
else {
|
|
165
|
+
return undefined;
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
catch {
|
|
169
|
+
return undefined;
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
};
|
|
173
|
+
exports.postmanOptionValueWithDefaults = postmanOptionValueWithDefaults;
|
|
174
|
+
exports.runParametersArgument = new commander_1.Argument("[optionKey=optionValue...]", "Specify one or more parameter which can be read in the simulation script with the getParameter() function; format must be key=value");
|
|
175
|
+
const parseRunParametersArgument = (args) => {
|
|
176
|
+
const parsedParameters = {};
|
|
177
|
+
for (const arg of args) {
|
|
178
|
+
const i = arg.indexOf("=");
|
|
179
|
+
if (i < 0) {
|
|
180
|
+
throw Error(`Parameter '${arg}' is not valid: format should be key=value`);
|
|
181
|
+
}
|
|
182
|
+
else {
|
|
183
|
+
const key = arg.slice(0, i).trim();
|
|
184
|
+
parsedParameters[key] = arg.slice(i + 1);
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
return parsedParameters;
|
|
188
|
+
};
|
|
189
|
+
exports.parseRunParametersArgument = parseRunParametersArgument;
|
|
190
|
+
exports.apiUrlOption = new commander_1.Option("--apiUrl <value>", "URL of the Gatling Enterprise API")
|
|
191
|
+
.default("https://api.gatling.io")
|
|
192
|
+
.hideHelp();
|
|
193
|
+
exports.apiUrlOptionValue = getStringValueMandatory(exports.apiUrlOption);
|
|
194
|
+
exports.webAppUrlOption = new commander_1.Option("--webAppUrl <value>", "URL of the Gatling Enterprise web app")
|
|
195
|
+
.default("https://cloud.gatling.io")
|
|
196
|
+
.hideHelp();
|
|
197
|
+
exports.webAppUrlOptionValue = getStringValueMandatory(exports.webAppUrlOption);
|
|
198
|
+
exports.apiTokenOption = new commander_1.Option("--api-token <value>", "API Token on Gatling Enterprise. Prefer configuration using `GATLING_ENTERPRISE_API_TOKEN` environment variable.");
|
|
199
|
+
exports.apiTokenOptionValue = getStringValueOptional(exports.apiTokenOption);
|
|
200
|
+
// Plugin configuration
|
|
201
|
+
exports.controlPlaneUrlOption = new commander_1.Option("--control-plane-url <value>", "URL of a control plane for Gatling Enterprise providing a private repository. If this parameter is provided, packages will be registered as private packages and uploaded through this private control plane.");
|
|
202
|
+
exports.controlPlaneUrlOptionValue = getStringValueOptional(exports.controlPlaneUrlOption);
|
|
203
|
+
// Descriptor file
|
|
204
|
+
exports.packageDescriptorFilenameOption = new commander_1.Option("--package-descriptor-filename <value>", "Path to a package descriptor inside the .gatling folder").default("package.conf");
|
|
205
|
+
exports.packageDescriptorFilenameOptionValue = getStringValueMandatory(exports.packageDescriptorFilenameOption);
|
|
206
|
+
// Deployment info
|
|
207
|
+
exports.enterpriseSimulationOption = new commander_1.Option("--enterprise-simulation <value>", "Specify the simulation name directly to bypass the prompt using the following command.");
|
|
208
|
+
exports.enterpriseSimulationOptionValue = getStringValueOptional(exports.enterpriseSimulationOption);
|
|
209
|
+
exports.runTitleOption = new commander_1.Option("--run-title <value>", "Allows setting a title for your run reports.");
|
|
210
|
+
exports.runTitleOptionValue = getStringValueOptional(exports.runTitleOption);
|
|
211
|
+
exports.runDescriptionOption = new commander_1.Option("--run-description <value>", "Allows setting a description for your run reports summary.");
|
|
212
|
+
exports.runDescriptionOptionValue = getStringValueOptional(exports.runDescriptionOption);
|
|
213
|
+
exports.waitForRunEndOption = new commander_1.Option("--wait-for-run-end", "Wait for the result after starting the simulation on Gatling Enterprise, and complete with an error if the simulation ends with any error status").default(false);
|
|
214
|
+
exports.waitForRunEndOptionValue = getBooleanValueMandatory(exports.waitForRunEndOption);
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const options_1 = require("./options");
|
|
4
|
+
const simulations_1 = require("../simulations");
|
|
5
|
+
const dependencies_1 = require("../dependencies");
|
|
6
|
+
const log_1 = require("../log");
|
|
7
|
+
const run_1 = require("../run");
|
|
8
|
+
exports.default = (program) => {
|
|
9
|
+
program
|
|
10
|
+
.command("recorder")
|
|
11
|
+
.description("Run the Gatling recorder")
|
|
12
|
+
.addOption(options_1.gatlingHomeOption)
|
|
13
|
+
.addOption(options_1.sourcesFolderOption)
|
|
14
|
+
.addOption(options_1.typescriptOption)
|
|
15
|
+
.addOption(options_1.resourcesFolderOption)
|
|
16
|
+
.action(async (options) => {
|
|
17
|
+
const gatlingHome = (0, options_1.gatlingHomeOptionValueWithDefaults)(options);
|
|
18
|
+
const sourcesFolder = (0, options_1.sourcesFolderOptionValue)(options);
|
|
19
|
+
const resourcesFolder = (0, options_1.resourcesFolderOptionValue)(options);
|
|
20
|
+
const simulations = await (0, simulations_1.findSimulations)(sourcesFolder);
|
|
21
|
+
const typescript = (0, options_1.typescriptOptionValueWithDefaults)(options, simulations);
|
|
22
|
+
const { graalvmHome, coursierBinary, jvmClasspath } = await (0, dependencies_1.installRecorder)({ gatlingHome });
|
|
23
|
+
log_1.logger.debug(`graalvmHome=${graalvmHome}`);
|
|
24
|
+
log_1.logger.debug(`coursierBinary=${coursierBinary}`);
|
|
25
|
+
log_1.logger.debug(`jvmClasspath=${jvmClasspath}`);
|
|
26
|
+
await (0, run_1.runRecorder)({ graalvmHome, jvmClasspath, sourcesFolder, typescript, resourcesFolder });
|
|
27
|
+
});
|
|
28
|
+
};
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const options_1 = require("./options");
|
|
4
|
+
const simulations_1 = require("../simulations");
|
|
5
|
+
const dependencies_1 = require("../dependencies");
|
|
6
|
+
const log_1 = require("../log");
|
|
7
|
+
const bundle_1 = require("../bundle");
|
|
8
|
+
const run_1 = require("../run");
|
|
9
|
+
exports.default = (program) => {
|
|
10
|
+
program
|
|
11
|
+
.command("run")
|
|
12
|
+
.description("Build and run a Gatling simulation, after installing all required components and dependencies for Gatling")
|
|
13
|
+
.addOption(options_1.sourcesFolderOption)
|
|
14
|
+
.addOption(options_1.simulationOption)
|
|
15
|
+
.addOption(options_1.typescriptOption)
|
|
16
|
+
.addOption(options_1.bundleFileOption)
|
|
17
|
+
.addOption(options_1.resourcesFolderOption)
|
|
18
|
+
.addOption(options_1.resultsFolderOption)
|
|
19
|
+
.addOption(options_1.gatlingHomeOption)
|
|
20
|
+
.addOption(options_1.memoryOption)
|
|
21
|
+
.addOption(options_1.postmanOption)
|
|
22
|
+
.addOption(options_1.nonInteractiveOption)
|
|
23
|
+
.addArgument(options_1.runParametersArgument)
|
|
24
|
+
.action(async (args, options) => {
|
|
25
|
+
const gatlingHome = (0, options_1.gatlingHomeOptionValueWithDefaults)(options);
|
|
26
|
+
const sourcesFolder = (0, options_1.sourcesFolderOptionValue)(options);
|
|
27
|
+
const bundleFile = (0, options_1.bundleFileOptionValue)(options);
|
|
28
|
+
const resourcesFolder = (0, options_1.resourcesFolderOptionValue)(options);
|
|
29
|
+
const resultsFolder = (0, options_1.resultsFolderOptionValue)(options);
|
|
30
|
+
const memory = (0, options_1.memoryOptionValue)(options);
|
|
31
|
+
const nonInteractive = (0, options_1.nonInteractiveOptionValue)(options);
|
|
32
|
+
const postman = (0, options_1.postmanOptionValueWithDefaults)(options);
|
|
33
|
+
const runParameters = (0, options_1.parseRunParametersArgument)(args);
|
|
34
|
+
const simulations = await (0, simulations_1.findSimulations)(sourcesFolder);
|
|
35
|
+
const typescript = (0, options_1.typescriptOptionValueWithDefaults)(options, simulations);
|
|
36
|
+
const simulation = (0, options_1.simulationOptionValueWithDefaults)(options, simulations, !nonInteractive);
|
|
37
|
+
const { graalvmHome, coursierBinary, jvmClasspath } = await (0, dependencies_1.installGatlingJs)({ gatlingHome, postman });
|
|
38
|
+
log_1.logger.debug(`graalvmHome=${graalvmHome}`);
|
|
39
|
+
log_1.logger.debug(`coursierBinary=${coursierBinary}`);
|
|
40
|
+
log_1.logger.debug(`jvmClasspath=${jvmClasspath}`);
|
|
41
|
+
await (0, bundle_1.bundle)({ sourcesFolder, bundleFile, postman, typescript, simulations });
|
|
42
|
+
await (0, run_1.runSimulation)({
|
|
43
|
+
graalvmHome,
|
|
44
|
+
jvmClasspath,
|
|
45
|
+
simulation,
|
|
46
|
+
bundleFile,
|
|
47
|
+
resourcesFolder,
|
|
48
|
+
resultsFolder,
|
|
49
|
+
memory,
|
|
50
|
+
runParameters
|
|
51
|
+
});
|
|
52
|
+
});
|
|
53
|
+
};
|