@rsdoctor/cli 1.2.2-beta.2 → 1.2.2
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/dist/commands/analyze.js +1 -1
- package/dist/commands/stats-analyze.d.ts +13 -0
- package/dist/commands/stats-analyze.d.ts.map +1 -0
- package/dist/commands/stats-analyze.js +98 -0
- package/dist/constants.d.ts +2 -1
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7 -1
- package/package.json +6 -5
package/dist/commands/analyze.js
CHANGED
|
@@ -64,7 +64,7 @@ example: ${bin} ${external_constants_js_namespaceObject.Commands.Analyze} --prof
|
|
|
64
64
|
type: 'number',
|
|
65
65
|
description: 'port for Rsdoctor Server'
|
|
66
66
|
}).option('type', {
|
|
67
|
-
type: '
|
|
67
|
+
type: 'string',
|
|
68
68
|
description: 'if need lite bundle mode'
|
|
69
69
|
});
|
|
70
70
|
},
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { RsdoctorSDK } from '@rsdoctor/sdk';
|
|
2
|
+
import { SDK } from '@rsdoctor/types';
|
|
3
|
+
import { Commands } from '../constants';
|
|
4
|
+
import { Command } from '../types';
|
|
5
|
+
interface Options {
|
|
6
|
+
profile: string;
|
|
7
|
+
open?: boolean;
|
|
8
|
+
port?: number;
|
|
9
|
+
type?: SDK.ToDataType;
|
|
10
|
+
}
|
|
11
|
+
export declare const statsAnalyze: Command<Commands.StatsAnalyze, Options, RsdoctorSDK>;
|
|
12
|
+
export {};
|
|
13
|
+
//# sourceMappingURL=stats-analyze.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stats-analyze.d.ts","sourceRoot":"","sources":["../../src/commands/stats-analyze.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAuC,GAAG,EAAE,MAAM,iBAAiB,CAAC;AAG3E,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AACxC,OAAO,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AAKnC,UAAU,OAAO;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,GAAG,CAAC,UAAU,CAAC;CACvB;AAED,eAAO,MAAM,YAAY,EAAE,OAAO,CAChC,QAAQ,CAAC,YAAY,EACrB,OAAO,EACP,WAAW,CA2DV,CAAC"}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __webpack_require__ = {};
|
|
3
|
+
(()=>{
|
|
4
|
+
__webpack_require__.n = (module)=>{
|
|
5
|
+
var getter = module && module.__esModule ? ()=>module['default'] : ()=>module;
|
|
6
|
+
__webpack_require__.d(getter, {
|
|
7
|
+
a: getter
|
|
8
|
+
});
|
|
9
|
+
return getter;
|
|
10
|
+
};
|
|
11
|
+
})();
|
|
12
|
+
(()=>{
|
|
13
|
+
__webpack_require__.d = (exports1, definition)=>{
|
|
14
|
+
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
15
|
+
enumerable: true,
|
|
16
|
+
get: definition[key]
|
|
17
|
+
});
|
|
18
|
+
};
|
|
19
|
+
})();
|
|
20
|
+
(()=>{
|
|
21
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
22
|
+
})();
|
|
23
|
+
(()=>{
|
|
24
|
+
__webpack_require__.r = (exports1)=>{
|
|
25
|
+
if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
26
|
+
value: 'Module'
|
|
27
|
+
});
|
|
28
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
29
|
+
value: true
|
|
30
|
+
});
|
|
31
|
+
};
|
|
32
|
+
})();
|
|
33
|
+
var __webpack_exports__ = {};
|
|
34
|
+
__webpack_require__.r(__webpack_exports__);
|
|
35
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
36
|
+
statsAnalyze: ()=>statsAnalyze
|
|
37
|
+
});
|
|
38
|
+
const sdk_namespaceObject = require("@rsdoctor/sdk");
|
|
39
|
+
const types_namespaceObject = require("@rsdoctor/types");
|
|
40
|
+
const external_picocolors_namespaceObject = require("picocolors");
|
|
41
|
+
const external_ora_namespaceObject = require("ora");
|
|
42
|
+
var external_ora_default = /*#__PURE__*/ __webpack_require__.n(external_ora_namespaceObject);
|
|
43
|
+
const external_constants_js_namespaceObject = require("../constants.js");
|
|
44
|
+
const external_utils_js_namespaceObject = require("../utils.js");
|
|
45
|
+
const common_utils_namespaceObject = require("@rsdoctor/core/common-utils");
|
|
46
|
+
const statsAnalyze = (0, external_utils_js_namespaceObject.enhanceCommand)(({ cwd, name, bin })=>({
|
|
47
|
+
command: external_constants_js_namespaceObject.Commands.StatsAnalyze,
|
|
48
|
+
description: `use ${name} to open "${types_namespaceObject.Constants.RsdoctorOutputManifestPath}" in browser for analysis.example: ${bin} ${external_constants_js_namespaceObject.Commands.StatsAnalyze} --profile "${types_namespaceObject.Constants.StatsFilePath}"`.trim(),
|
|
49
|
+
options (yargs) {
|
|
50
|
+
yargs.option('profile', {
|
|
51
|
+
type: 'string',
|
|
52
|
+
description: 'Path to webpack stats.json file for analysis',
|
|
53
|
+
demandOption: true
|
|
54
|
+
}).option('port', {
|
|
55
|
+
type: 'number',
|
|
56
|
+
description: 'port for Web Doctor Server'
|
|
57
|
+
}).option('type', {
|
|
58
|
+
type: 'string',
|
|
59
|
+
description: 'Bundle analysis mode (normal or lite)'
|
|
60
|
+
});
|
|
61
|
+
},
|
|
62
|
+
async action ({ profile, open = true, type = types_namespaceObject.SDK.ToDataType.Normal }) {
|
|
63
|
+
const spinner = external_ora_default()({
|
|
64
|
+
prefixText: (0, external_picocolors_namespaceObject.cyan)(`[${name}]`)
|
|
65
|
+
}).start(`start to loading "${profile}"`);
|
|
66
|
+
const statsStrings = await (0, external_utils_js_namespaceObject.readFile)(profile, cwd);
|
|
67
|
+
const json = JSON.parse(statsStrings);
|
|
68
|
+
spinner.text = "start server";
|
|
69
|
+
const { chunkGraph, moduleGraph } = await common_utils_namespaceObject.TransUtils.transStats(json);
|
|
70
|
+
const sdk = new sdk_namespaceObject.RsdoctorSDK({
|
|
71
|
+
name: 'stats-analyze',
|
|
72
|
+
root: process.cwd(),
|
|
73
|
+
type,
|
|
74
|
+
noServer: false
|
|
75
|
+
});
|
|
76
|
+
await sdk.bootstrap();
|
|
77
|
+
sdk.reportChunkGraph(chunkGraph);
|
|
78
|
+
sdk.reportModuleGraph(moduleGraph);
|
|
79
|
+
sdk.addClientRoutes([
|
|
80
|
+
types_namespaceObject.Manifest.RsdoctorManifestClientRoutes.Overall,
|
|
81
|
+
types_namespaceObject.Manifest.RsdoctorManifestClientRoutes.BundleSize,
|
|
82
|
+
types_namespaceObject.Manifest.RsdoctorManifestClientRoutes.ModuleGraph
|
|
83
|
+
]);
|
|
84
|
+
if (open) {
|
|
85
|
+
spinner.text = "open browser automatically";
|
|
86
|
+
await sdk.server.openClientPage('homepage');
|
|
87
|
+
}
|
|
88
|
+
spinner.succeed(`the local url: ${(0, external_picocolors_namespaceObject.cyan)(sdk.server.getClientUrl('homepage'))}`);
|
|
89
|
+
return sdk;
|
|
90
|
+
}
|
|
91
|
+
}));
|
|
92
|
+
exports.statsAnalyze = __webpack_exports__.statsAnalyze;
|
|
93
|
+
for(var __webpack_i__ in __webpack_exports__)if (-1 === [
|
|
94
|
+
"statsAnalyze"
|
|
95
|
+
].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
|
|
96
|
+
Object.defineProperty(exports, '__esModule', {
|
|
97
|
+
value: true
|
|
98
|
+
});
|
package/dist/constants.d.ts
CHANGED
package/dist/constants.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,oBAAY,QAAQ;IAClB,OAAO,YAAY;IACnB,UAAU,gBAAgB;
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,oBAAY,QAAQ;IAClB,OAAO,YAAY;IACnB,UAAU,gBAAgB;IAC1B,YAAY,kBAAkB;CAC/B;AAED,eAAO,MAAM,GAAG,EAAE;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACA,CAAC;AAE/B,eAAO,MAAM,GAAG,QAA0B,CAAC"}
|
package/dist/constants.js
CHANGED
|
@@ -46,6 +46,7 @@ var __webpack_exports__ = {};
|
|
|
46
46
|
var Commands = /*#__PURE__*/ function(Commands) {
|
|
47
47
|
Commands["Analyze"] = "analyze";
|
|
48
48
|
Commands["BundleDiff"] = "bundle-diff";
|
|
49
|
+
Commands["StatsAnalyze"] = "stats-analyze";
|
|
49
50
|
return Commands;
|
|
50
51
|
}({});
|
|
51
52
|
const pkg = __webpack_require__("../package.json");
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AACjD,OAAO,EAA2B,uBAAuB,EAAE,MAAM,SAAS,CAAC;AAC3E,OAAO,EAAE,QAAQ,EAAY,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AACjD,OAAO,EAA2B,uBAAuB,EAAE,MAAM,SAAS,CAAC;AAC3E,OAAO,EAAE,QAAQ,EAAY,MAAM,aAAa,CAAC;AAIjD,wBAAsB,OAAO,CAC3B,CAAC,SAAS,uBAAuB,CAAC,OAAO,OAAO,CAAC,EAEjD,OAAO,EAAE,QAAQ,CAAC,OAAO,GAAG,GAAG,QAAQ,CAAC,OAAO,EAAE,EACjD,OAAO,EAAE,CAAC,CAAC,SAAS,CAAC,GACpB,OAAO,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC;AAExB,wBAAsB,OAAO,CAC3B,CAAC,SAAS,uBAAuB,CAAC,OAAO,UAAU,CAAC,EAEpD,OAAO,EAAE,QAAQ,CAAC,UAAU,GAAG,GAAG,QAAQ,CAAC,UAAU,EAAE,EACvD,OAAO,EAAE,CAAC,CAAC,SAAS,CAAC,GACpB,OAAO,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC;AAExB,wBAAsB,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -42,6 +42,7 @@ const external_picocolors_namespaceObject = require("picocolors");
|
|
|
42
42
|
const index_js_namespaceObject = require("./commands/index.js");
|
|
43
43
|
const external_constants_js_namespaceObject = require("./constants.js");
|
|
44
44
|
const logger_namespaceObject = require("@rsdoctor/utils/logger");
|
|
45
|
+
const stats_analyze_js_namespaceObject = require("./commands/stats-analyze.js");
|
|
45
46
|
async function execute(command, options) {
|
|
46
47
|
const cwd = process.cwd();
|
|
47
48
|
const { name, version } = external_constants_js_namespaceObject.pkg;
|
|
@@ -54,6 +55,10 @@ async function execute(command, options) {
|
|
|
54
55
|
const { action } = (0, index_js_namespaceObject.analyze)(ctx);
|
|
55
56
|
return action(options);
|
|
56
57
|
}
|
|
58
|
+
if (command === external_constants_js_namespaceObject.Commands.StatsAnalyze) {
|
|
59
|
+
const { action } = (0, stats_analyze_js_namespaceObject.statsAnalyze)(ctx);
|
|
60
|
+
return action(options);
|
|
61
|
+
}
|
|
57
62
|
if (command === external_constants_js_namespaceObject.Commands.BundleDiff) {
|
|
58
63
|
const { action } = (0, index_js_namespaceObject.bundleDiff)(ctx);
|
|
59
64
|
return action(options);
|
|
@@ -63,7 +68,8 @@ async function execute(command, options) {
|
|
|
63
68
|
args.version(version);
|
|
64
69
|
const commands = [
|
|
65
70
|
index_js_namespaceObject.analyze,
|
|
66
|
-
index_js_namespaceObject.bundleDiff
|
|
71
|
+
index_js_namespaceObject.bundleDiff,
|
|
72
|
+
stats_analyze_js_namespaceObject.statsAnalyze
|
|
67
73
|
];
|
|
68
74
|
commands.forEach((cmd)=>{
|
|
69
75
|
const { command, description, options, action } = cmd(ctx);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rsdoctor/cli",
|
|
3
|
-
"version": "1.2.2
|
|
3
|
+
"version": "1.2.2",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/web-infra-dev/rsdoctor",
|
|
@@ -28,10 +28,11 @@
|
|
|
28
28
|
"picocolors": "^1.1.1",
|
|
29
29
|
"tslib": "2.8.1",
|
|
30
30
|
"yargs": "17.7.2",
|
|
31
|
-
"@rsdoctor/client": "1.2.2
|
|
32
|
-
"@rsdoctor/
|
|
33
|
-
"@rsdoctor/
|
|
34
|
-
"@rsdoctor/
|
|
31
|
+
"@rsdoctor/client": "1.2.2",
|
|
32
|
+
"@rsdoctor/types": "1.2.2",
|
|
33
|
+
"@rsdoctor/utils": "1.2.2",
|
|
34
|
+
"@rsdoctor/core": "1.2.2",
|
|
35
|
+
"@rsdoctor/sdk": "1.2.2"
|
|
35
36
|
},
|
|
36
37
|
"publishConfig": {
|
|
37
38
|
"access": "public",
|