cspell 8.9.0 → 8.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/dist/esm/application.d.mts +0 -1
- package/dist/esm/application.d.ts +0 -1
- package/dist/esm/cli-reporter.js +20 -17
- package/dist/esm/cli-reporter.mjs +20 -17
- package/dist/esm/commandTrace.js +5 -1
- package/dist/esm/commandTrace.mjs +5 -1
- package/dist/esm/emitters/suggestionsEmitter.js +1 -1
- package/dist/esm/emitters/suggestionsEmitter.mjs +1 -1
- package/dist/esm/emitters/traceEmitter.d.mts +4 -0
- package/dist/esm/emitters/traceEmitter.d.ts +4 -0
- package/dist/esm/emitters/traceEmitter.js +45 -39
- package/dist/esm/emitters/traceEmitter.mjs +45 -39
- package/dist/esm/util/pad.d.mts +6 -0
- package/dist/esm/util/pad.d.ts +6 -0
- package/dist/esm/util/pad.js +28 -0
- package/dist/esm/util/pad.mjs +28 -0
- package/dist/esm/util/table.d.mts +5 -1
- package/dist/esm/util/table.d.ts +5 -1
- package/dist/esm/util/table.js +32 -9
- package/dist/esm/util/table.mjs +32 -9
- package/dist/esm/util/util.d.mts +0 -4
- package/dist/esm/util/util.d.ts +0 -4
- package/dist/esm/util/util.js +0 -20
- package/dist/esm/util/util.mjs +0 -20
- package/dist/lib/file-entry-cache.cjs +1 -2
- package/package.json +12 -12
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/// <reference types="node" resolution-mode="require"/>
|
|
2
1
|
import type { CSpellReporter, RunResult } from '@cspell/cspell-types';
|
|
3
2
|
import type { CheckTextInfo, FeatureFlags, TraceWordResult } from 'cspell-lib';
|
|
4
3
|
import type { TimedSuggestionsForWordResult } from './emitters/suggestionsEmitter.mjs';
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/// <reference types="node" resolution-mode="require"/>
|
|
2
1
|
import type { CSpellReporter, RunResult } from '@cspell/cspell-types';
|
|
3
2
|
import type { CheckTextInfo, FeatureFlags, TraceWordResult } from 'cspell-lib';
|
|
4
3
|
import type { TimedSuggestionsForWordResult } from './emitters/suggestionsEmitter.js';
|
package/dist/esm/cli-reporter.js
CHANGED
|
@@ -12,6 +12,9 @@ const templateIssueWithContext = `{green $filename}:{yellow $row:$col} $padRowCo
|
|
|
12
12
|
const templateIssueWithContextWithSuggestions = `{green $filename}:{yellow $row:$col} $padRowCol- $message ({red $text})$padContext -- {gray $contextLeft}{red {underline $text}}{gray $contextRight}\n\t Suggestions: {yellow [$suggestions]}`;
|
|
13
13
|
const templateIssueLegacy = `${chalk.green('$filename')}[$row, $col]: $message: ${chalk.red('$text')}`;
|
|
14
14
|
const templateIssueWordsOnly = '$text';
|
|
15
|
+
function consoleError(...params) {
|
|
16
|
+
console.error(chalk.white('%s'), format(...params));
|
|
17
|
+
}
|
|
15
18
|
/**
|
|
16
19
|
*
|
|
17
20
|
* @param template - The template to use for the issue.
|
|
@@ -72,7 +75,7 @@ function reportProgressFileComplete(p) {
|
|
|
72
75
|
const time = reportTime(p.elapsedTimeMs, !!p.cached);
|
|
73
76
|
const skipped = p.processed === false ? ' skipped' : '';
|
|
74
77
|
const hasErrors = p.numErrors ? chalk.red ` X` : '';
|
|
75
|
-
|
|
78
|
+
consoleError(` ${time}${skipped}${hasErrors}`);
|
|
76
79
|
}
|
|
77
80
|
function reportTime(elapsedTimeMs, cached) {
|
|
78
81
|
if (cached)
|
|
@@ -133,7 +136,7 @@ export function getReporter(options, config) {
|
|
|
133
136
|
}
|
|
134
137
|
const errorText = format(chalk.red(message), error.toString());
|
|
135
138
|
errorCollection?.push(errorText);
|
|
136
|
-
|
|
139
|
+
consoleError(errorText);
|
|
137
140
|
}
|
|
138
141
|
const resultEmitter = (result) => {
|
|
139
142
|
if (!fileGlobs.length && !result.files) {
|
|
@@ -142,30 +145,30 @@ export function getReporter(options, config) {
|
|
|
142
145
|
const { files, issues, cachedFiles, filesWithIssues, errors } = result;
|
|
143
146
|
const numFilesWithIssues = filesWithIssues.size;
|
|
144
147
|
if (issuesCollection?.length || errorCollection?.length) {
|
|
145
|
-
|
|
148
|
+
consoleError('-------------------------------------------');
|
|
146
149
|
}
|
|
147
150
|
if (issuesCollection?.length) {
|
|
148
|
-
|
|
149
|
-
issuesCollection.forEach((issue) =>
|
|
151
|
+
consoleError('Issues found:');
|
|
152
|
+
issuesCollection.forEach((issue) => consoleError(issue));
|
|
150
153
|
}
|
|
151
154
|
const cachedFilesText = cachedFiles ? ` (${cachedFiles} from cache)` : '';
|
|
152
155
|
const withErrorsText = errors ? ` with ${errors} error${errors === 1 ? '' : 's'}` : '';
|
|
153
156
|
const numFilesWidthIssuesText = numFilesWithIssues === 1 ? '1 file' : `${numFilesWithIssues} files`;
|
|
154
157
|
const summaryMessage = `CSpell\u003A Files checked: ${files}${cachedFilesText}, Issues found: ${issues} in ${numFilesWidthIssuesText}${withErrorsText}.`;
|
|
155
|
-
|
|
158
|
+
consoleError(summaryMessage);
|
|
156
159
|
if (errorCollection?.length && issues > 5) {
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
errorCollection.forEach((error) =>
|
|
160
|
+
consoleError('-------------------------------------------');
|
|
161
|
+
consoleError('Errors:');
|
|
162
|
+
errorCollection.forEach((error) => consoleError(error));
|
|
160
163
|
}
|
|
161
164
|
if (options.showPerfSummary) {
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
165
|
+
consoleError('-------------------------------------------');
|
|
166
|
+
consoleError('Performance Summary:');
|
|
167
|
+
consoleError(` Files Processed: ${perfStats.filesProcessed.toString().padStart(6)}`);
|
|
168
|
+
consoleError(` Files Skipped : ${perfStats.filesSkipped.toString().padStart(6)}`);
|
|
169
|
+
consoleError(` Files Cached : ${perfStats.filesCached.toString().padStart(6)}`);
|
|
170
|
+
consoleError(` Processing Time: ${perfStats.elapsedTimeMs.toFixed(2).padStart(9)}ms`);
|
|
171
|
+
consoleError('Stats:');
|
|
169
172
|
const stats = Object.entries(perfStats.perf)
|
|
170
173
|
.filter((p) => !!p[1])
|
|
171
174
|
.map(([key, value]) => [key, value.toFixed(2)]);
|
|
@@ -173,7 +176,7 @@ export function getReporter(options, config) {
|
|
|
173
176
|
const padValue = Math.max(...stats.map((s) => s[1].length));
|
|
174
177
|
stats.sort((a, b) => a[0].localeCompare(b[0]));
|
|
175
178
|
for (const [key, value] of stats) {
|
|
176
|
-
value &&
|
|
179
|
+
value && consoleError(` ${key.padEnd(padName)}: ${value.padStart(padValue)}ms`);
|
|
177
180
|
}
|
|
178
181
|
}
|
|
179
182
|
};
|
|
@@ -12,6 +12,9 @@ const templateIssueWithContext = `{green $filename}:{yellow $row:$col} $padRowCo
|
|
|
12
12
|
const templateIssueWithContextWithSuggestions = `{green $filename}:{yellow $row:$col} $padRowCol- $message ({red $text})$padContext -- {gray $contextLeft}{red {underline $text}}{gray $contextRight}\n\t Suggestions: {yellow [$suggestions]}`;
|
|
13
13
|
const templateIssueLegacy = `${chalk.green('$filename')}[$row, $col]: $message: ${chalk.red('$text')}`;
|
|
14
14
|
const templateIssueWordsOnly = '$text';
|
|
15
|
+
function consoleError(...params) {
|
|
16
|
+
console.error(chalk.white('%s'), format(...params));
|
|
17
|
+
}
|
|
15
18
|
/**
|
|
16
19
|
*
|
|
17
20
|
* @param template - The template to use for the issue.
|
|
@@ -72,7 +75,7 @@ function reportProgressFileComplete(p) {
|
|
|
72
75
|
const time = reportTime(p.elapsedTimeMs, !!p.cached);
|
|
73
76
|
const skipped = p.processed === false ? ' skipped' : '';
|
|
74
77
|
const hasErrors = p.numErrors ? chalk.red ` X` : '';
|
|
75
|
-
|
|
78
|
+
consoleError(` ${time}${skipped}${hasErrors}`);
|
|
76
79
|
}
|
|
77
80
|
function reportTime(elapsedTimeMs, cached) {
|
|
78
81
|
if (cached)
|
|
@@ -133,7 +136,7 @@ export function getReporter(options, config) {
|
|
|
133
136
|
}
|
|
134
137
|
const errorText = format(chalk.red(message), error.toString());
|
|
135
138
|
errorCollection?.push(errorText);
|
|
136
|
-
|
|
139
|
+
consoleError(errorText);
|
|
137
140
|
}
|
|
138
141
|
const resultEmitter = (result) => {
|
|
139
142
|
if (!fileGlobs.length && !result.files) {
|
|
@@ -142,30 +145,30 @@ export function getReporter(options, config) {
|
|
|
142
145
|
const { files, issues, cachedFiles, filesWithIssues, errors } = result;
|
|
143
146
|
const numFilesWithIssues = filesWithIssues.size;
|
|
144
147
|
if (issuesCollection?.length || errorCollection?.length) {
|
|
145
|
-
|
|
148
|
+
consoleError('-------------------------------------------');
|
|
146
149
|
}
|
|
147
150
|
if (issuesCollection?.length) {
|
|
148
|
-
|
|
149
|
-
issuesCollection.forEach((issue) =>
|
|
151
|
+
consoleError('Issues found:');
|
|
152
|
+
issuesCollection.forEach((issue) => consoleError(issue));
|
|
150
153
|
}
|
|
151
154
|
const cachedFilesText = cachedFiles ? ` (${cachedFiles} from cache)` : '';
|
|
152
155
|
const withErrorsText = errors ? ` with ${errors} error${errors === 1 ? '' : 's'}` : '';
|
|
153
156
|
const numFilesWidthIssuesText = numFilesWithIssues === 1 ? '1 file' : `${numFilesWithIssues} files`;
|
|
154
157
|
const summaryMessage = `CSpell\u003A Files checked: ${files}${cachedFilesText}, Issues found: ${issues} in ${numFilesWidthIssuesText}${withErrorsText}.`;
|
|
155
|
-
|
|
158
|
+
consoleError(summaryMessage);
|
|
156
159
|
if (errorCollection?.length && issues > 5) {
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
errorCollection.forEach((error) =>
|
|
160
|
+
consoleError('-------------------------------------------');
|
|
161
|
+
consoleError('Errors:');
|
|
162
|
+
errorCollection.forEach((error) => consoleError(error));
|
|
160
163
|
}
|
|
161
164
|
if (options.showPerfSummary) {
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
165
|
+
consoleError('-------------------------------------------');
|
|
166
|
+
consoleError('Performance Summary:');
|
|
167
|
+
consoleError(` Files Processed: ${perfStats.filesProcessed.toString().padStart(6)}`);
|
|
168
|
+
consoleError(` Files Skipped : ${perfStats.filesSkipped.toString().padStart(6)}`);
|
|
169
|
+
consoleError(` Files Cached : ${perfStats.filesCached.toString().padStart(6)}`);
|
|
170
|
+
consoleError(` Processing Time: ${perfStats.elapsedTimeMs.toFixed(2).padStart(9)}ms`);
|
|
171
|
+
consoleError('Stats:');
|
|
169
172
|
const stats = Object.entries(perfStats.perf)
|
|
170
173
|
.filter((p) => !!p[1])
|
|
171
174
|
.map(([key, value]) => [key, value.toFixed(2)]);
|
|
@@ -173,7 +176,7 @@ export function getReporter(options, config) {
|
|
|
173
176
|
const padValue = Math.max(...stats.map((s) => s[1].length));
|
|
174
177
|
stats.sort((a, b) => a[0].localeCompare(b[0]));
|
|
175
178
|
for (const [key, value] of stats) {
|
|
176
|
-
value &&
|
|
179
|
+
value && consoleError(` ${key.padEnd(padName)}: ${value.padStart(padValue)}ms`);
|
|
177
180
|
}
|
|
178
181
|
}
|
|
179
182
|
};
|
package/dist/esm/commandTrace.js
CHANGED
|
@@ -66,7 +66,11 @@ function filterTraceResults(results, options) {
|
|
|
66
66
|
return results.filter((r) => filterTraceResult(r, options.onlyFound));
|
|
67
67
|
}
|
|
68
68
|
function filterTraceResult(result, onlyFound) {
|
|
69
|
-
return result.found ||
|
|
69
|
+
return (result.found ||
|
|
70
|
+
result.forbidden ||
|
|
71
|
+
result.noSuggest ||
|
|
72
|
+
!!result.preferredSuggestions ||
|
|
73
|
+
(!onlyFound && result.dictActive));
|
|
70
74
|
}
|
|
71
75
|
function groupBy(items, key) {
|
|
72
76
|
const map = new Map();
|
|
@@ -66,7 +66,11 @@ function filterTraceResults(results, options) {
|
|
|
66
66
|
return results.filter((r) => filterTraceResult(r, options.onlyFound));
|
|
67
67
|
}
|
|
68
68
|
function filterTraceResult(result, onlyFound) {
|
|
69
|
-
return result.found ||
|
|
69
|
+
return (result.found ||
|
|
70
|
+
result.forbidden ||
|
|
71
|
+
result.noSuggest ||
|
|
72
|
+
!!result.preferredSuggestions ||
|
|
73
|
+
(!onlyFound && result.dictActive));
|
|
70
74
|
}
|
|
71
75
|
function groupBy(items, key) {
|
|
72
76
|
const map = new Map();
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import chalk from 'chalk';
|
|
2
|
-
import { padLeft, padWidth, width } from '../util/
|
|
2
|
+
import { padLeft, padWidth, width } from '../util/pad.js';
|
|
3
3
|
// eslint-disable-next-line no-misleading-character-class
|
|
4
4
|
const regExpRTL = /([ \u0591-\u07FF\uFB1D-\uFDFD\uFE70-\uFEFC]+)/g;
|
|
5
5
|
function reverseRtlText(s) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import chalk from 'chalk';
|
|
2
|
-
import { padLeft, padWidth, width } from '../util/
|
|
2
|
+
import { padLeft, padWidth, width } from '../util/pad.mjs';
|
|
3
3
|
// eslint-disable-next-line no-misleading-character-class
|
|
4
4
|
const regExpRTL = /([ \u0591-\u07FF\uFB1D-\uFDFD\uFE70-\uFEFC]+)/g;
|
|
5
5
|
function reverseRtlText(s) {
|
|
@@ -15,6 +15,10 @@ export interface EmitTraceOptions {
|
|
|
15
15
|
showWordFound?: boolean;
|
|
16
16
|
}
|
|
17
17
|
export declare function emitTraceResults(word: string, found: boolean, results: TraceResult[], options: EmitTraceOptions): void;
|
|
18
|
+
export declare function calcTraceResultsReport(word: string, found: boolean, results: TraceResult[], options: EmitTraceOptions): {
|
|
19
|
+
table: string;
|
|
20
|
+
errors: string;
|
|
21
|
+
};
|
|
18
22
|
declare function trimMidPath(s: string, w: number, sep: string): string;
|
|
19
23
|
export declare const __testing__: {
|
|
20
24
|
trimMidPath: typeof trimMidPath;
|
|
@@ -15,6 +15,10 @@ export interface EmitTraceOptions {
|
|
|
15
15
|
showWordFound?: boolean;
|
|
16
16
|
}
|
|
17
17
|
export declare function emitTraceResults(word: string, found: boolean, results: TraceResult[], options: EmitTraceOptions): void;
|
|
18
|
+
export declare function calcTraceResultsReport(word: string, found: boolean, results: TraceResult[], options: EmitTraceOptions): {
|
|
19
|
+
table: string;
|
|
20
|
+
errors: string;
|
|
21
|
+
};
|
|
18
22
|
declare function trimMidPath(s: string, w: number, sep: string): string;
|
|
19
23
|
export declare const __testing__: {
|
|
20
24
|
trimMidPath: typeof trimMidPath;
|
|
@@ -1,57 +1,63 @@
|
|
|
1
1
|
import * as iPath from 'node:path';
|
|
2
2
|
import chalk from 'chalk';
|
|
3
|
-
import
|
|
4
|
-
|
|
3
|
+
import { tableToLines } from '../util/table.js';
|
|
4
|
+
const maxWidth = 120;
|
|
5
5
|
const colWidthDictionaryName = 20;
|
|
6
6
|
export function emitTraceResults(word, found, results, options) {
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
.
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
dictName: maxDictNameLength,
|
|
16
|
-
terminalWidth: options.lineWidth ?? (process.stdout.columns || 120),
|
|
17
|
-
location: options.dictionaryPathFormat === 'hide' ? 0 : 30,
|
|
18
|
-
};
|
|
7
|
+
const report = calcTraceResultsReport(word, found, results, options);
|
|
8
|
+
console.log(report.table);
|
|
9
|
+
if (report.errors) {
|
|
10
|
+
console.error('Errors:');
|
|
11
|
+
console.error(report.errors);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
export function calcTraceResultsReport(word, found, results, options) {
|
|
19
15
|
const col = new Intl.Collator();
|
|
20
16
|
results.sort((a, b) => col.compare(a.dictName, b.dictName));
|
|
21
17
|
options.showWordFound && console.log(`${options.prefix || ''}${word}: ${found ? 'Found' : 'Not Found'}`);
|
|
22
|
-
emitHeader(
|
|
23
|
-
results.
|
|
18
|
+
const header = emitHeader(options.dictionaryPathFormat !== 'hide');
|
|
19
|
+
const rows = results.map((r) => emitTraceResult(r, options));
|
|
20
|
+
const t = tableToLines({
|
|
21
|
+
header,
|
|
22
|
+
rows,
|
|
23
|
+
terminalWidth: options.lineWidth || process.stdout.columns || maxWidth,
|
|
24
|
+
deliminator: ' ',
|
|
25
|
+
});
|
|
26
|
+
return {
|
|
27
|
+
table: t.map((line) => line.trimEnd()).join('\n'),
|
|
28
|
+
errors: emitErrors(results).join('\n'),
|
|
29
|
+
};
|
|
24
30
|
}
|
|
25
|
-
function emitHeader(
|
|
26
|
-
const
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
pad('Dictionary', colWidths.dictName),
|
|
30
|
-
colWidths.location ? pad('Dictionary Location', colWidths.location) : '',
|
|
31
|
-
];
|
|
32
|
-
console.log(chalk.underline(line.join(' ').trim().slice(0, colWidths.terminalWidth)));
|
|
31
|
+
function emitHeader(location) {
|
|
32
|
+
const headers = ['Word', 'F', 'Dictionary'];
|
|
33
|
+
location && headers.push('Dictionary Location');
|
|
34
|
+
return headers;
|
|
33
35
|
}
|
|
34
|
-
function emitTraceResult(r,
|
|
35
|
-
const
|
|
36
|
-
const
|
|
37
|
-
const word = pad(r.foundWord || r.word, wordColWidth);
|
|
36
|
+
function emitTraceResult(r, options) {
|
|
37
|
+
const errors = !!r.errors?.length;
|
|
38
|
+
const word = r.foundWord || r.word;
|
|
38
39
|
const cWord = word.replaceAll('+', chalk.yellow('+'));
|
|
39
|
-
const
|
|
40
|
+
const sug = r.preferredSuggestions?.map((s) => chalk.yellowBright(s)).join(', ') || '';
|
|
41
|
+
const w = (r.forbidden ? chalk.red(cWord) : chalk.green(cWord)) + (sug ? `->(${sug})` : '');
|
|
40
42
|
const f = calcFoundChar(r);
|
|
41
43
|
const a = r.dictActive ? '*' : ' ';
|
|
42
|
-
const dictName =
|
|
44
|
+
const dictName = r.dictName.slice(0, colWidthDictionaryName - 1) + a;
|
|
43
45
|
const dictColor = r.dictActive ? chalk.yellowBright : chalk.rgb(200, 128, 50);
|
|
44
46
|
const n = dictColor(dictName);
|
|
45
|
-
const info = [w, f, n].join(' ') + ' ';
|
|
46
|
-
const used = width(strip(info));
|
|
47
|
-
const widthSrc = terminalWidth - used;
|
|
48
47
|
const c = colorize(errors ? chalk.red : chalk.white);
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
48
|
+
return [
|
|
49
|
+
w,
|
|
50
|
+
f,
|
|
51
|
+
n,
|
|
52
|
+
(widthSrc) => c(formatDictionaryLocation(r.dictSource, widthSrc ?? maxWidth, { iPath, ...options })),
|
|
53
|
+
];
|
|
54
|
+
}
|
|
55
|
+
function emitErrors(results) {
|
|
56
|
+
const errorResults = results.filter((r) => r.errors?.length);
|
|
57
|
+
return errorResults.map((r) => {
|
|
58
|
+
const errors = r.errors?.map((e) => e.message)?.join('\n\t') || '';
|
|
59
|
+
return chalk.bold(r.dictName) + '\n\t' + chalk.red(errors);
|
|
60
|
+
});
|
|
55
61
|
}
|
|
56
62
|
function trimMid(s, w) {
|
|
57
63
|
s = s.trim();
|
|
@@ -1,57 +1,63 @@
|
|
|
1
1
|
import * as iPath from 'node:path';
|
|
2
2
|
import chalk from 'chalk';
|
|
3
|
-
import
|
|
4
|
-
|
|
3
|
+
import { tableToLines } from '../util/table.mjs';
|
|
4
|
+
const maxWidth = 120;
|
|
5
5
|
const colWidthDictionaryName = 20;
|
|
6
6
|
export function emitTraceResults(word, found, results, options) {
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
.
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
dictName: maxDictNameLength,
|
|
16
|
-
terminalWidth: options.lineWidth ?? (process.stdout.columns || 120),
|
|
17
|
-
location: options.dictionaryPathFormat === 'hide' ? 0 : 30,
|
|
18
|
-
};
|
|
7
|
+
const report = calcTraceResultsReport(word, found, results, options);
|
|
8
|
+
console.log(report.table);
|
|
9
|
+
if (report.errors) {
|
|
10
|
+
console.error('Errors:');
|
|
11
|
+
console.error(report.errors);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
export function calcTraceResultsReport(word, found, results, options) {
|
|
19
15
|
const col = new Intl.Collator();
|
|
20
16
|
results.sort((a, b) => col.compare(a.dictName, b.dictName));
|
|
21
17
|
options.showWordFound && console.log(`${options.prefix || ''}${word}: ${found ? 'Found' : 'Not Found'}`);
|
|
22
|
-
emitHeader(
|
|
23
|
-
results.
|
|
18
|
+
const header = emitHeader(options.dictionaryPathFormat !== 'hide');
|
|
19
|
+
const rows = results.map((r) => emitTraceResult(r, options));
|
|
20
|
+
const t = tableToLines({
|
|
21
|
+
header,
|
|
22
|
+
rows,
|
|
23
|
+
terminalWidth: options.lineWidth || process.stdout.columns || maxWidth,
|
|
24
|
+
deliminator: ' ',
|
|
25
|
+
});
|
|
26
|
+
return {
|
|
27
|
+
table: t.map((line) => line.trimEnd()).join('\n'),
|
|
28
|
+
errors: emitErrors(results).join('\n'),
|
|
29
|
+
};
|
|
24
30
|
}
|
|
25
|
-
function emitHeader(
|
|
26
|
-
const
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
pad('Dictionary', colWidths.dictName),
|
|
30
|
-
colWidths.location ? pad('Dictionary Location', colWidths.location) : '',
|
|
31
|
-
];
|
|
32
|
-
console.log(chalk.underline(line.join(' ').trim().slice(0, colWidths.terminalWidth)));
|
|
31
|
+
function emitHeader(location) {
|
|
32
|
+
const headers = ['Word', 'F', 'Dictionary'];
|
|
33
|
+
location && headers.push('Dictionary Location');
|
|
34
|
+
return headers;
|
|
33
35
|
}
|
|
34
|
-
function emitTraceResult(r,
|
|
35
|
-
const
|
|
36
|
-
const
|
|
37
|
-
const word = pad(r.foundWord || r.word, wordColWidth);
|
|
36
|
+
function emitTraceResult(r, options) {
|
|
37
|
+
const errors = !!r.errors?.length;
|
|
38
|
+
const word = r.foundWord || r.word;
|
|
38
39
|
const cWord = word.replaceAll('+', chalk.yellow('+'));
|
|
39
|
-
const
|
|
40
|
+
const sug = r.preferredSuggestions?.map((s) => chalk.yellowBright(s)).join(', ') || '';
|
|
41
|
+
const w = (r.forbidden ? chalk.red(cWord) : chalk.green(cWord)) + (sug ? `->(${sug})` : '');
|
|
40
42
|
const f = calcFoundChar(r);
|
|
41
43
|
const a = r.dictActive ? '*' : ' ';
|
|
42
|
-
const dictName =
|
|
44
|
+
const dictName = r.dictName.slice(0, colWidthDictionaryName - 1) + a;
|
|
43
45
|
const dictColor = r.dictActive ? chalk.yellowBright : chalk.rgb(200, 128, 50);
|
|
44
46
|
const n = dictColor(dictName);
|
|
45
|
-
const info = [w, f, n].join(' ') + ' ';
|
|
46
|
-
const used = width(strip(info));
|
|
47
|
-
const widthSrc = terminalWidth - used;
|
|
48
47
|
const c = colorize(errors ? chalk.red : chalk.white);
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
48
|
+
return [
|
|
49
|
+
w,
|
|
50
|
+
f,
|
|
51
|
+
n,
|
|
52
|
+
(widthSrc) => c(formatDictionaryLocation(r.dictSource, widthSrc ?? maxWidth, { iPath, ...options })),
|
|
53
|
+
];
|
|
54
|
+
}
|
|
55
|
+
function emitErrors(results) {
|
|
56
|
+
const errorResults = results.filter((r) => r.errors?.length);
|
|
57
|
+
return errorResults.map((r) => {
|
|
58
|
+
const errors = r.errors?.map((e) => e.message)?.join('\n\t') || '';
|
|
59
|
+
return chalk.bold(r.dictName) + '\n\t' + chalk.red(errors);
|
|
60
|
+
});
|
|
55
61
|
}
|
|
56
62
|
function trimMid(s, w) {
|
|
57
63
|
s = s.trim();
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export declare function pad(s: string, w: number): string;
|
|
2
|
+
export declare function padWidth(s: string, target: number): number;
|
|
3
|
+
export declare function padLeft(s: string, w: number): string;
|
|
4
|
+
export declare function width(s: string): number;
|
|
5
|
+
export declare function ansiWidth(s: string): number;
|
|
6
|
+
//# sourceMappingURL=pad.d.mts.map
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export declare function pad(s: string, w: number): string;
|
|
2
|
+
export declare function padWidth(s: string, target: number): number;
|
|
3
|
+
export declare function padLeft(s: string, w: number): string;
|
|
4
|
+
export declare function width(s: string): number;
|
|
5
|
+
export declare function ansiWidth(s: string): number;
|
|
6
|
+
//# sourceMappingURL=pad.d.ts.map
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import strip from 'strip-ansi';
|
|
2
|
+
export function pad(s, w) {
|
|
3
|
+
const p = padWidth(s, w);
|
|
4
|
+
if (!p)
|
|
5
|
+
return s;
|
|
6
|
+
return s.padEnd(p + s.length);
|
|
7
|
+
}
|
|
8
|
+
export function padWidth(s, target) {
|
|
9
|
+
const sWidth = ansiWidth(s);
|
|
10
|
+
return Math.max(target - sWidth, 0);
|
|
11
|
+
}
|
|
12
|
+
export function padLeft(s, w) {
|
|
13
|
+
const p = padWidth(s, w);
|
|
14
|
+
if (!p)
|
|
15
|
+
return s;
|
|
16
|
+
return s.padStart(p + s.length);
|
|
17
|
+
}
|
|
18
|
+
export function width(s) {
|
|
19
|
+
// Remove control codes and high surrogates to get the approximate width.
|
|
20
|
+
return (s
|
|
21
|
+
// eslint-disable-next-line no-control-regex, no-misleading-character-class
|
|
22
|
+
.replaceAll(/[\u0000-\u001F\u0300-\u036F]/g, '')
|
|
23
|
+
.replaceAll(/[\uD800-\uDBFF][\uDC00-\uDFFF]/g, '.').length);
|
|
24
|
+
}
|
|
25
|
+
export function ansiWidth(s) {
|
|
26
|
+
return width(strip(s));
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=pad.js.map
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import strip from 'strip-ansi';
|
|
2
|
+
export function pad(s, w) {
|
|
3
|
+
const p = padWidth(s, w);
|
|
4
|
+
if (!p)
|
|
5
|
+
return s;
|
|
6
|
+
return s.padEnd(p + s.length);
|
|
7
|
+
}
|
|
8
|
+
export function padWidth(s, target) {
|
|
9
|
+
const sWidth = ansiWidth(s);
|
|
10
|
+
return Math.max(target - sWidth, 0);
|
|
11
|
+
}
|
|
12
|
+
export function padLeft(s, w) {
|
|
13
|
+
const p = padWidth(s, w);
|
|
14
|
+
if (!p)
|
|
15
|
+
return s;
|
|
16
|
+
return s.padStart(p + s.length);
|
|
17
|
+
}
|
|
18
|
+
export function width(s) {
|
|
19
|
+
// Remove control codes and high surrogates to get the approximate width.
|
|
20
|
+
return (s
|
|
21
|
+
// eslint-disable-next-line no-control-regex, no-misleading-character-class
|
|
22
|
+
.replaceAll(/[\u0000-\u001F\u0300-\u036F]/g, '')
|
|
23
|
+
.replaceAll(/[\uD800-\uDBFF][\uDC00-\uDFFF]/g, '.').length);
|
|
24
|
+
}
|
|
25
|
+
export function ansiWidth(s) {
|
|
26
|
+
return width(strip(s));
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=pad.mjs.map
|
|
@@ -1,6 +1,10 @@
|
|
|
1
|
+
export type RowTextFn = (maxWidth: number | undefined) => string;
|
|
2
|
+
export type TableCell = string | RowTextFn;
|
|
3
|
+
export type TableRow = TableCell[];
|
|
1
4
|
export interface Table {
|
|
2
5
|
header: string[];
|
|
3
|
-
rows:
|
|
6
|
+
rows: TableRow[];
|
|
7
|
+
terminalWidth?: number;
|
|
4
8
|
deliminator?: string;
|
|
5
9
|
}
|
|
6
10
|
export declare function tableToLines(table: Table, deliminator?: string): string[];
|
package/dist/esm/util/table.d.ts
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
|
+
export type RowTextFn = (maxWidth: number | undefined) => string;
|
|
2
|
+
export type TableCell = string | RowTextFn;
|
|
3
|
+
export type TableRow = TableCell[];
|
|
1
4
|
export interface Table {
|
|
2
5
|
header: string[];
|
|
3
|
-
rows:
|
|
6
|
+
rows: TableRow[];
|
|
7
|
+
terminalWidth?: number;
|
|
4
8
|
deliminator?: string;
|
|
5
9
|
}
|
|
6
10
|
export declare function tableToLines(table: Table, deliminator?: string): string[];
|
package/dist/esm/util/table.js
CHANGED
|
@@ -1,26 +1,49 @@
|
|
|
1
1
|
import chalk from 'chalk';
|
|
2
|
-
import
|
|
2
|
+
import { ansiWidth, pad } from './pad.js';
|
|
3
3
|
export function tableToLines(table, deliminator) {
|
|
4
|
-
|
|
4
|
+
const del = deliminator || table.deliminator || ' | ';
|
|
5
5
|
const columnWidths = [];
|
|
6
6
|
const { header, rows } = table;
|
|
7
|
-
function
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
function getText(col, maxWidth) {
|
|
8
|
+
return typeof col === 'string' ? col : col(maxWidth);
|
|
9
|
+
}
|
|
10
|
+
function getRCText(row, col, maxWidth) {
|
|
11
|
+
return getText(rows[row][col], maxWidth);
|
|
12
|
+
}
|
|
13
|
+
function recordHeaderWidths(header) {
|
|
14
|
+
header.forEach((col, idx) => {
|
|
15
|
+
columnWidths[idx] = Math.max(ansiWidth(col), columnWidths[idx] || 0);
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
function recordColWidths(row, rowIndex) {
|
|
19
|
+
row.forEach((_col, idx) => {
|
|
20
|
+
columnWidths[idx] = Math.max(ansiWidth(getRCText(rowIndex, idx, undefined)), columnWidths[idx] || 0);
|
|
10
21
|
});
|
|
11
22
|
}
|
|
12
23
|
function justifyRow(c, i) {
|
|
13
|
-
return c
|
|
24
|
+
return pad(c, columnWidths[i]);
|
|
14
25
|
}
|
|
15
26
|
function toLine(row) {
|
|
16
|
-
return decorateRowWith(row, justifyRow).join(
|
|
27
|
+
return decorateRowWith(row.map((c, i) => getText(c, columnWidths[i])), justifyRow).join(del);
|
|
17
28
|
}
|
|
18
29
|
function* process() {
|
|
19
30
|
yield toLine(decorateRowWith(header, headerDecorator));
|
|
20
31
|
yield* rows.map(toLine);
|
|
21
32
|
}
|
|
22
|
-
|
|
23
|
-
|
|
33
|
+
function adjustColWidths() {
|
|
34
|
+
if (!table.terminalWidth)
|
|
35
|
+
return;
|
|
36
|
+
const dWidth = (columnWidths.length - 1) * ansiWidth(del);
|
|
37
|
+
let remainder = table.terminalWidth - dWidth;
|
|
38
|
+
for (let i = 0; i < columnWidths.length; i++) {
|
|
39
|
+
const colWidth = Math.min(columnWidths[i], remainder);
|
|
40
|
+
columnWidths[i] = colWidth;
|
|
41
|
+
remainder -= colWidth;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
recordHeaderWidths(header);
|
|
45
|
+
rows.forEach(recordColWidths);
|
|
46
|
+
adjustColWidths();
|
|
24
47
|
return [...process()];
|
|
25
48
|
}
|
|
26
49
|
function headerDecorator(t) {
|
package/dist/esm/util/table.mjs
CHANGED
|
@@ -1,26 +1,49 @@
|
|
|
1
1
|
import chalk from 'chalk';
|
|
2
|
-
import
|
|
2
|
+
import { ansiWidth, pad } from './pad.mjs';
|
|
3
3
|
export function tableToLines(table, deliminator) {
|
|
4
|
-
|
|
4
|
+
const del = deliminator || table.deliminator || ' | ';
|
|
5
5
|
const columnWidths = [];
|
|
6
6
|
const { header, rows } = table;
|
|
7
|
-
function
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
function getText(col, maxWidth) {
|
|
8
|
+
return typeof col === 'string' ? col : col(maxWidth);
|
|
9
|
+
}
|
|
10
|
+
function getRCText(row, col, maxWidth) {
|
|
11
|
+
return getText(rows[row][col], maxWidth);
|
|
12
|
+
}
|
|
13
|
+
function recordHeaderWidths(header) {
|
|
14
|
+
header.forEach((col, idx) => {
|
|
15
|
+
columnWidths[idx] = Math.max(ansiWidth(col), columnWidths[idx] || 0);
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
function recordColWidths(row, rowIndex) {
|
|
19
|
+
row.forEach((_col, idx) => {
|
|
20
|
+
columnWidths[idx] = Math.max(ansiWidth(getRCText(rowIndex, idx, undefined)), columnWidths[idx] || 0);
|
|
10
21
|
});
|
|
11
22
|
}
|
|
12
23
|
function justifyRow(c, i) {
|
|
13
|
-
return c
|
|
24
|
+
return pad(c, columnWidths[i]);
|
|
14
25
|
}
|
|
15
26
|
function toLine(row) {
|
|
16
|
-
return decorateRowWith(row, justifyRow).join(
|
|
27
|
+
return decorateRowWith(row.map((c, i) => getText(c, columnWidths[i])), justifyRow).join(del);
|
|
17
28
|
}
|
|
18
29
|
function* process() {
|
|
19
30
|
yield toLine(decorateRowWith(header, headerDecorator));
|
|
20
31
|
yield* rows.map(toLine);
|
|
21
32
|
}
|
|
22
|
-
|
|
23
|
-
|
|
33
|
+
function adjustColWidths() {
|
|
34
|
+
if (!table.terminalWidth)
|
|
35
|
+
return;
|
|
36
|
+
const dWidth = (columnWidths.length - 1) * ansiWidth(del);
|
|
37
|
+
let remainder = table.terminalWidth - dWidth;
|
|
38
|
+
for (let i = 0; i < columnWidths.length; i++) {
|
|
39
|
+
const colWidth = Math.min(columnWidths[i], remainder);
|
|
40
|
+
columnWidths[i] = colWidth;
|
|
41
|
+
remainder -= colWidth;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
recordHeaderWidths(header);
|
|
45
|
+
rows.forEach(recordColWidths);
|
|
46
|
+
adjustColWidths();
|
|
24
47
|
return [...process()];
|
|
25
48
|
}
|
|
26
49
|
function headerDecorator(t) {
|
package/dist/esm/util/util.d.mts
CHANGED
|
@@ -5,9 +5,5 @@ export declare function uniqueFilterFnGenerator<T>(): FilterFn<T>;
|
|
|
5
5
|
export declare function uniqueFilterFnGenerator<T, U>(extractFn: (v: T) => U): FilterFn<T>;
|
|
6
6
|
export declare function unique<T>(src: T[]): T[];
|
|
7
7
|
export declare function clean<T extends object>(src: T): RemoveUndefined<T>;
|
|
8
|
-
export declare function padWidth(s: string, target: number): number;
|
|
9
|
-
export declare function pad(s: string, w: number): string;
|
|
10
|
-
export declare function padLeft(s: string, w: number): string;
|
|
11
|
-
export declare function width(s: string): number;
|
|
12
8
|
export {};
|
|
13
9
|
//# sourceMappingURL=util.d.mts.map
|
package/dist/esm/util/util.d.ts
CHANGED
|
@@ -5,9 +5,5 @@ export declare function uniqueFilterFnGenerator<T>(): FilterFn<T>;
|
|
|
5
5
|
export declare function uniqueFilterFnGenerator<T, U>(extractFn: (v: T) => U): FilterFn<T>;
|
|
6
6
|
export declare function unique<T>(src: T[]): T[];
|
|
7
7
|
export declare function clean<T extends object>(src: T): RemoveUndefined<T>;
|
|
8
|
-
export declare function padWidth(s: string, target: number): number;
|
|
9
|
-
export declare function pad(s: string, w: number): string;
|
|
10
|
-
export declare function padLeft(s: string, w: number): string;
|
|
11
|
-
export declare function width(s: string): number;
|
|
12
8
|
export {};
|
|
13
9
|
//# sourceMappingURL=util.d.ts.map
|
package/dist/esm/util/util.js
CHANGED
|
@@ -22,24 +22,4 @@ export function clean(src) {
|
|
|
22
22
|
}
|
|
23
23
|
return r;
|
|
24
24
|
}
|
|
25
|
-
export function padWidth(s, target) {
|
|
26
|
-
const sWidth = width(s);
|
|
27
|
-
return Math.max(target - sWidth, 0);
|
|
28
|
-
}
|
|
29
|
-
export function pad(s, w) {
|
|
30
|
-
const p = padWidth(s, w);
|
|
31
|
-
if (!p)
|
|
32
|
-
return s;
|
|
33
|
-
return s + ' '.repeat(p);
|
|
34
|
-
}
|
|
35
|
-
export function padLeft(s, w) {
|
|
36
|
-
const p = padWidth(s, w);
|
|
37
|
-
if (!p)
|
|
38
|
-
return s;
|
|
39
|
-
return ' '.repeat(p) + s;
|
|
40
|
-
}
|
|
41
|
-
export function width(s) {
|
|
42
|
-
// eslint-disable-next-line no-control-regex, no-misleading-character-class
|
|
43
|
-
return s.replaceAll(/[\u0000-\u001F\u0300-\u036F]/g, '').length;
|
|
44
|
-
}
|
|
45
25
|
//# sourceMappingURL=util.js.map
|
package/dist/esm/util/util.mjs
CHANGED
|
@@ -22,24 +22,4 @@ export function clean(src) {
|
|
|
22
22
|
}
|
|
23
23
|
return r;
|
|
24
24
|
}
|
|
25
|
-
export function padWidth(s, target) {
|
|
26
|
-
const sWidth = width(s);
|
|
27
|
-
return Math.max(target - sWidth, 0);
|
|
28
|
-
}
|
|
29
|
-
export function pad(s, w) {
|
|
30
|
-
const p = padWidth(s, w);
|
|
31
|
-
if (!p)
|
|
32
|
-
return s;
|
|
33
|
-
return s + ' '.repeat(p);
|
|
34
|
-
}
|
|
35
|
-
export function padLeft(s, w) {
|
|
36
|
-
const p = padWidth(s, w);
|
|
37
|
-
if (!p)
|
|
38
|
-
return s;
|
|
39
|
-
return ' '.repeat(p) + s;
|
|
40
|
-
}
|
|
41
|
-
export function width(s) {
|
|
42
|
-
// eslint-disable-next-line no-control-regex, no-misleading-character-class
|
|
43
|
-
return s.replaceAll(/[\u0000-\u001F\u0300-\u036F]/g, '').length;
|
|
44
|
-
}
|
|
45
25
|
//# sourceMappingURL=util.mjs.map
|
|
@@ -23,11 +23,10 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.createFromFile =
|
|
26
|
+
exports.createFromFile = createFromFile;
|
|
27
27
|
/* This is to work around a bug in file-entry-cache that uses `this` */
|
|
28
28
|
const fileEntryCache = __importStar(require("file-entry-cache"));
|
|
29
29
|
function createFromFile(pathToCache, useChecksum) {
|
|
30
30
|
return fileEntryCache.createFromFile(pathToCache, useChecksum);
|
|
31
31
|
}
|
|
32
|
-
exports.createFromFile = createFromFile;
|
|
33
32
|
//# sourceMappingURL=file-entry-cache.cjs.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cspell",
|
|
3
|
-
"version": "8.
|
|
3
|
+
"version": "8.10.0",
|
|
4
4
|
"description": "A Spelling Checker for Code!",
|
|
5
5
|
"funding": "https://github.com/streetsidesoftware/cspell?sponsor=1",
|
|
6
6
|
"bin": {
|
|
@@ -82,17 +82,17 @@
|
|
|
82
82
|
},
|
|
83
83
|
"homepage": "https://streetsidesoftware.github.io/cspell/",
|
|
84
84
|
"dependencies": {
|
|
85
|
-
"@cspell/cspell-json-reporter": "8.
|
|
86
|
-
"@cspell/cspell-pipe": "8.
|
|
87
|
-
"@cspell/cspell-types": "8.
|
|
88
|
-
"@cspell/dynamic-import": "8.
|
|
85
|
+
"@cspell/cspell-json-reporter": "8.10.0",
|
|
86
|
+
"@cspell/cspell-pipe": "8.10.0",
|
|
87
|
+
"@cspell/cspell-types": "8.10.0",
|
|
88
|
+
"@cspell/dynamic-import": "8.10.0",
|
|
89
89
|
"chalk": "^5.3.0",
|
|
90
90
|
"chalk-template": "^1.1.0",
|
|
91
91
|
"commander": "^12.1.0",
|
|
92
|
-
"cspell-gitignore": "8.
|
|
93
|
-
"cspell-glob": "8.
|
|
94
|
-
"cspell-io": "8.
|
|
95
|
-
"cspell-lib": "8.
|
|
92
|
+
"cspell-gitignore": "8.10.0",
|
|
93
|
+
"cspell-glob": "8.10.0",
|
|
94
|
+
"cspell-io": "8.10.0",
|
|
95
|
+
"cspell-lib": "8.10.0",
|
|
96
96
|
"fast-glob": "^3.3.2",
|
|
97
97
|
"fast-json-stable-stringify": "^2.1.0",
|
|
98
98
|
"file-entry-cache": "^8.0.0",
|
|
@@ -107,10 +107,10 @@
|
|
|
107
107
|
"devDependencies": {
|
|
108
108
|
"@types/file-entry-cache": "^5.0.4",
|
|
109
109
|
"@types/glob": "^8.1.0",
|
|
110
|
-
"@types/micromatch": "^4.0.
|
|
110
|
+
"@types/micromatch": "^4.0.9",
|
|
111
111
|
"@types/semver": "^7.5.8",
|
|
112
112
|
"micromatch": "^4.0.7",
|
|
113
|
-
"minimatch": "^9.0.
|
|
113
|
+
"minimatch": "^9.0.5"
|
|
114
114
|
},
|
|
115
|
-
"gitHead": "
|
|
115
|
+
"gitHead": "a5dde6ae7e2ac86ac956220d4b8c39a0e58e1bc6"
|
|
116
116
|
}
|