@skriptfabrik/json-schema-bundler 0.3.0 → 0.4.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,41 @@
1
+ version: 2
2
+
3
+ registries:
4
+ dockerhub:
5
+ type: 'docker-registry'
6
+ url: 'https://registry.hub.docker.com'
7
+ username: '${{ secrets.DOCKERHUB_USERNAME }}'
8
+ password: '${{ secrets.DOCKERHUB_TOKEN }}'
9
+ replaces-base: true
10
+
11
+ updates:
12
+ - package-ecosystem: 'github-actions'
13
+ directory: '/'
14
+ reviewers:
15
+ - 'skriptfabrik/developers'
16
+ schedule:
17
+ interval: 'weekly'
18
+ time: '08:00'
19
+ timezone: 'Europe/Berlin'
20
+
21
+ - package-ecosystem: 'npm'
22
+ directory: '/'
23
+ ignore:
24
+ - dependency-name: '@types/*'
25
+ reviewers:
26
+ - 'skriptfabrik/developers'
27
+ schedule:
28
+ interval: 'weekly'
29
+ time: '08:00'
30
+ timezone: 'Europe/Berlin'
31
+
32
+ - package-ecosystem: 'docker'
33
+ directory: '/'
34
+ reviewers:
35
+ - 'skriptfabrik/developers'
36
+ registries:
37
+ - 'dockerhub'
38
+ schedule:
39
+ interval: 'weekly'
40
+ time: '08:00'
41
+ timezone: 'Europe/Berlin'
@@ -0,0 +1,12 @@
1
+ ## Describe your changes
2
+
3
+ - [ ] Bug fix (non-breaking change which fixes an issue)
4
+ - [ ] New feature (non-breaking change which adds functionality)
5
+ - [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
6
+
7
+ ## Checklist before requesting a review
8
+
9
+ - [ ] I have included the ticket number of the issue at the beginning of the title of this pull request.
10
+ - [ ] I have updated the docs and/or specs to reflect this change.
11
+ - [ ] I have performed a self-review of my code.
12
+ - [ ] I have added thorough tests.
@@ -69,7 +69,7 @@ jobs:
69
69
 
70
70
  - name: Build and Push latest Docker image
71
71
  if: github.ref_name == 'main'
72
- uses: docker/build-push-action@v2
72
+ uses: docker/build-push-action@v4
73
73
  with:
74
74
  build-args: |-
75
75
  BUILDKIT_INLINE_CACHE=${{ env.DOCKER_BUILDKIT_INLINE_CACHE }}
@@ -91,7 +91,7 @@ jobs:
91
91
 
92
92
  - name: Build and Push Docker image release version
93
93
  if: github.ref_type == 'tag'
94
- uses: docker/build-push-action@v2
94
+ uses: docker/build-push-action@v4
95
95
  with:
96
96
  build-args: |-
97
97
  BUILDKIT_INLINE_CACHE=${{ env.DOCKER_BUILDKIT_INLINE_CACHE }}
package/Dockerfile CHANGED
@@ -1,4 +1,4 @@
1
- FROM node:18.2.0-alpine
1
+ FROM node:18.14.0-alpine
2
2
 
3
3
  LABEL maintainer="Daniel Schröder <daniel.schroeder@skriptfabrik.com>"
4
4
 
@@ -11,6 +11,6 @@ COPY . /opt/json-schema-bundler-${JSON_SCHEMA_BUNDLER_VERSION}
11
11
  RUN set -eux; \
12
12
  npm --prefix /opt/json-schema-bundler-${JSON_SCHEMA_BUNDLER_VERSION} install; \
13
13
  rm -Rf ~/.npm; \
14
- ln -s /opt/json-schema-bundler-${JSON_SCHEMA_BUNDLER_VERSION}/json-schema-bundler-cli.js /usr/local/bin/json-schema-bundler
14
+ ln -s /opt/json-schema-bundler-${JSON_SCHEMA_BUNDLER_VERSION}/json-schema-bundler-cli.mjs /usr/local/bin/json-schema-bundler
15
15
 
16
16
  ENTRYPOINT [ "json-schema-bundler" ]
package/README.md CHANGED
@@ -1,8 +1,8 @@
1
+ # JSON Schema Bundler
2
+
1
3
  [![NPM Version](https://img.shields.io/npm/v/@skriptfabrik/json-schema-bundler)](https://www.npmjs.com/package/@skriptfabrik/json-schema-bundler)
2
4
  [![NPM Downloads](https://img.shields.io/npm/dt/@skriptfabrik/json-schema-bundler)](https://www.npmjs.com/package/@skriptfabrik/json-schema-bundler)
3
- [![Continuous Integration](https://img.shields.io/github/workflow/status/skriptfabrik/json-schema-bundler/Continuous%20Integration)](https://github.com/skriptfabrik/json-schema-bundler/actions/workflows/ci.yml)
4
-
5
- # JSON Schema Bundler
5
+ [![Continuous Integration](https://img.shields.io/github/actions/workflow/status/skriptfabrik/json-schema-bundler/ci.yml)](https://github.com/skriptfabrik/json-schema-bundler/actions/workflows/ci.yml)
6
6
 
7
7
  > The missing CLI for the [JSON Schema $Ref Parser](https://github.com/APIDevTools/json-schema-ref-parser)
8
8
 
@@ -35,6 +35,7 @@ Options:
35
35
  -p, --pretty Pretty print output
36
36
  -s, --silent Silent mode
37
37
  -v, --version Print version number
38
+ -y, --yaml Output as YAML document instead of JSON
38
39
 
39
40
  Examples:
40
41
  Bundle all references in schema.json with internal $ref pointers and print output to stdout:
@@ -0,0 +1,80 @@
1
+ #!/usr/bin/env node
2
+
3
+ import $RefParser from '@apidevtools/json-schema-ref-parser';
4
+ import chalk from 'chalk';
5
+ import { readFile } from 'fs/promises';
6
+ import minimist from 'minimist';
7
+ import path from 'path';
8
+ import { fileURLToPath } from 'url';
9
+ import YAML from 'js-yaml';
10
+
11
+ const __filename = fileURLToPath(import.meta.url);
12
+ const __dirname = path.dirname(__filename);
13
+
14
+ const pkg = JSON.parse(await readFile(path.join(__dirname, 'package.json')));
15
+
16
+ const argv = minimist(process.argv.slice(2), {
17
+ boolean: ['d', 'h', 'p', 's', 'v', 'y'],
18
+ alias: {
19
+ d: 'dereference',
20
+ h: 'help',
21
+ p: 'pretty',
22
+ s: 'silent',
23
+ v: 'version',
24
+ y: 'yaml',
25
+ },
26
+ });
27
+
28
+ if (argv.v) {
29
+ console.log(pkg.version);
30
+ process.exit(0);
31
+ }
32
+
33
+ if (argv.h || argv._.length < 1) {
34
+ console.error(
35
+ `JSON Schema Bundler\n\n${chalk.yellow('Usage:')}\n%s\n\n${chalk.yellow('Arguments:')}\n%s\n\n${chalk.yellow('Options:')}\n%s\n\n${chalk.yellow('Examples:')}\n%s`,
36
+ ` ${path.basename(process.argv[1])} [options] <input>`,
37
+ ` ${chalk.green('input')} The path of the input schema file`,
38
+ [
39
+ ` ${chalk.green('-d, --dereference')} Replacing each reference with its resolved value`,
40
+ ` ${chalk.green('-h, --help')} Display this help message`,
41
+ ` ${chalk.green('-p, --pretty')} Pretty print output`,
42
+ ` ${chalk.green('-s, --silent')} Silent mode`,
43
+ ` ${chalk.green('-v, --version')} Print version number`,
44
+ ` ${chalk.green('-y, --yaml')} Output as YAML document instead of JSON`,
45
+ ].join('\n'),
46
+ [
47
+ ` Bundle all references in ${chalk.magenta('schema.json')} with internal $ref pointers and print output to ${chalk.magenta('stdout')}:`,
48
+ ``,
49
+ ` ${chalk.green(`${path.basename(process.argv[1])} schema.json`)}`,
50
+ ``,
51
+ ` Dereference all references in ${chalk.magenta('schema.json')} and print output to ${chalk.magenta('stdout')}:`,
52
+ ``,
53
+ ` ${chalk.green(`${path.basename(process.argv[1])} -d schema.json`)}`,
54
+ ].join('\n')
55
+ );
56
+ process.exit(argv.h ? 0 : 1);
57
+ }
58
+
59
+ const input = path.resolve(argv._[0]);
60
+
61
+ argv.s || console.error(`Bundling ${input}`);
62
+
63
+ let schema;
64
+
65
+ try {
66
+ if (argv.d) {
67
+ schema = await $RefParser.dereference(input);
68
+ } else {
69
+ schema = await $RefParser.bundle(input);
70
+ }
71
+ } catch (err) {
72
+ argv.s || console.error(err);
73
+ process.exit(1);
74
+ }
75
+
76
+ if (argv.y) {
77
+ console.log(YAML.dump(schema, argv.p ? undefined : { flowLevel: 3 }));
78
+ } else {
79
+ console.log(JSON.stringify(schema, undefined, argv.p ? 2 : undefined));
80
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@skriptfabrik/json-schema-bundler",
3
- "version": "0.3.0",
3
+ "version": "0.4.1",
4
4
  "description": "The missing CLI for the JSON Schema $Ref Parser",
5
5
  "keywords": [
6
6
  "json",
@@ -22,10 +22,15 @@
22
22
  },
23
23
  "license": "MIT",
24
24
  "dependencies": {
25
- "@apidevtools/json-schema-ref-parser": "^9.0.9",
26
- "minimist": "^1.2.6"
25
+ "@apidevtools/json-schema-ref-parser": "^10.1.0",
26
+ "chalk": "^5.2.0",
27
+ "js-yaml": "^4.1.0",
28
+ "minimist": "^1.2.8"
29
+ },
30
+ "devDependencies": {
31
+ "@types/js-yaml": "~4.0.0"
27
32
  },
28
33
  "bin": {
29
- "json-schema-bundler": "./json-schema-bundler-cli.js"
34
+ "json-schema-bundler": "./json-schema-bundler-cli.mjs"
30
35
  }
31
36
  }
@@ -1,76 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- const $RefParser = require('@apidevtools/json-schema-ref-parser');
4
- const minimist = require('minimist');
5
- const path = require('path');
6
- const pkg = require('./package.json');
7
-
8
- const argv = minimist(process.argv.slice(2), {
9
- boolean: ['d', 'h', 'p', 's', 'v'],
10
- alias: {
11
- d: 'dereference',
12
- h: 'help',
13
- p: 'pretty',
14
- s: 'silent',
15
- v: 'version',
16
- },
17
- });
18
-
19
- const colors = {
20
- end: '\x1b[0m',
21
- green: '\x1b[32m',
22
- yellow: '\x1b[33m',
23
- magenta: '\x1b[35m',
24
- };
25
-
26
- if (argv.v) {
27
- console.log(pkg.version);
28
- process.exit(0);
29
- }
30
-
31
- if (argv.h || argv._.length < 1) {
32
- console.error(
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`,
34
- `${path.basename(process.argv[1])} [options] <input>`,
35
- `${colors.green}input${colors.end} The path of the input schema file`,
36
- [
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`,
42
- ].join('\n '),
43
- [
44
- [
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}`,
47
- ].join('\n\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 '),
53
- );
54
- process.exit(argv.h ? 0 : 1);
55
- }
56
-
57
- const input = path.resolve(argv._[0]);
58
-
59
- argv.s || console.error(`Bundling ${input}`);
60
-
61
- (async () => {
62
- let schema;
63
-
64
- try {
65
- if (argv.d) {
66
- schema = await $RefParser.dereference(input);
67
- } else {
68
- schema = await $RefParser.bundle(input);
69
- }
70
- } catch (err) {
71
- argv.s || console.error(err);
72
- process.exit(1);
73
- }
74
-
75
- console.log(JSON.stringify(schema, undefined, argv.p ? 2 : undefined));
76
- })();