@sourcemeta/jsonschema 12.9.3 → 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.
- package/README.markdown +1 -1
- package/build/github-releases/jsonschema-darwin-arm64 +0 -0
- package/build/github-releases/jsonschema-darwin-x86_64 +0 -0
- package/build/github-releases/jsonschema-linux-arm64 +0 -0
- package/build/github-releases/jsonschema-linux-x86_64 +0 -0
- package/build/github-releases/jsonschema-windows-x86_64.exe +0 -0
- package/npm/main.js +37 -30
- package/package.json +1 -1
package/README.markdown
CHANGED
|
@@ -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.
|
|
135
|
+
uses: sourcemeta/jsonschema@v12.10.0
|
|
136
136
|
|
|
137
137
|
# Then use as usual
|
|
138
138
|
- run: jsonschema fmt path/to/schemas --check
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/npm/main.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const os = require('os');
|
|
2
2
|
const path = require('path');
|
|
3
|
-
const fs = require('fs');
|
|
3
|
+
const fs = require('fs/promises');
|
|
4
4
|
const child_process = require('child_process');
|
|
5
5
|
|
|
6
6
|
const PLATFORM = os.platform() === 'win32' ? 'windows' : os.platform();
|
|
@@ -9,31 +9,9 @@ const EXTENSION = PLATFORM === 'windows' ? '.exe' : '';
|
|
|
9
9
|
const EXECUTABLE = path.join(__dirname, '..', 'build', 'github-releases',
|
|
10
10
|
`jsonschema-${PLATFORM}-${ARCH}${EXTENSION}`);
|
|
11
11
|
|
|
12
|
-
function
|
|
13
|
-
const json = options.json === true;
|
|
14
|
-
const spawnArgs = json ? [...args, '--json'] : args;
|
|
15
|
-
|
|
12
|
+
function spawnProcess(executable, args, options) {
|
|
16
13
|
return new Promise((resolve, reject) => {
|
|
17
|
-
|
|
18
|
-
reject(new Error(
|
|
19
|
-
`The JSON Schema CLI NPM package does not support ${os.platform()} for ${os.arch()} yet. ` +
|
|
20
|
-
'Please open a GitHub issue at https://github.com/sourcemeta/jsonschema'
|
|
21
|
-
));
|
|
22
|
-
return;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
if (PLATFORM === 'darwin') {
|
|
26
|
-
child_process.spawnSync('/usr/bin/xattr', ['-c', EXECUTABLE], { stdio: 'inherit' });
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
const spawnOptions = {
|
|
30
|
-
windowsHide: true,
|
|
31
|
-
...options
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
delete spawnOptions.json;
|
|
35
|
-
|
|
36
|
-
const process = child_process.spawn(EXECUTABLE, spawnArgs, spawnOptions);
|
|
14
|
+
const process = child_process.spawn(executable, args, options);
|
|
37
15
|
|
|
38
16
|
let stdout = '';
|
|
39
17
|
let stderr = '';
|
|
@@ -55,13 +33,42 @@ function spawn(args, options = {}) {
|
|
|
55
33
|
});
|
|
56
34
|
|
|
57
35
|
process.on('close', (code) => {
|
|
58
|
-
resolve({
|
|
59
|
-
code: code,
|
|
60
|
-
stdout: json ? JSON.parse(stdout) : stdout,
|
|
61
|
-
stderr: stderr
|
|
62
|
-
});
|
|
36
|
+
resolve({ code, stdout, stderr });
|
|
63
37
|
});
|
|
64
38
|
});
|
|
65
39
|
}
|
|
66
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
|
+
|
|
67
74
|
module.exports = { spawn };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sourcemeta/jsonschema",
|
|
3
|
-
"version": "12.
|
|
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
5
|
"main": "npm/main.js",
|
|
6
6
|
"exports": {
|