react-visualizer 5.0.1 → 5.1.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.
|
@@ -3,6 +3,7 @@ const { parseArgs } = require("node:util");
|
|
|
3
3
|
const makeVisualizerPage = require("../src/makeVisualizerPage");
|
|
4
4
|
const { writeFileSync } = require("node:fs");
|
|
5
5
|
const assert = require("node:assert");
|
|
6
|
+
const fs = require("node:fs");
|
|
6
7
|
let argv = process.argv.slice(2);
|
|
7
8
|
const startIndex = argv.findIndex((arg) => arg === "makeVisualizerPage");
|
|
8
9
|
if (startIndex > -1) {
|
|
@@ -15,6 +16,10 @@ const { values: args } = parseArgs({
|
|
|
15
16
|
type: "boolean",
|
|
16
17
|
short: "h"
|
|
17
18
|
},
|
|
19
|
+
out: {
|
|
20
|
+
type: "string",
|
|
21
|
+
default: "visualizer.html"
|
|
22
|
+
},
|
|
18
23
|
fallbackVersion: {
|
|
19
24
|
type: "string"
|
|
20
25
|
},
|
|
@@ -24,20 +29,39 @@ const { values: args } = parseArgs({
|
|
|
24
29
|
cdn: {
|
|
25
30
|
type: "string"
|
|
26
31
|
},
|
|
27
|
-
|
|
32
|
+
scriptUrl: {
|
|
28
33
|
type: "string",
|
|
29
|
-
|
|
34
|
+
multiple: true
|
|
30
35
|
},
|
|
31
36
|
queryType: {
|
|
32
37
|
type: "string",
|
|
33
38
|
default: "query"
|
|
39
|
+
},
|
|
40
|
+
config: {
|
|
41
|
+
type: "string"
|
|
34
42
|
}
|
|
35
43
|
}
|
|
36
44
|
});
|
|
37
|
-
|
|
45
|
+
const { help, config, scriptUrl, ...options } = args;
|
|
46
|
+
const scripts = scriptUrl.map((url) => ({
|
|
47
|
+
url
|
|
48
|
+
}));
|
|
49
|
+
if (help) {
|
|
38
50
|
printHelp();
|
|
39
51
|
process.exit(0);
|
|
40
52
|
}
|
|
53
|
+
let fileConfig = {};
|
|
54
|
+
if (config) {
|
|
55
|
+
const str = fs.readFileSync(args.config, "utf-8");
|
|
56
|
+
try {
|
|
57
|
+
fileConfig = JSON.parse(str);
|
|
58
|
+
} catch {
|
|
59
|
+
console.error("Could not parse config file as JSON");
|
|
60
|
+
process.exit(1);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
const page = makeVisualizerPage({ scripts, ...fileConfig, ...options });
|
|
64
|
+
writeFileSync(args.out, page, "utf-8");
|
|
41
65
|
function printHelp() {
|
|
42
66
|
console.log(`
|
|
43
67
|
Usage:
|
|
@@ -60,6 +84,9 @@ Options:
|
|
|
60
84
|
--cdn <string>
|
|
61
85
|
CDN base URL for visualizer assets
|
|
62
86
|
|
|
87
|
+
--scriptUrl <string>
|
|
88
|
+
Script source url. You can specify this option multiple times to include multiple URLs.
|
|
89
|
+
|
|
63
90
|
--out <string>
|
|
64
91
|
Output file path to which to write the html file
|
|
65
92
|
Default: visualizer.html
|
|
@@ -69,7 +96,10 @@ Options:
|
|
|
69
96
|
'query': Uses the regular query string of the URL
|
|
70
97
|
'fragment': Uses the fragment identifier (aka hash) of the URL as query string
|
|
71
98
|
Default: query
|
|
99
|
+
|
|
100
|
+
--config <string>
|
|
101
|
+
Path to a configuration file.
|
|
102
|
+
Via the configuration file, you can specify additional options which should be passed to makeVisualizerPage generator.
|
|
103
|
+
The "out" parameter must always be specified via the command line options.
|
|
72
104
|
`);
|
|
73
105
|
}
|
|
74
|
-
const page = makeVisualizerPage(args);
|
|
75
|
-
writeFileSync(args.out, page, "utf-8");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-visualizer",
|
|
3
|
-
"version": "5.0
|
|
3
|
+
"version": "5.1.0",
|
|
4
4
|
"description": "The visualizer in a react component",
|
|
5
5
|
"main": "dist/src/index.js",
|
|
6
6
|
"bin": {
|
|
@@ -10,8 +10,9 @@
|
|
|
10
10
|
"build": "esbuild 'src/*' 'bin/*' --outdir=dist",
|
|
11
11
|
"prettier": "prettier --check .",
|
|
12
12
|
"prettier-write": "prettier --write .",
|
|
13
|
-
"
|
|
14
|
-
"
|
|
13
|
+
"prepack": "npm run build",
|
|
14
|
+
"test": "npm run prettier",
|
|
15
|
+
"watch-test": "esbuild test/app.js --bundle --outfile=test/built.js --watch"
|
|
15
16
|
},
|
|
16
17
|
"repository": {
|
|
17
18
|
"type": "git",
|