@memlab/cli 1.0.4 → 1.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -3,5 +3,6 @@
3
3
  This is the memlab CLI library. It contains all memlab commands, command-line options, and command-line interfaces.
4
4
  The library supports adding new commands.
5
5
 
6
- ## Full documentation
7
- https://facebookincubator.github.io/memlab
6
+ ## Online Resources
7
+ * [Official Website and Demo](https://facebookincubator.github.io/memlab)
8
+ * [Documentation](https://facebookincubator.github.io/memlab/docs/intro)
package/bin/memlab CHANGED
@@ -10,5 +10,10 @@
10
10
  * @format
11
11
  */
12
12
 
13
- var cli = require("@memlab/cli");
14
- cli.run();
13
+ var cli = require("../dist/index");
14
+
15
+ // register the `@memlab/cli` package info
16
+ // so that `memlab version` get use the info
17
+ (cli.registerPackage()).then(() => {
18
+ cli.run();
19
+ });
@@ -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
+ * @emails oncall+ws_labs
8
+ * @format
9
+ */
10
+ import type { CLIOptions } from '@memlab/core';
11
+ import BaseCommand from '../BaseCommand';
12
+ export default class GetVersionCommand extends BaseCommand {
13
+ getCommandName(): string;
14
+ getDescription(): string;
15
+ private loadDepencyPackageInfo;
16
+ run(options: CLIOptions): Promise<void>;
17
+ }
18
+ //# sourceMappingURL=GetVersionCommand.d.ts.map
@@ -0,0 +1,69 @@
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
+ * @emails oncall+ws_labs
9
+ * @format
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 chalk_1 = __importDefault(require("chalk"));
25
+ const BaseCommand_1 = __importDefault(require("../BaseCommand"));
26
+ const core_1 = require("@memlab/core");
27
+ const api_1 = require("@memlab/api");
28
+ const core_2 = require("@memlab/core");
29
+ const heap_analysis_1 = require("@memlab/heap-analysis");
30
+ const e2e_1 = require("@memlab/e2e");
31
+ class GetVersionCommand extends BaseCommand_1.default {
32
+ getCommandName() {
33
+ return 'version';
34
+ }
35
+ getDescription() {
36
+ return 'Show the versions of all memlab packages installed';
37
+ }
38
+ loadDepencyPackageInfo() {
39
+ return __awaiter(this, void 0, void 0, function* () {
40
+ // require all sub-packages to register package information
41
+ // memlab and cli packages already registered in the bin file
42
+ // the following sub-packages are registered here lazily to
43
+ // avoid too many file operations
44
+ return Promise.all([
45
+ (0, api_1.registerPackage)(),
46
+ (0, core_2.registerPackage)(),
47
+ (0, heap_analysis_1.registerPackage)(),
48
+ (0, e2e_1.registerPackage)(),
49
+ ]);
50
+ });
51
+ }
52
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
53
+ run(options) {
54
+ return __awaiter(this, void 0, void 0, function* () {
55
+ yield this.loadDepencyPackageInfo();
56
+ const packages = core_1.config.packageInfo;
57
+ core_1.info.topLevel('');
58
+ for (const pkg of packages) {
59
+ const version = chalk_1.default.grey(`@${pkg.version}`);
60
+ core_1.info.topLevel(` ${pkg.name}${version}`);
61
+ if (core_1.config.verbose && pkg.packageLocation) {
62
+ core_1.info.lowLevel(` ${pkg.packageLocation}`);
63
+ }
64
+ }
65
+ core_1.info.topLevel('');
66
+ });
67
+ }
68
+ }
69
+ exports.default = GetVersionCommand;
@@ -40,6 +40,7 @@ const ScenarioFileOption_1 = __importDefault(require("../options/ScenarioFileOpt
40
40
  const SetDeviceOption_1 = __importDefault(require("../options/SetDeviceOption"));
41
41
  const DisableXvfbOption_1 = __importDefault(require("../options/DisableXvfbOption"));
42
42
  const NumberOfRunsOption_1 = __importDefault(require("../options/NumberOfRunsOption"));
43
+ const HeadfulBrowserOption_1 = __importDefault(require("../options/HeadfulBrowserOption"));
43
44
  class RunMeasureCommand extends BaseCommand_1.default {
44
45
  getCommandName() {
45
46
  return 'measure';
@@ -59,6 +60,7 @@ class RunMeasureCommand extends BaseCommand_1.default {
59
60
  }
60
61
  getOptions() {
61
62
  return [
63
+ new HeadfulBrowserOption_1.default(),
62
64
  new NumberOfRunsOption_1.default(),
63
65
  new AppOption_1.default(),
64
66
  new InteractionOption_1.default(),
@@ -33,6 +33,7 @@ const SetDeviceOption_1 = __importDefault(require("../options/SetDeviceOption"))
33
33
  const DisableXvfbOption_1 = __importDefault(require("../options/DisableXvfbOption"));
34
34
  const SkipWarmupOption_1 = __importDefault(require("../options/SkipWarmupOption"));
35
35
  const CheckXvfbSupportCommand_1 = __importDefault(require("./snapshot/CheckXvfbSupportCommand"));
36
+ const HeadfulBrowserOption_1 = __importDefault(require("../options/HeadfulBrowserOption"));
36
37
  class FBWarmupAppCommand extends BaseCommand_1.default {
37
38
  getCommandName() {
38
39
  return 'warmup';
@@ -51,6 +52,7 @@ class FBWarmupAppCommand extends BaseCommand_1.default {
51
52
  }
52
53
  getOptions() {
53
54
  return [
55
+ new HeadfulBrowserOption_1.default(),
54
56
  new AppOption_1.default(),
55
57
  new InteractionOption_1.default(),
56
58
  new RunningModeOption_1.default(),
@@ -58,6 +58,8 @@ const LogTraceAsClusterOption_1 = __importDefault(require("../../options/heap/Lo
58
58
  const CleanLoggerDataCommand_1 = __importDefault(require("../CleanLoggerDataCommand"));
59
59
  const LeakFilterFileOption_1 = __importDefault(require("../../options/heap/leak-filter/LeakFilterFileOption"));
60
60
  const LeakClusterSizeThresholdOption_1 = __importDefault(require("../../options/heap/LeakClusterSizeThresholdOption"));
61
+ const MLClusteringOption_1 = __importDefault(require("../../options/MLClusteringOption"));
62
+ const MLClusteringLinkageMaxDistanceOption_1 = __importDefault(require("../../options/MLClusteringLinkageMaxDistanceOption"));
61
63
  class CheckLeakCommand extends BaseCommand_1.default {
62
64
  getCommandName() {
63
65
  return 'find-leaks';
@@ -83,6 +85,8 @@ class CheckLeakCommand extends BaseCommand_1.default {
83
85
  new LeakClusterSizeThresholdOption_1.default(),
84
86
  new TraceAllObjectsOption_1.default(),
85
87
  new LogTraceAsClusterOption_1.default(),
88
+ new MLClusteringOption_1.default(),
89
+ new MLClusteringLinkageMaxDistanceOption_1.default(),
86
90
  ];
87
91
  }
88
92
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
@@ -39,6 +39,7 @@ const SetDeviceOption_1 = __importDefault(require("../../options/SetDeviceOption
39
39
  const DisableXvfbOption_1 = __importDefault(require("../../options/DisableXvfbOption"));
40
40
  const InitDirectoryCommand_1 = __importDefault(require("../InitDirectoryCommand"));
41
41
  const CheckXvfbSupportCommand_1 = __importDefault(require("./CheckXvfbSupportCommand"));
42
+ const HeadfulBrowserOption_1 = __importDefault(require("../../options/HeadfulBrowserOption"));
42
43
  class TakeSnapshotCommand extends BaseCommand_1.default {
43
44
  getCommandName() {
44
45
  return 'snapshot';
@@ -62,6 +63,7 @@ class TakeSnapshotCommand extends BaseCommand_1.default {
62
63
  }
63
64
  getOptions() {
64
65
  return [
66
+ new HeadfulBrowserOption_1.default(),
65
67
  new AppOption_1.default(),
66
68
  new InteractionOption_1.default(),
67
69
  new FullExecutionOption_1.default(),
package/dist/index.d.ts CHANGED
@@ -7,5 +7,7 @@
7
7
  * @emails oncall+ws_labs
8
8
  * @format
9
9
  */
10
+ /** @internal */
11
+ export declare function registerPackage(): Promise<void>;
10
12
  export * from './runner';
11
13
  //# sourceMappingURL=index.d.ts.map
package/dist/index.js CHANGED
@@ -22,5 +22,27 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi
22
22
  var __exportStar = (this && this.__exportStar) || function(m, exports) {
23
23
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
24
24
  };
25
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
26
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
27
+ return new (P || (P = Promise))(function (resolve, reject) {
28
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
29
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
30
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
31
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
32
+ });
33
+ };
34
+ var __importDefault = (this && this.__importDefault) || function (mod) {
35
+ return (mod && mod.__esModule) ? mod : { "default": mod };
36
+ };
25
37
  Object.defineProperty(exports, "__esModule", { value: true });
38
+ exports.registerPackage = void 0;
39
+ const path_1 = __importDefault(require("path"));
40
+ const core_1 = require("@memlab/core");
41
+ /** @internal */
42
+ function registerPackage() {
43
+ return __awaiter(this, void 0, void 0, function* () {
44
+ return core_1.PackageInfoLoader.registerPackage(path_1.default.join(__dirname, '..'));
45
+ });
46
+ }
47
+ exports.registerPackage = registerPackage;
26
48
  __exportStar(require("./runner"), exports);
@@ -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
+ * @emails oncall+ws_labs
8
+ * @format
9
+ */
10
+ import type { ParsedArgs } from 'minimist';
11
+ import type { MemLabConfig } from '@memlab/core';
12
+ import { BaseOption } from '@memlab/core';
13
+ export default class HeadfulBrowserOption extends BaseOption {
14
+ getOptionName(): string;
15
+ getDescription(): string;
16
+ parse(config: MemLabConfig, args: ParsedArgs): Promise<void>;
17
+ }
18
+ //# sourceMappingURL=HeadfulBrowserOption.d.ts.map
@@ -0,0 +1,37 @@
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
+ * @emails oncall+ws_labs
9
+ * @format
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
+ Object.defineProperty(exports, "__esModule", { value: true });
21
+ const core_1 = require("@memlab/core");
22
+ class HeadfulBrowserOption extends core_1.BaseOption {
23
+ getOptionName() {
24
+ return 'headful';
25
+ }
26
+ getDescription() {
27
+ return 'start the browser in headful mode, but default it is headless';
28
+ }
29
+ parse(config, args) {
30
+ return __awaiter(this, void 0, void 0, function* () {
31
+ if (args[this.getOptionName()]) {
32
+ config.isHeadfulBrowser = true;
33
+ }
34
+ });
35
+ }
36
+ }
37
+ exports.default = HeadfulBrowserOption;
@@ -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
+ * @emails oncall+ws_labs
8
+ * @format
9
+ */
10
+ import type { ParsedArgs } from 'minimist';
11
+ import { MemLabConfig } from '@memlab/core';
12
+ import { BaseOption } from '@memlab/core';
13
+ export default class MLClusteringLinkageMaxDistanceOption extends BaseOption {
14
+ getOptionName(): string;
15
+ getDescription(): string;
16
+ parse(config: MemLabConfig, args: ParsedArgs): Promise<void>;
17
+ }
18
+ //# sourceMappingURL=MLClusteringLinkageMaxDistanceOption.d.ts.map
@@ -0,0 +1,47 @@
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
+ * @emails oncall+ws_labs
9
+ * @format
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
+ Object.defineProperty(exports, "__esModule", { value: true });
21
+ const core_1 = require("@memlab/core");
22
+ const core_2 = require("@memlab/core");
23
+ class MLClusteringLinkageMaxDistanceOption extends core_2.BaseOption {
24
+ getOptionName() {
25
+ return 'ml-linkage-max-dist';
26
+ }
27
+ getDescription() {
28
+ return 'set linkage max distance value for clustering. The value should be between [0, 1] inclusive.';
29
+ }
30
+ parse(config, args) {
31
+ return __awaiter(this, void 0, void 0, function* () {
32
+ if (args['ml-linkage-max-dist']) {
33
+ const linkageMaxDist = args['ml-linkage-max-dist'];
34
+ const linkageMaxDistNum = parseFloat(linkageMaxDist);
35
+ if (!isNaN(linkageMaxDistNum) &&
36
+ linkageMaxDistNum >= 0 &&
37
+ linkageMaxDistNum <= 1) {
38
+ config.mlClusteringLinkageMaxDistance = linkageMaxDistNum;
39
+ }
40
+ else {
41
+ core_1.utils.haltOrThrow(`ml-linkage-max-dist is not number between [0, 1]. ml-linkage-max-dist=${linkageMaxDist}`);
42
+ }
43
+ }
44
+ });
45
+ }
46
+ }
47
+ exports.default = MLClusteringLinkageMaxDistanceOption;
@@ -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
+ * @emails oncall+ws_labs
8
+ * @format
9
+ */
10
+ import type { ParsedArgs } from 'minimist';
11
+ import type { MemLabConfig } from '@memlab/core';
12
+ import { BaseOption } from '@memlab/core';
13
+ export default class MLClusteringOption extends BaseOption {
14
+ getOptionName(): string;
15
+ getDescription(): string;
16
+ parse(config: MemLabConfig, args: ParsedArgs): Promise<void>;
17
+ }
18
+ //# sourceMappingURL=MLClusteringOption.d.ts.map
@@ -0,0 +1,37 @@
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
+ * @emails oncall+ws_labs
9
+ * @format
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
+ Object.defineProperty(exports, "__esModule", { value: true });
21
+ const core_1 = require("@memlab/core");
22
+ class MLClusteringOption extends core_1.BaseOption {
23
+ getOptionName() {
24
+ return 'ml-clustering';
25
+ }
26
+ getDescription() {
27
+ return 'use machine learning algorithms for clustering leak traces (by default, traces are clustered by heuristics)';
28
+ }
29
+ parse(config, args) {
30
+ return __awaiter(this, void 0, void 0, function* () {
31
+ if (args['ml-clustering']) {
32
+ config.isMLClustering = true;
33
+ }
34
+ });
35
+ }
36
+ }
37
+ exports.default = MLClusteringOption;
@@ -24,10 +24,10 @@ class JSEngineOption extends core_1.BaseOption {
24
24
  return 'engine';
25
25
  }
26
26
  getDescription() {
27
- return 'set the JavaScript engine (default to v8)';
27
+ return 'set the JavaScript engine (default to V8)';
28
28
  }
29
29
  getExampleValues() {
30
- return ['v8', 'hermes'];
30
+ return ['V8', 'hermes'];
31
31
  }
32
32
  parse(config, args) {
33
33
  return __awaiter(this, void 0, void 0, function* () {
@@ -5,7 +5,6 @@
5
5
  * This source code is licensed under the MIT license found in the
6
6
  * LICENSE file in the root directory of this source tree.
7
7
  *
8
- * @emails oncall+ws_labs
9
8
  * @format
10
9
  * @oncall ws_labs
11
10
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@memlab/cli",
3
- "version": "1.0.4",
3
+ "version": "1.0.7",
4
4
  "license": "MIT",
5
5
  "description": "command line interface for memlab",
6
6
  "author": "Liang Gong <lgong@fb.com>",
@@ -24,10 +24,10 @@
24
24
  "access": "public"
25
25
  },
26
26
  "dependencies": {
27
- "@memlab/api": "^1.0.0",
28
- "@memlab/core": "^1.0.0",
29
- "@memlab/e2e": "^1.0.0",
30
- "@memlab/heap-analysis": "^1.0.0",
27
+ "@memlab/api": "^1.0.6",
28
+ "@memlab/core": "^1.1.6",
29
+ "@memlab/e2e": "^1.0.7",
30
+ "@memlab/heap-analysis": "^1.0.5",
31
31
  "ansi": "^0.3.1",
32
32
  "babar": "^0.2.0",
33
33
  "chalk": "^4.0.0",