@gatling.io/cli 3.13.2 → 3.13.104-M10

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.
Files changed (44) hide show
  1. package/package.json +22 -7
  2. package/target/bundle/index.js +17 -7
  3. package/target/commands/enterpriseDeploy.js +1 -1
  4. package/target/commands/enterpriseStart.js +1 -1
  5. package/target/commands/install.js +5 -3
  6. package/target/commands/options.d.ts +1 -0
  7. package/target/commands/options.js +3 -2
  8. package/target/commands/recorder.js +1 -2
  9. package/target/commands/run.js +1 -2
  10. package/target/dependencies/download.js +19 -4
  11. package/target/dependencies/index.d.ts +7 -6
  12. package/target/dependencies/index.js +138 -30
  13. package/target/dependencies/versions.d.ts +0 -1
  14. package/target/dependencies/versions.js +3 -4
  15. package/src/bundle/index.ts +0 -43
  16. package/src/bundle/polyfill.ts +0 -91
  17. package/src/commands/build.ts +0 -34
  18. package/src/commands/enterpriseDeploy.ts +0 -97
  19. package/src/commands/enterprisePackage.ts +0 -45
  20. package/src/commands/enterpriseStart.ts +0 -122
  21. package/src/commands/index.ts +0 -25
  22. package/src/commands/install.ts +0 -19
  23. package/src/commands/options.ts +0 -308
  24. package/src/commands/recorder.ts +0 -41
  25. package/src/commands/run.ts +0 -82
  26. package/src/commands/runOnly.ts +0 -56
  27. package/src/dependencies/coursier.ts +0 -84
  28. package/src/dependencies/download.ts +0 -11
  29. package/src/dependencies/graalVm.ts +0 -74
  30. package/src/dependencies/index.ts +0 -45
  31. package/src/dependencies/os.ts +0 -24
  32. package/src/dependencies/versions.ts +0 -15
  33. package/src/enterprise.ts +0 -227
  34. package/src/index.ts +0 -5
  35. package/src/java.ts +0 -48
  36. package/src/log.ts +0 -19
  37. package/src/readline.ts +0 -39
  38. package/src/run.ts +0 -68
  39. package/src/simulations.ts +0 -29
  40. package/target/dependencies/coursier.d.ts +0 -3
  41. package/target/dependencies/coursier.js +0 -74
  42. package/target/dependencies/graalVm.d.ts +0 -1
  43. package/target/dependencies/graalVm.js +0 -76
  44. package/tsconfig.json +0 -18
package/src/log.ts DELETED
@@ -1,19 +0,0 @@
1
- const debug: (message: string) => void =
2
- // On Node.js, console.debug is just an alias to console.log, so we handle debug level ourselves
3
- process.env["DEBUG"] === "true" ? console.debug : () => {};
4
-
5
- const info: (message: string) => void = console.info;
6
-
7
- const error: (message: string) => void = console.error;
8
-
9
- export interface Logger {
10
- debug: (message: string) => void;
11
- info: (message: string) => void;
12
- error: (message: string) => void;
13
- }
14
-
15
- export const logger: Logger = {
16
- debug,
17
- info,
18
- error
19
- };
package/src/readline.ts DELETED
@@ -1,39 +0,0 @@
1
- import { keyInSelect, BasicOptions } from "readline-sync";
2
-
3
- // Inspired by https://github.com/anseki/readline-sync/issues/60#issuecomment-324533678
4
- // Pagination avoids very long lists to scroll though, as well as the hard limit at 35 items for keyInSelect
5
- export const keyInSelectPaginated = (items: string[], query?: any, options?: BasicOptions | undefined): number => {
6
- if (items.length === 0) {
7
- return -1;
8
- }
9
-
10
- const maxItemsPerPage = 10;
11
- const maxPageIndex = Math.ceil(items.length / maxItemsPerPage) - 1;
12
-
13
- let pageIndex = 0;
14
- while (true) {
15
- const pageItems = [];
16
- let indexPrev = -1;
17
- let indexNext = -1;
18
- if (pageIndex > 0) {
19
- pageItems.push(`(PREVIOUS ${maxItemsPerPage} items)`);
20
- indexPrev = pageItems.length - 1;
21
- }
22
- pageItems.push(...items.slice(pageIndex * maxItemsPerPage, (pageIndex + 1) * maxItemsPerPage));
23
- if (pageIndex < maxPageIndex) {
24
- pageItems.push(
25
- `(NEXT ${pageIndex < maxPageIndex - 1 ? maxItemsPerPage : items.length - maxItemsPerPage * (pageIndex + 1)} item(s))`
26
- );
27
- indexNext = pageItems.length - 1;
28
- }
29
- console.log("\x1B[2J"); // clear screen
30
- const index = keyInSelect(pageItems, query, options);
31
- if (indexPrev !== -1 && index === indexPrev) {
32
- pageIndex--;
33
- } else if (indexNext !== -1 && index === indexNext) {
34
- pageIndex++;
35
- } else {
36
- return index === -1 ? index : index + pageIndex * maxItemsPerPage - (indexPrev === -1 ? 0 : 1);
37
- }
38
- }
39
- };
package/src/run.ts DELETED
@@ -1,68 +0,0 @@
1
- import { logger } from "./log";
2
- import { versions } from "./dependencies";
3
- import { RunJavaProcessOptions, runJavaProcess } from "./java";
4
-
5
- export interface RunSimulationOptions extends RunJavaProcessOptions {
6
- simulation: string;
7
- bundleFile: string;
8
- resourcesFolder: string;
9
- resultsFolder: string;
10
- memory?: number;
11
- runParameters: Record<string, string>;
12
- }
13
-
14
- export interface RunRecorderOptions extends RunJavaProcessOptions {
15
- sourcesFolder: string;
16
- typescript: boolean;
17
- resourcesFolder: string;
18
- }
19
-
20
- export const runSimulation = async (options: RunSimulationOptions): Promise<void> => {
21
- logger.info(`Running a Gatling simulation with options:
22
- - simulation: ${options.simulation}
23
- - bundleFile: ${options.bundleFile}
24
- - resourcesFolder: ${options.resourcesFolder}
25
- - resultsFolder: ${options.resultsFolder}`);
26
-
27
- const additionalClasspathElements = [options.resourcesFolder];
28
- const jitTuningArgs = ["-XX:JVMCINativeLibraryThreadFraction=0.8", "-Dgraal.MethodInlineBailoutLimit=500"];
29
- const memoryArgs = options.memory !== undefined ? [`-Xms${options.memory}M`, `-Xmx${options.memory}M`] : [];
30
- const javaArgs = [
31
- ...Object.entries(options.runParameters).map(([key, value]) => `-D${key}=${value}`),
32
- "--add-opens=java.base/java.lang=ALL-UNNAMED",
33
- `-Dgatling.js.bundle.filePath=${options.bundleFile}`,
34
- `-Dgatling.js.simulation=${options.simulation}`,
35
- ...jitTuningArgs,
36
- ...memoryArgs
37
- ];
38
- const simulationArgs = [
39
- "--results-folder",
40
- options.resultsFolder,
41
- "--simulation",
42
- "io.gatling.js.JsSimulation",
43
- "--launcher",
44
- "gatling-js-cli",
45
- "--build-tool-version",
46
- versions.gatling.jsAdapter
47
- ];
48
-
49
- return runJavaProcess(options, "io.gatling.app.Gatling", additionalClasspathElements, javaArgs, simulationArgs);
50
- };
51
-
52
- export const runRecorder = async (options: RunRecorderOptions): Promise<void> => {
53
- logger.info(`Running the Gatling Recorder with options:
54
- - sourcesFolder: ${options.sourcesFolder}
55
- - resourcesFolder: ${options.resourcesFolder}
56
- - typescript: ${options.typescript}`);
57
-
58
- const recorderArgs = [
59
- "--simulations-folder",
60
- options.sourcesFolder,
61
- "--resources-folder",
62
- options.resourcesFolder,
63
- "--format",
64
- options.typescript ? "typescript" : "javascript"
65
- ];
66
-
67
- return runJavaProcess(options, "io.gatling.recorder.GatlingRecorder", [], [], recorderArgs);
68
- };
@@ -1,29 +0,0 @@
1
- import fs from "fs/promises";
2
-
3
- export interface SimulationFile {
4
- path: string;
5
- name: string;
6
- type: "javascript" | "typescript";
7
- }
8
-
9
- export const findSimulations = async (sourcesFolder: string): Promise<Array<SimulationFile>> => {
10
- const children = await fs.readdir(sourcesFolder, { recursive: false });
11
- const simulations = children
12
- .filter((path) => path.endsWith(".gatling.js") || path.endsWith(".gatling.ts"))
13
- .map(
14
- (path): SimulationFile => ({
15
- path,
16
- name: path.slice(0, -11),
17
- type: path.endsWith(".ts") ? "typescript" : "javascript"
18
- })
19
- );
20
- const duplicates = simulations.filter(
21
- (value, index) => simulations.findIndex((other) => other.name === value.name) !== index
22
- );
23
- if (duplicates.length > 0) {
24
- throw Error(
25
- `Found ambiguous simulation name(s) ${duplicates.map((s) => s.name)}: found as both *.gatling.js and *.gatling.ts file(s)`
26
- );
27
- }
28
- return simulations;
29
- };
@@ -1,3 +0,0 @@
1
- export declare const installCoursier: (gatlingHomeDir: string, downloadDir: string) => Promise<string>;
2
- export declare const resolveGatlingJsDependencies: (coursierPath: string, javaHome: string, postmanVersion?: string) => Promise<string>;
3
- export declare const resolveRecorderDependencies: (coursierPath: string, javaHome: string) => Promise<string>;
@@ -1,74 +0,0 @@
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.resolveRecorderDependencies = exports.resolveGatlingJsDependencies = exports.installCoursier = void 0;
7
- const fs_1 = require("fs");
8
- const promises_1 = __importDefault(require("fs/promises"));
9
- const download_1 = require("./download");
10
- const log_1 = require("../log");
11
- const versions_1 = require("./versions");
12
- const util_1 = require("util");
13
- const child_process_1 = require("child_process");
14
- const os_1 = require("./os");
15
- const installCoursier = async (gatlingHomeDir, downloadDir) => {
16
- const coursierRootPath = `${gatlingHomeDir}/coursier/${versions_1.versions.coursier}`;
17
- const coursierPath = `${coursierRootPath}/cs`;
18
- if (!(0, fs_1.existsSync)(coursierPath)) {
19
- const jarUrl = `https://github.com/coursier/coursier/releases/download/v${versions_1.versions.coursier}/coursier`;
20
- const windowsBatUrl = `https://github.com/coursier/launchers/raw/master/coursier.bat`;
21
- const downloadPath = `${downloadDir}/cs`;
22
- if ((0, fs_1.existsSync)(coursierRootPath)) {
23
- await promises_1.default.rm(coursierRootPath, { recursive: true });
24
- }
25
- if ((0, fs_1.existsSync)(downloadPath)) {
26
- await promises_1.default.rm(downloadPath);
27
- }
28
- await promises_1.default.mkdir(coursierRootPath, { recursive: true });
29
- log_1.logger.info(`Downloading Coursier ${versions_1.versions.coursier} to ${downloadPath}`);
30
- await (0, download_1.downloadFile)(jarUrl, downloadPath);
31
- if (os_1.osType === "Windows_NT") {
32
- await (0, download_1.downloadFile)(windowsBatUrl, `${downloadPath}.bat`);
33
- }
34
- else {
35
- await promises_1.default.chmod(downloadPath, 0o744);
36
- }
37
- log_1.logger.info(`Installing Coursier to ${coursierPath}`);
38
- await promises_1.default.rename(downloadPath, coursierPath);
39
- if (os_1.osType === "Windows_NT") {
40
- await promises_1.default.rename(`${downloadPath}.bat`, `${coursierPath}.bat`);
41
- }
42
- }
43
- else {
44
- log_1.logger.info(`Coursier ${versions_1.versions.coursier} already installed at ${coursierPath}`);
45
- }
46
- return coursierPath;
47
- };
48
- exports.installCoursier = installCoursier;
49
- const resolveGatlingJsDependencies = async (coursierPath, javaHome, postmanVersion) => {
50
- const dependencies = [
51
- `"io.gatling.highcharts:gatling-charts-highcharts:${versions_1.versions.gatling.core}"`,
52
- `"io.gatling:gatling-jvm-to-js-adapter:${versions_1.versions.gatling.jsAdapter}"`,
53
- `"io.gatling:gatling-enterprise-plugin-commons:${versions_1.versions.gatling.enterprisePluginCommons}"`,
54
- `"org.graalvm.polyglot:js-community:${versions_1.versions.graalvm.js}"`
55
- ];
56
- if (postmanVersion !== undefined) {
57
- dependencies.push(`"io.gatling:gatling-postman-jvm-to-js-adapter:${postmanVersion}"`);
58
- }
59
- return await resolveDependencies(coursierPath, javaHome, ...dependencies);
60
- };
61
- exports.resolveGatlingJsDependencies = resolveGatlingJsDependencies;
62
- const resolveRecorderDependencies = async (coursierPath, javaHome) => {
63
- const recorderDep = `io.gatling:gatling-recorder:${versions_1.versions.gatling.core}`;
64
- return await resolveDependencies(coursierPath, javaHome, recorderDep);
65
- };
66
- exports.resolveRecorderDependencies = resolveRecorderDependencies;
67
- const resolveDependencies = async (coursierPath, javaHome, ...dependencies) => {
68
- const command = `"${coursierPath}" fetch --classpath ${dependencies.join(" ")}`;
69
- // TODO could add a timeout
70
- log_1.logger.info(`Resolving dependencies with Coursier`);
71
- const { stdout } = await execAsync(command, { env: { ...process.env, JAVA_HOME: javaHome } });
72
- return stdout;
73
- };
74
- const execAsync = (0, util_1.promisify)(child_process_1.exec);
@@ -1 +0,0 @@
1
- export declare const installGraalVm: (gatlingHomeDir: string, downloadDir: string) => Promise<string>;
@@ -1,76 +0,0 @@
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.installGraalVm = void 0;
7
- const fs_1 = require("fs");
8
- const promises_1 = __importDefault(require("fs/promises"));
9
- const decompress_1 = __importDefault(require("decompress"));
10
- const download_1 = require("./download");
11
- const log_1 = require("../log");
12
- const os_1 = require("./os");
13
- const versions_1 = require("./versions");
14
- const installGraalVm = async (gatlingHomeDir, downloadDir) => {
15
- const { os, arch, extension, homePath, binPath } = graalVmPlatformParams();
16
- const graalvmRootPath = `${gatlingHomeDir}/graalvm/${versions_1.versions.graalvm.jdk}`;
17
- const graalvmHomePath = `${graalvmRootPath}${homePath}`;
18
- const graalvmJavaPath = `${graalvmHomePath}${binPath}`;
19
- if (!(0, fs_1.existsSync)(graalvmJavaPath)) {
20
- const url = `https://github.com/graalvm/graalvm-ce-builds/releases/download/jdk-${versions_1.versions.graalvm.jdk}/graalvm-community-jdk-${versions_1.versions.graalvm.jdk}_${os}-${arch}_bin.${extension}`;
21
- const downloadPath = `${downloadDir}/graalvm.${extension}`;
22
- if ((0, fs_1.existsSync)(graalvmRootPath)) {
23
- await promises_1.default.rm(graalvmRootPath, { recursive: true });
24
- }
25
- if ((0, fs_1.existsSync)(downloadPath)) {
26
- await promises_1.default.rm(downloadPath);
27
- }
28
- await promises_1.default.mkdir(graalvmRootPath, { recursive: true });
29
- log_1.logger.info(`Downloading GraalVM Community Edition ${versions_1.versions.graalvm.jdk} to ${downloadPath}`);
30
- await (0, download_1.downloadFile)(url, downloadPath);
31
- log_1.logger.info(`Unpacking GraalVM to ${graalvmRootPath}`);
32
- await (0, decompress_1.default)(downloadPath, graalvmRootPath, {
33
- map: (file) => {
34
- // Remove first level of file name, because it already contains a root directory
35
- file.path = file.path.split("/").slice(1).join("/");
36
- return file;
37
- }
38
- });
39
- await promises_1.default.rm(downloadPath);
40
- }
41
- else {
42
- log_1.logger.info(`GraalVM Community Edition ${versions_1.versions.graalvm.jdk} already installed at ${graalvmRootPath}`);
43
- }
44
- return graalvmHomePath;
45
- };
46
- exports.installGraalVm = installGraalVm;
47
- const graalVmPlatformParams = () => {
48
- if (os_1.osType === "Linux") {
49
- const os = "linux";
50
- const extension = "tar.gz";
51
- const homePath = "";
52
- const binPath = "/bin/java";
53
- if (os_1.osArch === "x64") {
54
- return { os, arch: "x64", extension, homePath, binPath };
55
- }
56
- else if (os_1.osArch === "arm64") {
57
- return { os, arch: "aarch64", extension, homePath, binPath };
58
- }
59
- }
60
- else if (os_1.osType === "Darwin") {
61
- const os = "macos";
62
- const extension = "tar.gz";
63
- const homePath = "/Contents/Home";
64
- const binPath = "/bin/java";
65
- if (os_1.osArch === "x64") {
66
- return { os, arch: "x64", extension, homePath, binPath };
67
- }
68
- else if (os_1.osArch === "arm64") {
69
- return { os, arch: "aarch64", extension, homePath, binPath };
70
- }
71
- }
72
- else if (os_1.osType === "Windows_NT" && os_1.osArch === "x64") {
73
- return { os: "windows", arch: "x64", extension: "zip", homePath: "", binPath: "/bin/java.exe" };
74
- }
75
- throw Error(`Operating system type '${os_1.osType}' with architecture '${os_1.osArch}' is not currently supported.`);
76
- };
package/tsconfig.json DELETED
@@ -1,18 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "baseUrl": "./",
4
- "rootDir": "src",
5
- "outDir": "target",
6
- "lib": ["es2021", "dom"],
7
- "target": "es2021",
8
- "module": "node16",
9
- "esModuleInterop": true,
10
- "moduleResolution": "node16",
11
- "declaration": true,
12
- "strict": true,
13
- "forceConsistentCasingInFileNames": true,
14
- "resolveJsonModule": true
15
- },
16
- "include": ["src/**/*.ts"],
17
- "exclude": ["**/*.test.ts"]
18
- }