v8r 0.9.0 → 0.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/CHANGELOG.md +7 -0
- package/README.md +8 -6
- package/package.json +1 -1
- package/src/cli.js +15 -9
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 📦 [0.10.0](https://www.npmjs.com/package/v8r/v/0.10.0) - 2022-01-03
|
|
4
|
+
|
|
5
|
+
* Accept multiple filenames or globs as positional args. e.g:
|
|
6
|
+
```bash
|
|
7
|
+
v8r file1.json file2.json 'dir/*.yaml'
|
|
8
|
+
```
|
|
9
|
+
|
|
3
10
|
## 📦 [0.9.0](https://www.npmjs.com/package/v8r/v/0.9.0) - 2021-12-27
|
|
4
11
|
|
|
5
12
|
* Accept glob pattern instead of filename. It is now possible to validate multiple files at once. e.g:
|
package/README.md
CHANGED
|
@@ -25,15 +25,17 @@ v8r <filename>
|
|
|
25
25
|
|
|
26
26
|
### Validating files
|
|
27
27
|
|
|
28
|
-
v8r can validate JSON or YAML files. You can pass
|
|
28
|
+
v8r can validate JSON or YAML files. You can pass filenames or glob patterns:
|
|
29
29
|
|
|
30
30
|
```bash
|
|
31
31
|
# single filename
|
|
32
32
|
$ v8r package.json
|
|
33
33
|
|
|
34
|
+
# multiple files
|
|
35
|
+
$ v8r file1.json file2.json
|
|
36
|
+
|
|
34
37
|
# glob patterns
|
|
35
|
-
$ v8r '
|
|
36
|
-
$ v8r '{file1.json,file2.json}'
|
|
38
|
+
$ v8r 'dir/*.yml' 'dir/*.yaml'
|
|
37
39
|
```
|
|
38
40
|
|
|
39
41
|
[DigitalOcean's Glob Tool](https://www.digitalocean.com/community/tools/glob) can be used to help construct glob patterns
|
|
@@ -78,7 +80,7 @@ This can be used to specify different custom schemas for multiple file patterns.
|
|
|
78
80
|
## Exit codes
|
|
79
81
|
|
|
80
82
|
* v8r always exits with code `0` when:
|
|
81
|
-
* The input glob pattern matched one or more files, all input files were validated against a schema, and all input files were **valid**
|
|
83
|
+
* The input glob pattern(s) matched one or more files, all input files were validated against a schema, and all input files were **valid**
|
|
82
84
|
* `v8r` was called with `--help` or `--version` flags
|
|
83
85
|
|
|
84
86
|
* By default v8r exits with code `1` when an error was encountered trying to validate one or more input files. For example:
|
|
@@ -90,8 +92,8 @@ This can be used to specify different custom schemas for multiple file patterns.
|
|
|
90
92
|
This behaviour can be modified using the `--ignore-errors` flag. When invoked with `--ignore-errors` v8r will exit with code `0` even if one of these errors was encountered while attempting validation. A non-zero exit code will only be issued if validation could be completed successfully and the file was invalid.
|
|
91
93
|
|
|
92
94
|
* v8r always exits with code `98` when:
|
|
93
|
-
*
|
|
94
|
-
*
|
|
95
|
+
* An input glob pattern was invalid
|
|
96
|
+
* An input glob pattern was valid but did not match any files
|
|
95
97
|
|
|
96
98
|
* v8r always exits with code `99` when:
|
|
97
99
|
* The input glob pattern matched one or more files, one or more input files were validated against a schema and the input file was **invalid**
|
package/package.json
CHANGED
package/src/cli.js
CHANGED
|
@@ -152,11 +152,16 @@ function mergeResults(results, ignoreErrors) {
|
|
|
152
152
|
|
|
153
153
|
function Validator() {
|
|
154
154
|
return async function (args) {
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
155
|
+
let filenames = [];
|
|
156
|
+
for (const pattern of args.patterns) {
|
|
157
|
+
const matches = await getFiles(pattern);
|
|
158
|
+
if (matches.length === 0) {
|
|
159
|
+
logging.error(`Pattern '${pattern}' did not match any files`);
|
|
160
|
+
return EXIT.NOTFOUND;
|
|
161
|
+
}
|
|
162
|
+
filenames = filenames.concat(matches);
|
|
159
163
|
}
|
|
164
|
+
|
|
160
165
|
const ttl = secondsToMilliseconds(args.cacheTtl || 0);
|
|
161
166
|
const cache = new Cache(getFlatCache(), ttl);
|
|
162
167
|
|
|
@@ -185,11 +190,12 @@ async function cli(args) {
|
|
|
185
190
|
function parseArgs(argv) {
|
|
186
191
|
return yargs(hideBin(argv))
|
|
187
192
|
.command(
|
|
188
|
-
"$0 <
|
|
193
|
+
"$0 <patterns..>",
|
|
189
194
|
"Validate local json/yaml files against schema(s)",
|
|
190
195
|
(yargs) => {
|
|
191
|
-
yargs.positional("
|
|
192
|
-
describe:
|
|
196
|
+
yargs.positional("patterns", {
|
|
197
|
+
describe:
|
|
198
|
+
"One or more filenames or glob patterns describing local file or files to validate",
|
|
193
199
|
});
|
|
194
200
|
}
|
|
195
201
|
)
|
|
@@ -212,8 +218,8 @@ function parseArgs(argv) {
|
|
|
212
218
|
describe:
|
|
213
219
|
"Local path or URL of a schema to validate against. " +
|
|
214
220
|
"If not supplied, we will attempt to find an appropriate schema on " +
|
|
215
|
-
"schemastore.org using the filename. If passed with
|
|
216
|
-
"
|
|
221
|
+
"schemastore.org using the filename. If passed with glob pattern(s) " +
|
|
222
|
+
"matching multiple files, all matching files will be validated " +
|
|
217
223
|
"against this schema",
|
|
218
224
|
})
|
|
219
225
|
.option("catalogs", {
|