@skriptfabrik/json-schema-bundler 0.2.0 → 0.3.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.
package/README.md CHANGED
@@ -27,30 +27,35 @@ Usage:
27
27
  json-schema-bundler [options] <input>
28
28
 
29
29
  Arguments:
30
- input The path or URL of the input schema file
30
+ input The path of the input schema file
31
31
 
32
32
  Options:
33
- -h, --help Display this help message
34
- -p, --pretty Pretty print output
35
- -s, --silent Silent mode
36
- -v, --version Print version number
33
+ -d, --dereference Replacing each reference with its resolved value
34
+ -h, --help Display this help message
35
+ -p, --pretty Pretty print output
36
+ -s, --silent Silent mode
37
+ -v, --version Print version number
37
38
 
38
39
  Examples:
39
- Bundle all references in schema.json and print output to stdout:
40
+ Bundle all references in schema.json with internal $ref pointers and print output to stdout:
40
41
 
41
- json-schema-bundler -ps schema.json
42
+ json-schema-bundler schema.json
43
+
44
+ Dereference all references in schema.json and print output to stdout:
45
+
46
+ json-schema-bundler -d schema.json
42
47
  ```
43
48
 
44
49
  ## Docker
45
50
 
46
- Use the following command to bundle (dereference) all references in `schema.json` and print the output to `stdout`:
51
+ Use the following command to bundle all references in `schema.json` and print the output to `stdout`:
47
52
 
48
53
  ```bash
49
- docker run --rm -v `pwd`:/work -w /work skriptfabrik/json-schema-bundler -ps schema.json
54
+ docker run --rm -v `pwd`:/work -w /work skriptfabrik/json-schema-bundler schema.json
50
55
  ```
51
56
 
52
- It is also possible to print the status logs to `stderr` and redirect `stdout` to a file:
57
+ To dereference all references in `schema.json` and print the output to `stdout` add the `-d` option:
53
58
 
54
59
  ```bash
55
- docker run --rm -v `pwd`:/work -w /work skriptfabrik/json-schema-bundler -p schema.json > output.json
60
+ docker run --rm -v `pwd`:/work -w /work skriptfabrik/json-schema-bundler -d schema.json
56
61
  ```
@@ -1,13 +1,14 @@
1
1
  #!/usr/bin/env node
2
2
 
3
- const $RefParser = require('json-schema-ref-parser');
3
+ const $RefParser = require('@apidevtools/json-schema-ref-parser');
4
4
  const minimist = require('minimist');
5
5
  const path = require('path');
6
6
  const pkg = require('./package.json');
7
7
 
8
8
  const argv = minimist(process.argv.slice(2), {
9
- boolean: ['h', 'p', 's'],
9
+ boolean: ['d', 'h', 'p', 's', 'v'],
10
10
  alias: {
11
+ d: 'dereference',
11
12
  h: 'help',
12
13
  p: 'pretty',
13
14
  s: 'silent',
@@ -31,19 +32,24 @@ if (argv.h || argv._.length < 1) {
31
32
  console.error(
32
33
  `JSON Schema Bundler\n\n${colors.yellow}Usage:${colors.end}\n %s\n\n${colors.yellow}Arguments:${colors.end}\n %s\n\n${colors.yellow}Options:${colors.end}\n %s\n\n${colors.yellow}Examples:${colors.end}\n %s`,
33
34
  `${path.basename(process.argv[1])} [options] <input>`,
34
- `${colors.green}input${colors.end} The path or URL of the input schema file`,
35
+ `${colors.green}input${colors.end} The path of the input schema file`,
35
36
  [
36
- `${colors.green}-h, --help${colors.end} Display this help message`,
37
- `${colors.green}-p, --pretty${colors.end} Pretty print output`,
38
- `${colors.green}-s, --silent${colors.end} Silent mode`,
39
- `${colors.green}-v, --version${colors.end} Print version number`,
37
+ `${colors.green}-d, --dereference${colors.end} Replacing each reference with its resolved value`,
38
+ `${colors.green}-h, --help${colors.end} Display this help message`,
39
+ `${colors.green}-p, --pretty${colors.end} Pretty print output`,
40
+ `${colors.green}-s, --silent${colors.end} Silent mode`,
41
+ `${colors.green}-v, --version${colors.end} Print version number`,
40
42
  ].join('\n '),
41
43
  [
42
44
  [
43
- `Bundle all references in ${colors.magenta}schema.json${colors.end} and print output to ${colors.magenta}stdout${colors.end}:`,
44
- `${colors.green}${path.basename(process.argv[1])} -ps schema.json${colors.end}`,
45
+ `Bundle all references in ${colors.magenta}schema.json${colors.end} with internal $ref pointers and print output to ${colors.magenta}stdout${colors.end}:`,
46
+ `${colors.green}${path.basename(process.argv[1])} schema.json${colors.end}`,
45
47
  ].join('\n\n '),
46
- ].join('\n '),
48
+ [
49
+ `Dereference all references in ${colors.magenta}schema.json${colors.end} and print output to ${colors.magenta}stdout${colors.end}:`,
50
+ `${colors.green}${path.basename(process.argv[1])} -d schema.json${colors.end}`,
51
+ ].join('\n\n '),
52
+ ].join('\n\n '),
47
53
  );
48
54
  process.exit(argv.h ? 0 : 1);
49
55
  }
@@ -56,7 +62,11 @@ argv.s || console.error(`Bundling ${input}`);
56
62
  let schema;
57
63
 
58
64
  try {
59
- schema = await $RefParser.dereference(input);
65
+ if (argv.d) {
66
+ schema = await $RefParser.dereference(input);
67
+ } else {
68
+ schema = await $RefParser.bundle(input);
69
+ }
60
70
  } catch (err) {
61
71
  argv.s || console.error(err);
62
72
  process.exit(1);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@skriptfabrik/json-schema-bundler",
3
- "version": "0.2.0",
3
+ "version": "0.3.0",
4
4
  "description": "The missing CLI for the JSON Schema $Ref Parser",
5
5
  "keywords": [
6
6
  "json",
@@ -22,7 +22,7 @@
22
22
  },
23
23
  "license": "MIT",
24
24
  "dependencies": {
25
- "json-schema-ref-parser": "^9.0.9",
25
+ "@apidevtools/json-schema-ref-parser": "^9.0.9",
26
26
  "minimist": "^1.2.6"
27
27
  },
28
28
  "bin": {