@rsdoctor/cli 1.2.3 → 1.2.4-beta.1

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.
@@ -0,0 +1,13 @@
1
+ /*!
2
+ * mime-db
3
+ * Copyright(c) 2014 Jonathan Ong
4
+ * Copyright(c) 2015-2022 Douglas Christopher Wilson
5
+ * MIT Licensed
6
+ */
7
+
8
+ /*!
9
+ * mime-types
10
+ * Copyright(c) 2014 Jonathan Ong
11
+ * Copyright(c) 2015 Douglas Christopher Wilson
12
+ * MIT Licensed
13
+ */
package/dist/types.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { Common } from '@rsdoctor/types';
2
- import { Argv } from 'yargs';
2
+ import type { Command as CACCommand } from 'cac';
3
3
  export interface Command<CMD, Options = Common.PlainObject, Result = unknown> {
4
4
  (ctx: CommandContext): CommandOutput<CMD, Options, Result>;
5
5
  }
@@ -11,7 +11,7 @@ export interface CommandContext {
11
11
  export interface CommandOutput<CMD, Options, Result> {
12
12
  command: CMD;
13
13
  description: string;
14
- options(yargs: Argv<Options>): void;
14
+ options(cli: CACCommand): void;
15
15
  action(args: Options): Result | Promise<Result>;
16
16
  }
17
17
  export type GetCommandArgumentsType<T> = T extends Command<infer C, infer Options, infer Result> ? {
@@ -19,4 +19,3 @@ export type GetCommandArgumentsType<T> = T extends Command<infer C, infer Option
19
19
  options: Options;
20
20
  result: Result;
21
21
  } : unknown;
22
- //# sourceMappingURL=types.d.ts.map
package/dist/utils.d.ts CHANGED
@@ -7,4 +7,3 @@ export declare function readFile(url: string, cwd: string): Promise<string>;
7
7
  export declare function loadJSON<T extends Common.PlainObject>(uri: string, cwd: string): Promise<T>;
8
8
  export declare function loadShardingFile(uri: string, cwd: string): Promise<string>;
9
9
  export declare function loadShardingFileWithSpinner(uri: string, cwd: string, spinner: Ora): Promise<string>;
10
- //# sourceMappingURL=utils.d.ts.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rsdoctor/cli",
3
- "version": "1.2.3",
3
+ "version": "1.2.4-beta.1",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/web-infra-dev/rsdoctor",
@@ -13,24 +13,30 @@
13
13
  "bin",
14
14
  "dist"
15
15
  ],
16
+ "exports": {
17
+ ".": {
18
+ "types": "./dist/index.d.ts",
19
+ "import": "./dist/index.js",
20
+ "default": "./dist/index.cjs"
21
+ }
22
+ },
16
23
  "license": "MIT",
17
24
  "main": "dist/index.js",
18
- "module": "dist/index.js",
19
25
  "types": "dist/index.d.ts",
20
- "devDependencies": {
21
- "@rslib/core": "^0.11.0",
22
- "@types/yargs": "17.0.33",
23
- "typescript": "^5.2.2"
24
- },
26
+ "type": "module",
25
27
  "dependencies": {
26
- "axios": "^1.11.0",
27
28
  "ora": "^5.4.1",
28
- "picocolors": "^1.1.1",
29
- "yargs": "17.7.2",
30
- "@rsdoctor/types": "1.2.3",
31
- "@rsdoctor/utils": "1.2.3",
32
- "@rsdoctor/core": "1.2.3",
33
- "@rsdoctor/sdk": "1.2.3"
29
+ "@rsdoctor/sdk": "1.2.4-beta.1",
30
+ "@rsdoctor/core": "1.2.4-beta.1",
31
+ "@rsdoctor/types": "1.2.4-beta.1",
32
+ "@rsdoctor/utils": "1.2.4-beta.1",
33
+ "@rsdoctor/graph": "1.2.4-beta.1"
34
+ },
35
+ "devDependencies": {
36
+ "cac": "^6.7.14",
37
+ "typescript": "^5.9.2",
38
+ "axios": "^1.12.0",
39
+ "picocolors": "^1.1.1"
34
40
  },
35
41
  "publishConfig": {
36
42
  "access": "public",
@@ -1 +0,0 @@
1
- {"version":3,"file":"analyze.d.ts","sourceRoot":"","sources":["../../src/commands/analyze.ts"],"names":[],"mappings":"AACA,OAAO,EAAuC,GAAG,EAAE,MAAM,iBAAiB,CAAC;AAC3E,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAG5C,OAAO,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AAMnC,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAExC,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,OAAO,EAAE,OAAO,CAAC,QAAQ,CAAC,OAAO,EAAE,OAAO,EAAE,WAAW,CAyF/D,CAAC"}
@@ -1,117 +0,0 @@
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
- analyze: ()=>analyze
37
- });
38
- const common_namespaceObject = require("@rsdoctor/utils/common");
39
- const types_namespaceObject = require("@rsdoctor/types");
40
- const sdk_namespaceObject = require("@rsdoctor/sdk");
41
- const external_ora_namespaceObject = require("ora");
42
- var external_ora_default = /*#__PURE__*/ __webpack_require__.n(external_ora_namespaceObject);
43
- const external_picocolors_namespaceObject = require("picocolors");
44
- const external_utils_js_namespaceObject = require("../utils.js");
45
- const external_constants_js_namespaceObject = require("../constants.js");
46
- const analyze = (0, external_utils_js_namespaceObject.enhanceCommand)(({ cwd, name, bin })=>({
47
- command: external_constants_js_namespaceObject.Commands.Analyze,
48
- description: `
49
- use ${name} to open "${types_namespaceObject.Constants.RsdoctorOutputManifestPath}" in browser for analysis.
50
-
51
- example: ${bin} ${external_constants_js_namespaceObject.Commands.Analyze} --profile "${types_namespaceObject.Constants.RsdoctorOutputManifestPath}"
52
-
53
- `.trim(),
54
- options (yargs) {
55
- yargs.option('profile', {
56
- type: 'string',
57
- description: 'profile for Rsdoctor server',
58
- demandOption: true
59
- }).option('open', {
60
- type: 'boolean',
61
- description: 'turn off it if you need not open browser automatically',
62
- default: true
63
- }).option('port', {
64
- type: 'number',
65
- description: 'port for Rsdoctor Server'
66
- }).option('type', {
67
- type: 'string',
68
- description: 'if need lite bundle mode'
69
- });
70
- },
71
- async action ({ profile, open = true, port, type = types_namespaceObject.SDK.ToDataType.Normal }) {
72
- const spinner = external_ora_default()({
73
- prefixText: (0, external_picocolors_namespaceObject.cyan)(`[${name}]`)
74
- }).start(`start to loading "${profile}"`);
75
- const json = await (0, external_utils_js_namespaceObject.loadJSON)(profile, cwd);
76
- spinner.text = "start to loading data...";
77
- let dataValue;
78
- try {
79
- dataValue = await common_namespaceObject.Manifest.fetchShardingFiles(json.data, (url)=>(0, external_utils_js_namespaceObject.loadShardingFileWithSpinner)(url, cwd, spinner));
80
- } catch (error) {
81
- try {
82
- dataValue = await common_namespaceObject.Manifest.fetchShardingFiles(json.cloudData || {}, (url)=>(0, external_utils_js_namespaceObject.loadShardingFileWithSpinner)(url, cwd, spinner));
83
- } catch (e) {
84
- spinner.fail((0, external_picocolors_namespaceObject.red)(error.message));
85
- throw error;
86
- }
87
- }
88
- spinner.text = "start server";
89
- const sdk = new sdk_namespaceObject.RsdoctorSDK({
90
- name,
91
- root: cwd,
92
- port,
93
- type
94
- });
95
- await sdk.bootstrap();
96
- sdk.getStoreData = ()=>dataValue;
97
- sdk.getManifestData = ()=>json;
98
- const manifestBuffer = Buffer.from(JSON.stringify({
99
- ...json,
100
- __LOCAL__SERVER__: true
101
- }));
102
- sdk.server.proxy(types_namespaceObject.SDK.ServerAPI.API.Manifest, 'GET', ()=>manifestBuffer);
103
- if (open) {
104
- spinner.text = "open browser automatically";
105
- await sdk.server.openClientPage('homepage');
106
- }
107
- spinner.succeed(`the local url: ${(0, external_picocolors_namespaceObject.cyan)(sdk.server.getClientUrl('homepage'))}`);
108
- return sdk;
109
- }
110
- }));
111
- exports.analyze = __webpack_exports__.analyze;
112
- for(var __webpack_i__ in __webpack_exports__)if (-1 === [
113
- "analyze"
114
- ].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
115
- Object.defineProperty(exports, '__esModule', {
116
- value: true
117
- });
@@ -1 +0,0 @@
1
- {"version":3,"file":"bundle-diff.d.ts","sourceRoot":"","sources":["../../src/commands/bundle-diff.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AAMnC,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AACxC,OAAO,EAAoC,GAAG,EAAE,MAAM,iBAAiB,CAAC;AAIxE,UAAU,OAAO;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AAED,eAAO,MAAM,UAAU,EAAE,OAAO,CAC9B,QAAQ,CAAC,UAAU,EACnB,OAAO,EACP,GAAG,CAAC,mBAAmB,CAyJtB,CAAC"}
@@ -1,152 +0,0 @@
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
- bundleDiff: ()=>bundleDiff
37
- });
38
- const external_ora_namespaceObject = require("ora");
39
- var external_ora_default = /*#__PURE__*/ __webpack_require__.n(external_ora_namespaceObject);
40
- const external_picocolors_namespaceObject = require("picocolors");
41
- const external_utils_js_namespaceObject = require("../utils.js");
42
- const external_constants_js_namespaceObject = require("../constants.js");
43
- const types_namespaceObject = require("@rsdoctor/types");
44
- const common_namespaceObject = require("@rsdoctor/utils/common");
45
- const sdk_namespaceObject = require("@rsdoctor/sdk");
46
- const bundleDiff = (0, external_utils_js_namespaceObject.enhanceCommand)(({ cwd, bin, name })=>({
47
- command: external_constants_js_namespaceObject.Commands.BundleDiff,
48
- description: `
49
- use ${name} to open the bundle diff result in browser for analysis.
50
-
51
- example: ${bin} ${external_constants_js_namespaceObject.Commands.BundleDiff} --baseline="x.json" --current="x.json"
52
- `.trim(),
53
- options (yargs) {
54
- yargs.option('current', {
55
- type: 'string',
56
- description: 'the url or file path of the profile json as the current',
57
- demandOption: true
58
- }).option('baseline', {
59
- type: 'string',
60
- description: 'the url or file path of the profile json as the baseline',
61
- demandOption: true
62
- });
63
- },
64
- async action ({ baseline, current, open = true }) {
65
- const spinner = external_ora_default()({
66
- prefixText: (0, external_picocolors_namespaceObject.cyan)(`[${name}]`)
67
- }).start();
68
- spinner.text = `loading "${baseline}"`;
69
- const baselineData = {
70
- ...await (0, external_utils_js_namespaceObject.loadJSON)(baseline, cwd),
71
- client: {
72
- enableRoutes: []
73
- }
74
- };
75
- let baselineDataValue;
76
- try {
77
- baselineDataValue = await common_namespaceObject.Manifest.fetchShardingFiles(baselineData.data, (url)=>(0, external_utils_js_namespaceObject.loadShardingFileWithSpinner)(url, cwd, spinner));
78
- } catch (error) {
79
- if (baselineData.cloudData) {
80
- spinner.text = 'load the "baselineData.cloudData" instead of the "baselineData.data"';
81
- baselineDataValue = await common_namespaceObject.Manifest.fetchShardingFiles(baselineData.cloudData, (url)=>(0, external_utils_js_namespaceObject.loadShardingFileWithSpinner)(url, cwd, spinner));
82
- } else {
83
- spinner.fail((0, external_picocolors_namespaceObject.red)(error.message));
84
- throw error;
85
- }
86
- }
87
- spinner.text = `loading "${current}"`;
88
- const currentData = {
89
- ...await (0, external_utils_js_namespaceObject.loadJSON)(current, cwd),
90
- client: {
91
- enableRoutes: []
92
- }
93
- };
94
- let currentDataValue;
95
- try {
96
- currentDataValue = await common_namespaceObject.Manifest.fetchShardingFiles(currentData.data, (url)=>(0, external_utils_js_namespaceObject.loadShardingFileWithSpinner)(url, cwd, spinner));
97
- } catch (error) {
98
- if (currentData.cloudData) {
99
- spinner.text = 'load the "currentData.cloudData" instead of the "currentData.data"';
100
- currentDataValue = await common_namespaceObject.Manifest.fetchShardingFiles(currentData.cloudData, (url)=>(0, external_utils_js_namespaceObject.loadShardingFileWithSpinner)(url, cwd, spinner));
101
- } else {
102
- spinner.fail((0, external_picocolors_namespaceObject.red)(error.message));
103
- throw error;
104
- }
105
- }
106
- spinner.text = "start server";
107
- const baselineSdk = new sdk_namespaceObject.RsdoctorSDK({
108
- name,
109
- root: cwd
110
- });
111
- const currentSdk = new sdk_namespaceObject.RsdoctorSDK({
112
- name,
113
- root: cwd
114
- });
115
- await Promise.all([
116
- baselineSdk.bootstrap(),
117
- currentSdk.bootstrap()
118
- ]);
119
- const baselineManifestsBuffer = Buffer.from(JSON.stringify({
120
- __LOCAL__SERVER__: true,
121
- __SOCKET__URL__: baselineSdk.server.socketUrl.socketUrl,
122
- __SOCKET__PORT__: baselineSdk.server.socketUrl.port,
123
- ...baselineData
124
- }));
125
- const currentManifestsBuffer = Buffer.from(JSON.stringify({
126
- __LOCAL__SERVER__: true,
127
- __SOCKET__PORT__: currentSdk.server.socketUrl.port,
128
- __SOCKET__URL__: currentSdk.server.socketUrl.socketUrl,
129
- ...currentData
130
- }));
131
- baselineSdk.getStoreData = ()=>baselineDataValue;
132
- currentSdk.getStoreData = ()=>currentDataValue;
133
- baselineSdk.getManifestData = ()=>baselineData;
134
- currentSdk.getManifestData = ()=>currentData;
135
- baselineSdk.server.proxy(types_namespaceObject.SDK.ServerAPI.API.BundleDiffManifest, 'GET', ()=>baselineManifestsBuffer);
136
- currentSdk.server.proxy(types_namespaceObject.SDK.ServerAPI.API.BundleDiffManifest, 'GET', ()=>currentManifestsBuffer);
137
- spinner.text = "server bootstrap success";
138
- const localBaselineManifestUrl = baselineSdk.server.origin + types_namespaceObject.SDK.ServerAPI.API.BundleDiffManifest;
139
- const localCurrentManifestUrl = currentSdk.server.origin + types_namespaceObject.SDK.ServerAPI.API.BundleDiffManifest;
140
- baselineSdk.server.getClientUrl(types_namespaceObject.Client.RsdoctorClientRoutes.BundleDiff, localBaselineManifestUrl, localCurrentManifestUrl);
141
- if (open) await baselineSdk.server.openClientPage(types_namespaceObject.Client.RsdoctorClientRoutes.BundleDiff, localBaselineManifestUrl, localCurrentManifestUrl);
142
- spinner.succeed("Bundle Diff page has been open.");
143
- return baselineSdk;
144
- }
145
- }));
146
- exports.bundleDiff = __webpack_exports__.bundleDiff;
147
- for(var __webpack_i__ in __webpack_exports__)if (-1 === [
148
- "bundleDiff"
149
- ].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
150
- Object.defineProperty(exports, '__esModule', {
151
- value: true
152
- });
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/commands/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,eAAe,CAAC"}
@@ -1,69 +0,0 @@
1
- "use strict";
2
- var __webpack_modules__ = {
3
- "./analyze": function(module) {
4
- module.exports = require("./analyze.js");
5
- },
6
- "./bundle-diff": function(module) {
7
- module.exports = require("./bundle-diff.js");
8
- }
9
- };
10
- var __webpack_module_cache__ = {};
11
- function __webpack_require__(moduleId) {
12
- var cachedModule = __webpack_module_cache__[moduleId];
13
- if (void 0 !== cachedModule) return cachedModule.exports;
14
- var module = __webpack_module_cache__[moduleId] = {
15
- exports: {}
16
- };
17
- __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
18
- return module.exports;
19
- }
20
- (()=>{
21
- __webpack_require__.n = (module)=>{
22
- var getter = module && module.__esModule ? ()=>module['default'] : ()=>module;
23
- __webpack_require__.d(getter, {
24
- a: getter
25
- });
26
- return getter;
27
- };
28
- })();
29
- (()=>{
30
- __webpack_require__.d = (exports1, definition)=>{
31
- for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
32
- enumerable: true,
33
- get: definition[key]
34
- });
35
- };
36
- })();
37
- (()=>{
38
- __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
39
- })();
40
- (()=>{
41
- __webpack_require__.r = (exports1)=>{
42
- if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
43
- value: 'Module'
44
- });
45
- Object.defineProperty(exports1, '__esModule', {
46
- value: true
47
- });
48
- };
49
- })();
50
- var __webpack_exports__ = {};
51
- (()=>{
52
- __webpack_require__.r(__webpack_exports__);
53
- var _analyze__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("./analyze");
54
- var __WEBPACK_REEXPORT_OBJECT__ = {};
55
- for(var __WEBPACK_IMPORT_KEY__ in _analyze__WEBPACK_IMPORTED_MODULE_0__)if ("default" !== __WEBPACK_IMPORT_KEY__) __WEBPACK_REEXPORT_OBJECT__[__WEBPACK_IMPORT_KEY__] = (function(key) {
56
- return _analyze__WEBPACK_IMPORTED_MODULE_0__[key];
57
- }).bind(0, __WEBPACK_IMPORT_KEY__);
58
- __webpack_require__.d(__webpack_exports__, __WEBPACK_REEXPORT_OBJECT__);
59
- var _bundle_diff__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__("./bundle-diff");
60
- var __WEBPACK_REEXPORT_OBJECT__ = {};
61
- for(var __WEBPACK_IMPORT_KEY__ in _bundle_diff__WEBPACK_IMPORTED_MODULE_1__)if ("default" !== __WEBPACK_IMPORT_KEY__) __WEBPACK_REEXPORT_OBJECT__[__WEBPACK_IMPORT_KEY__] = (function(key) {
62
- return _bundle_diff__WEBPACK_IMPORTED_MODULE_1__[key];
63
- }).bind(0, __WEBPACK_IMPORT_KEY__);
64
- __webpack_require__.d(__webpack_exports__, __WEBPACK_REEXPORT_OBJECT__);
65
- })();
66
- for(var __webpack_i__ in __webpack_exports__)exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
67
- Object.defineProperty(exports, '__esModule', {
68
- value: true
69
- });
@@ -1 +0,0 @@
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"}
@@ -1,98 +0,0 @@
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
- });
@@ -1 +0,0 @@
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 DELETED
@@ -1,65 +0,0 @@
1
- "use strict";
2
- var __webpack_modules__ = {
3
- "../package.json": function(module) {
4
- module.exports = require("../package.json");
5
- }
6
- };
7
- var __webpack_module_cache__ = {};
8
- function __webpack_require__(moduleId) {
9
- var cachedModule = __webpack_module_cache__[moduleId];
10
- if (void 0 !== cachedModule) return cachedModule.exports;
11
- var module = __webpack_module_cache__[moduleId] = {
12
- exports: {}
13
- };
14
- __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
15
- return module.exports;
16
- }
17
- (()=>{
18
- __webpack_require__.d = (exports1, definition)=>{
19
- for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
20
- enumerable: true,
21
- get: definition[key]
22
- });
23
- };
24
- })();
25
- (()=>{
26
- __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
27
- })();
28
- (()=>{
29
- __webpack_require__.r = (exports1)=>{
30
- if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
31
- value: 'Module'
32
- });
33
- Object.defineProperty(exports1, '__esModule', {
34
- value: true
35
- });
36
- };
37
- })();
38
- var __webpack_exports__ = {};
39
- (()=>{
40
- __webpack_require__.r(__webpack_exports__);
41
- __webpack_require__.d(__webpack_exports__, {
42
- Commands: ()=>Commands,
43
- bin: ()=>bin,
44
- pkg: ()=>pkg
45
- });
46
- var Commands = /*#__PURE__*/ function(Commands) {
47
- Commands["Analyze"] = "analyze";
48
- Commands["BundleDiff"] = "bundle-diff";
49
- Commands["StatsAnalyze"] = "stats-analyze";
50
- return Commands;
51
- }({});
52
- const pkg = __webpack_require__("../package.json");
53
- const bin = Object.keys(pkg.bin)[0];
54
- })();
55
- exports.Commands = __webpack_exports__.Commands;
56
- exports.bin = __webpack_exports__.bin;
57
- exports.pkg = __webpack_exports__.pkg;
58
- for(var __webpack_i__ in __webpack_exports__)if (-1 === [
59
- "Commands",
60
- "bin",
61
- "pkg"
62
- ].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
63
- Object.defineProperty(exports, '__esModule', {
64
- value: true
65
- });
@@ -1 +0,0 @@
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"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AACzC,OAAO,EAAE,IAAI,EAAE,MAAM,OAAO,CAAC;AAE7B,MAAM,WAAW,OAAO,CAAC,GAAG,EAAE,OAAO,GAAG,MAAM,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO;IAC1E,CAAC,GAAG,EAAE,cAAc,GAAG,aAAa,CAAC,GAAG,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC;CAC5D;AAED,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC;CACb;AAED,MAAM,WAAW,aAAa,CAAC,GAAG,EAAE,OAAO,EAAE,MAAM;IACjD,OAAO,EAAE,GAAG,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,CAAC,KAAK,EAAE,IAAI,CAAC,OAAO,CAAC,GAAG,IAAI,CAAC;IACpC,MAAM,CAAC,IAAI,EAAE,OAAO,GAAG,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;CACjD;AAED,MAAM,MAAM,uBAAuB,CAAC,CAAC,IAAI,CAAC,SAAS,OAAO,CACxD,MAAM,CAAC,EACP,MAAM,OAAO,EACb,MAAM,MAAM,CACb,GACG;IACE,OAAO,EAAE,CAAC,CAAC;IACX,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;CAChB,GACD,OAAO,CAAC"}
package/dist/types.js DELETED
@@ -1,18 +0,0 @@
1
- "use strict";
2
- var __webpack_require__ = {};
3
- (()=>{
4
- __webpack_require__.r = (exports1)=>{
5
- if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
6
- value: 'Module'
7
- });
8
- Object.defineProperty(exports1, '__esModule', {
9
- value: true
10
- });
11
- };
12
- })();
13
- var __webpack_exports__ = {};
14
- __webpack_require__.r(__webpack_exports__);
15
- for(var __webpack_i__ in __webpack_exports__)exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
16
- Object.defineProperty(exports, '__esModule', {
17
- value: true
18
- });
@@ -1 +0,0 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAC1B,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAIzC,wBAAgB,cAAc,CAAC,GAAG,SAAS,MAAM,EAAE,OAAO,EAAE,MAAM,EAChE,EAAE,EAAE,OAAO,CAAC,GAAG,EAAE,OAAO,EAAE,MAAM,CAAC,GAChC,OAAO,CAAC,GAAG,EAAE,OAAO,EAAE,MAAM,CAAC,CAK/B;AAED,wBAAsB,SAAS,CAAC,GAAG,EAAE,MAAM,gBAS1C;AAED,wBAAsB,QAAQ,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,mBAItD;AAED,wBAAsB,QAAQ,CAAC,CAAC,SAAS,MAAM,CAAC,WAAW,EACzD,GAAG,EAAE,MAAM,EACX,GAAG,EAAE,MAAM,GACV,OAAO,CAAC,CAAC,CAAC,CAUZ;AAED,wBAAsB,gBAAgB,CACpC,GAAG,EAAE,MAAM,EACX,GAAG,EAAE,MAAM,GACV,OAAO,CAAC,MAAM,CAAC,CAUjB;AAED,wBAAsB,2BAA2B,CAC/C,GAAG,EAAE,MAAM,EACX,GAAG,EAAE,MAAM,EACX,OAAO,EAAE,GAAG,GACX,OAAO,CAAC,MAAM,CAAC,CAKjB"}