@rsdoctor/cli 1.5.5 → 1.5.6-canary.0

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.
@@ -6,6 +6,7 @@ interface Options {
6
6
  baseline: string;
7
7
  open?: boolean;
8
8
  html?: boolean;
9
+ json?: boolean | string;
9
10
  output?: string;
10
11
  }
11
12
  export declare const bundleDiff: Command<Commands.BundleDiff, Options, RsdoctorSDK<{
package/dist/index.cjs CHANGED
@@ -4295,7 +4295,7 @@ for(var __rspack_i in (()=>{
4295
4295
  async function loadShardingFileWithSpinner(uri, cwd, spinner) {
4296
4296
  return loadShardingFile(uri, cwd).then((res)=>(spinner.text = `loaded "${uri}"`, res));
4297
4297
  }
4298
- var package_namespaceObject = JSON.parse('{"name":"@rsdoctor/cli","version":"1.5.5","repository":{"type":"git","url":"https://github.com/web-infra-dev/rsdoctor","directory":"packages/cli"},"bin":{"rsdoctor":"./bin/rsdoctor"},"files":["bin","dist"],"exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js","default":"./dist/index.cjs"}},"license":"MIT","main":"dist/index.js","types":"dist/index.d.ts","scripts":{"dev":"npm run start","build":"rslib build","start":"rslib build -w","test":"rstest run"},"type":"module","dependencies":{"ora":"^5.4.1","@rsdoctor/core":"workspace:*","@rsdoctor/sdk":"workspace:*","@rsdoctor/types":"workspace:*","@rsdoctor/utils":"workspace:*","@rsdoctor/graph":"workspace:*"},"devDependencies":{"@rsdoctor/client":"workspace:*","cac":"^7.0.0","typescript":"^5.9.2","axios":"^1.13.6","picocolors":"^1.1.1"},"peerDependencies":{"@rsdoctor/client":"workspace:*"},"publishConfig":{"access":"public","registry":"https://registry.npmjs.org/"}}');
4298
+ var package_namespaceObject = JSON.parse('{"name":"@rsdoctor/cli","version":"1.5.6-canary.0","repository":{"type":"git","url":"https://github.com/web-infra-dev/rsdoctor","directory":"packages/cli"},"bin":{"rsdoctor":"./bin/rsdoctor"},"files":["bin","dist"],"exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js","default":"./dist/index.cjs"}},"license":"MIT","main":"dist/index.js","types":"dist/index.d.ts","scripts":{"dev":"npm run start","build":"rslib build","start":"rslib build -w","test":"rstest run"},"type":"module","dependencies":{"ora":"^5.4.1","@rsdoctor/core":"workspace:*","@rsdoctor/sdk":"workspace:*","@rsdoctor/types":"workspace:*","@rsdoctor/utils":"workspace:*","@rsdoctor/graph":"workspace:*"},"devDependencies":{"@rsdoctor/client":"workspace:*","cac":"^7.0.0","typescript":"^5.9.2","axios":"^1.13.6","picocolors":"^1.1.1"},"peerDependencies":{"@rsdoctor/client":"workspace:*"},"publishConfig":{"access":"public","registry":"https://registry.npmjs.org/"}}');
4299
4299
  let constants_bin = Object.keys(package_namespaceObject.bin)[0], analyze = enhanceCommand(({ cwd, name, bin })=>({
4300
4300
  command: "analyze",
4301
4301
  description: `
@@ -4345,9 +4345,9 @@ use ${name} to open the bundle diff result in browser for analysis.
4345
4345
  example: ${bin} bundle-diff --baseline="x.json" --current="x.json"
4346
4346
  `.trim(),
4347
4347
  options (cli) {
4348
- cli.option('--current <path>', 'the url or file path of the profile json as the current').option('--baseline <path>', 'the url or file path of the profile json as the baseline').option('--html', 'output as a standalone HTML file').option('--output <path>', 'output file path for HTML mode (default: rsdoctor-diff.html)');
4348
+ cli.option('--current <path>', 'the url or file path of the profile json as the current').option('--baseline <path>', 'the url or file path of the profile json as the baseline').option('--html', 'output as a standalone HTML file').option('--json [path]', 'output as a JSON file, optionally specify file path (default: rsdoctor-diff.json)').option('--output <path>', 'output file path for HTML/JSON mode (default: rsdoctor-diff.html or rsdoctor-diff.json)');
4349
4349
  },
4350
- async action ({ baseline, current, open = !0, html = !1, output = 'rsdoctor-diff.html' }) {
4350
+ async action ({ baseline, current, open = !0, html = !1, json = !1, output }) {
4351
4351
  let baselineDataValue, currentDataValue, spinner = external_ora_default()({
4352
4352
  prefixText: (0, picocolors.cyan)(`[${name}]`)
4353
4353
  }).start();
@@ -4377,6 +4377,15 @@ example: ${bin} bundle-diff --baseline="x.json" --current="x.json"
4377
4377
  if (currentData.cloudData) spinner.text = 'load the "currentData.cloudData" instead of the "currentData.data"', currentDataValue = await common_namespaceObject.Manifest.fetchShardingFiles(currentData.cloudData, (url)=>loadShardingFileWithSpinner(url, cwd, spinner));
4378
4378
  else throw spinner.fail((0, picocolors.red)(error.message)), error;
4379
4379
  }
4380
+ if (json) {
4381
+ spinner.text = 'Generating JSON output file...';
4382
+ let outputPath = external_path_default().resolve(cwd, 'string' == typeof json ? json : 'rsdoctor-diff.json');
4383
+ external_fs_default().mkdirSync(external_path_default().dirname(outputPath), {
4384
+ recursive: !0
4385
+ });
4386
+ let jsonData = common_namespaceObject.Graph.getBundleDiffResult(baselineDataValue, currentDataValue);
4387
+ return external_fs_default().writeFileSync(outputPath, JSON.stringify(jsonData, null, 2), 'utf-8'), spinner.succeed(`Generated JSON output file at: ${outputPath}`), null;
4388
+ }
4380
4389
  if (!html) {
4381
4390
  spinner.text = "start server";
4382
4391
  let baselineSdk = new sdk_namespaceObject.RsdoctorSDK({
@@ -4437,7 +4446,7 @@ example: ${bin} bundle-diff --baseline="x.json" --current="x.json"
4437
4446
  `window.${types_namespaceObject.Constants.WINDOW_RSDOCTOR_TAG}.mode = 'diff';`
4438
4447
  ].map((script)=>`<script>${script}</script>`).join('\n');
4439
4448
  htmlContent = htmlContent.replace('<body>', `<body>${compressTextScripts}`);
4440
- let outputPath = external_path_default().resolve(cwd, output);
4449
+ let outputPath = external_path_default().resolve(cwd, output || 'rsdoctor-diff.html');
4441
4450
  external_fs_default().mkdirSync(external_path_default().dirname(outputPath), {
4442
4451
  recursive: !0
4443
4452
  }), external_fs_default().writeFileSync(outputPath, htmlContent, 'utf-8'), spinner.succeed(`Generated standalone HTML file at: ${outputPath}`);
package/dist/index.js CHANGED
@@ -12,7 +12,7 @@ import * as __rspack_external_tty from "tty";
12
12
  import url_0, * as __rspack_external_url from "url";
13
13
  import util, * as __rspack_external_util from "util";
14
14
  import { __webpack_require__ } from "./rslib-runtime.js";
15
- import { Algorithm, Manifest, Url } from "@rsdoctor/utils/common";
15
+ import { Algorithm, Graph, Manifest, Url } from "@rsdoctor/utils/common";
16
16
  import { Client, Constants, Manifest as types_Manifest, SDK } from "@rsdoctor/types";
17
17
  import { RsdoctorSDK } from "@rsdoctor/sdk";
18
18
  import ora from "ora";
@@ -4208,7 +4208,7 @@ axios.Axios = Axios, axios.CanceledError = cancel_CanceledError, axios.CancelTok
4208
4208
  }, axios.isAxiosError = function(payload) {
4209
4209
  return utils.isObject(payload) && !0 === payload.isAxiosError;
4210
4210
  }, axios.mergeConfig = mergeConfig, axios.AxiosHeaders = AxiosHeaders, axios.formToJSON = (thing)=>helpers_formDataToJSON(utils.isHTMLForm(thing) ? new FormData(thing) : thing), axios.getAdapter = adapters_adapters_getAdapter, axios.HttpStatusCode = HttpStatusCode, axios.default = axios;
4211
- var package_namespaceObject = JSON.parse('{"name":"@rsdoctor/cli","version":"1.5.5","repository":{"type":"git","url":"https://github.com/web-infra-dev/rsdoctor","directory":"packages/cli"},"bin":{"rsdoctor":"./bin/rsdoctor"},"files":["bin","dist"],"exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js","default":"./dist/index.cjs"}},"license":"MIT","main":"dist/index.js","types":"dist/index.d.ts","scripts":{"dev":"npm run start","build":"rslib build","start":"rslib build -w","test":"rstest run"},"type":"module","dependencies":{"ora":"^5.4.1","@rsdoctor/core":"workspace:*","@rsdoctor/sdk":"workspace:*","@rsdoctor/types":"workspace:*","@rsdoctor/utils":"workspace:*","@rsdoctor/graph":"workspace:*"},"devDependencies":{"@rsdoctor/client":"workspace:*","cac":"^7.0.0","typescript":"^5.9.2","axios":"^1.13.6","picocolors":"^1.1.1"},"peerDependencies":{"@rsdoctor/client":"workspace:*"},"publishConfig":{"access":"public","registry":"https://registry.npmjs.org/"}}');
4211
+ var package_namespaceObject = JSON.parse('{"name":"@rsdoctor/cli","version":"1.5.6-canary.0","repository":{"type":"git","url":"https://github.com/web-infra-dev/rsdoctor","directory":"packages/cli"},"bin":{"rsdoctor":"./bin/rsdoctor"},"files":["bin","dist"],"exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js","default":"./dist/index.cjs"}},"license":"MIT","main":"dist/index.js","types":"dist/index.d.ts","scripts":{"dev":"npm run start","build":"rslib build","start":"rslib build -w","test":"rstest run"},"type":"module","dependencies":{"ora":"^5.4.1","@rsdoctor/core":"workspace:*","@rsdoctor/sdk":"workspace:*","@rsdoctor/types":"workspace:*","@rsdoctor/utils":"workspace:*","@rsdoctor/graph":"workspace:*"},"devDependencies":{"@rsdoctor/client":"workspace:*","cac":"^7.0.0","typescript":"^5.9.2","axios":"^1.13.6","picocolors":"^1.1.1"},"peerDependencies":{"@rsdoctor/client":"workspace:*"},"publishConfig":{"access":"public","registry":"https://registry.npmjs.org/"}}');
4212
4212
  let constants_bin = Object.keys(package_namespaceObject.bin)[0], picocolors = __webpack_require__("../../node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.js"), analyze = (fn = ({ cwd, name, bin })=>({
4213
4213
  command: "analyze",
4214
4214
  description: `
@@ -4256,9 +4256,9 @@ use ${name} to open the bundle diff result in browser for analysis.
4256
4256
  example: ${bin} bundle-diff --baseline="x.json" --current="x.json"
4257
4257
  `.trim(),
4258
4258
  options (cli) {
4259
- cli.option('--current <path>', 'the url or file path of the profile json as the current').option('--baseline <path>', 'the url or file path of the profile json as the baseline').option('--html', 'output as a standalone HTML file').option('--output <path>', 'output file path for HTML mode (default: rsdoctor-diff.html)');
4259
+ cli.option('--current <path>', 'the url or file path of the profile json as the current').option('--baseline <path>', 'the url or file path of the profile json as the baseline').option('--html', 'output as a standalone HTML file').option('--json [path]', 'output as a JSON file, optionally specify file path (default: rsdoctor-diff.json)').option('--output <path>', 'output file path for HTML/JSON mode (default: rsdoctor-diff.html or rsdoctor-diff.json)');
4260
4260
  },
4261
- async action ({ baseline, current, open = !0, html = !1, output = 'rsdoctor-diff.html' }) {
4261
+ async action ({ baseline, current, open = !0, html = !1, json = !1, output }) {
4262
4262
  let baselineDataValue, currentDataValue, spinner = ora({
4263
4263
  prefixText: (0, picocolors.cyan)(`[${name}]`)
4264
4264
  }).start();
@@ -4288,6 +4288,15 @@ example: ${bin} bundle-diff --baseline="x.json" --current="x.json"
4288
4288
  if (currentData.cloudData) spinner.text = 'load the "currentData.cloudData" instead of the "currentData.data"', currentDataValue = await Manifest.fetchShardingFiles(currentData.cloudData, (url)=>loadShardingFileWithSpinner(url, cwd, spinner));
4289
4289
  else throw spinner.fail((0, picocolors.red)(error.message)), error;
4290
4290
  }
4291
+ if (json) {
4292
+ spinner.text = 'Generating JSON output file...';
4293
+ let outputPath = path_0.resolve(cwd, 'string' == typeof json ? json : 'rsdoctor-diff.json');
4294
+ fs.mkdirSync(path_0.dirname(outputPath), {
4295
+ recursive: !0
4296
+ });
4297
+ let jsonData = Graph.getBundleDiffResult(baselineDataValue, currentDataValue);
4298
+ return fs.writeFileSync(outputPath, JSON.stringify(jsonData, null, 2), 'utf-8'), spinner.succeed(`Generated JSON output file at: ${outputPath}`), null;
4299
+ }
4291
4300
  if (!html) {
4292
4301
  spinner.text = "start server";
4293
4302
  let baselineSdk = new RsdoctorSDK({
@@ -4348,7 +4357,7 @@ example: ${bin} bundle-diff --baseline="x.json" --current="x.json"
4348
4357
  `window.${Constants.WINDOW_RSDOCTOR_TAG}.mode = 'diff';`
4349
4358
  ].map((script)=>`<script>${script}</script>`).join('\n');
4350
4359
  htmlContent = htmlContent.replace('<body>', `<body>${compressTextScripts}`);
4351
- let outputPath = path_0.resolve(cwd, output);
4360
+ let outputPath = path_0.resolve(cwd, output || 'rsdoctor-diff.html');
4352
4361
  fs.mkdirSync(path_0.dirname(outputPath), {
4353
4362
  recursive: !0
4354
4363
  }), fs.writeFileSync(outputPath, htmlContent, 'utf-8'), spinner.succeed(`Generated standalone HTML file at: ${outputPath}`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rsdoctor/cli",
3
- "version": "1.5.5",
3
+ "version": "1.5.6-canary.0",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/web-infra-dev/rsdoctor",
@@ -26,21 +26,21 @@
26
26
  "type": "module",
27
27
  "dependencies": {
28
28
  "ora": "^5.4.1",
29
- "@rsdoctor/core": "1.5.5",
30
- "@rsdoctor/sdk": "1.5.5",
31
- "@rsdoctor/types": "1.5.5",
32
- "@rsdoctor/utils": "1.5.5",
33
- "@rsdoctor/graph": "1.5.5"
29
+ "@rsdoctor/core": "1.5.6-canary.0",
30
+ "@rsdoctor/types": "1.5.6-canary.0",
31
+ "@rsdoctor/sdk": "1.5.6-canary.0",
32
+ "@rsdoctor/utils": "1.5.6-canary.0",
33
+ "@rsdoctor/graph": "1.5.6-canary.0"
34
34
  },
35
35
  "devDependencies": {
36
36
  "cac": "^7.0.0",
37
37
  "typescript": "^5.9.2",
38
38
  "axios": "^1.13.6",
39
39
  "picocolors": "^1.1.1",
40
- "@rsdoctor/client": "1.5.5"
40
+ "@rsdoctor/client": "1.5.6-canary.0"
41
41
  },
42
42
  "peerDependencies": {
43
- "@rsdoctor/client": "1.5.5"
43
+ "@rsdoctor/client": "1.5.6-canary.0"
44
44
  },
45
45
  "publishConfig": {
46
46
  "access": "public",