@cspell/cspell-json-reporter 7.1.1 → 7.3.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/dist/esm/CSpellJSONReporterOutput.js +2 -0
- package/dist/esm/CSpellJSONReporterSettings.js +2 -0
- package/dist/esm/{index.mjs → index.js} +3 -2
- package/dist/esm/utils/{setToJSONReplacer.mjs → setToJSONReplacer.js} +1 -0
- package/dist/esm/utils/{validateSettings.mjs → validateSettings.js} +1 -0
- package/package.json +8 -12
- package/dist/cjs/CSpellJSONReporterOutput.js +0 -3
- package/dist/cjs/CSpellJSONReporterSettings.js +0 -3
- package/dist/cjs/index.js +0 -102
- package/dist/cjs/utils/setToJSONReplacer.js +0 -14
- package/dist/cjs/utils/validateSettings.js +0 -38
- package/dist/esm/CSpellJSONReporterOutput.d.mts +0 -36
- package/dist/esm/CSpellJSONReporterOutput.mjs +0 -1
- package/dist/esm/CSpellJSONReporterSettings.d.mts +0 -33
- package/dist/esm/CSpellJSONReporterSettings.mjs +0 -1
- package/dist/esm/index.d.mts +0 -4
- package/dist/esm/utils/setToJSONReplacer.d.mts +0 -5
- package/dist/esm/utils/validateSettings.d.mts +0 -6
- /package/dist/{cjs → esm}/CSpellJSONReporterOutput.d.ts +0 -0
- /package/dist/{cjs → esm}/CSpellJSONReporterSettings.d.ts +0 -0
- /package/dist/{cjs → esm}/index.d.ts +0 -0
- /package/dist/{cjs → esm}/utils/setToJSONReplacer.d.ts +0 -0
- /package/dist/{cjs → esm}/utils/validateSettings.d.ts +0 -0
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { MessageTypes } from '@cspell/cspell-types';
|
|
2
2
|
import { promises as fs } from 'fs';
|
|
3
3
|
import * as path from 'path';
|
|
4
|
-
import { setToJSONReplacer } from './utils/setToJSONReplacer.
|
|
5
|
-
import { validateSettings } from './utils/validateSettings.
|
|
4
|
+
import { setToJSONReplacer } from './utils/setToJSONReplacer.js';
|
|
5
|
+
import { validateSettings } from './utils/validateSettings.js';
|
|
6
6
|
function mkdirp(p) {
|
|
7
7
|
return fs.mkdir(p, { recursive: true });
|
|
8
8
|
}
|
|
@@ -72,3 +72,4 @@ function push(src, value) {
|
|
|
72
72
|
}
|
|
73
73
|
return [value];
|
|
74
74
|
}
|
|
75
|
+
//# sourceMappingURL=index.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cspell/cspell-json-reporter",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.3.0",
|
|
4
4
|
"description": "JSON reporter for CSpell",
|
|
5
5
|
"author": "Jason Dent",
|
|
6
6
|
"license": "MIT",
|
|
@@ -8,20 +8,16 @@
|
|
|
8
8
|
"url": "https://github.com/streetsidesoftware/cspell/labels/cspell-json-reporter"
|
|
9
9
|
},
|
|
10
10
|
"homepage": "https://github.com/streetsidesoftware/cspell/tree/main/packages/cspell-json-reporter#readme",
|
|
11
|
-
"type": "
|
|
12
|
-
"
|
|
13
|
-
"
|
|
14
|
-
"module": "dist/esm/index.mjs",
|
|
11
|
+
"type": "module",
|
|
12
|
+
"types": "dist/esm/index.d.ts",
|
|
13
|
+
"module": "dist/esm/index.js",
|
|
15
14
|
"exports": {
|
|
16
15
|
".": {
|
|
17
|
-
"import": "./dist/esm/index.
|
|
18
|
-
"require": "./dist/cjs/index.js"
|
|
16
|
+
"import": "./dist/esm/index.js"
|
|
19
17
|
}
|
|
20
18
|
},
|
|
21
19
|
"files": [
|
|
22
20
|
"dist",
|
|
23
|
-
"!dist/esm/**/*.js",
|
|
24
|
-
"!dist/esm/**/*.ts",
|
|
25
21
|
"!**/*.tsbuildInfo",
|
|
26
22
|
"!**/__mocks__",
|
|
27
23
|
"!**/test/**",
|
|
@@ -38,7 +34,7 @@
|
|
|
38
34
|
},
|
|
39
35
|
"scripts": {
|
|
40
36
|
"clean": "shx rm -rf dist temp coverage \"*.tsbuildInfo\"",
|
|
41
|
-
"build": "tsc -b .
|
|
37
|
+
"build": "tsc -b .",
|
|
42
38
|
"build:esm": "tsc -p tsconfig.esm.json",
|
|
43
39
|
"clean-build": "pnpm run clean && pnpm run build",
|
|
44
40
|
"coverage": "vitest run --coverage",
|
|
@@ -47,10 +43,10 @@
|
|
|
47
43
|
"watch": "tsc -b . -w"
|
|
48
44
|
},
|
|
49
45
|
"dependencies": {
|
|
50
|
-
"@cspell/cspell-types": "7.
|
|
46
|
+
"@cspell/cspell-types": "7.3.0"
|
|
51
47
|
},
|
|
52
48
|
"engines": {
|
|
53
49
|
"node": ">=16"
|
|
54
50
|
},
|
|
55
|
-
"gitHead": "
|
|
51
|
+
"gitHead": "4a16b099b64c5b55645529a4ae79bc32aaf0fc8e"
|
|
56
52
|
}
|
package/dist/cjs/index.js
DELETED
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.getReporter = void 0;
|
|
27
|
-
const cspell_types_1 = require("@cspell/cspell-types");
|
|
28
|
-
const fs_1 = require("fs");
|
|
29
|
-
const path = __importStar(require("path"));
|
|
30
|
-
const setToJSONReplacer_js_1 = require("./utils/setToJSONReplacer.js");
|
|
31
|
-
const validateSettings_js_1 = require("./utils/validateSettings.js");
|
|
32
|
-
function mkdirp(p) {
|
|
33
|
-
return fs_1.promises.mkdir(p, { recursive: true });
|
|
34
|
-
}
|
|
35
|
-
const noopReporter = () => undefined;
|
|
36
|
-
const STDOUT = 'stdout';
|
|
37
|
-
const STDERR = 'stderr';
|
|
38
|
-
function getReporter(settings, cliOptions) {
|
|
39
|
-
const useSettings = normalizeSettings(settings);
|
|
40
|
-
const reportData = { issues: [], info: [], debug: [], error: [], progress: [] };
|
|
41
|
-
return {
|
|
42
|
-
issue: (issue) => {
|
|
43
|
-
reportData.issues.push(issue);
|
|
44
|
-
},
|
|
45
|
-
info: (message, msgType) => {
|
|
46
|
-
if (msgType === cspell_types_1.MessageTypes.Debug && !useSettings.debug) {
|
|
47
|
-
return;
|
|
48
|
-
}
|
|
49
|
-
if (msgType === cspell_types_1.MessageTypes.Info && !useSettings.verbose) {
|
|
50
|
-
return;
|
|
51
|
-
}
|
|
52
|
-
reportData.info = push(reportData.info, { message, msgType });
|
|
53
|
-
},
|
|
54
|
-
debug: useSettings.debug
|
|
55
|
-
? (message) => {
|
|
56
|
-
reportData.debug = push(reportData.debug, { message });
|
|
57
|
-
}
|
|
58
|
-
: noopReporter,
|
|
59
|
-
error: (message, error) => {
|
|
60
|
-
reportData.error = push(reportData.error, { message, error });
|
|
61
|
-
},
|
|
62
|
-
progress: useSettings.progress
|
|
63
|
-
? (item) => {
|
|
64
|
-
reportData.progress = push(reportData.progress, item);
|
|
65
|
-
}
|
|
66
|
-
: noopReporter,
|
|
67
|
-
result: async (result) => {
|
|
68
|
-
const outFile = useSettings.outFile || STDOUT;
|
|
69
|
-
const output = {
|
|
70
|
-
...reportData,
|
|
71
|
-
result,
|
|
72
|
-
};
|
|
73
|
-
const jsonData = JSON.stringify(output, setToJSONReplacer_js_1.setToJSONReplacer, 4);
|
|
74
|
-
if (outFile === STDOUT) {
|
|
75
|
-
console.log(jsonData);
|
|
76
|
-
return;
|
|
77
|
-
}
|
|
78
|
-
if (outFile === STDERR) {
|
|
79
|
-
console.error(jsonData);
|
|
80
|
-
return;
|
|
81
|
-
}
|
|
82
|
-
const outFilePath = path.join(cliOptions?.root ?? process.cwd(), outFile);
|
|
83
|
-
await mkdirp(path.dirname(outFilePath));
|
|
84
|
-
return fs_1.promises.writeFile(outFilePath, jsonData);
|
|
85
|
-
},
|
|
86
|
-
};
|
|
87
|
-
}
|
|
88
|
-
exports.getReporter = getReporter;
|
|
89
|
-
function normalizeSettings(settings) {
|
|
90
|
-
if (settings === undefined)
|
|
91
|
-
return { outFile: STDOUT };
|
|
92
|
-
(0, validateSettings_js_1.validateSettings)(settings);
|
|
93
|
-
return settings;
|
|
94
|
-
}
|
|
95
|
-
function push(src, value) {
|
|
96
|
-
if (src) {
|
|
97
|
-
src.push(value);
|
|
98
|
-
return src;
|
|
99
|
-
}
|
|
100
|
-
return [value];
|
|
101
|
-
}
|
|
102
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.setToJSONReplacer = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* JSON.stringify replacer which converts Set to Array to allow serialization
|
|
6
|
-
*/
|
|
7
|
-
function setToJSONReplacer(_, value) {
|
|
8
|
-
if (typeof value === 'object' && value instanceof Set) {
|
|
9
|
-
return [...value];
|
|
10
|
-
}
|
|
11
|
-
return value;
|
|
12
|
-
}
|
|
13
|
-
exports.setToJSONReplacer = setToJSONReplacer;
|
|
14
|
-
//# sourceMappingURL=setToJSONReplacer.js.map
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.validateSettings = void 0;
|
|
4
|
-
const assert_1 = require("assert");
|
|
5
|
-
function assertBooleanOrUndefined(key, value) {
|
|
6
|
-
if (typeof value !== 'boolean' && value !== undefined) {
|
|
7
|
-
throw new assert_1.AssertionError({
|
|
8
|
-
message: `cspell-json-reporter settings.${key} must be a boolean`,
|
|
9
|
-
actual: typeof value,
|
|
10
|
-
expected: 'boolean',
|
|
11
|
-
});
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
/**
|
|
15
|
-
* Throws an error if passed cspell-json-reporter settings are invalid
|
|
16
|
-
*/
|
|
17
|
-
function validateSettings(settings) {
|
|
18
|
-
if (!settings || typeof settings !== 'object' || Array.isArray(settings)) {
|
|
19
|
-
throw new assert_1.AssertionError({
|
|
20
|
-
message: 'cspell-json-reporter settings must be an object',
|
|
21
|
-
actual: typeof settings,
|
|
22
|
-
expected: 'object',
|
|
23
|
-
});
|
|
24
|
-
}
|
|
25
|
-
const { outFile = 'stdout', debug, verbose, progress } = settings;
|
|
26
|
-
if (typeof outFile !== 'string') {
|
|
27
|
-
throw new assert_1.AssertionError({
|
|
28
|
-
message: 'cspell-json-reporter settings.outFile must be a string',
|
|
29
|
-
actual: typeof outFile,
|
|
30
|
-
expected: 'string',
|
|
31
|
-
});
|
|
32
|
-
}
|
|
33
|
-
assertBooleanOrUndefined('verbose', verbose);
|
|
34
|
-
assertBooleanOrUndefined('debug', debug);
|
|
35
|
-
assertBooleanOrUndefined('progress', progress);
|
|
36
|
-
}
|
|
37
|
-
exports.validateSettings = validateSettings;
|
|
38
|
-
//# sourceMappingURL=validateSettings.js.map
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import type { ErrorLike, Issue, MessageType, ProgressFileComplete, ProgressItem, RunResult } from '@cspell/cspell-types';
|
|
2
|
-
export type CSpellJSONReporterOutput = {
|
|
3
|
-
/**
|
|
4
|
-
* Found spelling issues
|
|
5
|
-
*/
|
|
6
|
-
issues: Array<Issue>;
|
|
7
|
-
/**
|
|
8
|
-
* CSpell execution logs
|
|
9
|
-
*/
|
|
10
|
-
info?: Array<{
|
|
11
|
-
message: string;
|
|
12
|
-
msgType: MessageType;
|
|
13
|
-
}>;
|
|
14
|
-
/**
|
|
15
|
-
* CSpell debug logs
|
|
16
|
-
*/
|
|
17
|
-
debug?: Array<{
|
|
18
|
-
message: string;
|
|
19
|
-
}>;
|
|
20
|
-
/**
|
|
21
|
-
* CSpell error logs
|
|
22
|
-
*/
|
|
23
|
-
error?: Array<{
|
|
24
|
-
message: string;
|
|
25
|
-
error: ErrorLike;
|
|
26
|
-
}>;
|
|
27
|
-
/**
|
|
28
|
-
* CSpell file progress logs
|
|
29
|
-
*/
|
|
30
|
-
progress?: Array<ProgressItem | ProgressFileComplete>;
|
|
31
|
-
/**
|
|
32
|
-
* Execution result
|
|
33
|
-
*/
|
|
34
|
-
result: RunResult;
|
|
35
|
-
};
|
|
36
|
-
//# sourceMappingURL=CSpellJSONReporterOutput.d.mts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* CSpell-json-reporter settings type definition
|
|
3
|
-
*/
|
|
4
|
-
export type CSpellJSONReporterSettings = {
|
|
5
|
-
/**
|
|
6
|
-
* Path to the output file.
|
|
7
|
-
*
|
|
8
|
-
* Relative paths are relative to the current working directory.
|
|
9
|
-
*
|
|
10
|
-
* Special values:
|
|
11
|
-
* - `stdout` - write the JSON to `stdout`.
|
|
12
|
-
* - `stderr` - write the JSON to `stderr`.
|
|
13
|
-
*
|
|
14
|
-
* @default stdout
|
|
15
|
-
*/
|
|
16
|
-
outFile?: string;
|
|
17
|
-
/**
|
|
18
|
-
* Add more information about the files being checked and the configuration
|
|
19
|
-
* @default false
|
|
20
|
-
*/
|
|
21
|
-
verbose?: boolean;
|
|
22
|
-
/**
|
|
23
|
-
* Add information useful for debugging cspell.json files
|
|
24
|
-
* @default false
|
|
25
|
-
*/
|
|
26
|
-
debug?: boolean;
|
|
27
|
-
/**
|
|
28
|
-
* Add progress messages
|
|
29
|
-
* @default false
|
|
30
|
-
*/
|
|
31
|
-
progress?: boolean;
|
|
32
|
-
};
|
|
33
|
-
//# sourceMappingURL=CSpellJSONReporterSettings.d.mts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/dist/esm/index.d.mts
DELETED
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import type { CSpellReporter, ReporterConfiguration } from '@cspell/cspell-types';
|
|
2
|
-
import type { CSpellJSONReporterSettings } from './CSpellJSONReporterSettings.mjs';
|
|
3
|
-
export declare function getReporter(settings: unknown | CSpellJSONReporterSettings, cliOptions?: ReporterConfiguration): Required<CSpellReporter>;
|
|
4
|
-
//# sourceMappingURL=index.d.mts.map
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import type { CSpellJSONReporterSettings } from '../CSpellJSONReporterSettings.mjs';
|
|
2
|
-
/**
|
|
3
|
-
* Throws an error if passed cspell-json-reporter settings are invalid
|
|
4
|
-
*/
|
|
5
|
-
export declare function validateSettings(settings: unknown): asserts settings is CSpellJSONReporterSettings;
|
|
6
|
-
//# sourceMappingURL=validateSettings.d.mts.map
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|