@memlab/cli 1.0.24 → 1.0.26

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 (46) hide show
  1. package/dist/BaseCommand.d.ts +3 -3
  2. package/dist/BaseCommand.js +5 -1
  3. package/dist/Dispatcher.js +6 -0
  4. package/dist/commands/MemLabRunCommand.d.ts +2 -2
  5. package/dist/commands/RunMeasureCommand.d.ts +2 -2
  6. package/dist/commands/RunMeasureCommand.js +2 -0
  7. package/dist/commands/WarmupAppCommand.d.ts +2 -2
  8. package/dist/commands/WarmupAppCommand.js +2 -0
  9. package/dist/commands/heap/CheckLeakCommand.d.ts +2 -1
  10. package/dist/commands/heap/CheckLeakCommand.js +44 -5
  11. package/dist/commands/heap/DiffLeakCommand.d.ts +13 -1
  12. package/dist/commands/heap/DiffLeakCommand.js +44 -14
  13. package/dist/commands/heap/GetRetainerTraceCommand.d.ts +2 -2
  14. package/dist/commands/heap/HeapAnalysisCommand.d.ts +2 -2
  15. package/dist/commands/heap/interactive/InteractiveHeapCommand.d.ts +2 -2
  16. package/dist/commands/heap/interactive/InteractiveHeapExploreCommand.d.ts +2 -2
  17. package/dist/commands/heap/interactive/ui-components/HeapViewUtils.d.ts +2 -0
  18. package/dist/commands/heap/interactive/ui-components/HeapViewUtils.js +25 -21
  19. package/dist/commands/heap/interactive/ui-components/ListComponent.js +1 -1
  20. package/dist/commands/helper/GenerateCLIDocCommand.js +10 -7
  21. package/dist/commands/helper/HelperCommand.d.ts +7 -4
  22. package/dist/commands/helper/HelperCommand.js +17 -13
  23. package/dist/commands/helper/lib/DocUtils.d.ts +19 -0
  24. package/dist/commands/helper/lib/DocUtils.js +39 -0
  25. package/dist/commands/snapshot/TakeSnapshotCommand.d.ts +2 -2
  26. package/dist/commands/snapshot/TakeSnapshotCommand.js +2 -0
  27. package/dist/commands/snapshot/WarmupAndSnapshotCommand.d.ts +3 -1
  28. package/dist/commands/snapshot/WarmupAndSnapshotCommand.js +23 -0
  29. package/dist/lib/CLIUtils.js +15 -2
  30. package/dist/options/SetMaxClusterSampleSizeOption.d.ts +19 -0
  31. package/dist/options/SetMaxClusterSampleSizeOption.js +49 -0
  32. package/dist/options/e2e/SetChromiumBinaryOption.d.ts +18 -0
  33. package/dist/options/e2e/SetChromiumBinaryOption.js +43 -0
  34. package/dist/options/experiment/ExperimentOptionUtils.d.ts +13 -0
  35. package/dist/options/experiment/ExperimentOptionUtils.js +39 -0
  36. package/dist/options/experiment/SetControlWorkDirOption.d.ts +3 -4
  37. package/dist/options/experiment/SetControlWorkDirOption.js +3 -25
  38. package/dist/options/experiment/SetTreatmentWorkDirOption.d.ts +2 -2
  39. package/dist/options/experiment/SetTreatmentWorkDirOption.js +4 -13
  40. package/dist/options/heap/SetTraceContainsFilterOption.d.ts +18 -0
  41. package/dist/options/heap/SetTraceContainsFilterOption.js +42 -0
  42. package/dist/options/heap/TraceAllObjectsOption.d.ts +4 -2
  43. package/dist/options/heap/TraceAllObjectsOption.js +26 -4
  44. package/dist/options/lib/OptionConstant.d.ts +6 -0
  45. package/dist/options/lib/OptionConstant.js +3 -0
  46. package/package.json +1 -1
@@ -49,6 +49,7 @@ const chalk_1 = __importDefault(require("chalk"));
49
49
  const string_width_1 = __importDefault(require("string-width"));
50
50
  const core_1 = require("@memlab/core");
51
51
  const heap_analysis_1 = require("@memlab/heap-analysis");
52
+ const DocUtils_1 = __importDefault(require("./lib/DocUtils"));
52
53
  const CommandOrder_1 = __importDefault(require("./lib/CommandOrder"));
53
54
  const BaseCommand_1 = __importStar(require("../../BaseCommand"));
54
55
  const UniversalOptions_1 = __importDefault(require("../../options/lib/UniversalOptions"));
@@ -188,21 +189,22 @@ class HelperCommand extends BaseCommand_1.default {
188
189
  });
189
190
  return `${headerString}${descString.substring(headerStringWidth)}`;
190
191
  }
191
- printCommand(command, extraIndent = '', printOptions = false) {
192
+ printCommand(command, extraIndent = '', options = {}) {
193
+ var _a;
192
194
  const indent = ' ' + extraIndent;
193
195
  const name = command.getFullCommand();
194
196
  const desc = core_1.utils.upperCaseFirstCharacter(command.getDescription().trim());
195
197
  const cmdDoc = command.getDocumenation().trim();
196
198
  // get example
197
199
  const examples = command.getExamples();
198
- let example = '';
199
- if (examples.length > 0) {
200
- example = ' ' + examples[0].trim();
201
- }
202
- const cmd = chalk_1.default.green(`memlab ${name}${example}`);
200
+ const example = (_a = examples[0]) !== null && _a !== void 0 ? _a : '';
201
+ // write command synopsis
202
+ const cmd = DocUtils_1.default.generateExampleCommand(name, example, {
203
+ descriptionAsBashComment: false,
204
+ });
203
205
  let msg = `${indent}${cmd}`;
204
206
  msg += `\n${indent}${desc}`;
205
- if (cmdDoc.length > 0) {
207
+ if (options.printOptions && cmdDoc.length > 0) {
206
208
  const cmdDocBlock = (0, CLIUtils_1.alignTextInBlock)(cmdDoc, {
207
209
  leftIndent: indent.length + 2,
208
210
  });
@@ -210,7 +212,7 @@ class HelperCommand extends BaseCommand_1.default {
210
212
  }
211
213
  core_1.info.topLevel(msg);
212
214
  // print options info
213
- if (printOptions) {
215
+ if (options.printOptions) {
214
216
  // print full options description
215
217
  this.printOptions(command, indent);
216
218
  }
@@ -224,11 +226,12 @@ class HelperCommand extends BaseCommand_1.default {
224
226
  core_1.info.topLevel('');
225
227
  }
226
228
  printHelperTextForCommand(command, options) {
229
+ var _a;
227
230
  return __awaiter(this, void 0, void 0, function* () {
228
231
  // print helper text for a specific command
229
- this.printCommand(command, options.indent, options.printOptions);
232
+ this.printCommand(command, options.indent, options);
230
233
  // print helper text for its subcommands
231
- const subcommands = command.getSubCommands();
234
+ const subcommands = (_a = command.getSubCommands()) !== null && _a !== void 0 ? _a : [];
232
235
  const subOptions = Object.assign({}, options);
233
236
  subOptions.indent = (subOptions.indent || '') + ' ';
234
237
  for (const subcommand of subcommands) {
@@ -238,6 +241,7 @@ class HelperCommand extends BaseCommand_1.default {
238
241
  });
239
242
  }
240
243
  printFullHelperTextForCommand(args, modules) {
244
+ var _a, _b;
241
245
  return __awaiter(this, void 0, void 0, function* () {
242
246
  // get the command to print
243
247
  let map = modules;
@@ -252,7 +256,7 @@ class HelperCommand extends BaseCommand_1.default {
252
256
  if (!command) {
253
257
  break;
254
258
  }
255
- const subCommands = command.getSubCommands();
259
+ const subCommands = (_a = command.getSubCommands()) !== null && _a !== void 0 ? _a : [];
256
260
  map = new Map(subCommands.map((cmd) => [cmd.getCommandName(), cmd]));
257
261
  }
258
262
  if (!command) {
@@ -260,9 +264,9 @@ class HelperCommand extends BaseCommand_1.default {
260
264
  }
261
265
  // print the helper text of the command
262
266
  core_1.info.topLevel('');
263
- this.printCommand(command, '', true);
267
+ this.printCommand(command, '', { printOptions: true, printDoc: true });
264
268
  // print the helper text of the subcommands
265
- const subCommands = command.getSubCommands();
269
+ const subCommands = (_b = command.getSubCommands()) !== null && _b !== void 0 ? _b : [];
266
270
  if (subCommands.length > 0) {
267
271
  core_1.info.topLevel(chalk_1.default.bold(' SUB-COMMANDS\n'));
268
272
  for (const subCommand of subCommands) {
@@ -0,0 +1,19 @@
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 { CommandOptionExample } from '@memlab/core';
11
+ declare type GenerateExampleCommandOption = {
12
+ descriptionAsBashComment?: boolean;
13
+ };
14
+ declare function generateExampleCommand(command: string, cliExample: CommandOptionExample, options?: GenerateExampleCommandOption): string;
15
+ declare const _default: {
16
+ generateExampleCommand: typeof generateExampleCommand;
17
+ };
18
+ export default _default;
19
+ //# sourceMappingURL=DocUtils.d.ts.map
@@ -0,0 +1,39 @@
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
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ function generateExampleCommand(command, cliExample, options = {}) {
13
+ if (typeof cliExample === 'string') {
14
+ return exampleFromCliOptionString(command, cliExample);
15
+ }
16
+ let commandExample = '';
17
+ if (cliExample.description != null &&
18
+ // if it's not null, undefined, or true
19
+ options.descriptionAsBashComment !== false) {
20
+ const desc = cliExample.description.trim();
21
+ if (desc.length > 0) {
22
+ // inject the description as a bash command in the bash example
23
+ const bashText = cliExample.description
24
+ .trim()
25
+ .split('\n')
26
+ .map(line => `# ${line.trim()}`)
27
+ .join('\n');
28
+ commandExample += bashText + '\n';
29
+ }
30
+ }
31
+ commandExample += exampleFromCliOptionString(command, cliExample.cliOptionExample);
32
+ return commandExample;
33
+ }
34
+ function exampleFromCliOptionString(command, cliExample) {
35
+ return `memlab ${command} ${cliExample.trim()}`;
36
+ }
37
+ exports.default = {
38
+ generateExampleCommand,
39
+ };
@@ -7,14 +7,14 @@
7
7
  * @format
8
8
  * @oncall web_perf_infra
9
9
  */
10
- import type { CLIOptions } from '@memlab/core';
10
+ import type { CLIOptions, CommandOptionExample } from '@memlab/core';
11
11
  import BaseCommand from '../../BaseCommand';
12
12
  import { BaseOption } from '@memlab/core';
13
13
  export default class TakeSnapshotCommand extends BaseCommand {
14
14
  getCommandName(): string;
15
15
  getDescription(): string;
16
16
  getPrerequisites(): BaseCommand[];
17
- getExamples(): string[];
17
+ getExamples(): CommandOptionExample[];
18
18
  getOptions(): BaseOption[];
19
19
  run(_options: CLIOptions): Promise<void>;
20
20
  }
@@ -45,6 +45,7 @@ const DisableWebSecurityOption_1 = __importDefault(require("../../options/e2e/Di
45
45
  const EnableJSRewriteOption_1 = __importDefault(require("../../options/e2e/EnableJSRewriteOption"));
46
46
  const EnableJSInterceptOption_1 = __importDefault(require("../../options/e2e/EnableJSInterceptOption"));
47
47
  const TargetWorkerOption_1 = __importDefault(require("../../options/e2e/TargetWorkerOption"));
48
+ const SetChromiumBinaryOption_1 = __importDefault(require("../../options/e2e/SetChromiumBinaryOption"));
48
49
  class TakeSnapshotCommand extends BaseCommand_1.default {
49
50
  getCommandName() {
50
51
  return 'snapshot';
@@ -80,6 +81,7 @@ class TakeSnapshotCommand extends BaseCommand_1.default {
80
81
  new RunningModeOption_1.default(),
81
82
  new RemoteBrowserDebugOption_1.default(),
82
83
  new ScenarioFileOption_1.default(),
84
+ new SetChromiumBinaryOption_1.default(),
83
85
  new SetDeviceOption_1.default(),
84
86
  new SetUserAgentOption_1.default(),
85
87
  new DisableXvfbOption_1.default(),
@@ -7,11 +7,13 @@
7
7
  * @format
8
8
  * @oncall web_perf_infra
9
9
  */
10
- import type { CLIOptions } from '@memlab/core';
10
+ import type { CLIOptions, CommandOptionExample } from '@memlab/core';
11
11
  import BaseCommand from '../../BaseCommand';
12
12
  export default class WarmupAndSnapshotCommand extends BaseCommand {
13
13
  getCommandName(): string;
14
14
  getDescription(): string;
15
+ getDocumenation(): string;
16
+ getExamples(): CommandOptionExample[];
15
17
  getPrerequisites(): BaseCommand[];
16
18
  run(_options: CLIOptions): Promise<void>;
17
19
  }
@@ -22,6 +22,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
22
22
  };
23
23
  Object.defineProperty(exports, "__esModule", { value: true });
24
24
  const BaseCommand_1 = __importDefault(require("../../BaseCommand"));
25
+ const SetWorkingDirectoryOption_1 = __importDefault(require("../../options/SetWorkingDirectoryOption"));
25
26
  const InitDirectoryCommand_1 = __importDefault(require("../InitDirectoryCommand"));
26
27
  const WarmupAppCommand_1 = __importDefault(require("../WarmupAppCommand"));
27
28
  const TakeSnapshotCommand_1 = __importDefault(require("./TakeSnapshotCommand"));
@@ -32,6 +33,28 @@ class WarmupAndSnapshotCommand extends BaseCommand_1.default {
32
33
  getDescription() {
33
34
  return 'Warm up server and take heap snapshots';
34
35
  }
36
+ getDocumenation() {
37
+ const warmupCommand = new WarmupAppCommand_1.default();
38
+ const warmupCLI = `memlab ${warmupCommand.getCommandName()}`;
39
+ const takeSnapshotCommand = new TakeSnapshotCommand_1.default();
40
+ const snapshotCLI = `memlab ${takeSnapshotCommand.getCommandName()}`;
41
+ return ('This is equivalent to running ' +
42
+ `\`${warmupCLI}\` and \`${snapshotCLI}\`.`);
43
+ }
44
+ getExamples() {
45
+ return [
46
+ {
47
+ description: 'specify a test scenario file, memlab will ' +
48
+ 'warm up the server and take heap snapshots',
49
+ cliOptionExample: '--scenario <TEST_SCENARIO_FILE>',
50
+ },
51
+ '--scenario /tmp/test-scenario.js',
52
+ {
53
+ description: new SetWorkingDirectoryOption_1.default().getDescription(),
54
+ cliOptionExample: '--scenario /tmp/test-scenario.js --work-dir /tmp/test-1/',
55
+ },
56
+ ];
57
+ }
35
58
  getPrerequisites() {
36
59
  return [
37
60
  new InitDirectoryCommand_1.default(),
@@ -39,6 +39,19 @@ function filterAndGetUndefinedArgs(cliArgs) {
39
39
  return ret;
40
40
  }
41
41
  exports.filterAndGetUndefinedArgs = filterAndGetUndefinedArgs;
42
+ function quoteIfNecessary(v) {
43
+ if (typeof v !== 'string') {
44
+ return v;
45
+ }
46
+ // if the string contains any whitespace character
47
+ if (/\s/.test(v)) {
48
+ // escape any existing " character
49
+ v = v.replace(/"/g, '\\"');
50
+ // wrap the string with "
51
+ v = `"${v}"`;
52
+ }
53
+ return v;
54
+ }
42
55
  function argsToString(args) {
43
56
  let ret = '';
44
57
  for (const optionName of Object.keys(args)) {
@@ -51,11 +64,11 @@ function argsToString(args) {
51
64
  }
52
65
  else if (Array.isArray(value)) {
53
66
  value.forEach(v => {
54
- ret += `--${optionName}=${v} `;
67
+ ret += `--${optionName}=${quoteIfNecessary(v)} `;
55
68
  });
56
69
  }
57
70
  else {
58
- ret += `--${optionName}=${value} `;
71
+ ret += `--${optionName}=${quoteIfNecessary(value)} `;
59
72
  }
60
73
  }
61
74
  return ret.trim();
@@ -0,0 +1,19 @@
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 SetMaxClusterSampleSizeOption extends BaseOption {
14
+ getOptionName(): string;
15
+ getDescription(): string;
16
+ getExampleValues(): string[];
17
+ parse(config: MemLabConfig, args: ParsedArgs): Promise<void>;
18
+ }
19
+ //# sourceMappingURL=SetMaxClusterSampleSizeOption.d.ts.map
@@ -0,0 +1,49 @@
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 SetMaxClusterSampleSizeOption extends core_1.BaseOption {
27
+ getOptionName() {
28
+ return OptionConstant_1.default.optionNames.MAX_CLUSTER_SAMPLE_SIZE;
29
+ }
30
+ getDescription() {
31
+ return ('specify the max number of leak traces as input to leak trace ' +
32
+ 'clustering algorithm. Big sample size will preserve more complete ' +
33
+ 'inforrmation, but may risk out-of-memory crash.');
34
+ }
35
+ getExampleValues() {
36
+ return ['5000', '10000'];
37
+ }
38
+ parse(config, args) {
39
+ return __awaiter(this, void 0, void 0, function* () {
40
+ if (args[this.getOptionName()]) {
41
+ const sampleSize = parseInt(args[this.getOptionName()], 10);
42
+ if (!isNaN(sampleSize)) {
43
+ config.maxSamplesForClustering = sampleSize;
44
+ }
45
+ }
46
+ });
47
+ }
48
+ }
49
+ exports.default = SetMaxClusterSampleSizeOption;
@@ -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 { MemLabConfig } from '@memlab/core';
12
+ import { BaseOption } from '@memlab/core';
13
+ export default class SetChromiumBinaryOption extends BaseOption {
14
+ getOptionName(): string;
15
+ getDescription(): string;
16
+ parse(config: MemLabConfig, args: ParsedArgs): Promise<void>;
17
+ }
18
+ //# sourceMappingURL=SetChromiumBinaryOption.d.ts.map
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ const path_1 = __importDefault(require("path"));
16
+ const fs_1 = __importDefault(require("fs"));
17
+ const core_1 = require("@memlab/core");
18
+ const OptionConstant_1 = __importDefault(require("../lib/OptionConstant"));
19
+ class SetChromiumBinaryOption extends core_1.BaseOption {
20
+ getOptionName() {
21
+ return OptionConstant_1.default.optionNames.CHROMIUM_BINARY;
22
+ }
23
+ getDescription() {
24
+ return 'set the chromium binary for E2E run';
25
+ }
26
+ parse(config, args) {
27
+ return __awaiter(this, void 0, void 0, function* () {
28
+ const name = this.getOptionName();
29
+ const arg = args[name];
30
+ if (arg) {
31
+ const binaryPath = path_1.default.resolve(process.cwd(), arg);
32
+ if (!fs_1.default.existsSync(binaryPath)) {
33
+ throw core_1.utils.haltOrThrow(`Chromium binary does not exist: ${binaryPath}`);
34
+ }
35
+ if (config.verbose) {
36
+ core_1.info.lowLevel(`Using ${binaryPath} as Chromium binary for E2E run`);
37
+ }
38
+ config.puppeteerConfig.executablePath = binaryPath;
39
+ }
40
+ });
41
+ }
42
+ }
43
+ exports.default = SetChromiumBinaryOption;
@@ -0,0 +1,13 @@
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 { Nullable } from '@memlab/core';
12
+ export declare function extractAndCheckWorkDirs(optionName: string, args: ParsedArgs): Nullable<string[]>;
13
+ //# sourceMappingURL=ExperimentOptionUtils.d.ts.map
@@ -0,0 +1,39 @@
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 __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.extractAndCheckWorkDirs = void 0;
16
+ const fs_1 = __importDefault(require("fs"));
17
+ const core_1 = require("@memlab/core");
18
+ function extractAndCheckWorkDirs(optionName, args) {
19
+ let dirs = [];
20
+ const flagValue = args[optionName];
21
+ if (!flagValue) {
22
+ return null;
23
+ }
24
+ if (Array.isArray(flagValue)) {
25
+ dirs = flagValue;
26
+ }
27
+ else {
28
+ dirs = [flagValue];
29
+ }
30
+ for (const dir of dirs) {
31
+ if (fs_1.default.existsSync(dir)) {
32
+ core_1.fileManager.createDefaultVisitOrderMetaFile({
33
+ workDir: dir,
34
+ });
35
+ }
36
+ }
37
+ return dirs;
38
+ }
39
+ exports.extractAndCheckWorkDirs = extractAndCheckWorkDirs;
@@ -8,14 +8,13 @@
8
8
  * @oncall web_perf_infra
9
9
  */
10
10
  import type { ParsedArgs } from 'minimist';
11
- import type { MemLabConfig } from '@memlab/core';
11
+ import type { MemLabConfig, Nullable } from '@memlab/core';
12
12
  import { BaseOption } from '@memlab/core';
13
13
  export default class SetControlWorkDirOption extends BaseOption {
14
14
  getOptionName(): string;
15
15
  getDescription(): string;
16
- protected extractAndCheckWorkDirs(args: ParsedArgs): string[];
17
- parse(config: MemLabConfig, args: ParsedArgs): Promise<{
18
- controlWorkDirs?: string[];
16
+ parse(_config: MemLabConfig, args: ParsedArgs): Promise<{
17
+ controlWorkDirs?: Nullable<string[]>;
19
18
  }>;
20
19
  }
21
20
  //# sourceMappingURL=SetControlWorkDirOption.d.ts.map
@@ -21,9 +21,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
21
21
  return (mod && mod.__esModule) ? mod : { "default": mod };
22
22
  };
23
23
  Object.defineProperty(exports, "__esModule", { value: true });
24
- const fs_1 = __importDefault(require("fs"));
25
24
  const core_1 = require("@memlab/core");
26
25
  const OptionConstant_1 = __importDefault(require("../lib/OptionConstant"));
26
+ const ExperimentOptionUtils_1 = require("./ExperimentOptionUtils");
27
27
  class SetControlWorkDirOption extends core_1.BaseOption {
28
28
  getOptionName() {
29
29
  return OptionConstant_1.default.optionNames.CONTROL_WORK_DIR;
@@ -31,31 +31,9 @@ class SetControlWorkDirOption extends core_1.BaseOption {
31
31
  getDescription() {
32
32
  return 'set the working directory of the control run';
33
33
  }
34
- extractAndCheckWorkDirs(args) {
35
- let dirs = [];
36
- const name = this.getOptionName();
37
- const flagValue = args[name];
38
- if (!flagValue) {
39
- return dirs;
40
- }
41
- if (Array.isArray(flagValue)) {
42
- dirs = flagValue;
43
- }
44
- else {
45
- dirs = [flagValue];
46
- }
47
- for (const dir of dirs) {
48
- if (fs_1.default.existsSync(dir)) {
49
- core_1.fileManager.createDefaultVisitOrderMetaFile({
50
- workDir: dir,
51
- });
52
- }
53
- }
54
- return dirs;
55
- }
56
- parse(config, args) {
34
+ parse(_config, args) {
57
35
  return __awaiter(this, void 0, void 0, function* () {
58
- const dirs = this.extractAndCheckWorkDirs(args);
36
+ const dirs = (0, ExperimentOptionUtils_1.extractAndCheckWorkDirs)(this.getOptionName(), args);
59
37
  return { controlWorkDirs: dirs };
60
38
  });
61
39
  }
@@ -8,13 +8,13 @@
8
8
  * @oncall web_perf_infra
9
9
  */
10
10
  import type { ParsedArgs } from 'minimist';
11
- import type { MemLabConfig } from '@memlab/core';
11
+ import type { MemLabConfig, Nullable } from '@memlab/core';
12
12
  import { BaseOption } from '@memlab/core';
13
13
  export default class SetTreatmentWorkDirOption extends BaseOption {
14
14
  getOptionName(): string;
15
15
  getDescription(): string;
16
16
  parse(config: MemLabConfig, args: ParsedArgs): Promise<{
17
- treatmentWorkDir?: string;
17
+ treatmentWorkDirs?: Nullable<string[]>;
18
18
  }>;
19
19
  }
20
20
  //# sourceMappingURL=SetTreatmentWorkDirOption.d.ts.map
@@ -21,29 +21,20 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
21
21
  return (mod && mod.__esModule) ? mod : { "default": mod };
22
22
  };
23
23
  Object.defineProperty(exports, "__esModule", { value: true });
24
- const fs_1 = __importDefault(require("fs"));
25
24
  const core_1 = require("@memlab/core");
26
25
  const OptionConstant_1 = __importDefault(require("../lib/OptionConstant"));
26
+ const ExperimentOptionUtils_1 = require("./ExperimentOptionUtils");
27
27
  class SetTreatmentWorkDirOption extends core_1.BaseOption {
28
28
  getOptionName() {
29
29
  return OptionConstant_1.default.optionNames.TREATMENT_WORK_DIR;
30
30
  }
31
31
  getDescription() {
32
- return 'set the working directory of the test (treatment) run';
32
+ return 'set the working directory of the treatment run';
33
33
  }
34
34
  parse(config, args) {
35
35
  return __awaiter(this, void 0, void 0, function* () {
36
- const name = this.getOptionName();
37
- const ret = {};
38
- if (args[name]) {
39
- ret.treatmentWorkDir = args[name];
40
- if (fs_1.default.existsSync(ret.treatmentWorkDir)) {
41
- core_1.fileManager.createDefaultVisitOrderMetaFile({
42
- workDir: ret.treatmentWorkDir,
43
- });
44
- }
45
- }
46
- return ret;
36
+ const dirs = (0, ExperimentOptionUtils_1.extractAndCheckWorkDirs)(this.getOptionName(), args);
37
+ return { treatmentWorkDirs: dirs };
47
38
  });
48
39
  }
49
40
  }
@@ -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 SetTraceContainsFilterOption extends BaseOption {
14
+ getOptionName(): string;
15
+ getDescription(): string;
16
+ parse(config: MemLabConfig, args: ParsedArgs): Promise<void>;
17
+ }
18
+ //# sourceMappingURL=SetTraceContainsFilterOption.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 SetTraceContainsFilterOption extends core_1.BaseOption {
27
+ getOptionName() {
28
+ return OptionConstant_1.default.optionNames.TRACE_CONTAINS;
29
+ }
30
+ getDescription() {
31
+ return 'set the node name or edge name to filter leak traces that contain the name';
32
+ }
33
+ parse(config, args) {
34
+ return __awaiter(this, void 0, void 0, function* () {
35
+ const filterName = args[this.getOptionName()];
36
+ if (filterName != null) {
37
+ config.filterTraceByName = filterName;
38
+ }
39
+ });
40
+ }
41
+ }
42
+ exports.default = SetTraceContainsFilterOption;
@@ -8,11 +8,13 @@
8
8
  * @oncall web_perf_infra
9
9
  */
10
10
  import type { ParsedArgs } from 'minimist';
11
- import type { MemLabConfig } from '@memlab/core';
12
- import { BaseOption } from '@memlab/core';
11
+ import { MemLabConfig } from '@memlab/core';
12
+ import { BaseOption, TraceObjectMode } from '@memlab/core';
13
13
  export default class TraceAllObjectsOption extends BaseOption {
14
14
  getOptionName(): string;
15
15
  getDescription(): string;
16
+ getAvailableOptions(): Array<string>;
17
+ getMode(optionValue: string): TraceObjectMode;
16
18
  parse(config: MemLabConfig, args: ParsedArgs): Promise<void>;
17
19
  }
18
20
  //# sourceMappingURL=TraceAllObjectsOption.d.ts.map