v8r 4.3.0 → 5.0.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 +44 -0
- package/config-schema.json +1 -1
- package/package.json +6 -6
- package/src/bootstrap.js +3 -3
- package/src/cli.js +5 -3
- package/src/glob.js +0 -8
- package/src/logger.js +6 -0
- package/src/plugins/output-text.js +1 -1
- package/src/plugins.js +6 -17
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,49 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 📦 [5.0.0](https://www.npmjs.com/package/v8r/v/5.0.0) - 2025-05-10
|
|
4
|
+
|
|
5
|
+
Following on from the deprecations in version 4.4.0,
|
|
6
|
+
version 5.0.0 contains a number of breaking changes:
|
|
7
|
+
|
|
8
|
+
* The `--format` CLI argument and `format` config file key have been removed.
|
|
9
|
+
Switch to using `--output-format` and `outputFormat`.
|
|
10
|
+
* v8r now ignores patterns in `.gitignore` by default.
|
|
11
|
+
* The `fileLocation` argument of `getSingleResultLogMessage` has been removed.
|
|
12
|
+
The signature is now `getSingleResultLogMessage(result, format)`.
|
|
13
|
+
Plugins implementing the `getSingleResultLogMessage` hook will need to to update
|
|
14
|
+
the signature.
|
|
15
|
+
If you are using `fileLocation` in the `getSingleResultLogMessage` function body,
|
|
16
|
+
switch to using `result.fileLocation`.
|
|
17
|
+
* File paths are no longer passed to plugins in dot-relative notation.
|
|
18
|
+
Plugins implementing the `getSingleResultLogMessage`, `getAllResultsLogMessage` and `parseInputFile`
|
|
19
|
+
plugin hooks may need to be updated.
|
|
20
|
+
* The minimum compatible node version is now Node 20.
|
|
21
|
+
|
|
22
|
+
Other changes in this release:
|
|
23
|
+
|
|
24
|
+
* v8r is now tested on node 24
|
|
25
|
+
* Upgrade to latest major versions of core packages (got, glob, minimatch, etc)
|
|
26
|
+
|
|
27
|
+
## 📦 [4.4.0](https://www.npmjs.com/package/v8r/v/4.4.0) - 2025-04-26
|
|
28
|
+
|
|
29
|
+
Version 4.4.0 is a deprecation release. This release adds deprecation warnings for
|
|
30
|
+
upcoming breaking changes that will be made in version 5.0
|
|
31
|
+
|
|
32
|
+
* This release adds the `--output-format` CLI argument and `outputFormat` config file key.
|
|
33
|
+
In v8r 4.4.0 `--format` and `format` can still be used as aliases.
|
|
34
|
+
In version 5 `--format` and `format` will be removed.
|
|
35
|
+
It is recommended to switch to using `--output-format` and `outputFormat` now.
|
|
36
|
+
* Starting from v8r version 5, v8r will ignore patterns in `.gitignore` by default.
|
|
37
|
+
* In v8r version 5 the `fileLocation` argument of `getSingleResultLogMessage` will be removed.
|
|
38
|
+
The signature will become `getSingleResultLogMessage(result, format)`.
|
|
39
|
+
Plugins implementing the `getSingleResultLogMessage` plugin hook will need to to update
|
|
40
|
+
the signature to be compatible with version 5.
|
|
41
|
+
If you are using `fileLocation` in the `getSingleResultLogMessage` function body,
|
|
42
|
+
switch to using `result.fileLocation`.
|
|
43
|
+
* Starting from v8r version 5 file paths will no longer be passed to plugins in dot-relative notation.
|
|
44
|
+
Plugins implementing the `getSingleResultLogMessage`, `getAllResultsLogMessage` and `parseInputFile`
|
|
45
|
+
plugin hooks may need to be updated.
|
|
46
|
+
|
|
3
47
|
## 📦 [4.3.0](https://www.npmjs.com/package/v8r/v/4.3.0) - 2025-04-21
|
|
4
48
|
|
|
5
49
|
* Add ignore patern files. v8r now looks for ignore patterns in `.v8rignore` by default.
|
package/config-schema.json
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "v8r",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "5.0.0",
|
|
4
4
|
"description": "A command-line JSON, YAML and TOML validator that's on your wavelength",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"test": "V8R_CACHE_NAME=v8r-test c8 --reporter=text mocha \"src/**/*.spec.js\"",
|
|
@@ -34,14 +34,14 @@
|
|
|
34
34
|
"cosmiconfig": "^9.0.0",
|
|
35
35
|
"decamelize": "^6.0.0",
|
|
36
36
|
"flat-cache": "^6.1.4",
|
|
37
|
-
"glob": "^
|
|
37
|
+
"glob": "^11.0.0",
|
|
38
38
|
"global-agent": "^3.0.0",
|
|
39
|
-
"got": "^
|
|
39
|
+
"got": "^14.0.0",
|
|
40
40
|
"ignore": "^7.0.0",
|
|
41
41
|
"is-url": "^1.2.4",
|
|
42
42
|
"js-yaml": "^4.0.0",
|
|
43
43
|
"json5": "^2.2.0",
|
|
44
|
-
"minimatch": "^
|
|
44
|
+
"minimatch": "^10.0.0",
|
|
45
45
|
"smol-toml": "^1.0.1",
|
|
46
46
|
"yargs": "^17.0.1"
|
|
47
47
|
},
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
"eslint": "^9.9.0",
|
|
51
51
|
"eslint-config-prettier": "^10.1.2",
|
|
52
52
|
"eslint-plugin-jsdoc": "^50.2.2",
|
|
53
|
-
"eslint-plugin-mocha": "^
|
|
53
|
+
"eslint-plugin-mocha": "^11.0.0",
|
|
54
54
|
"eslint-plugin-prettier": "^5.0.0",
|
|
55
55
|
"mocha": "^11.0.1",
|
|
56
56
|
"mock-cwd": "^1.0.0",
|
|
@@ -59,7 +59,7 @@
|
|
|
59
59
|
"prettier-plugin-jsdoc": "^1.3.0"
|
|
60
60
|
},
|
|
61
61
|
"engines": {
|
|
62
|
-
"node": ">=
|
|
62
|
+
"node": ">=20"
|
|
63
63
|
},
|
|
64
64
|
"type": "module",
|
|
65
65
|
"keywords": [
|
package/src/bootstrap.js
CHANGED
|
@@ -79,7 +79,7 @@ function parseArgs(argv, config, documentFormats, outputFormats) {
|
|
|
79
79
|
const ignoreFilesOpts = {
|
|
80
80
|
describe: "A list of files containing glob patterns to ignore",
|
|
81
81
|
};
|
|
82
|
-
let ignoreFilesDefault = [".v8rignore"];
|
|
82
|
+
let ignoreFilesDefault = [".v8rignore", ".gitignore"];
|
|
83
83
|
ignoreFilesOpts.defaultDescription = `${JSON.stringify(ignoreFilesDefault)}`;
|
|
84
84
|
if (Object.keys(config.config).includes("ignorePatternFiles")) {
|
|
85
85
|
ignoreFilesDefault = config.config.ignorePatternFiles;
|
|
@@ -177,7 +177,7 @@ function parseArgs(argv, config, documentFormats, outputFormats) {
|
|
|
177
177
|
"Remove cached HTTP responses older than <cache-ttl> seconds old. " +
|
|
178
178
|
"Passing 0 clears and disables cache completely",
|
|
179
179
|
})
|
|
180
|
-
.option("format", {
|
|
180
|
+
.option("output-format", {
|
|
181
181
|
type: "string",
|
|
182
182
|
choices: outputFormats,
|
|
183
183
|
default: "text",
|
|
@@ -193,7 +193,7 @@ function parseArgs(argv, config, documentFormats, outputFormats) {
|
|
|
193
193
|
]);
|
|
194
194
|
|
|
195
195
|
for (const [key, value] of Object.entries(config.config)) {
|
|
196
|
-
if (["cacheTtl", "
|
|
196
|
+
if (["cacheTtl", "outputFormat", "ignoreErrors", "verbose"].includes(key)) {
|
|
197
197
|
parser.default(
|
|
198
198
|
decamelize(key, { separator: "-" }),
|
|
199
199
|
value,
|
package/src/cli.js
CHANGED
|
@@ -144,8 +144,7 @@ async function validateFile(filename, config, plugins, cache) {
|
|
|
144
144
|
for (const plugin of plugins) {
|
|
145
145
|
const message = plugin.getSingleResultLogMessage(
|
|
146
146
|
result,
|
|
147
|
-
|
|
148
|
-
config.format,
|
|
147
|
+
config.outputFormat,
|
|
149
148
|
);
|
|
150
149
|
if (message != null) {
|
|
151
150
|
logger.log(message);
|
|
@@ -191,7 +190,10 @@ function Validator() {
|
|
|
191
190
|
}
|
|
192
191
|
|
|
193
192
|
for (const plugin of plugins) {
|
|
194
|
-
const message = plugin.getAllResultsLogMessage(
|
|
193
|
+
const message = plugin.getAllResultsLogMessage(
|
|
194
|
+
results,
|
|
195
|
+
config.outputFormat,
|
|
196
|
+
);
|
|
195
197
|
if (message != null) {
|
|
196
198
|
logger.log(message);
|
|
197
199
|
break;
|
package/src/glob.js
CHANGED
|
@@ -43,10 +43,6 @@ async function readIgnoreFiles(filenames) {
|
|
|
43
43
|
return content;
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
-
function getSeparator() {
|
|
47
|
-
return process.platform == "win32" ? "\\" : "/";
|
|
48
|
-
}
|
|
49
|
-
|
|
50
46
|
async function getFiles(patterns, ignorePatternFiles) {
|
|
51
47
|
let filenames = [];
|
|
52
48
|
|
|
@@ -80,10 +76,6 @@ async function getFiles(patterns, ignorePatternFiles) {
|
|
|
80
76
|
throw new NotFound(`Could not find any files to validate`);
|
|
81
77
|
}
|
|
82
78
|
|
|
83
|
-
const sep = getSeparator();
|
|
84
|
-
filteredFilenames = filteredFilenames.map((fn) =>
|
|
85
|
-
!fn.startsWith(".." + sep) ? "." + sep + fn : fn,
|
|
86
|
-
);
|
|
87
79
|
return filteredFilenames;
|
|
88
80
|
}
|
|
89
81
|
|
package/src/logger.js
CHANGED
|
@@ -47,6 +47,12 @@ class Logger {
|
|
|
47
47
|
this.writeErr(formatedMessage);
|
|
48
48
|
}
|
|
49
49
|
|
|
50
|
+
warning(message) {
|
|
51
|
+
const formatedMessage = chalk.yellow.bold("▲ ") + message;
|
|
52
|
+
this.stderr.push(formatedMessage);
|
|
53
|
+
this.writeErr(formatedMessage);
|
|
54
|
+
}
|
|
55
|
+
|
|
50
56
|
error(message) {
|
|
51
57
|
const formatedMessage = chalk.red.bold("✖ ") + message;
|
|
52
58
|
this.stderr.push(formatedMessage);
|
|
@@ -8,7 +8,7 @@ class TextOutput extends BasePlugin {
|
|
|
8
8
|
return ["text"];
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
-
getSingleResultLogMessage(result,
|
|
11
|
+
getSingleResultLogMessage(result, format) {
|
|
12
12
|
if (result.valid === false && format === "text") {
|
|
13
13
|
return formatErrors(getDocumentLocation(result), result.errors);
|
|
14
14
|
}
|
package/src/plugins.js
CHANGED
|
@@ -36,10 +36,7 @@ class BasePlugin {
|
|
|
36
36
|
* Document object or an array of Document objects.
|
|
37
37
|
*
|
|
38
38
|
* @param {string} contents - The unparsed file content.
|
|
39
|
-
* @param {string} fileLocation - The file path.
|
|
40
|
-
* normalised using dot-relative notation. This means relative paths in the
|
|
41
|
-
* current directory will be prefixed with `./` (or `.\` on Windows) even if
|
|
42
|
-
* this was not present in the input filename or pattern.
|
|
39
|
+
* @param {string} fileLocation - The file path.
|
|
43
40
|
* @param {string | undefined} parser - If the user has specified a parser to
|
|
44
41
|
* use for this file in a custom schema, this will be passed to
|
|
45
42
|
* `parseInputFile` in the `parser` param.
|
|
@@ -53,8 +50,8 @@ class BasePlugin {
|
|
|
53
50
|
/**
|
|
54
51
|
* Use the `registerOutputFormats` hook to tell v8r about additional output
|
|
55
52
|
* formats that can be generated. Any formats registered with this hook become
|
|
56
|
-
* valid values for the `
|
|
57
|
-
* `--format` command line argument.
|
|
53
|
+
* valid values for the `outputFormat` property in the config file and the
|
|
54
|
+
* `--output-format` command line argument.
|
|
58
55
|
*
|
|
59
56
|
* @returns {string[]} Output formats to register
|
|
60
57
|
*/
|
|
@@ -75,16 +72,12 @@ class BasePlugin {
|
|
|
75
72
|
*
|
|
76
73
|
* @param {ValidationResult} result - Result of attempting to validate this
|
|
77
74
|
* document.
|
|
78
|
-
* @param {string} fileLocation - The document file path. Filenames are
|
|
79
|
-
* resolved and normalised using dot-relative notation. This means relative
|
|
80
|
-
* paths in the current directory will be prefixed with `./` (or `.\` on
|
|
81
|
-
* Windows) even if this was not present in the input filename or pattern.
|
|
82
75
|
* @param {string} format - The user's requested output format as specified in
|
|
83
|
-
* the config file or via the `--format` command line argument.
|
|
76
|
+
* the config file or via the `--output-format` command line argument.
|
|
84
77
|
* @returns {string | undefined} Log message
|
|
85
78
|
*/
|
|
86
79
|
// eslint-disable-next-line no-unused-vars
|
|
87
|
-
getSingleResultLogMessage(result,
|
|
80
|
+
getSingleResultLogMessage(result, format) {
|
|
88
81
|
return undefined;
|
|
89
82
|
}
|
|
90
83
|
|
|
@@ -102,7 +95,7 @@ class BasePlugin {
|
|
|
102
95
|
* @param {ValidationResult[]} results - Results of attempting to validate
|
|
103
96
|
* these documents.
|
|
104
97
|
* @param {string} format - The user's requested output format as specified in
|
|
105
|
-
* the config file or via the `--format` command line argument.
|
|
98
|
+
* the config file or via the `--output-format` command line argument.
|
|
106
99
|
* @returns {string | undefined} Log message
|
|
107
100
|
*/
|
|
108
101
|
// eslint-disable-next-line no-unused-vars
|
|
@@ -199,10 +192,6 @@ async function loadAllPlugins(userPlugins) {
|
|
|
199
192
|
/**
|
|
200
193
|
* @typedef {object} ValidationResult
|
|
201
194
|
* @property {string} fileLocation - Path of the document that was validated.
|
|
202
|
-
* Filenames are resolved and normalised using dot-relative notation. This
|
|
203
|
-
* means relative paths in the current directory will be prefixed with `./`
|
|
204
|
-
* (or `.\` on Windows) even if this was not present in the input filename or
|
|
205
|
-
* pattern.
|
|
206
195
|
* @property {number | null} documentIndex - Some file formats allow multiple
|
|
207
196
|
* documents to be embedded in one file (e.g:
|
|
208
197
|
* [yaml](https://www.yaml.info/learn/document.html)). In these cases,
|