@gatling.io/cli 3.11.5 → 3.11.7

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gatling.io/cli",
3
- "version": "3.11.5",
3
+ "version": "3.11.7",
4
4
  "license": "Apache-2.0",
5
5
  "bin": {
6
6
  "gatling": "target/index.js"
@@ -19,15 +19,16 @@
19
19
  "devDependencies": {
20
20
  "@types/archiver": "6.0.2",
21
21
  "@types/decompress": "4.2.7",
22
- "@types/node": "20.14.9",
22
+ "@types/node": "20.14.12",
23
23
  "@types/readline-sync": "1.4.8",
24
- "prettier": "3.3.2",
25
- "rimraf": "5.0.7",
26
- "typescript": "5.4.5"
24
+ "prettier": "3.3.3",
25
+ "rimraf": "6.0.1",
26
+ "typescript": "5.5.4"
27
27
  },
28
28
  "scripts": {
29
29
  "clean": "rimraf target",
30
30
  "format": "prettier --write '**/*.ts'",
31
+ "format-check": "prettier --check '**/*.ts'",
31
32
  "build": "tsc -p . && chmod +x ./target/index.js"
32
33
  }
33
34
  }
@@ -3,13 +3,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.versions = void 0;
4
4
  exports.versions = {
5
5
  graalvm: {
6
- jdk: "22.0.1",
7
- js: "24.0.1"
6
+ jdk: "22.0.2",
7
+ js: "24.0.2"
8
8
  },
9
9
  coursier: "2.1.10",
10
10
  gatling: {
11
11
  core: "3.11.5",
12
- enterprisePluginCommons: "1.9.4",
13
- jsAdapter: "3.11.5"
12
+ enterprisePluginCommons: "1.9.6",
13
+ jsAdapter: "3.11.7"
14
14
  }
15
15
  };
@@ -39,17 +39,19 @@ const generateManifest = (simulationNames) => {
39
39
  const continuation = utf8Encoder.encode("\n ");
40
40
  const lines = [
41
41
  "Manifest-Version: 1.0",
42
- "Implementation-Title: gatling-javascript",
43
- `Implementation-Version: ${versions_1.versions.gatling.jsAdapter}`,
44
- "Implementation-Vendor: GatlingCorp",
45
42
  "Specification-Vendor: GatlingCorp",
46
43
  "Gatling-Context: js",
47
44
  `Gatling-Version: ${versions_1.versions.gatling.core}`,
48
- "Gatling-Packager: javascript",
45
+ "Gatling-Packager: js-cli",
49
46
  `Gatling-Packager-Version: ${versions_1.versions.gatling.jsAdapter}`,
50
47
  `Gatling-Simulations: ${simulationNames.join(",")}`,
51
48
  `Java-Version: ${versions_1.versions.graalvm.jdk.split(".")[0]}`
52
49
  ];
50
+ const pkg = getPackageNameAndVersion();
51
+ lines.push(`Implementation-Title: ${pkg.name}`);
52
+ if (pkg.version !== undefined) {
53
+ lines.push(`Implementation-Version: ${pkg.version}`);
54
+ }
53
55
  let totalLength = 0;
54
56
  const buffer = [];
55
57
  for (const line of lines) {
@@ -81,6 +83,30 @@ const generateManifest = (simulationNames) => {
81
83
  }
82
84
  return manifest;
83
85
  };
86
+ const getPackageNameAndVersion = () => {
87
+ // npm_package_* env vars are available when launching CLI with npx
88
+ let name = process.env.npm_package_name;
89
+ let version = process.env.npm_package_version;
90
+ // otherwise, try to read from package.json file
91
+ if (name === undefined || version === undefined) {
92
+ if (!fs_1.default.existsSync("package.json")) {
93
+ throw Error("package.json not found");
94
+ }
95
+ const pkg = JSON.parse(fs_1.default.readFileSync("package.json", "utf-8"));
96
+ if (name === undefined) {
97
+ if (typeof pkg.name === "string") {
98
+ name = pkg.name;
99
+ }
100
+ else {
101
+ throw Error("package.json does not contain a valid package name");
102
+ }
103
+ }
104
+ if (version === undefined && typeof pkg.version === "string") {
105
+ version = pkg.version;
106
+ }
107
+ }
108
+ return { name: name, version: version };
109
+ };
84
110
  const javaArgsFromPluginOptions = (options) => {
85
111
  const javaArgs = [];
86
112
  // Base
@@ -92,7 +118,7 @@ const javaArgsFromPluginOptions = (options) => {
92
118
  if (options.controlPlaneUrl !== undefined) {
93
119
  javaArgs.push(`-Dgatling.enterprise.controlPlaneUrl=${options.controlPlaneUrl}`);
94
120
  }
95
- javaArgs.push("-Dgatling.enterprise.buildTool=JS_CLI");
121
+ javaArgs.push("-Dgatling.enterprise.buildTool=js-cli");
96
122
  javaArgs.push(`-Dgatling.enterprise.pluginVersion=${versions_1.versions.gatling.jsAdapter}`);
97
123
  if (options.nonInteractive) {
98
124
  javaArgs.push(`-Dgatling.enterprise.batchMode=true`);
@@ -106,9 +132,7 @@ const javaArgsFromDeployOptions = (options) => {
106
132
  javaArgs.push(`-Dgatling.enterprise.packageDescriptorFilename=${options.packageDescriptorFilename}`);
107
133
  // Deployment info
108
134
  javaArgs.push(`-Dgatling.enterprise.packageFile=${options.packageFile}`);
109
- if (process.env.npm_package_name !== undefined) {
110
- javaArgs.push(`-Dgatling.enterprise.artifactId=${process.env.npm_package_name}`);
111
- }
135
+ javaArgs.push(`-Dgatling.enterprise.artifactId=${getPackageNameAndVersion().name}`);
112
136
  return javaArgs;
113
137
  };
114
138
  const enterpriseDeploy = async (options) => {
package/target/index.js CHANGED
@@ -77,20 +77,20 @@ const memoryOption = new commander_1.Option("--memory <value>", "Heap space memo
77
77
  return parsedValue;
78
78
  });
79
79
  const nonInteractiveOption = new commander_1.Option("--non-interactive", "Switch to non-interactive mode and fail if no simulation is explicitly specified").default(false);
80
- const runOptionsArgument = new commander_1.Argument("[optionKey=optionValue...]", "Specify one or more option which can be read in the simulation script with the getOption() function; format must be key=value");
81
- const parseRunOptions = (args) => {
82
- const parsedOptions = {};
80
+ const 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");
81
+ const parseRunParameters = (args) => {
82
+ const parsedParameters = {};
83
83
  for (const arg of args) {
84
84
  const i = arg.indexOf("=");
85
85
  if (i < 0) {
86
- throw Error(`Option '${arg}' is not valid: format should be key=value`);
86
+ throw Error(`Parameter '${arg}' is not valid: format should be key=value`);
87
87
  }
88
88
  else {
89
89
  const key = arg.slice(0, i).trim();
90
- parsedOptions[key] = arg.slice(i + 1);
90
+ parsedParameters[key] = arg.slice(i + 1);
91
91
  }
92
92
  }
93
- return parsedOptions;
93
+ return parsedParameters;
94
94
  };
95
95
  program
96
96
  .command("install")
@@ -126,7 +126,7 @@ program
126
126
  .addOption(resourcesFolderOption)
127
127
  .addOption(resultsFolderOption)
128
128
  .addOption(memoryOption)
129
- .addArgument(runOptionsArgument)
129
+ .addArgument(runParametersArgument)
130
130
  .action(async (args, options) => {
131
131
  const graalvmHome = options.graalvmHome;
132
132
  const jvmClasspath = options.jvmClasspath;
@@ -135,7 +135,7 @@ program
135
135
  const resourcesFolder = options.resourcesFolder;
136
136
  const resultsFolder = options.resultsFolder;
137
137
  const memory = options.memory;
138
- const runOptions = parseRunOptions(args);
138
+ const runParameters = parseRunParameters(args);
139
139
  await (0, run_1.runSimulation)({
140
140
  graalvmHome,
141
141
  jvmClasspath,
@@ -144,7 +144,7 @@ program
144
144
  resourcesFolder,
145
145
  resultsFolder,
146
146
  memory,
147
- runOptions
147
+ runParameters
148
148
  });
149
149
  });
150
150
  program
@@ -159,7 +159,7 @@ program
159
159
  .addOption(gatlingHomeOption)
160
160
  .addOption(memoryOption)
161
161
  .addOption(nonInteractiveOption)
162
- .addArgument(runOptionsArgument)
162
+ .addArgument(runParametersArgument)
163
163
  .action(async (args, options) => {
164
164
  const gatlingHome = gatlingHomeDirWithDefaults(options);
165
165
  const sourcesFolder = options.sourcesFolder;
@@ -168,7 +168,7 @@ program
168
168
  const resultsFolder = options.resultsFolder;
169
169
  const memory = options.memory;
170
170
  const nonInteractive = options.nonInteractive;
171
- const runOptions = parseRunOptions(args);
171
+ const runParameters = parseRunParameters(args);
172
172
  const simulations = await (0, simulations_1.findSimulations)(sourcesFolder);
173
173
  const typescript = typescriptWithDefaults(options, simulations);
174
174
  const simulation = simulationWithDefaults(options, simulations, !nonInteractive);
@@ -185,7 +185,7 @@ program
185
185
  resourcesFolder,
186
186
  resultsFolder,
187
187
  memory,
188
- runOptions
188
+ runParameters
189
189
  });
190
190
  });
191
191
  program
package/target/run.d.ts CHANGED
@@ -5,7 +5,7 @@ export interface RunSimulationOptions extends RunJavaProcessOptions {
5
5
  resourcesFolder: string;
6
6
  resultsFolder: string;
7
7
  memory?: number;
8
- runOptions: Record<string, string>;
8
+ runParameters: Record<string, string>;
9
9
  }
10
10
  export interface RunRecorderOptions extends RunJavaProcessOptions {
11
11
  sourcesFolder: string;
package/target/run.js CHANGED
@@ -13,7 +13,7 @@ const runSimulation = async (options) => {
13
13
  const additionalClasspathElements = [options.resourcesFolder];
14
14
  const memoryArgs = options.memory !== undefined ? [`-Xms${options.memory}M`, `-Xmx${options.memory}M`] : [];
15
15
  const javaArgs = [
16
- ...Object.entries(options.runOptions).map(([key, value]) => `-D${key}=${value}`),
16
+ ...Object.entries(options.runParameters).map(([key, value]) => `-D${key}=${value}`),
17
17
  `-Dgatling.js.bundle.filePath=${options.bundleFile}`,
18
18
  `-Dgatling.js.simulation=${options.simulation}`,
19
19
  ...memoryArgs