@memlab/cli 1.0.17 → 1.0.19

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 (47) hide show
  1. package/dist/options/DebugOption.js +6 -2
  2. package/dist/options/HelperOption.js +6 -2
  3. package/dist/options/MLClusteringLinkageMaxDistanceOption.js +9 -3
  4. package/dist/options/MLClusteringMaxDFOption.js +9 -3
  5. package/dist/options/MLClusteringOption.js +7 -2
  6. package/dist/options/NumberOfRunsOption.js +5 -1
  7. package/dist/options/SetContinuousTestOption.js +7 -2
  8. package/dist/options/SetWorkingDirectoryOption.js +5 -1
  9. package/dist/options/SilentOption.js +6 -2
  10. package/dist/options/VerboseOption.js +6 -2
  11. package/dist/options/constant.d.ts +50 -0
  12. package/dist/options/constant.js +52 -0
  13. package/dist/options/e2e/AppOption.js +9 -5
  14. package/dist/options/e2e/DisableWebSecurityOption.js +5 -1
  15. package/dist/options/e2e/DisableXvfbOption.js +6 -2
  16. package/dist/options/e2e/EnableJSInterceptOption.d.ts +18 -0
  17. package/dist/options/e2e/EnableJSInterceptOption.js +42 -0
  18. package/dist/options/e2e/EnableJSRewriteOption.js +8 -1
  19. package/dist/options/e2e/FullExecutionOption.js +6 -2
  20. package/dist/options/e2e/HeadfulBrowserOption.js +5 -1
  21. package/dist/options/e2e/InteractionOption.js +9 -5
  22. package/dist/options/e2e/RemoteBrowserDebugOption.js +6 -2
  23. package/dist/options/e2e/RunningModeOption.js +6 -2
  24. package/dist/options/e2e/ScenarioFileOption.js +9 -3
  25. package/dist/options/e2e/SetDeviceOption.js +9 -3
  26. package/dist/options/e2e/SetUserAgentOption.js +5 -1
  27. package/dist/options/e2e/SkipExtraOperationOption.js +7 -2
  28. package/dist/options/e2e/SkipGCOption.js +5 -1
  29. package/dist/options/e2e/SkipScreenshotOption.js +6 -2
  30. package/dist/options/e2e/SkipScrollOption.js +6 -2
  31. package/dist/options/e2e/SkipSnapshotOption.js +6 -2
  32. package/dist/options/e2e/SkipWarmupOption.js +5 -1
  33. package/dist/options/heap/BaselineFileOption.js +5 -3
  34. package/dist/options/heap/FinalFileOption.js +5 -3
  35. package/dist/options/heap/HeapNodeIdOption.js +5 -1
  36. package/dist/options/heap/JSEngineOption.js +8 -3
  37. package/dist/options/heap/LeakClusterSizeThresholdOption.js +5 -1
  38. package/dist/options/heap/LogTraceAsClusterOption.js +5 -1
  39. package/dist/options/heap/OversizeThresholdOption.js +5 -1
  40. package/dist/options/heap/SnapshotDirectoryOption.js +5 -3
  41. package/dist/options/heap/SnapshotFileOption.js +5 -3
  42. package/dist/options/heap/TargetFileOption.js +5 -3
  43. package/dist/options/heap/TraceAllObjectsOption.js +5 -1
  44. package/dist/options/heap/leak-filter/LeakFilterFileOption.js +5 -1
  45. package/dist/options/lib/OptionConstant.d.ts +116 -0
  46. package/dist/options/lib/OptionConstant.js +67 -0
  47. package/package.json +1 -1
@@ -17,18 +17,22 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
17
17
  step((generator = generator.apply(thisArg, _arguments || [])).next());
18
18
  });
19
19
  };
20
+ var __importDefault = (this && this.__importDefault) || function (mod) {
21
+ return (mod && mod.__esModule) ? mod : { "default": mod };
22
+ };
20
23
  Object.defineProperty(exports, "__esModule", { value: true });
21
24
  const core_1 = require("@memlab/core");
25
+ const OptionConstant_1 = __importDefault(require("./lib/OptionConstant"));
22
26
  class DebugOption extends core_1.BaseOption {
23
27
  getOptionName() {
24
- return 'debug';
28
+ return OptionConstant_1.default.optionNames.DEBUG;
25
29
  }
26
30
  getDescription() {
27
31
  return 'enable manual debugging';
28
32
  }
29
33
  parse(config, args) {
30
34
  return __awaiter(this, void 0, void 0, function* () {
31
- if (args['debug']) {
35
+ if (args[this.getOptionName()]) {
32
36
  config.isManualDebug = true;
33
37
  }
34
38
  });
@@ -17,14 +17,18 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
17
17
  step((generator = generator.apply(thisArg, _arguments || [])).next());
18
18
  });
19
19
  };
20
+ var __importDefault = (this && this.__importDefault) || function (mod) {
21
+ return (mod && mod.__esModule) ? mod : { "default": mod };
22
+ };
20
23
  Object.defineProperty(exports, "__esModule", { value: true });
21
24
  const core_1 = require("@memlab/core");
25
+ const OptionConstant_1 = __importDefault(require("./lib/OptionConstant"));
22
26
  class HelperOption extends core_1.BaseOption {
23
27
  getOptionName() {
24
- return 'help';
28
+ return OptionConstant_1.default.optionNames.HELP;
25
29
  }
26
30
  getOptionShortcut() {
27
- return 'h';
31
+ return OptionConstant_1.default.optionShortcuts.H;
28
32
  }
29
33
  getDescription() {
30
34
  return 'print helper text';
@@ -17,20 +17,26 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
17
17
  step((generator = generator.apply(thisArg, _arguments || [])).next());
18
18
  });
19
19
  };
20
+ var __importDefault = (this && this.__importDefault) || function (mod) {
21
+ return (mod && mod.__esModule) ? mod : { "default": mod };
22
+ };
20
23
  Object.defineProperty(exports, "__esModule", { value: true });
21
24
  const core_1 = require("@memlab/core");
22
25
  const core_2 = require("@memlab/core");
26
+ const OptionConstant_1 = __importDefault(require("./lib/OptionConstant"));
23
27
  class MLClusteringLinkageMaxDistanceOption extends core_2.BaseOption {
24
28
  getOptionName() {
25
- return 'ml-linkage-max-dist';
29
+ return OptionConstant_1.default.optionNames.ML_LINKAGE_MAX_DIST;
26
30
  }
27
31
  getDescription() {
28
32
  return 'set linkage max distance value for clustering. The value should be between [0, 1] inclusive.';
29
33
  }
30
34
  parse(config, args) {
31
35
  return __awaiter(this, void 0, void 0, function* () {
32
- if (args['ml-linkage-max-dist']) {
33
- const linkageMaxDist = args['ml-linkage-max-dist'];
36
+ const name = this.getOptionName();
37
+ const arg = args[name];
38
+ if (arg) {
39
+ const linkageMaxDist = arg;
34
40
  const linkageMaxDistNum = parseFloat(linkageMaxDist);
35
41
  if (!isNaN(linkageMaxDistNum) &&
36
42
  linkageMaxDistNum >= 0 &&
@@ -17,20 +17,26 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
17
17
  step((generator = generator.apply(thisArg, _arguments || [])).next());
18
18
  });
19
19
  };
20
+ var __importDefault = (this && this.__importDefault) || function (mod) {
21
+ return (mod && mod.__esModule) ? mod : { "default": mod };
22
+ };
20
23
  Object.defineProperty(exports, "__esModule", { value: true });
21
24
  const core_1 = require("@memlab/core");
22
25
  const core_2 = require("@memlab/core");
26
+ const OptionConstant_1 = __importDefault(require("./lib/OptionConstant"));
23
27
  class MLClusteringMaxDFOption extends core_2.BaseOption {
24
28
  getOptionName() {
25
- return 'ml-clustering-max-df';
29
+ return OptionConstant_1.default.optionNames.ML_CLUSTERING_MAX_DF;
26
30
  }
27
31
  getDescription() {
28
32
  return 'set percentage based max document frequency for limiting the terms that appear too often';
29
33
  }
30
34
  parse(config, args) {
31
35
  return __awaiter(this, void 0, void 0, function* () {
32
- if (args['ml-clustering-max-df']) {
33
- const clusteringMaxDFStr = args['ml-clustering-max-df'];
36
+ const name = this.getOptionName();
37
+ const arg = args[name];
38
+ if (arg) {
39
+ const clusteringMaxDFStr = arg;
34
40
  const clusteringMaxDF = parseFloat(clusteringMaxDFStr);
35
41
  if (!isNaN(clusteringMaxDF) &&
36
42
  clusteringMaxDF >= 0 &&
@@ -17,18 +17,23 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
17
17
  step((generator = generator.apply(thisArg, _arguments || [])).next());
18
18
  });
19
19
  };
20
+ var __importDefault = (this && this.__importDefault) || function (mod) {
21
+ return (mod && mod.__esModule) ? mod : { "default": mod };
22
+ };
20
23
  Object.defineProperty(exports, "__esModule", { value: true });
21
24
  const core_1 = require("@memlab/core");
25
+ const OptionConstant_1 = __importDefault(require("./lib/OptionConstant"));
22
26
  class MLClusteringOption extends core_1.BaseOption {
23
27
  getOptionName() {
24
- return 'ml-clustering';
28
+ return OptionConstant_1.default.optionNames.ML_CLUSTERING;
25
29
  }
26
30
  getDescription() {
27
31
  return 'use machine learning algorithms for clustering leak traces (by default, traces are clustered by heuristics)';
28
32
  }
29
33
  parse(config, args) {
30
34
  return __awaiter(this, void 0, void 0, function* () {
31
- if (args['ml-clustering']) {
35
+ const name = this.getOptionName();
36
+ if (args[name]) {
32
37
  config.isMLClustering = true;
33
38
  }
34
39
  });
@@ -17,11 +17,15 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
17
17
  step((generator = generator.apply(thisArg, _arguments || [])).next());
18
18
  });
19
19
  };
20
+ var __importDefault = (this && this.__importDefault) || function (mod) {
21
+ return (mod && mod.__esModule) ? mod : { "default": mod };
22
+ };
20
23
  Object.defineProperty(exports, "__esModule", { value: true });
21
24
  const core_1 = require("@memlab/core");
25
+ const OptionConstant_1 = __importDefault(require("./lib/OptionConstant"));
22
26
  class NumberOfRunsOption extends core_1.BaseOption {
23
27
  getOptionName() {
24
- return 'run-num';
28
+ return OptionConstant_1.default.optionNames.RUN_NUM;
25
29
  }
26
30
  getDescription() {
27
31
  return 'set number of runs';
@@ -17,18 +17,23 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
17
17
  step((generator = generator.apply(thisArg, _arguments || [])).next());
18
18
  });
19
19
  };
20
+ var __importDefault = (this && this.__importDefault) || function (mod) {
21
+ return (mod && mod.__esModule) ? mod : { "default": mod };
22
+ };
20
23
  Object.defineProperty(exports, "__esModule", { value: true });
21
24
  const core_1 = require("@memlab/core");
25
+ const OptionConstant_1 = __importDefault(require("./lib/OptionConstant"));
22
26
  class SetContinuousTestOption extends core_1.BaseOption {
23
27
  getOptionName() {
24
- return 'sc';
28
+ return OptionConstant_1.default.optionNames.SC;
25
29
  }
26
30
  getDescription() {
27
31
  return 'set to continuous test mode';
28
32
  }
29
33
  parse(config, args) {
30
34
  return __awaiter(this, void 0, void 0, function* () {
31
- if (args['ContinuousTest'] || args[this.getOptionName()]) {
35
+ if (args[OptionConstant_1.default.optionNames.CONTINUS_TEST] ||
36
+ args[this.getOptionName()]) {
32
37
  config.isContinuousTest = true;
33
38
  }
34
39
  });
@@ -17,11 +17,15 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
17
17
  step((generator = generator.apply(thisArg, _arguments || [])).next());
18
18
  });
19
19
  };
20
+ var __importDefault = (this && this.__importDefault) || function (mod) {
21
+ return (mod && mod.__esModule) ? mod : { "default": mod };
22
+ };
20
23
  Object.defineProperty(exports, "__esModule", { value: true });
21
24
  const core_1 = require("@memlab/core");
25
+ const OptionConstant_1 = __importDefault(require("./lib/OptionConstant"));
22
26
  class SetWorkingDirectoryOption extends core_1.BaseOption {
23
27
  getOptionName() {
24
- return 'work-dir';
28
+ return OptionConstant_1.default.optionNames.WORK_DIR;
25
29
  }
26
30
  getDescription() {
27
31
  return 'set the working directory of the current run';
@@ -17,14 +17,18 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
17
17
  step((generator = generator.apply(thisArg, _arguments || [])).next());
18
18
  });
19
19
  };
20
+ var __importDefault = (this && this.__importDefault) || function (mod) {
21
+ return (mod && mod.__esModule) ? mod : { "default": mod };
22
+ };
20
23
  Object.defineProperty(exports, "__esModule", { value: true });
21
24
  const core_1 = require("@memlab/core");
25
+ const OptionConstant_1 = __importDefault(require("./lib/OptionConstant"));
22
26
  class SilentOption extends core_1.BaseOption {
23
27
  getOptionName() {
24
- return 'silent';
28
+ return OptionConstant_1.default.optionNames.SILENT;
25
29
  }
26
30
  getOptionShortcut() {
27
- return 's';
31
+ return OptionConstant_1.default.optionShortcuts.S;
28
32
  }
29
33
  getDescription() {
30
34
  return 'mute all terminal output';
@@ -17,14 +17,18 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
17
17
  step((generator = generator.apply(thisArg, _arguments || [])).next());
18
18
  });
19
19
  };
20
+ var __importDefault = (this && this.__importDefault) || function (mod) {
21
+ return (mod && mod.__esModule) ? mod : { "default": mod };
22
+ };
20
23
  Object.defineProperty(exports, "__esModule", { value: true });
21
24
  const core_1 = require("@memlab/core");
25
+ const OptionConstant_1 = __importDefault(require("./lib/OptionConstant"));
22
26
  class VerboseOption extends core_1.BaseOption {
23
27
  getOptionName() {
24
- return 'verbose';
28
+ return OptionConstant_1.default.optionNames.VERBOSE;
25
29
  }
26
30
  getOptionShortcut() {
27
- return 'v';
31
+ return OptionConstant_1.default.optionShortcuts.V;
28
32
  }
29
33
  getDescription() {
30
34
  return 'show more details';
@@ -0,0 +1,50 @@
1
+ export declare const OptionNames: {
2
+ DEBUG: string;
3
+ HELP: string;
4
+ ML_LINKAGE_MAX_DIST: string;
5
+ ML_CLUSTERING_MAX_DF: string;
6
+ ML_CLUSTERING: string;
7
+ RUN_NUM: string;
8
+ SC: string;
9
+ CONTINUS_TEST: string;
10
+ WORK_DIR: string;
11
+ SILENT: string;
12
+ VERBOSE: string;
13
+ LEAK_FILTER: string;
14
+ BASELINE: string;
15
+ FINAL: string;
16
+ NODE_ID: string;
17
+ ENGINE: string;
18
+ IGNORE_LEAK_CLUSTER_SIZE_BELOW: string;
19
+ SAVE_TRACE_AS_UNCLASSIFIED_CLUSTER: string;
20
+ TRACE_OBJECT_SIZE_ABOVE: string;
21
+ SNAPSHOT_DIR: string;
22
+ SNAPSHOT: string;
23
+ TARGET: string;
24
+ TRACE_ALL_OBJECTS: string;
25
+ APP: string;
26
+ DISABLE_WEB_SECURITY: string;
27
+ DISABLE_XVFB: string;
28
+ REWRITE_JS: string;
29
+ FULL: string;
30
+ HEADFUL: string;
31
+ INTERACTION: string;
32
+ LOCAL_PUPPETEER: string;
33
+ RUN_MODE: string;
34
+ SCENARIO: string;
35
+ DEVICE: string;
36
+ USER_AGENT: string;
37
+ SKIP_EXTRA_OPS: string;
38
+ SKIP_EXTRA_OP: string;
39
+ SKIP_GC: string;
40
+ SKIP_SCREENSHOT: string;
41
+ SKIP_SCROLL: string;
42
+ SKIP_SNAPSHOT: string;
43
+ SKIP_WARMUP: string;
44
+ };
45
+ export declare const OptionShortcuts: {
46
+ H: string;
47
+ S: string;
48
+ V: string;
49
+ };
50
+ //# sourceMappingURL=constant.d.ts.map
@@ -0,0 +1,52 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.OptionShortcuts = exports.OptionNames = void 0;
4
+ exports.OptionNames = {
5
+ DEBUG: 'debug',
6
+ HELP: 'help',
7
+ ML_LINKAGE_MAX_DIST: 'ml-linkage-max-dist',
8
+ ML_CLUSTERING_MAX_DF: 'ml-clustering-max-df',
9
+ ML_CLUSTERING: 'ml-clustering',
10
+ RUN_NUM: 'run-num',
11
+ SC: 'sc',
12
+ CONTINUS_TEST: 'ContinuousTest',
13
+ WORK_DIR: 'work-dir',
14
+ SILENT: 'silent',
15
+ VERBOSE: 'verbose',
16
+ LEAK_FILTER: 'leak-filter',
17
+ BASELINE: 'baseline',
18
+ FINAL: 'final',
19
+ NODE_ID: 'node-id',
20
+ ENGINE: 'engine',
21
+ IGNORE_LEAK_CLUSTER_SIZE_BELOW: 'ignore-leak-cluster-size-below',
22
+ SAVE_TRACE_AS_UNCLASSIFIED_CLUSTER: 'save-trace-as-unclassified-cluster',
23
+ TRACE_OBJECT_SIZE_ABOVE: 'trace-object-size-above',
24
+ SNAPSHOT_DIR: 'snapshot-dir',
25
+ SNAPSHOT: 'snapshot',
26
+ TARGET: 'target',
27
+ TRACE_ALL_OBJECTS: 'trace-all-objects',
28
+ APP: 'app',
29
+ DISABLE_WEB_SECURITY: 'disable-web-security',
30
+ DISABLE_XVFB: 'disable-xvfb',
31
+ REWRITE_JS: 'rewrite-js',
32
+ FULL: 'full',
33
+ HEADFUL: 'headful',
34
+ INTERACTION: 'interaction',
35
+ LOCAL_PUPPETEER: 'local-puppeteer',
36
+ RUN_MODE: 'run-mode',
37
+ SCENARIO: 'scenario',
38
+ DEVICE: 'device',
39
+ USER_AGENT: 'user-agent',
40
+ SKIP_EXTRA_OPS: 'skip-extra-ops',
41
+ SKIP_EXTRA_OP: 'skip-extra-op',
42
+ SKIP_GC: 'skip-gc',
43
+ SKIP_SCREENSHOT: 'skip-screenshot',
44
+ SKIP_SCROLL: 'skip-scroll',
45
+ SKIP_SNAPSHOT: 'skip-snapshot',
46
+ SKIP_WARMUP: 'skip-warmup',
47
+ };
48
+ exports.OptionShortcuts = {
49
+ H: 'h',
50
+ S: 's',
51
+ V: 'v',
52
+ };
@@ -17,11 +17,15 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
17
17
  step((generator = generator.apply(thisArg, _arguments || [])).next());
18
18
  });
19
19
  };
20
+ var __importDefault = (this && this.__importDefault) || function (mod) {
21
+ return (mod && mod.__esModule) ? mod : { "default": mod };
22
+ };
20
23
  Object.defineProperty(exports, "__esModule", { value: true });
21
24
  const core_1 = require("@memlab/core");
25
+ const OptionConstant_1 = __importDefault(require("../lib/OptionConstant"));
22
26
  class AppOption extends core_1.BaseOption {
23
27
  getOptionName() {
24
- return 'app';
28
+ return OptionConstant_1.default.optionNames.APP;
25
29
  }
26
30
  getDescription() {
27
31
  return 'set name for onboarded web application';
@@ -31,10 +35,10 @@ class AppOption extends core_1.BaseOption {
31
35
  }
32
36
  parse(config, args) {
33
37
  return __awaiter(this, void 0, void 0, function* () {
34
- if (args.app) {
35
- config.targetApp = Array.isArray(args.app)
36
- ? args.app[args.app.length - 1]
37
- : args.app;
38
+ const name = this.getOptionName();
39
+ const arg = args[name];
40
+ if (arg) {
41
+ config.targetApp = Array.isArray(arg) ? arg[arg.length - 1] : arg;
38
42
  }
39
43
  });
40
44
  }
@@ -17,11 +17,15 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
17
17
  step((generator = generator.apply(thisArg, _arguments || [])).next());
18
18
  });
19
19
  };
20
+ var __importDefault = (this && this.__importDefault) || function (mod) {
21
+ return (mod && mod.__esModule) ? mod : { "default": mod };
22
+ };
20
23
  Object.defineProperty(exports, "__esModule", { value: true });
21
24
  const core_1 = require("@memlab/core");
25
+ const OptionConstant_1 = __importDefault(require("../lib/OptionConstant"));
22
26
  class DisableWebSecurityOption extends core_1.BaseOption {
23
27
  getOptionName() {
24
- return 'disable-web-security';
28
+ return OptionConstant_1.default.optionNames.DISABLE_WEB_SECURITY;
25
29
  }
26
30
  getDescription() {
27
31
  return ('disable web security in Chromium to enable cross domain requests; ' +
@@ -17,18 +17,22 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
17
17
  step((generator = generator.apply(thisArg, _arguments || [])).next());
18
18
  });
19
19
  };
20
+ var __importDefault = (this && this.__importDefault) || function (mod) {
21
+ return (mod && mod.__esModule) ? mod : { "default": mod };
22
+ };
20
23
  Object.defineProperty(exports, "__esModule", { value: true });
21
24
  const core_1 = require("@memlab/core");
25
+ const OptionConstant_1 = __importDefault(require("../lib/OptionConstant"));
22
26
  class DisableXvfbOption extends core_1.BaseOption {
23
27
  getOptionName() {
24
- return 'disable-xvfb';
28
+ return OptionConstant_1.default.optionNames.DISABLE_XVFB;
25
29
  }
26
30
  getDescription() {
27
31
  return 'disable Xvfb (X virtual framebuffer) for simulating headful browser rendering';
28
32
  }
29
33
  parse(config, args) {
30
34
  return __awaiter(this, void 0, void 0, function* () {
31
- if (args['disable-xvfb']) {
35
+ if (args[this.getOptionName()]) {
32
36
  config.useXVFB = false;
33
37
  }
34
38
  });
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ * @format
8
+ * @oncall web_perf_infra
9
+ */
10
+ import type { ParsedArgs } from 'minimist';
11
+ import type { MemLabConfig } from '@memlab/core';
12
+ import { BaseOption } from '@memlab/core';
13
+ export default class EnableJSInterceptOption extends BaseOption {
14
+ getOptionName(): string;
15
+ getDescription(): string;
16
+ parse(config: MemLabConfig, args: ParsedArgs): Promise<void>;
17
+ }
18
+ //# sourceMappingURL=EnableJSInterceptOption.d.ts.map
@@ -0,0 +1,42 @@
1
+ "use strict";
2
+ /**
3
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
4
+ *
5
+ * This source code is licensed under the MIT license found in the
6
+ * LICENSE file in the root directory of this source tree.
7
+ *
8
+ * @format
9
+ * @oncall web_perf_infra
10
+ */
11
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
12
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
13
+ return new (P || (P = Promise))(function (resolve, reject) {
14
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
15
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
16
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
17
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
18
+ });
19
+ };
20
+ var __importDefault = (this && this.__importDefault) || function (mod) {
21
+ return (mod && mod.__esModule) ? mod : { "default": mod };
22
+ };
23
+ Object.defineProperty(exports, "__esModule", { value: true });
24
+ const core_1 = require("@memlab/core");
25
+ const OptionConstant_1 = __importDefault(require("../lib/OptionConstant"));
26
+ class EnableJSInterceptOption extends core_1.BaseOption {
27
+ getOptionName() {
28
+ return OptionConstant_1.default.optionNames.LOG_SCRIPT;
29
+ }
30
+ getDescription() {
31
+ return 'enable intercepting and logging JavaScript code in browser';
32
+ }
33
+ parse(config, args) {
34
+ return __awaiter(this, void 0, void 0, function* () {
35
+ if (args[this.getOptionName()]) {
36
+ // intercept script
37
+ config.interceptScript = true;
38
+ }
39
+ });
40
+ }
41
+ }
42
+ exports.default = EnableJSInterceptOption;
@@ -17,11 +17,15 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
17
17
  step((generator = generator.apply(thisArg, _arguments || [])).next());
18
18
  });
19
19
  };
20
+ var __importDefault = (this && this.__importDefault) || function (mod) {
21
+ return (mod && mod.__esModule) ? mod : { "default": mod };
22
+ };
20
23
  Object.defineProperty(exports, "__esModule", { value: true });
21
24
  const core_1 = require("@memlab/core");
25
+ const OptionConstant_1 = __importDefault(require("../lib/OptionConstant"));
22
26
  class EnableJSRewriteOption extends core_1.BaseOption {
23
27
  getOptionName() {
24
- return 'rewrite-js';
28
+ return OptionConstant_1.default.optionNames.REWRITE_JS;
25
29
  }
26
30
  getDescription() {
27
31
  return 'enable instrument JavaScript code in browser';
@@ -29,6 +33,9 @@ class EnableJSRewriteOption extends core_1.BaseOption {
29
33
  parse(config, args) {
30
34
  return __awaiter(this, void 0, void 0, function* () {
31
35
  if (args[this.getOptionName()]) {
36
+ // intercept script
37
+ config.interceptScript = true;
38
+ // rewrite script
32
39
  config.instrumentJS = true;
33
40
  }
34
41
  });
@@ -17,18 +17,22 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
17
17
  step((generator = generator.apply(thisArg, _arguments || [])).next());
18
18
  });
19
19
  };
20
+ var __importDefault = (this && this.__importDefault) || function (mod) {
21
+ return (mod && mod.__esModule) ? mod : { "default": mod };
22
+ };
20
23
  Object.defineProperty(exports, "__esModule", { value: true });
21
24
  const core_1 = require("@memlab/core");
25
+ const OptionConstant_1 = __importDefault(require("../lib/OptionConstant"));
22
26
  class FullExecutionOption extends core_1.BaseOption {
23
27
  getOptionName() {
24
- return 'full';
28
+ return OptionConstant_1.default.optionNames.FULL;
25
29
  }
26
30
  getDescription() {
27
31
  return 'take heap snapshot for every step in E2E interaction';
28
32
  }
29
33
  parse(config, args) {
30
34
  return __awaiter(this, void 0, void 0, function* () {
31
- if (args.full) {
35
+ if (args[this.getOptionName()]) {
32
36
  config.isFullRun = true;
33
37
  }
34
38
  });
@@ -17,11 +17,15 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
17
17
  step((generator = generator.apply(thisArg, _arguments || [])).next());
18
18
  });
19
19
  };
20
+ var __importDefault = (this && this.__importDefault) || function (mod) {
21
+ return (mod && mod.__esModule) ? mod : { "default": mod };
22
+ };
20
23
  Object.defineProperty(exports, "__esModule", { value: true });
21
24
  const core_1 = require("@memlab/core");
25
+ const OptionConstant_1 = __importDefault(require("../lib/OptionConstant"));
22
26
  class HeadfulBrowserOption extends core_1.BaseOption {
23
27
  getOptionName() {
24
- return 'headful';
28
+ return OptionConstant_1.default.optionNames.HEADFUL;
25
29
  }
26
30
  getDescription() {
27
31
  return 'start the browser in headful mode, but default it is headless';
@@ -17,11 +17,15 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
17
17
  step((generator = generator.apply(thisArg, _arguments || [])).next());
18
18
  });
19
19
  };
20
+ var __importDefault = (this && this.__importDefault) || function (mod) {
21
+ return (mod && mod.__esModule) ? mod : { "default": mod };
22
+ };
20
23
  Object.defineProperty(exports, "__esModule", { value: true });
21
24
  const core_1 = require("@memlab/core");
25
+ const OptionConstant_1 = __importDefault(require("../lib/OptionConstant"));
22
26
  class InteractionOption extends core_1.BaseOption {
23
27
  getOptionName() {
24
- return 'interaction';
28
+ return OptionConstant_1.default.optionNames.INTERACTION;
25
29
  }
26
30
  getDescription() {
27
31
  return 'set name for onboarded interaction';
@@ -31,10 +35,10 @@ class InteractionOption extends core_1.BaseOption {
31
35
  }
32
36
  parse(config, args) {
33
37
  return __awaiter(this, void 0, void 0, function* () {
34
- if (args.interaction) {
35
- config.targetTab = Array.isArray(args.interaction)
36
- ? args.interaction[args.interaction.length - 1]
37
- : args.interaction;
38
+ const name = this.getOptionName();
39
+ const arg = args[name];
40
+ if (arg) {
41
+ config.targetTab = Array.isArray(arg) ? arg[arg.length - 1] : arg;
38
42
  }
39
43
  });
40
44
  }
@@ -17,18 +17,22 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
17
17
  step((generator = generator.apply(thisArg, _arguments || [])).next());
18
18
  });
19
19
  };
20
+ var __importDefault = (this && this.__importDefault) || function (mod) {
21
+ return (mod && mod.__esModule) ? mod : { "default": mod };
22
+ };
20
23
  Object.defineProperty(exports, "__esModule", { value: true });
21
24
  const core_1 = require("@memlab/core");
25
+ const OptionConstant_1 = __importDefault(require("../lib/OptionConstant"));
22
26
  class RemoteBrowserDebugOption extends core_1.BaseOption {
23
27
  getOptionName() {
24
- return 'local-puppeteer';
28
+ return OptionConstant_1.default.optionNames.LOCAL_PUPPETEER;
25
29
  }
26
30
  getDescription() {
27
31
  return 'enable remote browser instance debugging via local puppeteer';
28
32
  }
29
33
  parse(config, args) {
30
34
  return __awaiter(this, void 0, void 0, function* () {
31
- if (args['local-puppeteer']) {
35
+ if (args[this.getOptionName()]) {
32
36
  config.isLocalPuppeteer = true;
33
37
  }
34
38
  });
@@ -17,11 +17,15 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
17
17
  step((generator = generator.apply(thisArg, _arguments || [])).next());
18
18
  });
19
19
  };
20
+ var __importDefault = (this && this.__importDefault) || function (mod) {
21
+ return (mod && mod.__esModule) ? mod : { "default": mod };
22
+ };
20
23
  Object.defineProperty(exports, "__esModule", { value: true });
21
24
  const core_1 = require("@memlab/core");
25
+ const OptionConstant_1 = __importDefault(require("../lib/OptionConstant"));
22
26
  class RunningModeOption extends core_1.BaseOption {
23
27
  getOptionName() {
24
- return 'run-mode';
28
+ return OptionConstant_1.default.optionNames.RUN_MODE;
25
29
  }
26
30
  getDescription() {
27
31
  return 'set running mode';
@@ -31,7 +35,7 @@ class RunningModeOption extends core_1.BaseOption {
31
35
  }
32
36
  parse(config, args) {
33
37
  return __awaiter(this, void 0, void 0, function* () {
34
- if (args['run-mode']) {
38
+ if (args[this.getOptionName()]) {
35
39
  config.runningMode = core_1.modes.get(args['run-mode'], config);
36
40
  }
37
41
  });