@gatling.io/cli 0.1.2 → 3.11.3-M1

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 ADDED
@@ -0,0 +1,15 @@
1
+ # Gatling JS - CLI
2
+
3
+ Gatling JS is a JavaScript/TypeScript interface for the [Gatling load testing tool](https://gatling.io/).
4
+
5
+ This package contains a command-line utility for use with Gatling JS, to allow you to easily build and run you Gatling JS projects.
6
+
7
+ To get started with Gatling JS, see our [introduction to JavaScript scripting](https://docs.gatling.io/tutorials/scripting-intro-js); or simply have a look at [our demo projects](https://github.com/gatling/gatling-js-demo).
8
+
9
+ ## Questions, help?
10
+
11
+ Read the [documentation](https://docs.gatling.io).
12
+
13
+ Join the [Gatling Community Forum](https://community.gatling.io).
14
+
15
+ Found a real bug? Raise an [issue](https://github.com/gatling/gatling/issues).
package/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "@gatling.io/cli",
3
- "version": "0.1.2",
3
+ "version": "3.11.3-M1",
4
4
  "license": "Apache-2.0",
5
5
  "bin": {
6
- "gatling-js-cli": "target/index.js"
6
+ "gatling": "target/index.js"
7
7
  },
8
8
  "main": "target/index.js",
9
9
  "types": "target/index.d.ts",
@@ -22,7 +22,7 @@
22
22
  "typescript": "5.4.5"
23
23
  },
24
24
  "scripts": {
25
- "clean": "rimraf target results tmp",
25
+ "clean": "rimraf target",
26
26
  "format": "prettier --write '**/*.ts'",
27
27
  "build": "tsc -p . && chmod +x ./target/index.js"
28
28
  }
@@ -1,5 +1,5 @@
1
1
  export interface BundleOptions {
2
- entrypointFile: string;
2
+ sourcesFolder: string;
3
3
  bundleFile: string;
4
4
  typescript: boolean;
5
5
  }
package/target/bundle.js CHANGED
@@ -29,14 +29,23 @@ Object.defineProperty(exports, "__esModule", { value: true });
29
29
  exports.bundle = void 0;
30
30
  const esbuild = __importStar(require("esbuild"));
31
31
  const esbuild_plugin_tsc_1 = __importDefault(require("esbuild-plugin-tsc"));
32
+ const promises_1 = __importDefault(require("fs/promises"));
32
33
  const log_1 = require("./log");
33
34
  const bundle = async (options) => {
34
35
  log_1.logger.info(`Packaging a Gatling simulation with options:
35
- - entrypointFile: ${options.entrypointFile}
36
+ - sourcesFolder: ${options.sourcesFolder}
36
37
  - bundleFile: ${options.bundleFile}`);
38
+ const children = await promises_1.default.readdir(options.sourcesFolder, { recursive: false });
39
+ const contents = children
40
+ .filter((f) => (options.typescript ? f.endsWith(".gatling.ts") : f.endsWith(".gatling.js")))
41
+ .map((f) => `export { default as "${f.slice(0, -11)}" } from "./${f}";`)
42
+ .join("\n");
37
43
  const plugins = options.typescript ? [(0, esbuild_plugin_tsc_1.default)({ force: true })] : [];
38
44
  await esbuild.build({
39
- entryPoints: [options.entrypointFile],
45
+ stdin: {
46
+ contents,
47
+ resolveDir: options.sourcesFolder
48
+ },
40
49
  outfile: options.bundleFile,
41
50
  bundle: true,
42
51
  minify: false,
@@ -0,0 +1,2 @@
1
+ export declare const installCoursier: (gatlingHomeDir: string, downloadDir: string) => Promise<string>;
2
+ export declare const resolveDependencies: (coursierPath: string, javaHome: string) => Promise<string>;
@@ -0,0 +1,60 @@
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.resolveDependencies = 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 resolveDependencies = async (coursierPath, javaHome) => {
50
+ const gatlingDep = `"io.gatling.highcharts:gatling-charts-highcharts:${versions_1.versions.gatling.core}"`;
51
+ const gatlingAdapterDep = `"io.gatling:gatling-jvm-to-js-adapter:${versions_1.versions.gatling.jsAdapter}"`;
52
+ const graalvmJsDep = `"org.graalvm.polyglot:js-community:${versions_1.versions.graalvm.js}"`;
53
+ const command = `"${coursierPath}" fetch --classpath ${gatlingDep} ${gatlingAdapterDep} ${graalvmJsDep}`;
54
+ // TODO could add a timeout
55
+ log_1.logger.info(`Resolving dependencies with Coursier`);
56
+ const { stdout } = await execAsync(command, { env: { ...process.env, JAVA_HOME: javaHome } });
57
+ return stdout;
58
+ };
59
+ exports.resolveDependencies = resolveDependencies;
60
+ const execAsync = (0, util_1.promisify)(child_process_1.exec);
@@ -0,0 +1 @@
1
+ export declare const installGraalVm: (gatlingHomeDir: string, downloadDir: string) => Promise<string>;
@@ -0,0 +1,76 @@
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
+ };
@@ -1,6 +1,3 @@
1
- /// <reference types="node" />
2
- import { exec } from "child_process";
3
- export declare const execAsync: typeof exec.__promisify__;
4
1
  export interface DependenciesOptions {
5
2
  gatlingHome: string;
6
3
  }
@@ -3,23 +3,16 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.installAll = exports.execAsync = void 0;
7
- const child_process_1 = require("child_process");
8
- const decompress_1 = __importDefault(require("decompress"));
9
- const fs_1 = require("fs");
6
+ exports.installAll = void 0;
10
7
  const promises_1 = __importDefault(require("fs/promises"));
11
- const os_1 = __importDefault(require("os"));
12
- const util_1 = require("util");
13
- const download_1 = require("./download");
14
- const log_1 = require("../log");
15
- const versions_1 = require("./versions");
16
- exports.execAsync = (0, util_1.promisify)(child_process_1.exec);
8
+ const coursier_1 = require("./coursier");
9
+ const graalVm_1 = require("./graalVm");
17
10
  const installAll = async (options) => {
18
11
  const downloadDir = `${options.gatlingHome}/tmp/download`;
19
12
  await promises_1.default.mkdir(downloadDir, { recursive: true });
20
- const graalvmHomePath = await installGraalVm(options.gatlingHome, downloadDir);
21
- const coursierPath = await installCoursier(options.gatlingHome, downloadDir);
22
- const classpath = await resolveDependencies(coursierPath, graalvmHomePath);
13
+ const graalvmHomePath = await (0, graalVm_1.installGraalVm)(options.gatlingHome, downloadDir);
14
+ const coursierPath = await (0, coursier_1.installCoursier)(options.gatlingHome, downloadDir);
15
+ const classpath = await (0, coursier_1.resolveDependencies)(coursierPath, graalvmHomePath);
23
16
  return {
24
17
  graalvmHome: graalvmHomePath,
25
18
  coursierBinary: coursierPath,
@@ -27,101 +20,3 @@ const installAll = async (options) => {
27
20
  };
28
21
  };
29
22
  exports.installAll = installAll;
30
- const installGraalVm = async (gatlingHomeDir, downloadDir) => {
31
- // TODO test Linux and Windows
32
- const { os, arch, extension, homePath } = graalVmPlatformParams();
33
- const graalvmRootPath = `${gatlingHomeDir}/graalvm/${versions_1.versions.graalvm.jdk}`;
34
- const graalvmHomePath = `${graalvmRootPath}${homePath}`;
35
- const graalvmJavaPath = `${graalvmHomePath}/bin/java`;
36
- if (!(0, fs_1.existsSync)(graalvmJavaPath)) {
37
- 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}`;
38
- const downloadPath = `${downloadDir}/graalvm.${extension}`;
39
- if ((0, fs_1.existsSync)(graalvmRootPath)) {
40
- await promises_1.default.rm(graalvmRootPath, { recursive: true });
41
- }
42
- if ((0, fs_1.existsSync)(downloadPath)) {
43
- await promises_1.default.rm(downloadPath);
44
- }
45
- await promises_1.default.mkdir(graalvmRootPath, { recursive: true });
46
- log_1.logger.info(`Downloading GraalVM Community Edition ${versions_1.versions.graalvm.jdk} to ${downloadPath}`);
47
- await (0, download_1.downloadFile)(url, downloadPath);
48
- log_1.logger.info(`Unpacking GraalVM to ${graalvmRootPath}`);
49
- await (0, decompress_1.default)(downloadPath, graalvmRootPath, {
50
- map: (file) => {
51
- // Remove first level of file name, because it already contains a root directory
52
- file.path = file.path.split("/").slice(1).join("/");
53
- return file;
54
- }
55
- });
56
- await promises_1.default.rm(downloadPath);
57
- }
58
- else {
59
- log_1.logger.info(`GraalVM Community Edition ${versions_1.versions.graalvm.jdk} already installed at ${graalvmRootPath}`);
60
- }
61
- return graalvmHomePath;
62
- };
63
- const graalVmPlatformParams = () => {
64
- const osType = os_1.default.type(); // 'Darwin', 'Linux', 'Windows_NT'
65
- const osArch = os_1.default.arch(); // 'x64', 'arm64', etc.
66
- if (osType === "Linux") {
67
- const os = "linux";
68
- const extension = "tar.gz";
69
- const homePath = "";
70
- if (osArch === "x64") {
71
- return { os, arch: "x64", extension, homePath };
72
- }
73
- else if (osArch === "arm64") {
74
- return { os, arch: "aarch64", extension, homePath };
75
- }
76
- }
77
- else if (osType === "Darwin") {
78
- const os = "macos";
79
- const extension = "tar.gz";
80
- const homePath = "/Contents/Home";
81
- if (osArch === "x64") {
82
- return { os, arch: "x64", extension, homePath };
83
- }
84
- else if (osArch === "arm64") {
85
- return { os, arch: "aarch64", extension, homePath };
86
- }
87
- }
88
- else if (osType === "Windows_NT" && osArch === "x64") {
89
- return { os: "windows", arch: "x64", extension: "zip", homePath: "" };
90
- }
91
- throw Error(`Operating system type '${osType}' with architecture '${osArch}' is not currently supported.`);
92
- };
93
- const installCoursier = async (gatlingHomeDir, downloadDir) => {
94
- const coursierRootPath = `${gatlingHomeDir}/coursier/${versions_1.versions.coursier}`;
95
- const coursierPath = `${coursierRootPath}/cs`;
96
- if (!(0, fs_1.existsSync)(coursierPath)) {
97
- // TODO test Linux/windows
98
- const url = `https://github.com/coursier/coursier/releases/download/v${versions_1.versions.coursier}/coursier`;
99
- const downloadPath = `${downloadDir}/cs`;
100
- if ((0, fs_1.existsSync)(coursierRootPath)) {
101
- await promises_1.default.rm(coursierRootPath, { recursive: true });
102
- }
103
- if ((0, fs_1.existsSync)(downloadPath)) {
104
- await promises_1.default.rm(downloadPath);
105
- }
106
- await promises_1.default.mkdir(coursierRootPath, { recursive: true });
107
- log_1.logger.info(`Downloading Coursier ${versions_1.versions.coursier} to ${downloadPath}`);
108
- await (0, download_1.downloadFile)(url, downloadPath);
109
- await promises_1.default.chmod(downloadPath, 0o744);
110
- log_1.logger.info(`Installing Coursier to ${coursierPath}`);
111
- await promises_1.default.rename(downloadPath, coursierPath);
112
- }
113
- else {
114
- log_1.logger.info(`Coursier ${versions_1.versions.coursier} already installed at ${coursierPath}`);
115
- }
116
- return coursierPath;
117
- };
118
- const resolveDependencies = async (coursierPath, javaHome) => {
119
- const gatlingDep = `"io.gatling.highcharts:gatling-charts-highcharts:${versions_1.versions.gatling.core}"`;
120
- const gatlingAdapterDep = `"io.gatling:gatling-jvm-to-js-adapter:${versions_1.versions.gatling.jsAdapter}"`;
121
- const graalvmJsDep = `"org.graalvm.polyglot:js-community:${versions_1.versions.graalvm.js}"`;
122
- const command = `"${coursierPath}" fetch --classpath ${gatlingDep} ${gatlingAdapterDep} ${graalvmJsDep}`;
123
- // TODO could add a timeout
124
- log_1.logger.info(`Resolving dependencies with Coursier`);
125
- const { stdout } = await (0, exports.execAsync)(command, { env: { ...process.env, JAVA_HOME: javaHome } });
126
- return stdout;
127
- };
@@ -0,0 +1,2 @@
1
+ export declare const osType: "Darwin" | "Linux" | "Windows_NT";
2
+ export declare const osArch: "x64" | "arm64";
@@ -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.osArch = exports.osType = void 0;
7
+ const os_1 = __importDefault(require("os"));
8
+ const resolveOsType = () => {
9
+ const t = os_1.default.type();
10
+ if (t !== "Darwin" && t !== "Linux" && t !== "Windows_NT") {
11
+ throw Error(`Gatling JS does not support the Operating System '${t}'`);
12
+ }
13
+ return t;
14
+ };
15
+ exports.osType = resolveOsType();
16
+ const resolveOsArch = () => {
17
+ const a = os_1.default.arch();
18
+ if (a !== "x64" && a !== "arm64") {
19
+ throw Error(`Gatling JS does not support the architecture '${a}'`);
20
+ }
21
+ if (exports.osType === "Windows_NT" && a === "arm64") {
22
+ // GraalVM distribution not available for Windows on ARM
23
+ // TODO see if we can recommend a solution
24
+ throw Error(`Gatling JS does not support Windows on the ARM architecture`);
25
+ }
26
+ return a;
27
+ };
28
+ exports.osArch = resolveOsArch();
@@ -9,6 +9,6 @@ exports.versions = {
9
9
  coursier: "2.1.10",
10
10
  gatling: {
11
11
  core: "3.11.2",
12
- jsAdapter: "0.1.2"
12
+ jsAdapter: "3.11.3-M1"
13
13
  }
14
14
  };
package/target/index.js CHANGED
@@ -16,12 +16,11 @@ const program = new commander_1.Command()
16
16
  .description("The Gatling Javascript run & packaging tool");
17
17
  const gatlingHomeOption = new commander_1.Option("--gatling-home <value>", 'The folder used to download and install Gatling components (default: "~/.gatling")');
18
18
  const gatlingHomeDirWithDefaults = (options) => options.gatlingHome || `${os_1.default.homedir()}/.gatling`;
19
- const entrypointFileOption = new commander_1.Option("--entrypoint-file <value>", 'The simulation entry point source file path (default: "src/index.js", or "src/index.ts" when using the "--typescript" option)');
20
- const simulationNameOption = new commander_1.Option("--simulation-name <value>", "The simulation entry point function name").default("default", '"default", compatible with using "export default"');
21
- const entrypointFileWithDefaults = (options) => options.entrypointFile || (options.typescript ? "src/index.ts" : "src/index.js");
19
+ const sourcesFolderOption = new commander_1.Option("--sources-folder <value>", "The sources folder path").default("src");
20
+ const simulationOption = new commander_1.Option("--simulation <value>", "The simulation entry point function name").default("default", '"default", compatible with using "export default"');
22
21
  const bundleFileOption = new commander_1.Option("--bundle-file <value>", "The simulation target bundle file path").default("target/bundle.js");
23
22
  const resourcesFolderOption = new commander_1.Option("--resources-folder <value>", "The resources folder path").default("resources");
24
- const resultsFolderOption = new commander_1.Option("--results-folder <value>", "The results folder path").default("results");
23
+ const resultsFolderOption = new commander_1.Option("--results-folder <value>", "The results folder path").default("target/gatling");
25
24
  const typescriptOption = new commander_1.Option("--typescript", "Use the typescript compiler to compile your code").default(false);
26
25
  const graalvmHomeMandatoryOption = new commander_1.Option("--graalvm-home <value>", "Path to the GraalVM home").makeOptionMandatory(true);
27
26
  const jvmClasspathMandatoryOption = new commander_1.Option("--jvm-classpath <value>", "The classpath containing all Gatling JVM components").makeOptionMandatory(true);
@@ -39,38 +38,38 @@ program
39
38
  program
40
39
  .command("build")
41
40
  .description("Build a Gatling simulation")
42
- .addOption(entrypointFileOption)
41
+ .addOption(sourcesFolderOption)
43
42
  .addOption(bundleFileOption)
44
43
  .addOption(typescriptOption)
45
44
  .action(async (options) => {
46
- const entrypointFile = entrypointFileWithDefaults(options);
45
+ const sourcesFolder = options.sourcesFolder;
47
46
  const bundleFile = options.bundleFile;
48
47
  const typescript = options.typescript;
49
- await (0, bundle_1.bundle)({ entrypointFile, bundleFile, typescript });
48
+ await (0, bundle_1.bundle)({ sourcesFolder, bundleFile, typescript });
50
49
  });
51
50
  program
52
51
  .command("run-only")
53
52
  .description("Run a Gatling simulation")
54
53
  .addOption(graalvmHomeMandatoryOption)
55
54
  .addOption(jvmClasspathMandatoryOption)
56
- .addOption(simulationNameOption)
55
+ .addOption(simulationOption)
57
56
  .addOption(bundleFileOption)
58
57
  .addOption(resourcesFolderOption)
59
58
  .addOption(resultsFolderOption)
60
59
  .action(async (options) => {
61
60
  const graalvmHome = options.graalvmHome;
62
61
  const jvmClasspath = options.jvmClasspath;
63
- const simulationName = options.simulationName;
62
+ const simulation = options.simulation;
64
63
  const bundleFile = options.bundleFile;
65
64
  const resourcesFolder = options.resourcesFolder;
66
65
  const resultsFolder = options.resultsFolder;
67
- await (0, run_1.run)({ graalvmHome, jvmClasspath, simulationName, bundleFile, resourcesFolder, resultsFolder });
66
+ await (0, run_1.run)({ graalvmHome, jvmClasspath, simulation: simulation, bundleFile, resourcesFolder, resultsFolder });
68
67
  });
69
68
  program
70
69
  .command("run")
71
70
  .description("Build and run a Gatling simulation, after installing all required components and dependencies for Gatling")
72
- .addOption(entrypointFileOption)
73
- .addOption(simulationNameOption)
71
+ .addOption(sourcesFolderOption)
72
+ .addOption(simulationOption)
74
73
  .addOption(typescriptOption)
75
74
  .addOption(bundleFileOption)
76
75
  .addOption(resourcesFolderOption)
@@ -78,8 +77,8 @@ program
78
77
  .addOption(gatlingHomeOption)
79
78
  .action(async (options) => {
80
79
  const gatlingHome = gatlingHomeDirWithDefaults(options);
81
- const entrypointFile = entrypointFileWithDefaults(options);
82
- const simulationName = options.simulationName;
80
+ const sourcesFolder = options.sourcesFolder;
81
+ const simulation = options.simulation;
83
82
  const bundleFile = options.bundleFile;
84
83
  const resourcesFolder = options.resourcesFolder;
85
84
  const resultsFolder = options.resultsFolder;
@@ -88,7 +87,7 @@ program
88
87
  log_1.logger.debug(`graalvmHome=${graalvmHome}`);
89
88
  log_1.logger.debug(`coursierBinary=${coursierBinary}`);
90
89
  log_1.logger.debug(`jvmClasspath=${jvmClasspath}`);
91
- await (0, bundle_1.bundle)({ entrypointFile, bundleFile, typescript });
92
- await (0, run_1.run)({ graalvmHome, jvmClasspath, simulationName, bundleFile, resourcesFolder, resultsFolder });
90
+ await (0, bundle_1.bundle)({ sourcesFolder, bundleFile, typescript });
91
+ await (0, run_1.run)({ graalvmHome, jvmClasspath, simulation, bundleFile, resourcesFolder, resultsFolder });
93
92
  });
94
93
  program.parse(process.argv);
package/target/run.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  export interface RunOptions {
2
2
  graalvmHome: string;
3
3
  jvmClasspath: string;
4
- simulationName: string;
4
+ simulation: string;
5
5
  bundleFile: string;
6
6
  resourcesFolder: string;
7
7
  resultsFolder: string;
package/target/run.js CHANGED
@@ -1,39 +1,16 @@
1
1
  "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
2
  Object.defineProperty(exports, "__esModule", { value: true });
26
3
  exports.run = void 0;
27
4
  const child_process_1 = require("child_process");
28
- const path = __importStar(require("path"));
29
5
  const log_1 = require("./log");
6
+ const versions_1 = require("./dependencies/versions");
7
+ const os_1 = require("./dependencies/os");
30
8
  const run = async (options) => {
31
9
  log_1.logger.info(`Running a Gatling simulation with options:
32
- - entrypointName: ${options.simulationName}
10
+ - simulation: ${options.simulation}
33
11
  - bundleFile: ${options.bundleFile}`);
34
- const bundleFolder = path.parse(options.bundleFile).dir;
35
- const bundleFileName = path.parse(options.bundleFile).base;
36
12
  const command = `${options.graalvmHome}/bin/java`;
13
+ const classpathSeparator = os_1.osType === "Windows_NT" ? ";" : ":";
37
14
  const args = [
38
15
  "-server",
39
16
  "-XX:+HeapDumpOnOutOfMemoryError",
@@ -41,14 +18,18 @@ const run = async (options) => {
41
18
  "-XX:MaxTrivialSize=12",
42
19
  "-Xmx1G",
43
20
  "-classpath",
44
- `${bundleFolder}:${options.resourcesFolder}:${options.jvmClasspath}`,
45
- `-Dgatling.js.bundle.resourcePath=${bundleFileName}`,
46
- `-Dgatling.js.simulationName=${options.simulationName}`,
21
+ `${options.resourcesFolder}${classpathSeparator}${options.jvmClasspath}`,
22
+ `-Dgatling.js.bundle.filePath=${options.bundleFile}`,
23
+ `-Dgatling.js.simulation=${options.simulation}`,
47
24
  "io.gatling.app.Gatling",
48
25
  "--results-folder",
49
26
  options.resultsFolder,
50
27
  "--simulation",
51
- "io.gatling.js.JsSimulation"
28
+ "io.gatling.js.JsSimulation",
29
+ "--launcher",
30
+ "gatling-js-cli",
31
+ "--build-tool-version",
32
+ versions_1.versions.gatling.jsAdapter
52
33
  ];
53
34
  const process = (0, child_process_1.spawn)(command, args);
54
35
  return new Promise((resolve, reject) => {