cspell 5.18.3 → 5.18.4
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/application.d.ts +3 -2
- package/dist/application.js +22 -4
- package/dist/commandSuggestion.js +2 -1
- package/dist/emitters/suggestionsEmitter.d.ts +4 -1
- package/dist/emitters/suggestionsEmitter.js +2 -1
- package/dist/lint/lint.js +2 -2
- package/dist/options.d.ts +4 -0
- package/dist/repl/index.d.ts +18 -0
- package/dist/repl/index.js +71 -0
- package/package.json +9 -9
package/dist/application.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import type { CSpellReporter, RunResult } from '@cspell/cspell-types';
|
|
3
|
-
import type { CheckTextInfo,
|
|
3
|
+
import type { CheckTextInfo, TraceResult } from 'cspell-lib';
|
|
4
|
+
import { TimedSuggestionsForWordResult } from './emitters/suggestionsEmitter';
|
|
4
5
|
import { BaseOptions, LegacyOptions, LinterOptions, SuggestionOptions, TraceOptions } from './options';
|
|
5
6
|
export { IncludeExcludeFlag } from 'cspell-lib';
|
|
6
7
|
export type { TraceResult } from 'cspell-lib';
|
|
@@ -9,6 +10,6 @@ export declare function lint(fileGlobs: string[], options: LinterOptions, emitte
|
|
|
9
10
|
export declare function trace(words: string[], options: TraceOptions): AsyncIterableIterator<TraceResult[]>;
|
|
10
11
|
export declare type CheckTextResult = CheckTextInfo;
|
|
11
12
|
export declare function checkText(filename: string, options: BaseOptions & LegacyOptions): Promise<CheckTextResult>;
|
|
12
|
-
export declare function suggestions(words: string[], options: SuggestionOptions): AsyncIterable<
|
|
13
|
+
export declare function suggestions(words: string[], options: SuggestionOptions): AsyncIterable<TimedSuggestionsForWordResult>;
|
|
13
14
|
export declare function createInit(): Promise<void>;
|
|
14
15
|
//# sourceMappingURL=application.d.ts.map
|
package/dist/application.js
CHANGED
|
@@ -20,13 +20,15 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
20
20
|
};
|
|
21
21
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
22
|
exports.createInit = exports.suggestions = exports.checkText = exports.trace = exports.lint = exports.IncludeExcludeFlag = void 0;
|
|
23
|
+
const cspell_pipe_1 = require("@cspell/cspell-pipe");
|
|
23
24
|
const cspell_lib_1 = require("cspell-lib");
|
|
24
25
|
const path = __importStar(require("path"));
|
|
25
26
|
const lint_1 = require("./lint");
|
|
26
27
|
const options_1 = require("./options");
|
|
27
|
-
const
|
|
28
|
+
const repl_1 = require("./repl");
|
|
28
29
|
const fileHelper_1 = require("./util/fileHelper");
|
|
29
30
|
const stdin_1 = require("./util/stdin");
|
|
31
|
+
const timer_1 = require("./util/timer");
|
|
30
32
|
const util = __importStar(require("./util/util"));
|
|
31
33
|
var cspell_lib_2 = require("cspell-lib");
|
|
32
34
|
Object.defineProperty(exports, "IncludeExcludeFlag", { enumerable: true, get: function () { return cspell_lib_2.IncludeExcludeFlag; } });
|
|
@@ -38,7 +40,7 @@ function lint(fileGlobs, options, emitters) {
|
|
|
38
40
|
exports.lint = lint;
|
|
39
41
|
async function* trace(words, options) {
|
|
40
42
|
options = (0, options_1.fixLegacy)(options);
|
|
41
|
-
const iWords = options.stdin ?
|
|
43
|
+
const iWords = options.stdin ? (0, cspell_pipe_1.toAsyncIterable)(words, (0, stdin_1.readStdin)()) : words;
|
|
42
44
|
const { languageId, locale, allowCompoundWords, ignoreCase } = options;
|
|
43
45
|
const configFile = await (0, fileHelper_1.readConfig)(options.config, undefined);
|
|
44
46
|
const config = (0, cspell_lib_1.mergeSettings)((0, cspell_lib_1.getDefaultSettings)(), (0, cspell_lib_1.getGlobalSettings)(), configFile.config);
|
|
@@ -60,9 +62,25 @@ exports.checkText = checkText;
|
|
|
60
62
|
async function* suggestions(words, options) {
|
|
61
63
|
options = (0, options_1.fixLegacy)(options);
|
|
62
64
|
const configFile = await (0, fileHelper_1.readConfig)(options.config, undefined);
|
|
63
|
-
|
|
65
|
+
let timer;
|
|
66
|
+
function tapStart() {
|
|
67
|
+
timer = (0, timer_1.getTimeMeasurer)();
|
|
68
|
+
}
|
|
69
|
+
function mapStart(v) {
|
|
70
|
+
tapStart();
|
|
71
|
+
return v;
|
|
72
|
+
}
|
|
73
|
+
function mapEnd(v) {
|
|
74
|
+
const elapsedTimeMs = timer === null || timer === void 0 ? void 0 : timer();
|
|
75
|
+
return { ...v, elapsedTimeMs };
|
|
76
|
+
}
|
|
77
|
+
const iWords = options.repl
|
|
78
|
+
? (0, cspell_pipe_1.pipeAsync)((0, cspell_pipe_1.toAsyncIterable)(words, (0, repl_1.simpleRepl)()), (0, cspell_pipe_1.opTap)(tapStart))
|
|
79
|
+
: options.useStdin
|
|
80
|
+
? (0, cspell_pipe_1.pipeAsync)((0, cspell_pipe_1.toAsyncIterable)(words, (0, stdin_1.readStdin)()), (0, cspell_pipe_1.opTap)(tapStart))
|
|
81
|
+
: words.map(mapStart);
|
|
64
82
|
try {
|
|
65
|
-
const results = (0, cspell_lib_1.suggestionsForWords)(iWords, options, configFile.config);
|
|
83
|
+
const results = (0, cspell_pipe_1.pipeAsync)((0, cspell_lib_1.suggestionsForWords)(iWords, options, configFile.config), (0, cspell_pipe_1.opMap)(mapEnd));
|
|
66
84
|
yield* results;
|
|
67
85
|
}
|
|
68
86
|
catch (e) {
|
|
@@ -53,6 +53,7 @@ function commandSuggestion(prog) {
|
|
|
53
53
|
.option('--num-suggestions <number>', 'Number of suggestions', asNumber, 8)
|
|
54
54
|
.option('--no-include-ties', 'Force the number of suggested to be limited, by not including suggestions that have the same edit cost.')
|
|
55
55
|
.option('--stdin', 'Use stdin for input.')
|
|
56
|
+
.addOption(new commander_1.Option('--repl', 'REPL interface for looking up suggestions.').hideHelp())
|
|
56
57
|
.option('-v, --verbose', 'Show detailed output.', count, 0)
|
|
57
58
|
.option('-d, --dictionary <dictionary name>', 'Use the dictionary specified. Only dictionaries specified will be used.', collect)
|
|
58
59
|
.option('--dictionaries <dictionary names...>', 'Use the dictionaries specified. Only dictionaries specified will be used.')
|
|
@@ -62,7 +63,7 @@ function commandSuggestion(prog) {
|
|
|
62
63
|
.action(async (words, options) => {
|
|
63
64
|
options.useStdin = options.stdin;
|
|
64
65
|
options.dictionaries = mergeArrays(options.dictionaries, options.dictionary);
|
|
65
|
-
if (!words.length && !options.useStdin) {
|
|
66
|
+
if (!words.length && !options.useStdin && !options.repl) {
|
|
66
67
|
suggestionCommand.outputHelp();
|
|
67
68
|
throw new errors_1.CheckFailed('outputHelp', 1);
|
|
68
69
|
}
|
|
@@ -6,5 +6,8 @@ export interface EmitSuggestionOptions {
|
|
|
6
6
|
log: (text: string) => void;
|
|
7
7
|
};
|
|
8
8
|
}
|
|
9
|
-
export
|
|
9
|
+
export interface TimedSuggestionsForWordResult extends SuggestionsForWordResult {
|
|
10
|
+
elapsedTimeMs?: number;
|
|
11
|
+
}
|
|
12
|
+
export declare function emitSuggestionResult(result: TimedSuggestionsForWordResult, options: EmitSuggestionOptions): void;
|
|
10
13
|
//# sourceMappingURL=suggestionsEmitter.d.ts.map
|
|
@@ -6,7 +6,8 @@ const util_1 = require("../util/util");
|
|
|
6
6
|
function emitSuggestionResult(result, options) {
|
|
7
7
|
const { word, suggestions } = result;
|
|
8
8
|
const { verbose, output = console } = options;
|
|
9
|
-
|
|
9
|
+
const elapsed = verbose && verbose > 1 && result.elapsedTimeMs ? ` ${result.elapsedTimeMs.toFixed(2)} ms` : '';
|
|
10
|
+
output.log((word ? chalk.yellow(word) : chalk.yellow('<empty>')) + ':' + elapsed);
|
|
10
11
|
if (!suggestions.length) {
|
|
11
12
|
console.log(chalk.yellow(' <no suggestions>'));
|
|
12
13
|
return;
|
package/dist/lint/lint.js
CHANGED
|
@@ -46,10 +46,11 @@ async function runLint(cfg) {
|
|
|
46
46
|
return lintResult;
|
|
47
47
|
async function processFile(filename, configInfo, cache) {
|
|
48
48
|
var _a, _b, _c, _d;
|
|
49
|
+
const getElapsedTimeMs = (0, timer_1.getTimeMeasurer)();
|
|
49
50
|
const cachedResult = await cache.getCachedLintResults(filename);
|
|
50
51
|
if (cachedResult) {
|
|
51
52
|
reporter.debug(`Filename: ${filename}, using cache`);
|
|
52
|
-
return cachedResult;
|
|
53
|
+
return { ...cachedResult, elapsedTimeMs: getElapsedTimeMs() };
|
|
53
54
|
}
|
|
54
55
|
const result = {
|
|
55
56
|
fileInfo: {
|
|
@@ -74,7 +75,6 @@ async function runLint(cfg) {
|
|
|
74
75
|
const { text } = fileInfo;
|
|
75
76
|
reporter.debug(`Filename: ${filename}, LanguageIds: ${(_a = doc.languageId) !== null && _a !== void 0 ? _a : 'default'}`);
|
|
76
77
|
result.fileInfo = fileInfo;
|
|
77
|
-
const getElapsedTimeMs = (0, timer_1.getTimeMeasurer)();
|
|
78
78
|
let spellResult = {};
|
|
79
79
|
reporter.info(`Checking: ${filename}, File type: ${(_b = doc.languageId) !== null && _b !== void 0 ? _b : 'auto'}, Language: ${(_c = doc.locale) !== null && _c !== void 0 ? _c : 'default'}`, cspell_types_1.MessageTypes.Info);
|
|
80
80
|
try {
|
package/dist/options.d.ts
CHANGED
|
@@ -98,6 +98,10 @@ export interface SuggestionOptions extends BaseOptions {
|
|
|
98
98
|
* Use stdin for the input
|
|
99
99
|
*/
|
|
100
100
|
useStdin?: boolean;
|
|
101
|
+
/**
|
|
102
|
+
* Use REPL interface for making suggestions.
|
|
103
|
+
*/
|
|
104
|
+
repl?: boolean;
|
|
101
105
|
}
|
|
102
106
|
export interface LegacyOptions {
|
|
103
107
|
local?: string;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export declare function simpleRepl(): AsyncIterable<string>;
|
|
2
|
+
export declare type CompleterResult = [string[], string];
|
|
3
|
+
export declare type Completer = (line: string) => CompleterResult;
|
|
4
|
+
export declare class SimpleRepl implements AsyncIterable<string> {
|
|
5
|
+
prompt: string;
|
|
6
|
+
beforeEach: undefined | (() => void);
|
|
7
|
+
completer: undefined | Completer;
|
|
8
|
+
private _history;
|
|
9
|
+
private rl;
|
|
10
|
+
constructor(prompt?: string);
|
|
11
|
+
question(query: string): Promise<string>;
|
|
12
|
+
private _completer;
|
|
13
|
+
get history(): string[];
|
|
14
|
+
[Symbol.asyncIterator](): {
|
|
15
|
+
next: () => Promise<IteratorResult<string, undefined>>;
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
+
}) : function(o, v) {
|
|
12
|
+
o["default"] = v;
|
|
13
|
+
});
|
|
14
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
+
if (mod && mod.__esModule) return mod;
|
|
16
|
+
var result = {};
|
|
17
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
+
__setModuleDefault(result, mod);
|
|
19
|
+
return result;
|
|
20
|
+
};
|
|
21
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
+
exports.SimpleRepl = exports.simpleRepl = void 0;
|
|
23
|
+
const readline = __importStar(require("readline"));
|
|
24
|
+
function simpleRepl() {
|
|
25
|
+
return new SimpleRepl();
|
|
26
|
+
}
|
|
27
|
+
exports.simpleRepl = simpleRepl;
|
|
28
|
+
class SimpleRepl {
|
|
29
|
+
constructor(prompt = '> ') {
|
|
30
|
+
this.prompt = prompt;
|
|
31
|
+
this._history = [];
|
|
32
|
+
this.rl = readline.createInterface({
|
|
33
|
+
input: process.stdin,
|
|
34
|
+
output: process.stdout,
|
|
35
|
+
prompt,
|
|
36
|
+
history: this._history,
|
|
37
|
+
historySize: 100,
|
|
38
|
+
completer: (line) => this._completer(line),
|
|
39
|
+
});
|
|
40
|
+
this.rl.on('history', (h) => ((this._history = h), undefined));
|
|
41
|
+
}
|
|
42
|
+
question(query) {
|
|
43
|
+
return new Promise((resolve) => {
|
|
44
|
+
this.rl.question(query, resolve);
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
_completer(line) {
|
|
48
|
+
// console.log('Complete: %s', line);
|
|
49
|
+
// console.log('History: %o', this._history);
|
|
50
|
+
if (this.completer)
|
|
51
|
+
return this.completer(line);
|
|
52
|
+
const hist = this._history.filter((h) => h.startsWith(line));
|
|
53
|
+
return [hist, line];
|
|
54
|
+
}
|
|
55
|
+
get history() {
|
|
56
|
+
return this._history;
|
|
57
|
+
}
|
|
58
|
+
[Symbol.asyncIterator]() {
|
|
59
|
+
const next = () => {
|
|
60
|
+
if (this.beforeEach)
|
|
61
|
+
this.beforeEach();
|
|
62
|
+
// console.log('%o', this.rl);
|
|
63
|
+
return this.question(this.prompt)
|
|
64
|
+
.then((value) => ({ value }))
|
|
65
|
+
.catch(() => ({ done: true, value: undefined }));
|
|
66
|
+
};
|
|
67
|
+
return { next };
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
exports.SimpleRepl = SimpleRepl;
|
|
71
|
+
//# sourceMappingURL=index.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cspell",
|
|
3
|
-
"version": "5.18.
|
|
3
|
+
"version": "5.18.4",
|
|
4
4
|
"description": "A Spelling Checker for Code!",
|
|
5
5
|
"funding": "https://github.com/streetsidesoftware/cspell?sponsor=1",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -70,13 +70,13 @@
|
|
|
70
70
|
},
|
|
71
71
|
"homepage": "https://streetsidesoftware.github.io/cspell/",
|
|
72
72
|
"dependencies": {
|
|
73
|
-
"@cspell/cspell-pipe": "^5.18.
|
|
73
|
+
"@cspell/cspell-pipe": "^5.18.4",
|
|
74
74
|
"chalk": "^4.1.2",
|
|
75
75
|
"commander": "^9.0.0",
|
|
76
76
|
"comment-json": "^4.2.2",
|
|
77
|
-
"cspell-gitignore": "^5.18.
|
|
78
|
-
"cspell-glob": "^5.18.
|
|
79
|
-
"cspell-lib": "^5.18.
|
|
77
|
+
"cspell-gitignore": "^5.18.4",
|
|
78
|
+
"cspell-glob": "^5.18.4",
|
|
79
|
+
"cspell-lib": "^5.18.4",
|
|
80
80
|
"fast-json-stable-stringify": "^2.1.0",
|
|
81
81
|
"file-entry-cache": "^6.0.1",
|
|
82
82
|
"fs-extra": "^10.0.0",
|
|
@@ -91,8 +91,8 @@
|
|
|
91
91
|
"node": ">=12.13.0"
|
|
92
92
|
},
|
|
93
93
|
"devDependencies": {
|
|
94
|
-
"@cspell/cspell-json-reporter": "^5.18.
|
|
95
|
-
"@cspell/cspell-types": "^5.18.
|
|
94
|
+
"@cspell/cspell-json-reporter": "^5.18.4",
|
|
95
|
+
"@cspell/cspell-types": "^5.18.4",
|
|
96
96
|
"@types/file-entry-cache": "^5.0.2",
|
|
97
97
|
"@types/fs-extra": "^9.0.13",
|
|
98
98
|
"@types/glob": "^7.2.0",
|
|
@@ -100,12 +100,12 @@
|
|
|
100
100
|
"@types/micromatch": "^4.0.2",
|
|
101
101
|
"@types/minimatch": "^3.0.5",
|
|
102
102
|
"@types/semver": "^7.3.9",
|
|
103
|
-
"jest": "^27.
|
|
103
|
+
"jest": "^27.5.0",
|
|
104
104
|
"micromatch": "^4.0.4",
|
|
105
105
|
"minimatch": "^3.0.4",
|
|
106
106
|
"rimraf": "^3.0.2",
|
|
107
107
|
"rollup": "^2.67.0",
|
|
108
108
|
"rollup-plugin-dts": "^4.1.0"
|
|
109
109
|
},
|
|
110
|
-
"gitHead": "
|
|
110
|
+
"gitHead": "26769ba64ce9eff227492524e5210709bec36416"
|
|
111
111
|
}
|