@sourcemeta/jsonschema 12.8.0 → 12.10.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.
@@ -132,7 +132,7 @@ Where `X.Y.Z` is replaced with the desired version. For example:
132
132
  uses: actions/checkout@v4
133
133
 
134
134
  - name: Install the JSON Schema CLI
135
- uses: sourcemeta/jsonschema@v12.8.0
135
+ uses: sourcemeta/jsonschema@v12.10.0
136
136
 
137
137
  # Then use as usual
138
138
  - run: jsonschema fmt path/to/schemas --check
package/npm/cli.js ADDED
@@ -0,0 +1,12 @@
1
+ #!/usr/bin/env node
2
+
3
+ const { spawn } = require('./main.js');
4
+
5
+ spawn(process.argv.slice(2), { stdio: 'inherit' })
6
+ .then((result) => {
7
+ process.exit(result.code);
8
+ })
9
+ .catch((error) => {
10
+ console.error(error.message);
11
+ process.exit(1);
12
+ });
package/npm/main.js ADDED
@@ -0,0 +1,74 @@
1
+ const os = require('os');
2
+ const path = require('path');
3
+ const fs = require('fs/promises');
4
+ const child_process = require('child_process');
5
+
6
+ const PLATFORM = os.platform() === 'win32' ? 'windows' : os.platform();
7
+ const ARCH = os.arch() === 'x64' ? 'x86_64' : os.arch();
8
+ const EXTENSION = PLATFORM === 'windows' ? '.exe' : '';
9
+ const EXECUTABLE = path.join(__dirname, '..', 'build', 'github-releases',
10
+ `jsonschema-${PLATFORM}-${ARCH}${EXTENSION}`);
11
+
12
+ function spawnProcess(executable, args, options) {
13
+ return new Promise((resolve, reject) => {
14
+ const process = child_process.spawn(executable, args, options);
15
+
16
+ let stdout = '';
17
+ let stderr = '';
18
+
19
+ if (process.stdout) {
20
+ process.stdout.on('data', (data) => {
21
+ stdout += data.toString();
22
+ });
23
+ }
24
+
25
+ if (process.stderr) {
26
+ process.stderr.on('data', (data) => {
27
+ stderr += data.toString();
28
+ });
29
+ }
30
+
31
+ process.on('error', (error) => {
32
+ reject(error);
33
+ });
34
+
35
+ process.on('close', (code) => {
36
+ resolve({ code, stdout, stderr });
37
+ });
38
+ });
39
+ }
40
+
41
+ async function spawn(args, options = {}) {
42
+ const json = options.json === true;
43
+ const spawnArgs = json ? [...args, '--json'] : args;
44
+
45
+ try {
46
+ await fs.access(EXECUTABLE);
47
+ } catch {
48
+ throw new Error(
49
+ `The JSON Schema CLI NPM package does not support ${os.platform()} for ${os.arch()} yet. ` +
50
+ 'Please open a GitHub issue at https://github.com/sourcemeta/jsonschema'
51
+ );
52
+ }
53
+
54
+ if (PLATFORM === 'darwin') {
55
+ await spawnProcess('/usr/bin/xattr', ['-c', EXECUTABLE], { stdio: 'inherit' });
56
+ }
57
+
58
+ const spawnOptions = {
59
+ windowsHide: true,
60
+ ...options
61
+ };
62
+
63
+ delete spawnOptions.json;
64
+
65
+ const result = await spawnProcess(EXECUTABLE, spawnArgs, spawnOptions);
66
+
67
+ return {
68
+ code: result.code,
69
+ stdout: json ? JSON.parse(result.stdout) : result.stdout,
70
+ stderr: result.stderr
71
+ };
72
+ }
73
+
74
+ module.exports = { spawn };
package/package.json CHANGED
@@ -1,13 +1,14 @@
1
1
  {
2
2
  "name": "@sourcemeta/jsonschema",
3
- "version": "12.8.0",
3
+ "version": "12.10.0",
4
4
  "description": "The CLI for working with JSON Schema. Covers formatting, linting, testing, and much more for both local development and CI/CD pipelines",
5
- "main": "cli.js",
6
- "bin": {
7
- "jsonschema": "cli.js"
5
+ "main": "npm/main.js",
6
+ "exports": {
7
+ ".": "./npm/main.js",
8
+ "./package.json": "./package.json"
8
9
  },
9
- "scripts": {
10
- "test": "eslint cli.js && node cli.js"
10
+ "bin": {
11
+ "jsonschema": "npm/cli.js"
11
12
  },
12
13
  "license": "AGPL-3.0",
13
14
  "homepage": "https://github.com/sourcemeta/jsonschema",
@@ -16,18 +17,38 @@
16
17
  "name": "Sourcemeta",
17
18
  "url": "https://www.sourcemeta.com"
18
19
  },
19
- "os": [ "darwin", "linux", "win32" ],
20
- "cpu": [ "x64", "arm64" ],
20
+ "os": [
21
+ "darwin",
22
+ "linux",
23
+ "win32"
24
+ ],
25
+ "cpu": [
26
+ "x64",
27
+ "arm64"
28
+ ],
21
29
  "engines": {
22
30
  "node": ">=16"
23
31
  },
24
32
  "funding": "https://github.com/sponsors/sourcemeta",
25
33
  "keywords": [
26
- "jsonschema", "json", "schema", "json-schema",
27
- "cli", "$ref", "dereference", "reference", "resolve",
28
- "json-pointer", "validator", "validation", "bundle",
29
- "json-schema-validator", "json-schema-validation",
30
- "lint", "format", "draft"
34
+ "jsonschema",
35
+ "json",
36
+ "schema",
37
+ "json-schema",
38
+ "cli",
39
+ "$ref",
40
+ "dereference",
41
+ "reference",
42
+ "resolve",
43
+ "json-pointer",
44
+ "validator",
45
+ "validation",
46
+ "bundle",
47
+ "json-schema-validator",
48
+ "json-schema-validation",
49
+ "lint",
50
+ "format",
51
+ "draft"
31
52
  ],
32
53
  "bugs": {
33
54
  "url": "https://github.com/sourcemeta/jsonschema/issues"
@@ -37,6 +58,7 @@
37
58
  "url": "git+https://github.com/sourcemeta/jsonschema.git"
38
59
  },
39
60
  "publishConfig": {
61
+ "provenance": true,
40
62
  "access": "public"
41
63
  },
42
64
  "devDependencies": {
package/cli.js DELETED
@@ -1,29 +0,0 @@
1
- #!/usr/bin/env node
2
- const os = require('os');
3
- const path = require('path');
4
- const fs = require('fs');
5
- const child_process = require('child_process');
6
-
7
- const PLATFORM = os.platform() === 'win32' ? 'windows' : os.platform();
8
- const ARCH = os.arch() === 'x64' ? 'x86_64' : os.arch();
9
- const EXECUTABLE = PLATFORM === 'windows'
10
- ? path.join(__dirname, `jsonschema-${PLATFORM}-${ARCH}.exe`)
11
- : path.join(__dirname, `jsonschema-${PLATFORM}-${ARCH}`);
12
-
13
- if (!fs.existsSync(EXECUTABLE)) {
14
- console.error(`The JSON Schema CLI NPM package does not support ${os.platform()} for ${ARCH} yet`);
15
- console.error('Please open a GitHub issue at https://github.com/sourcemeta/jsonschema');
16
- process.exit(1);
17
- }
18
-
19
- if (PLATFORM === 'darwin') {
20
- child_process.spawnSync('/usr/bin/xattr', [ '-c', EXECUTABLE ], { stdio: 'inherit' });
21
- }
22
-
23
- const result = child_process.spawnSync(EXECUTABLE, process.argv.slice(2), {
24
- stdio: 'inherit',
25
- // Do not open a command prompt on spawning
26
- windowsHide: true
27
- });
28
-
29
- process.exit(result.status);