@memlab/cli 1.0.29 → 1.0.30
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/bin/memlab.js +1 -1
- package/dist/commands/heap/HeapAnalysisCommand.d.ts +3 -1
- package/dist/commands/heap/HeapAnalysisCommand.d.ts.map +1 -1
- package/dist/commands/heap/HeapAnalysisCommand.js +33 -14
- package/dist/options/e2e/SetChromiumBinaryOption.d.ts.map +1 -1
- package/dist/options/e2e/SetChromiumBinaryOption.js +1 -10
- package/dist/options/heap/HeapAnalysisPluginOption.d.ts +20 -0
- package/dist/options/heap/HeapAnalysisPluginOption.d.ts.map +1 -0
- package/dist/options/heap/HeapAnalysisPluginOption.js +46 -0
- package/dist/options/lib/OptionConstant.d.ts +2 -0
- package/dist/options/lib/OptionConstant.d.ts.map +1 -1
- package/dist/options/lib/OptionConstant.js +1 -0
- package/package.json +5 -5
package/bin/memlab.js
CHANGED
|
@@ -7,15 +7,17 @@
|
|
|
7
7
|
* @format
|
|
8
8
|
* @oncall web_perf_infra
|
|
9
9
|
*/
|
|
10
|
-
import type { CLIOptions, CommandOptionExample } from '@memlab/core';
|
|
10
|
+
import type { BaseOption, CLIOptions, CommandOptionExample } from '@memlab/core';
|
|
11
11
|
import BaseCommand, { CommandCategory } from '../../BaseCommand';
|
|
12
12
|
export default class RunHeapAnalysisCommand extends BaseCommand {
|
|
13
13
|
getCommandName(): string;
|
|
14
14
|
getDescription(): string;
|
|
15
15
|
getCategory(): CommandCategory;
|
|
16
16
|
getPrerequisites(): BaseCommand[];
|
|
17
|
+
getOptions(): BaseOption[];
|
|
17
18
|
getSubCommands(): BaseCommand[];
|
|
18
19
|
getExamples(): CommandOptionExample[];
|
|
20
|
+
private errorIfNoSubCommand;
|
|
19
21
|
run(options: CLIOptions): Promise<void>;
|
|
20
22
|
}
|
|
21
23
|
//# sourceMappingURL=HeapAnalysisCommand.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HeapAnalysisCommand.d.ts","sourceRoot":"","sources":["../../../src/commands/heap/HeapAnalysisCommand.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAC,UAAU,EAAE,oBAAoB,EAAC,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"HeapAnalysisCommand.d.ts","sourceRoot":"","sources":["../../../src/commands/heap/HeapAnalysisCommand.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAC,UAAU,EAAE,UAAU,EAAE,oBAAoB,EAAC,MAAM,cAAc,CAAC;AAG/E,OAAO,WAAW,EAAE,EAAC,eAAe,EAAC,MAAM,mBAAmB,CAAC;AAS/D,MAAM,CAAC,OAAO,OAAO,sBAAuB,SAAQ,WAAW;IAC7D,cAAc,IAAI,MAAM;IAIxB,cAAc,IAAI,MAAM;IAIxB,WAAW,IAAI,eAAe;IAI9B,gBAAgB,IAAI,WAAW,EAAE;IAIjC,UAAU,IAAI,UAAU,EAAE;IAI1B,cAAc,IAAI,WAAW,EAAE;IAU/B,WAAW,IAAI,oBAAoB,EAAE;YAIvB,mBAAmB;IAwB3B,GAAG,CAAC,OAAO,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC;CAc9C"}
|
|
@@ -50,12 +50,13 @@ const heap_analysis_1 = require("@memlab/heap-analysis");
|
|
|
50
50
|
const HeapAnalysisSubCommandWrapper_1 = __importDefault(require("./HeapAnalysisSubCommandWrapper"));
|
|
51
51
|
const HelperCommand_1 = __importDefault(require("../helper/HelperCommand"));
|
|
52
52
|
const InitDirectoryCommand_1 = __importDefault(require("../InitDirectoryCommand"));
|
|
53
|
+
const HeapAnalysisPluginOption_1 = __importDefault(require("../../options/heap/HeapAnalysisPluginOption"));
|
|
53
54
|
class RunHeapAnalysisCommand extends BaseCommand_1.default {
|
|
54
55
|
getCommandName() {
|
|
55
56
|
return 'analyze';
|
|
56
57
|
}
|
|
57
58
|
getDescription() {
|
|
58
|
-
return 'Run heap analysis
|
|
59
|
+
return 'Run heap analysis on heap snapshots.\n';
|
|
59
60
|
}
|
|
60
61
|
getCategory() {
|
|
61
62
|
return BaseCommand_1.CommandCategory.COMMON;
|
|
@@ -63,6 +64,9 @@ class RunHeapAnalysisCommand extends BaseCommand_1.default {
|
|
|
63
64
|
getPrerequisites() {
|
|
64
65
|
return [new InitDirectoryCommand_1.default()];
|
|
65
66
|
}
|
|
67
|
+
getOptions() {
|
|
68
|
+
return [new HeapAnalysisPluginOption_1.default()];
|
|
69
|
+
}
|
|
66
70
|
getSubCommands() {
|
|
67
71
|
const analyses = [...heap_analysis_1.heapAnalysisLoader.loadAllAnalysis().values()];
|
|
68
72
|
return analyses.map((analysis) => {
|
|
@@ -75,23 +79,38 @@ class RunHeapAnalysisCommand extends BaseCommand_1.default {
|
|
|
75
79
|
getExamples() {
|
|
76
80
|
return ['<PLUGIN_NAME> [PLUGIN_OPTIONS]'];
|
|
77
81
|
}
|
|
82
|
+
errorIfNoSubCommand(args, analysisMap) {
|
|
83
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
84
|
+
if (args && args._.length >= 2 && analysisMap.has(args._[1])) {
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
const helper = new HelperCommand_1.default();
|
|
88
|
+
const modules = new Map();
|
|
89
|
+
for (const subCommand of this.getSubCommands()) {
|
|
90
|
+
modules.set(subCommand.getCommandName(), subCommand);
|
|
91
|
+
}
|
|
92
|
+
const errMsg = args && args._.length < 2
|
|
93
|
+
? `\n Heap analysis plugin name missing\n`
|
|
94
|
+
: `\n Invalid command \`memlab ${this.getCommandName()} ${args === null || args === void 0 ? void 0 : args._[1]}\`\n`;
|
|
95
|
+
core_1.info.error(errMsg);
|
|
96
|
+
yield helper.run({ cliArgs: args, modules, command: this });
|
|
97
|
+
core_1.utils.haltOrThrow(errMsg, { printErrorBeforeHalting: false });
|
|
98
|
+
});
|
|
99
|
+
}
|
|
78
100
|
run(options) {
|
|
101
|
+
var _a;
|
|
79
102
|
return __awaiter(this, void 0, void 0, function* () {
|
|
103
|
+
// process command line arguments and load analysis modules
|
|
80
104
|
const args = options.cliArgs;
|
|
81
|
-
|
|
82
|
-
if (
|
|
83
|
-
|
|
84
|
-
const modules = new Map();
|
|
85
|
-
for (const subCommand of this.getSubCommands()) {
|
|
86
|
-
modules.set(subCommand.getCommandName(), subCommand);
|
|
87
|
-
}
|
|
88
|
-
const errMsg = args && args._.length < 2
|
|
89
|
-
? `\n Heap analysis plugin name missing\n`
|
|
90
|
-
: `\n Invalid command \`memlab ${this.getCommandName()} ${args === null || args === void 0 ? void 0 : args._[1]}\`\n`;
|
|
91
|
-
core_1.info.error(errMsg);
|
|
92
|
-
yield helper.run({ cliArgs: args, modules, command: this });
|
|
93
|
-
core_1.utils.haltOrThrow(errMsg, { printErrorBeforeHalting: false });
|
|
105
|
+
let plugin = (_a = options.configFromOptions) === null || _a === void 0 ? void 0 : _a.heapAnalysisPlugin;
|
|
106
|
+
if (plugin != null) {
|
|
107
|
+
plugin = `${plugin}`;
|
|
94
108
|
}
|
|
109
|
+
const analysisMap = heap_analysis_1.heapAnalysisLoader.loadAllAnalysis({
|
|
110
|
+
heapAnalysisPlugin: plugin,
|
|
111
|
+
errorWhenPluginFailed: true,
|
|
112
|
+
});
|
|
113
|
+
yield this.errorIfNoSubCommand(args, analysisMap);
|
|
95
114
|
});
|
|
96
115
|
}
|
|
97
116
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SetChromiumBinaryOption.d.ts","sourceRoot":"","sources":["../../../src/options/e2e/SetChromiumBinaryOption.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,KAAK,EAAC,UAAU,EAAC,MAAM,UAAU,CAAC;AACzC,OAAO,EAAC,YAAY,EAAC,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"SetChromiumBinaryOption.d.ts","sourceRoot":"","sources":["../../../src/options/e2e/SetChromiumBinaryOption.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,KAAK,EAAC,UAAU,EAAC,MAAM,UAAU,CAAC;AACzC,OAAO,EAAC,YAAY,EAAC,MAAM,cAAc,CAAC;AAE1C,OAAO,EAAQ,UAAU,EAAC,MAAM,cAAc,CAAC;AAG/C,MAAM,CAAC,OAAO,OAAO,uBAAwB,SAAQ,UAAU;IAC7D,aAAa,IAAI,MAAM;IAIvB,cAAc,IAAI,MAAM;IAIlB,KAAK,CAAC,MAAM,EAAE,YAAY,EAAE,IAAI,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC;CAOnE"}
|
|
@@ -12,8 +12,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
12
12
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
const path_1 = __importDefault(require("path"));
|
|
16
|
-
const fs_1 = __importDefault(require("fs"));
|
|
17
15
|
const core_1 = require("@memlab/core");
|
|
18
16
|
const OptionConstant_1 = __importDefault(require("../lib/OptionConstant"));
|
|
19
17
|
class SetChromiumBinaryOption extends core_1.BaseOption {
|
|
@@ -28,14 +26,7 @@ class SetChromiumBinaryOption extends core_1.BaseOption {
|
|
|
28
26
|
const name = this.getOptionName();
|
|
29
27
|
const arg = args[name];
|
|
30
28
|
if (arg) {
|
|
31
|
-
|
|
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;
|
|
29
|
+
core_1.utils.setChromiumBinary(config, arg);
|
|
39
30
|
}
|
|
40
31
|
});
|
|
41
32
|
}
|
|
@@ -0,0 +1,20 @@
|
|
|
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 HeapAnalysisPluginOption extends BaseOption {
|
|
14
|
+
getOptionName(): string;
|
|
15
|
+
getDescription(): string;
|
|
16
|
+
parse(config: MemLabConfig, args: ParsedArgs): Promise<{
|
|
17
|
+
workDir?: string;
|
|
18
|
+
}>;
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=HeapAnalysisPluginOption.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"HeapAnalysisPluginOption.d.ts","sourceRoot":"","sources":["../../../src/options/heap/HeapAnalysisPluginOption.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAC,UAAU,EAAC,MAAM,UAAU,CAAC;AACzC,OAAO,EAAY,YAAY,EAAC,MAAM,cAAc,CAAC;AACrD,OAAO,EAAC,UAAU,EAAC,MAAM,cAAc,CAAC;AAGxC,MAAM,CAAC,OAAO,OAAO,wBAAyB,SAAQ,UAAU;IAC9D,aAAa,IAAI,MAAM;IAIvB,cAAc,IAAI,MAAM;IAOlB,KAAK,CACT,MAAM,EAAE,YAAY,EACpB,IAAI,EAAE,UAAU,GACf,OAAO,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,CAAA;KAAC,CAAC;CAS/B"}
|
|
@@ -0,0 +1,46 @@
|
|
|
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 HeapAnalysisPluginOption extends core_1.BaseOption {
|
|
27
|
+
getOptionName() {
|
|
28
|
+
return OptionConstant_1.default.optionNames.HEAP_ANALYSIS_PLUGIN_FILE;
|
|
29
|
+
}
|
|
30
|
+
getDescription() {
|
|
31
|
+
return ('specify the external heap analysis plugin file ' +
|
|
32
|
+
'(must be a vanilla JS file ended with `Analysis.js` suffix)');
|
|
33
|
+
}
|
|
34
|
+
parse(config, args) {
|
|
35
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
36
|
+
const name = this.getOptionName();
|
|
37
|
+
const ret = {};
|
|
38
|
+
const heapAnalysisPlugin = args[name];
|
|
39
|
+
if (heapAnalysisPlugin) {
|
|
40
|
+
ret.heapAnalysisPlugin = heapAnalysisPlugin;
|
|
41
|
+
}
|
|
42
|
+
return ret;
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
exports.default = HeapAnalysisPluginOption;
|
|
@@ -24,6 +24,7 @@ declare const optionConstants: {
|
|
|
24
24
|
FINAL: string;
|
|
25
25
|
FULL: string;
|
|
26
26
|
HEADFUL: string;
|
|
27
|
+
HEAP_ANALYSIS_PLUGIN_FILE: string;
|
|
27
28
|
HELP: string;
|
|
28
29
|
IGNORE_LEAK_CLUSTER_SIZE_BELOW: string;
|
|
29
30
|
INTERACTION: string;
|
|
@@ -87,6 +88,7 @@ declare const _default: {
|
|
|
87
88
|
FINAL: string;
|
|
88
89
|
FULL: string;
|
|
89
90
|
HEADFUL: string;
|
|
91
|
+
HEAP_ANALYSIS_PLUGIN_FILE: string;
|
|
90
92
|
HELP: string;
|
|
91
93
|
IGNORE_LEAK_CLUSTER_SIZE_BELOW: string;
|
|
92
94
|
INTERACTION: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OptionConstant.d.ts","sourceRoot":"","sources":["../../../src/options/lib/OptionConstant.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;
|
|
1
|
+
{"version":3,"file":"OptionConstant.d.ts","sourceRoot":"","sources":["../../../src/options/lib/OptionConstant.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAmEH,QAAA,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAGpB,CAAC;AACF,MAAM,MAAM,eAAe,GAAG,OAAO,eAAe,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACrD,wBAIE"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@memlab/cli",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.30",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "command line interface for memlab",
|
|
6
6
|
"author": "Liang Gong <lgong@fb.com>",
|
|
@@ -26,10 +26,10 @@
|
|
|
26
26
|
"access": "public"
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@memlab/api": "^1.0.
|
|
30
|
-
"@memlab/core": "^1.1.
|
|
31
|
-
"@memlab/e2e": "^1.0.
|
|
32
|
-
"@memlab/heap-analysis": "^1.0.
|
|
29
|
+
"@memlab/api": "^1.0.27",
|
|
30
|
+
"@memlab/core": "^1.1.28",
|
|
31
|
+
"@memlab/e2e": "^1.0.28",
|
|
32
|
+
"@memlab/heap-analysis": "^1.0.25",
|
|
33
33
|
"ansi": "^0.3.1",
|
|
34
34
|
"babar": "^0.2.0",
|
|
35
35
|
"blessed": "^0.1.81",
|