react-visualizer 5.0.0 → 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.
@@ -0,0 +1,105 @@
1
+ #!/usr/bin/env node
2
+ const { parseArgs } = require("node:util");
3
+ const makeVisualizerPage = require("../src/makeVisualizerPage");
4
+ const { writeFileSync } = require("node:fs");
5
+ const assert = require("node:assert");
6
+ const fs = require("node:fs");
7
+ let argv = process.argv.slice(2);
8
+ const startIndex = argv.findIndex((arg) => arg === "makeVisualizerPage");
9
+ if (startIndex > -1) {
10
+ argv = argv.slice(startIndex + 1);
11
+ }
12
+ const { values: args } = parseArgs({
13
+ args: argv,
14
+ options: {
15
+ help: {
16
+ type: "boolean",
17
+ short: "h"
18
+ },
19
+ out: {
20
+ type: "string",
21
+ default: "visualizer.html"
22
+ },
23
+ fallbackVersion: {
24
+ type: "string"
25
+ },
26
+ loadversion: {
27
+ type: "string"
28
+ },
29
+ cdn: {
30
+ type: "string"
31
+ },
32
+ scriptUrl: {
33
+ type: "string",
34
+ multiple: true
35
+ },
36
+ queryType: {
37
+ type: "string",
38
+ default: "query"
39
+ },
40
+ config: {
41
+ type: "string"
42
+ }
43
+ }
44
+ });
45
+ const { help, config, scriptUrl, ...options } = args;
46
+ const scripts = scriptUrl.map((url) => ({
47
+ url
48
+ }));
49
+ if (help) {
50
+ printHelp();
51
+ process.exit(0);
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");
65
+ function printHelp() {
66
+ console.log(`
67
+ Usage:
68
+ makeVisualizerPage [options]
69
+
70
+ Options:
71
+ -h, --help
72
+ Show this help message and exit
73
+
74
+ --fallbackVersion <string>
75
+ Visualizer version to use if it is not specified in the search url and not loaded from the view
76
+
77
+ --loadversion <'none' | 'exact' | 'major-latest'>
78
+ What version to load based on the version referenced by the view.
79
+ 'exact': load exactly the version of the view.
80
+ 'latest-major': use the major version of the view, but its latest version.
81
+ 'none': do not use the view to decide which version to load.
82
+ Default: 'none'
83
+
84
+ --cdn <string>
85
+ CDN base URL for visualizer assets
86
+
87
+ --scriptUrl <string>
88
+ Script source url. You can specify this option multiple times to include multiple URLs.
89
+
90
+ --out <string>
91
+ Output file path to which to write the html file
92
+ Default: visualizer.html
93
+
94
+ --queryType <'fragment' | 'query'>
95
+ Where the search parameters should be read from.
96
+ 'query': Uses the regular query string of the URL
97
+ 'fragment': Uses the fragment identifier (aka hash) of the URL as query string
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.
104
+ `);
105
+ }
package/package.json CHANGED
@@ -1,17 +1,18 @@
1
1
  {
2
2
  "name": "react-visualizer",
3
- "version": "5.0.0",
3
+ "version": "5.1.0",
4
4
  "description": "The visualizer in a react component",
5
- "main": "dist/index.js",
5
+ "main": "dist/src/index.js",
6
+ "bin": {
7
+ "makeVisualizerPage": "./dist/bin/makeVisualizerPage.js"
8
+ },
6
9
  "scripts": {
7
- "build": "esbuild 'src/*' --outdir=dist",
10
+ "build": "esbuild 'src/*' 'bin/*' --outdir=dist",
8
11
  "prettier": "prettier --check .",
9
12
  "prettier-write": "prettier --write .",
10
- "watch-test": "esbuild test/app.js --bundle --outfile=test/built.js --watch",
11
- "prepack": "npm run build"
12
- },
13
- "bin": {
14
- "makeVisualizerPage": "./bin/makeVisualizerPage.js"
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",
@@ -1,82 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- const { parseArgs } = require('node:util');
4
- const makeVisualizerPage = require('../src/makeVisualizerPage');
5
- const { writeFileSync } = require('node:fs');
6
- const assert = require('node:assert');
7
-
8
- let argv = process.argv.slice(2);
9
- const startIndex = argv.findIndex((arg) => arg === 'makeVisualizerPage');
10
- if (startIndex > -1) {
11
- argv = argv.slice(startIndex + 1);
12
- }
13
-
14
- const { values: args } = parseArgs({
15
- args: argv,
16
- options: {
17
- help: {
18
- type: 'boolean',
19
- short: 'h',
20
- },
21
- fallbackVersion: {
22
- type: 'string',
23
- },
24
- loadversion: {
25
- type: 'string',
26
- },
27
- cdn: {
28
- type: 'string',
29
- },
30
- out: {
31
- type: 'string',
32
- default: 'visualizer.html',
33
- },
34
- queryType: {
35
- type: 'string',
36
- default: 'query',
37
- },
38
- },
39
- });
40
-
41
- if (args.help) {
42
- printHelp();
43
- process.exit(0);
44
- }
45
-
46
- function printHelp() {
47
- console.log(`
48
- Usage:
49
- makeVisualizerPage [options]
50
-
51
- Options:
52
- -h, --help
53
- Show this help message and exit
54
-
55
- --fallbackVersion <string>
56
- Visualizer version to use if it is not specified in the search url and not loaded from the view
57
-
58
- --loadversion <'none' | 'exact' | 'major-latest'>
59
- What version to load based on the version referenced by the view.
60
- 'exact': load exactly the version of the view.
61
- 'latest-major': use the major version of the view, but its latest version.
62
- 'none': do not use the view to decide which version to load.
63
- Default: 'none'
64
-
65
- --cdn <string>
66
- CDN base URL for visualizer assets
67
-
68
- --out <string>
69
- Output file path to which to write the html file
70
- Default: visualizer.html
71
-
72
- --queryType <'fragment' | 'query'>
73
- Where the search parameters should be read from.
74
- 'query': Uses the regular query string of the URL
75
- 'fragment': Uses the fragment identifier (aka hash) of the URL as query string
76
- Default: query
77
- `);
78
- }
79
-
80
- const page = makeVisualizerPage(args);
81
-
82
- writeFileSync(args.out, page, 'utf-8');
File without changes
File without changes
File without changes