@memlab/cli 1.0.22 → 1.0.23

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.
@@ -7,9 +7,8 @@
7
7
  * @format
8
8
  * @oncall web_perf_infra
9
9
  */
10
- import { CLIOptions } from '@memlab/core';
10
+ import type { BaseOption, CLIOptions } from '@memlab/core';
11
11
  import BaseCommand, { CommandCategory } from '../../BaseCommand';
12
- import { BaseOption } from '@memlab/core';
13
12
  export default class CheckLeakCommand extends BaseCommand {
14
13
  getCommandName(): string;
15
14
  getDescription(): string;
@@ -44,9 +44,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
44
44
  return (mod && mod.__esModule) ? mod : { "default": mod };
45
45
  };
46
46
  Object.defineProperty(exports, "__esModule", { value: true });
47
- const core_1 = require("@memlab/core");
48
47
  const BaseCommand_1 = __importStar(require("../../BaseCommand"));
49
- const core_2 = require("@memlab/core");
48
+ const core_1 = require("@memlab/core");
50
49
  const BaselineFileOption_1 = __importDefault(require("../../options/heap/BaselineFileOption"));
51
50
  const FinalFileOption_1 = __importDefault(require("../../options/heap/FinalFileOption"));
52
51
  const JSEngineOption_1 = __importDefault(require("../../options/heap/JSEngineOption"));
@@ -63,6 +62,7 @@ const MLClusteringOption_1 = __importDefault(require("../../options/MLClustering
63
62
  const MLClusteringLinkageMaxDistanceOption_1 = __importDefault(require("../../options/MLClusteringLinkageMaxDistanceOption"));
64
63
  const MLClusteringMaxDFOption_1 = __importDefault(require("../../options/MLClusteringMaxDFOption"));
65
64
  const CleanupSnapshotOption_1 = __importDefault(require("../../options/heap/CleanupSnapshotOption"));
65
+ const SetWorkingDirectoryOption_1 = __importDefault(require("../../options/SetWorkingDirectoryOption"));
66
66
  class CheckLeakCommand extends BaseCommand_1.default {
67
67
  getCommandName() {
68
68
  return 'find-leaks';
@@ -92,14 +92,17 @@ class CheckLeakCommand extends BaseCommand_1.default {
92
92
  new MLClusteringLinkageMaxDistanceOption_1.default(),
93
93
  new MLClusteringMaxDFOption_1.default(),
94
94
  new CleanupSnapshotOption_1.default(),
95
+ new SetWorkingDirectoryOption_1.default(),
95
96
  ];
96
97
  }
97
98
  run(options) {
98
- var _a;
99
+ var _a, _b;
99
100
  return __awaiter(this, void 0, void 0, function* () {
100
- core_2.config.chaseWeakMapEdge = false;
101
- yield core_2.analysis.checkLeak();
102
- const configFromOptions = (_a = options.configFromOptions) !== null && _a !== void 0 ? _a : {};
101
+ const workDir = (_a = options.configFromOptions) === null || _a === void 0 ? void 0 : _a.workDir;
102
+ core_1.fileManager.initDirs(core_1.config, { workDir });
103
+ core_1.config.chaseWeakMapEdge = false;
104
+ yield core_1.analysis.checkLeak();
105
+ const configFromOptions = (_b = options.configFromOptions) !== null && _b !== void 0 ? _b : {};
103
106
  if (configFromOptions['cleanUpSnapshot']) {
104
107
  core_1.fileManager.removeSnapshotFiles();
105
108
  }
@@ -53,6 +53,7 @@ const JSEngineOption_1 = __importDefault(require("../../../options/heap/JSEngine
53
53
  const CliScreen_1 = __importDefault(require("./ui-components/CliScreen"));
54
54
  const HeapNodeIdOption_1 = __importDefault(require("../../../options/heap/HeapNodeIdOption"));
55
55
  const MLClusteringOption_1 = __importDefault(require("../../../options/MLClusteringOption"));
56
+ const SetWorkingDirectoryOption_1 = __importDefault(require("../../../options/SetWorkingDirectoryOption"));
56
57
  class InteractiveHeapViewCommand extends BaseCommand_1.default {
57
58
  getCommandName() {
58
59
  return 'view-heap';
@@ -72,6 +73,7 @@ class InteractiveHeapViewCommand extends BaseCommand_1.default {
72
73
  new JSEngineOption_1.default(),
73
74
  new HeapNodeIdOption_1.default(),
74
75
  new MLClusteringOption_1.default(),
76
+ new SetWorkingDirectoryOption_1.default(),
75
77
  ];
76
78
  }
77
79
  // get the heap snapshot to view
@@ -160,6 +162,7 @@ class InteractiveHeapViewCommand extends BaseCommand_1.default {
160
162
  var _a;
161
163
  return __awaiter(this, void 0, void 0, function* () {
162
164
  const workDir = (_a = options.configFromOptions) === null || _a === void 0 ? void 0 : _a.workDir;
165
+ core_1.fileManager.initDirs(core_1.config, { workDir, errorWhenAbsent: true });
163
166
  const reportOutDir = core_1.fileManager.getReportOutDir({ workDir });
164
167
  fs_extra_1.default.emptyDirSync(reportOutDir);
165
168
  const heap = yield this.getHeap(options);
@@ -44,6 +44,7 @@ const SetUserAgentOption_1 = __importDefault(require("../../options/e2e/SetUserA
44
44
  const DisableWebSecurityOption_1 = __importDefault(require("../../options/e2e/DisableWebSecurityOption"));
45
45
  const EnableJSRewriteOption_1 = __importDefault(require("../../options/e2e/EnableJSRewriteOption"));
46
46
  const EnableJSInterceptOption_1 = __importDefault(require("../../options/e2e/EnableJSInterceptOption"));
47
+ const TargetWorkerOption_1 = __importDefault(require("../../options/e2e/TargetWorkerOption"));
47
48
  class TakeSnapshotCommand extends BaseCommand_1.default {
48
49
  getCommandName() {
49
50
  return 'snapshot';
@@ -85,6 +86,7 @@ class TakeSnapshotCommand extends BaseCommand_1.default {
85
86
  new DisableWebSecurityOption_1.default(),
86
87
  new EnableJSRewriteOption_1.default(),
87
88
  new EnableJSInterceptOption_1.default(),
89
+ new TargetWorkerOption_1.default(),
88
90
  ];
89
91
  }
90
92
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
@@ -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 TargetWorkerOption extends BaseOption {
14
+ getOptionName(): string;
15
+ getDescription(): string;
16
+ getExampleValues(): string[];
17
+ parse(config: MemLabConfig, args: ParsedArgs): Promise<void>;
18
+ }
19
+ //# sourceMappingURL=TargetWorkerOption.d.ts.map
@@ -0,0 +1,51 @@
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 TargetWorkerOption extends core_1.BaseOption {
27
+ getOptionName() {
28
+ return OptionConstant_1.default.optionNames.WORKER_TITLE;
29
+ }
30
+ getDescription() {
31
+ return ('set title of the target (worker) that ' +
32
+ 'needs to be selected and analyzed');
33
+ }
34
+ getExampleValues() {
35
+ return ['WorkerTitle'];
36
+ }
37
+ parse(config, args) {
38
+ return __awaiter(this, void 0, void 0, function* () {
39
+ const name = this.getOptionName();
40
+ const arg = args[name];
41
+ if (arg) {
42
+ config.isAnalyzingMainThread = false;
43
+ const value = Array.isArray(arg) ? arg[arg.length - 1] : arg;
44
+ if (typeof value === 'string') {
45
+ config.targetWorkerTitle = value;
46
+ }
47
+ }
48
+ });
49
+ }
50
+ }
51
+ exports.default = TargetWorkerOption;
@@ -54,6 +54,7 @@ declare const optionConstants: {
54
54
  USER_AGENT: string;
55
55
  VERBOSE: string;
56
56
  WORK_DIR: string;
57
+ WORKER_TITLE: string;
57
58
  DEBUG: string;
58
59
  };
59
60
  optionShortcuts: {
@@ -110,6 +111,7 @@ declare const _default: {
110
111
  USER_AGENT: string;
111
112
  VERBOSE: string;
112
113
  WORK_DIR: string;
114
+ WORKER_TITLE: string;
113
115
  DEBUG: string;
114
116
  };
115
117
  optionShortcuts: {
@@ -56,6 +56,7 @@ const optionNames = {
56
56
  USER_AGENT: 'user-agent',
57
57
  VERBOSE: 'verbose',
58
58
  WORK_DIR: 'work-dir',
59
+ WORKER_TITLE: 'worker',
59
60
  DEBUG: 'debug',
60
61
  };
61
62
  const optionShortcuts = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@memlab/cli",
3
- "version": "1.0.22",
3
+ "version": "1.0.23",
4
4
  "license": "MIT",
5
5
  "description": "command line interface for memlab",
6
6
  "author": "Liang Gong <lgong@fb.com>",