@gatling.io/cli 3.13.103 → 3.13.104-M11

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 +7 -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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gatling.io/cli",
3
- "version": "3.13.103",
3
+ "version": "3.13.104-M11",
4
4
  "license": "Apache-2.0",
5
5
  "homepage": "https://gatling.io",
6
6
  "repository": "github:gatling/gatling-js",
@@ -25,22 +25,22 @@
25
25
  "dependencies": {
26
26
  "@jspm/core": "2.1.0",
27
27
  "archiver": "7.0.1",
28
- "axios": "1.7.7",
28
+ "node-stream-zip": "1.15.0",
29
29
  "commander": "12.1.0",
30
- "decompress": "4.2.1",
31
30
  "esbuild": "0.24.0",
32
31
  "esbuild-plugin-tsc": "0.4.0",
33
32
  "import-meta-resolve": "4.1.0",
33
+ "make-fetch-happen": "14.0.3",
34
34
  "readline-sync": "1.4.10"
35
35
  },
36
36
  "devDependencies": {
37
37
  "@types/archiver": "6.0.3",
38
- "@types/decompress": "4.2.7",
39
- "@types/node": "18.19.64",
38
+ "@types/make-fetch-happen": "10.0.4",
39
+ "@types/node": "18.19.67",
40
40
  "@types/readline-sync": "1.4.8",
41
- "prettier": "3.3.3",
41
+ "prettier": "3.4.1",
42
42
  "rimraf": "6.0.1",
43
- "typescript": "5.6.3"
43
+ "typescript": "5.7.2"
44
44
  },
45
45
  "scripts": {
46
46
  "clean": "rimraf target",
@@ -15,13 +15,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
15
15
  }) : function(o, v) {
16
16
  o["default"] = v;
17
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
- };
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
25
35
  var __importDefault = (this && this.__importDefault) || function (mod) {
26
36
  return (mod && mod.__esModule) ? mod : { "default": mod };
27
37
  };
@@ -43,7 +43,7 @@ exports.default = (program) => {
43
43
  const nonInteractive = (0, options_1.nonInteractiveOptionValue)(options);
44
44
  const packageDescriptorFilename = (0, options_1.packageDescriptorFilenameOptionValue)(options);
45
45
  const packageFile = (0, options_1.packageFileOptionValue)(options);
46
- const { graalvmHome, jvmClasspath } = await (0, dependencies_1.installGatlingJs)({ gatlingHome });
46
+ const { graalvmHome, jvmClasspath } = await (0, dependencies_1.resolveBundle)({ gatlingHome });
47
47
  await (0, bundle_1.bundle)({ sourcesFolder, bundleFile, postman, typescript, simulations });
48
48
  await (0, enterprise_1.enterprisePackage)({ bundleFile, resourcesFolder, packageFile, simulations });
49
49
  await (0, enterprise_1.enterpriseDeploy)({
@@ -55,7 +55,7 @@ exports.default = (program) => {
55
55
  if ((0, options_1.nonInteractiveOptionValue)(options) && enterpriseSimulation === undefined) {
56
56
  throw new Error(`No simulation specified when using non-interactive mode`);
57
57
  }
58
- const { graalvmHome, jvmClasspath } = await (0, dependencies_1.installGatlingJs)({ gatlingHome });
58
+ const { graalvmHome, jvmClasspath } = await (0, dependencies_1.resolveBundle)({ gatlingHome });
59
59
  await (0, bundle_1.bundle)({ sourcesFolder, bundleFile, postman, typescript, simulations });
60
60
  await (0, enterprise_1.enterprisePackage)({ bundleFile, resourcesFolder, packageFile, simulations });
61
61
  await (0, enterprise_1.enterpriseStart)({
@@ -8,11 +8,13 @@ exports.default = (program) => {
8
8
  .command("install")
9
9
  .description("Install all required components and dependencies for Gatling")
10
10
  .addOption(options_1.gatlingHomeOption)
11
- .action(async (options) => {
11
+ .addArgument(options_1.bundleFileArgument)
12
+ .action(async (bundleFilePath, options) => {
12
13
  const gatlingHome = (0, options_1.gatlingHomeOptionValueWithDefaults)(options);
13
- const { graalvmHome, coursierBinary, jvmClasspath } = await (0, dependencies_1.installGatlingJs)({ gatlingHome });
14
+ const { graalvmHome, jvmClasspath } = bundleFilePath !== undefined
15
+ ? await (0, dependencies_1.installBundleFile)({ gatlingHome, bundleFilePath })
16
+ : await (0, dependencies_1.resolveBundle)({ gatlingHome });
14
17
  log_1.logger.info(`graalvmHome=${graalvmHome}`);
15
- log_1.logger.info(`coursierBinary=${coursierBinary}`);
16
18
  log_1.logger.info(`jvmClasspath=${jvmClasspath}`);
17
19
  });
18
20
  };
@@ -30,6 +30,7 @@ export declare const postmanOption: Option;
30
30
  export declare const postmanOptionValueWithDefaults: (options: any) => string | undefined;
31
31
  export declare const runParametersArgument: Argument;
32
32
  export declare const parseRunParametersArgument: (args: string[]) => Record<string, string>;
33
+ export declare const bundleFileArgument: Argument;
33
34
  export declare const apiUrlOption: Option;
34
35
  export declare const apiUrlOptionValue: (options: any) => string;
35
36
  export declare const webAppUrlOption: Option;
@@ -3,7 +3,7 @@ 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.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;
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.bundleFileArgument = 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
7
  const commander_1 = require("commander");
8
8
  const fs_1 = __importDefault(require("fs"));
9
9
  const os_1 = __importDefault(require("os"));
@@ -55,7 +55,7 @@ const getNumberValueOptional = (option) => (options) => {
55
55
  throw Error(`Expected type number|undefined for attribute ${option.attributeName()}, got ${typeof value} - please report this as a bug.`);
56
56
  }
57
57
  };
58
- exports.gatlingHomeOption = new commander_1.Option("--gatling-home <value>", 'The folder used to download and install Gatling components (default: "~/.gatling")');
58
+ exports.gatlingHomeOption = new commander_1.Option("--gatling-home <value>", 'The folder used to download and install Gatling components (default: "<user home>/.gatling")');
59
59
  const gatlingHomeOptionValueWithDefaults = (options) => getStringValueOptional(exports.gatlingHomeOption)(options) || `${os_1.default.homedir()}/.gatling`;
60
60
  exports.gatlingHomeOptionValueWithDefaults = gatlingHomeOptionValueWithDefaults;
61
61
  exports.sourcesFolderOption = new commander_1.Option("--sources-folder <value>", "The sources folder path").default("src");
@@ -187,6 +187,7 @@ const parseRunParametersArgument = (args) => {
187
187
  return parsedParameters;
188
188
  };
189
189
  exports.parseRunParametersArgument = parseRunParametersArgument;
190
+ exports.bundleFileArgument = new commander_1.Argument("[bundleFile]", "Specify the path to a Gatling JS bundle file to install; if not specified, bundle will be downloaded automatically");
190
191
  exports.apiUrlOption = new commander_1.Option("--apiUrl <value>", "URL of the Gatling Enterprise API")
191
192
  .default("https://api.gatling.io")
192
193
  .hideHelp();
@@ -19,9 +19,8 @@ exports.default = (program) => {
19
19
  const resourcesFolder = (0, options_1.resourcesFolderOptionValue)(options);
20
20
  const simulations = await (0, simulations_1.findSimulations)(sourcesFolder);
21
21
  const typescript = (0, options_1.typescriptOptionValueWithDefaults)(options, simulations);
22
- const { graalvmHome, coursierBinary, jvmClasspath } = await (0, dependencies_1.installRecorder)({ gatlingHome });
22
+ const { graalvmHome, jvmClasspath } = await (0, dependencies_1.resolveBundle)({ gatlingHome });
23
23
  log_1.logger.debug(`graalvmHome=${graalvmHome}`);
24
- log_1.logger.debug(`coursierBinary=${coursierBinary}`);
25
24
  log_1.logger.debug(`jvmClasspath=${jvmClasspath}`);
26
25
  await (0, run_1.runRecorder)({ graalvmHome, jvmClasspath, sourcesFolder, typescript, resourcesFolder });
27
26
  });
@@ -34,9 +34,8 @@ exports.default = (program) => {
34
34
  const simulations = await (0, simulations_1.findSimulations)(sourcesFolder);
35
35
  const typescript = (0, options_1.typescriptOptionValueWithDefaults)(options, simulations);
36
36
  const simulation = (0, options_1.simulationOptionValueWithDefaults)(options, simulations, !nonInteractive);
37
- const { graalvmHome, coursierBinary, jvmClasspath } = await (0, dependencies_1.installGatlingJs)({ gatlingHome, postman });
37
+ const { graalvmHome, jvmClasspath } = await (0, dependencies_1.resolveBundle)({ gatlingHome });
38
38
  log_1.logger.debug(`graalvmHome=${graalvmHome}`);
39
- log_1.logger.debug(`coursierBinary=${coursierBinary}`);
40
39
  log_1.logger.debug(`jvmClasspath=${jvmClasspath}`);
41
40
  await (0, bundle_1.bundle)({ sourcesFolder, bundleFile, postman, typescript, simulations });
42
41
  await (0, run_1.runSimulation)({
@@ -4,13 +4,28 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.downloadFile = void 0;
7
- const axios_1 = __importDefault(require("axios"));
7
+ const make_fetch_happen_1 = __importDefault(require("make-fetch-happen"));
8
8
  const fs_1 = __importDefault(require("fs"));
9
- const stream_1 = __importDefault(require("stream"));
10
9
  const util_1 = __importDefault(require("util"));
10
+ const stream_1 = __importDefault(require("stream"));
11
11
  const pipeline = util_1.default.promisify(stream_1.default.pipeline);
12
+ const NPM_CONFIG_PROXY_KEY = "npm_config_proxy";
13
+ const NPM_CONFIG_HTTPS_PROXY_KEY = "npm_config_https_proxy";
14
+ const NPM_CONFIG_NOPROXY_KEY = "npm_config_noproxy";
15
+ const fetchOptionsFromNpmConfiguration = () => {
16
+ const proxy = process.env[NPM_CONFIG_HTTPS_PROXY_KEY] || process.env[NPM_CONFIG_PROXY_KEY] || undefined;
17
+ const noProxy = process.env[NPM_CONFIG_NOPROXY_KEY] || undefined;
18
+ return {
19
+ proxy,
20
+ noProxy
21
+ };
22
+ };
12
23
  const downloadFile = async (url, targetFile) => {
13
- const request = await axios_1.default.get(url, { responseType: "stream" });
14
- await pipeline(request.data, fs_1.default.createWriteStream(targetFile));
24
+ const options = fetchOptionsFromNpmConfiguration();
25
+ const response = await (0, make_fetch_happen_1.default)(url, options);
26
+ if (!response.ok) {
27
+ throw new Error(`Failed to fetch: ${response.status} ${response.statusText}`);
28
+ }
29
+ await pipeline(response.body, fs_1.default.createWriteStream(targetFile));
15
30
  };
16
31
  exports.downloadFile = downloadFile;
@@ -1,12 +1,13 @@
1
1
  export { versions } from "./versions";
2
- export interface DependenciesOptions {
2
+ export interface BundleOptions {
3
3
  gatlingHome: string;
4
- postman?: string;
5
4
  }
6
- export interface ResolvedDependencies {
5
+ export interface BundleInstallOptions extends BundleOptions {
6
+ bundleFilePath: string;
7
+ }
8
+ export interface ResolvedBundle {
7
9
  graalvmHome: string;
8
- coursierBinary: string;
9
10
  jvmClasspath: string;
10
11
  }
11
- export declare const installGatlingJs: (options: DependenciesOptions) => Promise<ResolvedDependencies>;
12
- export declare const installRecorder: (options: DependenciesOptions) => Promise<ResolvedDependencies>;
12
+ export declare const installBundleFile: (options: BundleInstallOptions) => Promise<ResolvedBundle>;
13
+ export declare const resolveBundle: (options: BundleOptions) => Promise<ResolvedBundle>;
@@ -1,37 +1,145 @@
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 () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
2
35
  var __importDefault = (this && this.__importDefault) || function (mod) {
3
36
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
37
  };
5
38
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.installRecorder = exports.installGatlingJs = exports.versions = void 0;
7
- const promises_1 = __importDefault(require("fs/promises"));
8
- const coursier_1 = require("./coursier");
9
- const graalVm_1 = require("./graalVm");
10
- var versions_1 = require("./versions");
11
- Object.defineProperty(exports, "versions", { enumerable: true, get: function () { return versions_1.versions; } });
12
- const installGatlingJs = async (options) => {
13
- const downloadDir = `${options.gatlingHome}/tmp/download`;
14
- await promises_1.default.mkdir(downloadDir, { recursive: true });
15
- const graalvmHomePath = await (0, graalVm_1.installGraalVm)(options.gatlingHome, downloadDir);
16
- const coursierPath = await (0, coursier_1.installCoursier)(options.gatlingHome, downloadDir);
17
- const classpath = await (0, coursier_1.resolveGatlingJsDependencies)(coursierPath, graalvmHomePath, options.postman);
18
- return {
19
- graalvmHome: graalvmHomePath,
20
- coursierBinary: coursierPath,
21
- jvmClasspath: classpath.trim()
22
- };
39
+ exports.resolveBundle = exports.installBundleFile = exports.versions = void 0;
40
+ const fsSync = __importStar(require("node:fs"));
41
+ const promises_1 = __importDefault(require("node:fs/promises"));
42
+ const node_path_1 = __importDefault(require("node:path"));
43
+ const node_stream_zip_1 = __importDefault(require("node-stream-zip"));
44
+ const download_1 = require("./download");
45
+ const log_1 = require("../log");
46
+ const os_1 = require("./os");
47
+ const versions_1 = require("./versions");
48
+ var versions_2 = require("./versions");
49
+ Object.defineProperty(exports, "versions", { enumerable: true, get: function () { return versions_2.versions; } });
50
+ const installBundleFile = async (options) => {
51
+ log_1.logger.info(`bundleFilePath: ${options.bundleFilePath}`);
52
+ const zip = new node_stream_zip_1.default.async({ file: options.bundleFilePath });
53
+ const metadata = await zip.entryData(metadataFileName);
54
+ const { version } = JSON.parse(metadata.toString("utf-8"));
55
+ if (version === versions_1.versions.gatling.jsAdapter) {
56
+ log_1.logger.info(`Installing dependencies bundle for Gatling JS ${version}, which is the current version`);
57
+ }
58
+ else {
59
+ log_1.logger.info(`Installing dependencies bundle for Gatling JS ${version}, which is not the current version (${versions_1.versions.gatling.jsAdapter})`);
60
+ }
61
+ const bundlePath = getBundlePath(options, version);
62
+ if (await canReadPath(bundlePath)) {
63
+ throw Error(`Directory ${bundlePath} already exists`);
64
+ }
65
+ await promises_1.default.mkdir(bundlePath, { recursive: true });
66
+ await zip.extract(null, bundlePath);
67
+ if (os_1.osType !== "Windows_NT") {
68
+ const graalVmBinDir = node_path_1.default.join(bundlePath, "graalvm", "bin");
69
+ const binFiles = await promises_1.default.readdir(graalVmBinDir);
70
+ for (const binFile of binFiles) {
71
+ await promises_1.default.chmod(node_path_1.default.join(graalVmBinDir, binFile), 0o744); // chmod +x
72
+ }
73
+ }
74
+ log_1.logger.info(`Gatling JS dependencies bundle installed in ${bundlePath}`);
75
+ return getResolvedBundle(bundlePath);
23
76
  };
24
- exports.installGatlingJs = installGatlingJs;
25
- const installRecorder = async (options) => {
26
- const downloadDir = `${options.gatlingHome}/tmp/download`;
27
- await promises_1.default.mkdir(downloadDir, { recursive: true });
28
- const graalvmHomePath = await (0, graalVm_1.installGraalVm)(options.gatlingHome, downloadDir);
29
- const coursierPath = await (0, coursier_1.installCoursier)(options.gatlingHome, downloadDir);
30
- const classpath = await (0, coursier_1.resolveRecorderDependencies)(coursierPath, graalvmHomePath);
31
- return {
32
- graalvmHome: graalvmHomePath,
33
- coursierBinary: coursierPath,
34
- jvmClasspath: classpath.trim()
35
- };
77
+ exports.installBundleFile = installBundleFile;
78
+ const resolveBundle = async (options) => {
79
+ const bundlePath = getBundlePath(options, versions_1.versions.gatling.jsAdapter);
80
+ if (await canReadPath(bundlePath)) {
81
+ // Basic check of the installed bundle we found
82
+ const bundleMetadataPath = node_path_1.default.join(bundlePath, metadataFileName);
83
+ let version = "";
84
+ try {
85
+ const f = await promises_1.default.readFile(bundleMetadataPath, { encoding: "utf-8" });
86
+ const metadata = JSON.parse(f);
87
+ version = metadata.version;
88
+ }
89
+ catch { }
90
+ if (version !== versions_1.versions.gatling.jsAdapter) {
91
+ throw Error(`Inconsistent bundle content found at ${bundlePath}`);
92
+ }
93
+ return getResolvedBundle(bundlePath);
94
+ }
95
+ else {
96
+ return await downloadAndInstallBundle(options);
97
+ }
98
+ };
99
+ exports.resolveBundle = resolveBundle;
100
+ const getBundlePath = (options, version) => node_path_1.default.join(options.gatlingHome, "gatling-js-bundle", version);
101
+ const metadataFileName = "gatling-bundle.json";
102
+ const canReadPath = async (path) => {
103
+ try {
104
+ await promises_1.default.access(path, promises_1.default.constants.R_OK);
105
+ return true;
106
+ }
107
+ catch (e) {
108
+ if (e.code === "ENOENT") {
109
+ return false;
110
+ }
111
+ else {
112
+ throw e;
113
+ }
114
+ }
115
+ };
116
+ const getResolvedBundle = (bundlePath) => ({
117
+ graalvmHome: node_path_1.default.join(bundlePath, "graalvm"),
118
+ jvmClasspath: node_path_1.default.join(bundlePath, "lib", "java", "*")
119
+ });
120
+ const downloadAndInstallBundle = async (options) => {
121
+ const tmpFolder = node_path_1.default.join(options.gatlingHome, "tmp");
122
+ if (!fsSync.existsSync(tmpFolder)) {
123
+ await promises_1.default.mkdir(tmpFolder);
124
+ }
125
+ const tmpFile = node_path_1.default.join(tmpFolder, "bundle-download.zip");
126
+ if (fsSync.existsSync(tmpFile)) {
127
+ await promises_1.default.rm(tmpFile);
128
+ }
129
+ const version = versions_1.versions.gatling.jsAdapter;
130
+ const url = `https://github.com/gatling/gatling-js/releases/download/v${version}/gatling-js-bundle-${version}-${os_1.osType}-${os_1.osArch}.zip`;
131
+ try {
132
+ log_1.logger.info(`Downloading bundle file from ${url} to temporary file ${tmpFile}`);
133
+ await (0, download_1.downloadFile)(url, tmpFile);
134
+ const resolvedBundle = await (0, exports.installBundleFile)({ ...options, bundleFilePath: tmpFile });
135
+ log_1.logger.info(`Deleting temporary file ${tmpFile}`);
136
+ await promises_1.default.rm(tmpFile);
137
+ return resolvedBundle;
138
+ }
139
+ catch (e) {
140
+ log_1.logger.error(`Failed to automatically download and install the Gatling dependency bundle. You can try to:
141
+ 1. Make sure you have access to https://github.com/gatling/gatling-js/releases/; and if you connect to the Internet through a proxy, make sure it is configured in your NPM configuration file (.npmrc).
142
+ 2. Alternatively, you can try manually downloading the file from ${url}, and install it with the command 'npx gatling install <path-to-downloaded-file.zip>'.`);
143
+ throw e;
144
+ }
36
145
  };
37
- exports.installRecorder = installRecorder;
@@ -6,7 +6,6 @@ export declare const versions: {
6
6
  java: {
7
7
  compilerRelease: string;
8
8
  };
9
- coursier: string;
10
9
  gatling: {
11
10
  core: string;
12
11
  enterprisePluginCommons: string;
@@ -3,16 +3,15 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.versions = void 0;
4
4
  exports.versions = {
5
5
  graalvm: {
6
- jdk: "23.0.0",
6
+ jdk: "23.0.1",
7
7
  js: "24.1.1"
8
8
  },
9
9
  java: {
10
10
  compilerRelease: "21"
11
11
  },
12
- coursier: "2.1.12",
13
12
  gatling: {
14
13
  core: "3.13.1",
15
- enterprisePluginCommons: "1.9.8",
16
- jsAdapter: "3.13.103"
14
+ enterprisePluginCommons: "1.11.0",
15
+ jsAdapter: "3.13.104-M11"
17
16
  }
18
17
  };
@@ -1,43 +0,0 @@
1
- import * as esbuild from "esbuild";
2
- import esbuildPluginTsc from "esbuild-plugin-tsc";
3
-
4
- import { polyfill } from "./polyfill";
5
- import { SimulationFile } from "../simulations";
6
- import { logger } from "../log";
7
-
8
- export interface BundleOptions {
9
- sourcesFolder: string;
10
- bundleFile: string;
11
- postman?: string;
12
- typescript: boolean;
13
- simulations: SimulationFile[];
14
- }
15
-
16
- export const bundle = async (options: BundleOptions): Promise<void> => {
17
- logger.info(`Bundling a Gatling simulation with options:
18
- - sourcesFolder: ${options.sourcesFolder}
19
- - bundleFile: ${options.bundleFile}
20
- - typescript: ${options.typescript}`);
21
-
22
- const contents = options.simulations.map((s) => `export { default as "${s.name}" } from "./${s.path}";`).join("\n");
23
-
24
- const plugins = options.typescript ? [esbuildPluginTsc({ force: true })] : [];
25
- if (options.postman !== undefined) {
26
- plugins.push(polyfill());
27
- }
28
- await esbuild.build({
29
- stdin: {
30
- contents,
31
- resolveDir: options.sourcesFolder
32
- },
33
- outfile: options.bundleFile,
34
- platform: "neutral",
35
- mainFields: ["main", "module"],
36
- bundle: true,
37
- minify: false,
38
- sourcemap: true,
39
- format: "iife",
40
- globalName: "gatling",
41
- plugins
42
- });
43
- };
@@ -1,91 +0,0 @@
1
- import type { Plugin } from "esbuild";
2
- import { fileURLToPath, pathToFileURL } from "url";
3
- import { resolve, dirname } from "path";
4
-
5
- // This is largely inspired by https://github.com/cyco130/esbuild-plugin-polyfill-node
6
-
7
- export const polyfill = (): Plugin => ({
8
- name: "gatling-js-polyfill",
9
- setup: async (build) => {
10
- // modules
11
- const jspmResolved = await resolveImport(`@jspm/core/nodelibs/fs`);
12
- build.onResolve({ filter: polyfillsFilter }, async ({ path }) => {
13
- const [, , moduleName] = path.match(polyfillsFilter)!;
14
- const resolved = customPolyfills.find((name) => name === moduleName)
15
- ? resolve(dirname(__filename), `../../polyfills/${moduleName}.js`)
16
- : resolve(jspmResolved, `../../browser/${moduleName}.js`);
17
- return { path: resolved };
18
- });
19
-
20
- // Globals
21
- build.initialOptions.inject = build.initialOptions.inject || [];
22
- const injectGlobal = (name: string) =>
23
- (build.initialOptions.inject as string[]).push(resolve(dirname(__filename), `../../polyfills/${name}.js`));
24
- injectGlobal("global");
25
- }
26
- });
27
-
28
- const customPolyfills = ["crypto"];
29
-
30
- const jspmPolyfills = ["buffer", "path", "string_decoder"];
31
-
32
- // Other available jspm-core modules:
33
- // "_stream_duplex"
34
- // "_stream_passthrough"
35
- // "_stream_readable"
36
- // "_stream_transform"
37
- // "_stream_writable"
38
- // "assert"
39
- // "assert/strict"
40
- // "async_hooks"
41
- // "child_process"
42
- // "cluster"
43
- // "console"
44
- // "constants"
45
- // "crypto"
46
- // "dgram"
47
- // "diagnostics_channel"
48
- // "dns"
49
- // "domain"
50
- // "events"
51
- // "fs"
52
- // "fs/promises"
53
- // "http"
54
- // "http2"
55
- // "https"
56
- // "module"
57
- // "net"
58
- // "os"
59
- // "perf_hooks"
60
- // "process"
61
- // "punycode"
62
- // "querystring"
63
- // "readline"
64
- // "repl"
65
- // "stream"
66
- // "sys"
67
- // "timers"
68
- // "timers/promises"
69
- // "tls"
70
- // "tty"
71
- // "url"
72
- // "util"
73
- // "v8"
74
- // "vm"
75
- // "wasi"
76
- // "worker_threads"
77
- // "zlib"
78
-
79
- const polyfillsFilter = new RegExp(`^(node:)?(${jspmPolyfills.concat(customPolyfills).join("|")})$`);
80
-
81
- let importMetaResolve: (specifier: string, parent: string) => string;
82
-
83
- const importMetaUrl = pathToFileURL(__filename).href;
84
-
85
- const resolveImport = async (specifier: string) => {
86
- if (!importMetaResolve) {
87
- importMetaResolve = (await import("import-meta-resolve")).resolve;
88
- }
89
- const resolved = importMetaResolve(specifier, importMetaUrl);
90
- return fileURLToPath(resolved);
91
- };
@@ -1,34 +0,0 @@
1
- import { Command } from "commander";
2
-
3
- import {
4
- bundleFileOption,
5
- bundleFileOptionValue,
6
- postmanOption,
7
- postmanOptionValueWithDefaults,
8
- sourcesFolderOption,
9
- sourcesFolderOptionValue,
10
- typescriptOption,
11
- typescriptOptionValueWithDefaults
12
- } from "./options";
13
- import { findSimulations } from "../simulations";
14
- import { bundle } from "../bundle";
15
-
16
- export default (program: Command): void => {
17
- program
18
- .command("build")
19
- .description("Build Gatling simulations")
20
- .addOption(sourcesFolderOption)
21
- .addOption(bundleFileOption)
22
- .addOption(postmanOption)
23
- .addOption(typescriptOption)
24
- .action(async (options) => {
25
- const sourcesFolder: string = sourcesFolderOptionValue(options);
26
- const bundleFile = bundleFileOptionValue(options);
27
-
28
- const simulations = await findSimulations(sourcesFolder);
29
- const postman = postmanOptionValueWithDefaults(options);
30
- const typescript = typescriptOptionValueWithDefaults(options, simulations);
31
-
32
- await bundle({ sourcesFolder, bundleFile, postman, typescript, simulations });
33
- });
34
- };