cspell 7.0.0-alpha.1 → 7.0.1-alpha.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.
Files changed (91) hide show
  1. package/dist/esm/application.d.mts +1 -1
  2. package/dist/esm/cli-reporter.mjs +2 -1
  3. package/dist/esm/util/constants.d.mts +1 -1
  4. package/dist/esm/util/fileHelper.d.mts +1 -1
  5. package/dist/lib/file-entry-cache.cjs +3 -2
  6. package/dist/lib/file-entry-cache.d.cts +2 -2
  7. package/dist/lib/pkgInfo.cjs +3 -25
  8. package/package.json +31 -36
  9. package/bin.js +0 -16
  10. package/dist/cjs/app.d.ts +0 -5
  11. package/dist/cjs/app.js +0 -50
  12. package/dist/cjs/application.d.ts +0 -16
  13. package/dist/cjs/application.js +0 -121
  14. package/dist/cjs/cli-reporter.d.ts +0 -16
  15. package/dist/cjs/cli-reporter.js +0 -247
  16. package/dist/cjs/commandCheck.d.ts +0 -3
  17. package/dist/cjs/commandCheck.js +0 -78
  18. package/dist/cjs/commandLink.d.ts +0 -3
  19. package/dist/cjs/commandLink.js +0 -51
  20. package/dist/cjs/commandLint.d.ts +0 -3
  21. package/dist/cjs/commandLint.js +0 -150
  22. package/dist/cjs/commandSuggestion.d.ts +0 -3
  23. package/dist/cjs/commandSuggestion.js +0 -88
  24. package/dist/cjs/commandTrace.d.ts +0 -3
  25. package/dist/cjs/commandTrace.js +0 -87
  26. package/dist/cjs/emitters/DictionaryPathFormat.d.ts +0 -3
  27. package/dist/cjs/emitters/DictionaryPathFormat.js +0 -16
  28. package/dist/cjs/emitters/suggestionsEmitter.d.ts +0 -13
  29. package/dist/cjs/emitters/suggestionsEmitter.js +0 -84
  30. package/dist/cjs/emitters/traceEmitter.d.ts +0 -21
  31. package/dist/cjs/emitters/traceEmitter.js +0 -171
  32. package/dist/cjs/featureFlags/featureFlags.d.ts +0 -4
  33. package/dist/cjs/featureFlags/featureFlags.js +0 -25
  34. package/dist/cjs/featureFlags/index.d.ts +0 -2
  35. package/dist/cjs/featureFlags/index.js +0 -7
  36. package/dist/cjs/index.d.ts +0 -5
  37. package/dist/cjs/index.js +0 -22
  38. package/dist/cjs/link.d.ts +0 -8
  39. package/dist/cjs/link.js +0 -47
  40. package/dist/cjs/lint/LintRequest.d.ts +0 -23
  41. package/dist/cjs/lint/LintRequest.js +0 -48
  42. package/dist/cjs/lint/index.d.ts +0 -3
  43. package/dist/cjs/lint/index.js +0 -8
  44. package/dist/cjs/lint/lint.d.ts +0 -4
  45. package/dist/cjs/lint/lint.js +0 -499
  46. package/dist/cjs/options.d.ts +0 -178
  47. package/dist/cjs/options.js +0 -12
  48. package/dist/cjs/repl/index.d.ts +0 -18
  49. package/dist/cjs/repl/index.js +0 -75
  50. package/dist/cjs/util/InMemoryReporter.d.ts +0 -28
  51. package/dist/cjs/util/InMemoryReporter.js +0 -47
  52. package/dist/cjs/util/async.d.ts +0 -3
  53. package/dist/cjs/util/async.js +0 -12
  54. package/dist/cjs/util/cache/CSpellLintResultCache.d.ts +0 -20
  55. package/dist/cjs/util/cache/CSpellLintResultCache.js +0 -3
  56. package/dist/cjs/util/cache/CacheOptions.d.ts +0 -34
  57. package/dist/cjs/util/cache/CacheOptions.js +0 -3
  58. package/dist/cjs/util/cache/DiskCache.d.ts +0 -63
  59. package/dist/cjs/util/cache/DiskCache.js +0 -237
  60. package/dist/cjs/util/cache/DummyCache.d.ts +0 -11
  61. package/dist/cjs/util/cache/DummyCache.js +0 -22
  62. package/dist/cjs/util/cache/ObjectCollection.d.ts +0 -17
  63. package/dist/cjs/util/cache/ObjectCollection.js +0 -136
  64. package/dist/cjs/util/cache/createCache.d.ts +0 -31
  65. package/dist/cjs/util/cache/createCache.js +0 -77
  66. package/dist/cjs/util/cache/fileEntryCache.d.ts +0 -9
  67. package/dist/cjs/util/cache/fileEntryCache.js +0 -107
  68. package/dist/cjs/util/cache/index.d.ts +0 -4
  69. package/dist/cjs/util/cache/index.js +0 -8
  70. package/dist/cjs/util/constants.d.ts +0 -6
  71. package/dist/cjs/util/constants.js +0 -8
  72. package/dist/cjs/util/errors.d.ts +0 -23
  73. package/dist/cjs/util/errors.js +0 -60
  74. package/dist/cjs/util/fileHelper.d.ts +0 -63
  75. package/dist/cjs/util/fileHelper.js +0 -226
  76. package/dist/cjs/util/glob.d.ts +0 -45
  77. package/dist/cjs/util/glob.js +0 -175
  78. package/dist/cjs/util/prefetch.d.ts +0 -2
  79. package/dist/cjs/util/prefetch.js +0 -23
  80. package/dist/cjs/util/reporters.d.ts +0 -14
  81. package/dist/cjs/util/reporters.js +0 -68
  82. package/dist/cjs/util/stdin.d.ts +0 -2
  83. package/dist/cjs/util/stdin.js +0 -32
  84. package/dist/cjs/util/table.d.ts +0 -10
  85. package/dist/cjs/util/table.js +0 -40
  86. package/dist/cjs/util/timer.d.ts +0 -8
  87. package/dist/cjs/util/timer.js +0 -17
  88. package/dist/cjs/util/types.d.ts +0 -7
  89. package/dist/cjs/util/types.js +0 -6
  90. package/dist/cjs/util/util.d.ts +0 -13
  91. package/dist/cjs/util/util.js +0 -55
@@ -1,226 +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
- var __importDefault = (this && this.__importDefault) || function (mod) {
26
- return (mod && mod.__esModule) ? mod : { "default": mod };
27
- };
28
- Object.defineProperty(exports, "__esModule", { value: true });
29
- exports.isNotDir = exports.isDir = exports.isFile = exports.readFileListFile = exports.readFileListFiles = exports.calcFinalConfigInfo = exports.findFiles = exports.readFile = exports.readFileInfo = exports.resolveFilename = exports.isBinaryFile = exports.filenameToUri = exports.filenameToUrlString = exports.fileInfoToDocument = exports.readConfig = void 0;
30
- const cspell_io_1 = require("cspell-io");
31
- const cspell = __importStar(require("cspell-lib"));
32
- const cspell_lib_1 = require("cspell-lib");
33
- const fs_1 = require("fs");
34
- const get_stdin_1 = __importDefault(require("get-stdin"));
35
- const path = __importStar(require("path"));
36
- const url_1 = require("url");
37
- const uri_cjs_1 = require("../../lib/uri.cjs");
38
- const async_js_1 = require("./async.js");
39
- const constants_js_1 = require("./constants.js");
40
- const errors_js_1 = require("./errors.js");
41
- const glob_js_1 = require("./glob.js");
42
- const stdin_js_1 = require("./stdin.js");
43
- const util_js_1 = require("./util.js");
44
- const doesMatchUrl = /^(file|stdin|https?):\/\//;
45
- async function readConfig(configFile, root) {
46
- if (configFile) {
47
- const config = (await cspell.loadConfig(configFile)) || {};
48
- return { source: configFile, config };
49
- }
50
- const config = await cspell.searchForConfig(root);
51
- return { source: config?.__importRef?.filename || 'None found', config: config || {} };
52
- }
53
- exports.readConfig = readConfig;
54
- function fileInfoToDocument(fileInfo, languageId, locale) {
55
- const { filename, text } = fileInfo;
56
- languageId = languageId || undefined;
57
- locale = locale || undefined;
58
- const uri = filenameToUrlString(filename);
59
- if (uri.startsWith(constants_js_1.STDINProtocol)) {
60
- return (0, util_js_1.clean)({
61
- uri,
62
- text,
63
- languageId,
64
- locale,
65
- });
66
- }
67
- return (0, cspell_lib_1.fileToDocument)(uri, text, languageId, locale);
68
- }
69
- exports.fileInfoToDocument = fileInfoToDocument;
70
- function filenameToUrlString(filename, cwd = '.') {
71
- if (filename === constants_js_1.STDIN)
72
- return 'stdin:///';
73
- if (filename.startsWith(constants_js_1.STDINProtocol)) {
74
- const filePath = filename.slice(constants_js_1.STDINProtocol.length);
75
- const fullPath = path.resolve(cwd, filePath);
76
- return (0, url_1.pathToFileURL)(fullPath).toString();
77
- }
78
- if (doesMatchUrl.test(filename))
79
- return filename;
80
- return (0, url_1.pathToFileURL)(path.resolve(cwd, filename)).toString();
81
- }
82
- exports.filenameToUrlString = filenameToUrlString;
83
- function filenameToUri(filename, cwd) {
84
- return uri_cjs_1.URI.parse(filenameToUrlString(filename, cwd));
85
- }
86
- exports.filenameToUri = filenameToUri;
87
- function isBinaryFile(filename, cwd) {
88
- const uri = filenameToUri(filename, cwd);
89
- if (uri.scheme.startsWith('stdin'))
90
- return false;
91
- return (0, cspell_lib_1.isBinaryFile)(uri);
92
- }
93
- exports.isBinaryFile = isBinaryFile;
94
- function resolveFilename(filename, cwd) {
95
- cwd = cwd || process.cwd();
96
- if (filename === constants_js_1.STDIN)
97
- return constants_js_1.STDINProtocol;
98
- if (filename.startsWith(constants_js_1.FileProtocol)) {
99
- const url = new URL(filename.slice(constants_js_1.FileProtocol.length), (0, url_1.pathToFileURL)(cwd + path.sep));
100
- return (0, url_1.fileURLToPath)(url);
101
- }
102
- const scheme = filename.startsWith(constants_js_1.STDINProtocol) ? constants_js_1.STDINProtocol : '';
103
- const pathname = filename.slice(scheme.length);
104
- return scheme + path.resolve(cwd, pathname);
105
- }
106
- exports.resolveFilename = resolveFilename;
107
- function readFileInfo(filename, encoding = constants_js_1.UTF8, handleNotFound = false) {
108
- filename = resolveFilename(filename);
109
- const pText = filename.startsWith(constants_js_1.STDINProtocol) ? (0, get_stdin_1.default)() : (0, cspell_io_1.readFile)(filename, encoding);
110
- return pText.then((text) => ({ text, filename }), (e) => {
111
- const error = (0, errors_js_1.toError)(e);
112
- return handleNotFound && error.code === 'EISDIR'
113
- ? Promise.resolve({ text: '', filename, errorCode: error.code })
114
- : handleNotFound && error.code === 'ENOENT'
115
- ? Promise.resolve({ text: '', filename, errorCode: error.code })
116
- : Promise.reject(new errors_js_1.IOError(`Error reading file: "${filename}"`, error));
117
- });
118
- }
119
- exports.readFileInfo = readFileInfo;
120
- function readFile(filename, encoding = constants_js_1.UTF8) {
121
- return readFileInfo(filename, encoding).then((info) => info.text);
122
- }
123
- exports.readFile = readFile;
124
- /**
125
- * Looks for matching glob patterns or stdin
126
- * @param globPatterns patterns or stdin
127
- */
128
- async function findFiles(globPatterns, options) {
129
- const stdin = [];
130
- const globPats = globPatterns.filter((filename) => filename !== constants_js_1.STDIN && !filename.startsWith(constants_js_1.STDINProtocol) && !filename.startsWith(constants_js_1.FileProtocol)
131
- ? true
132
- : (stdin.push(filename), false));
133
- const globResults = globPats.length ? await (0, glob_js_1.globP)(globPats, options) : [];
134
- const cwd = options.cwd || process.cwd();
135
- return [...stdin, ...globResults].map((filename) => resolveFilename(filename, cwd));
136
- }
137
- exports.findFiles = findFiles;
138
- function calcFinalConfigInfo(configInfo, settingsFromCommandLine, filename, text) {
139
- const basename = path.basename(filename);
140
- const fileSettings = cspell.calcOverrideSettings(configInfo.config, path.resolve(filename));
141
- const loadDefault = settingsFromCommandLine.loadDefaultConfiguration ??
142
- configInfo.config.loadDefaultConfiguration ??
143
- fileSettings.loadDefaultConfiguration ??
144
- true;
145
- const settings = cspell.mergeSettings(cspell.getDefaultSettings(loadDefault), cspell.getGlobalSettings(), fileSettings, settingsFromCommandLine);
146
- const languageIds = settings.languageId
147
- ? Array.isArray(settings.languageId)
148
- ? settings.languageId
149
- : [settings.languageId]
150
- : cspell.getLanguageIdsForBaseFilename(basename);
151
- const config = cspell.constructSettingsForText(settings, text, languageIds);
152
- return {
153
- configInfo: { ...configInfo, config },
154
- filename,
155
- text,
156
- languageIds,
157
- };
158
- }
159
- exports.calcFinalConfigInfo = calcFinalConfigInfo;
160
- const resolveFilenames = (0, async_js_1.asyncMap)(resolveFilename);
161
- /**
162
- * Read
163
- * @param listFiles - array of file paths to read that will contain a list of files. Paths contained in each
164
- * file will be resolved relative to the containing file.
165
- * @returns - a list of files to be processed.
166
- */
167
- function readFileListFiles(listFiles) {
168
- let useStdin = false;
169
- const files = listFiles.filter((file) => {
170
- const isStdin = file === 'stdin';
171
- useStdin = useStdin || isStdin;
172
- return !isStdin;
173
- });
174
- const found = (0, async_js_1.asyncPipe)(files, (0, async_js_1.asyncMap)((file) => readFileListFile(file)), (0, async_js_1.asyncAwait)(), (0, async_js_1.asyncFlatten)());
175
- // Move `stdin` to the end.
176
- const stdin = useStdin ? (0, stdin_js_1.readStdin)() : [];
177
- return (0, async_js_1.asyncPipe)((0, async_js_1.mergeAsyncIterables)(found, stdin), resolveFilenames);
178
- }
179
- exports.readFileListFiles = readFileListFiles;
180
- /**
181
- * Read a `listFile` and return the containing file paths resolved relative to the `listFile`.
182
- * @param listFiles - array of file paths to read that will contain a list of files. Paths contained in each
183
- * file will be resolved relative to the containing file.
184
- * @returns - a list of files to be processed.
185
- */
186
- async function readFileListFile(listFile) {
187
- try {
188
- const relTo = path.resolve(path.dirname(listFile));
189
- const content = await readFile(listFile);
190
- const lines = content
191
- .split('\n')
192
- .map((a) => a.trim())
193
- .filter((a) => !!a)
194
- .map((file) => path.resolve(relTo, file));
195
- return lines;
196
- }
197
- catch (err) {
198
- throw (0, errors_js_1.toApplicationError)(err, `Error reading file list from: "${listFile}"`);
199
- }
200
- }
201
- exports.readFileListFile = readFileListFile;
202
- async function isFile(filename) {
203
- try {
204
- const stat = await fs_1.promises.stat(filename);
205
- return stat.isFile();
206
- }
207
- catch (e) {
208
- return false;
209
- }
210
- }
211
- exports.isFile = isFile;
212
- async function isDir(filename) {
213
- try {
214
- const stat = await fs_1.promises.stat(filename);
215
- return stat.isDirectory();
216
- }
217
- catch (e) {
218
- return false;
219
- }
220
- }
221
- exports.isDir = isDir;
222
- function isNotDir(filename) {
223
- return isDir(filename).then((a) => !a);
224
- }
225
- exports.isNotDir = isNotDir;
226
- //# sourceMappingURL=fileHelper.js.map
@@ -1,45 +0,0 @@
1
- import type { CSpellUserSettings, Glob } from '@cspell/cspell-types';
2
- import type { GlobPatternWithRoot } from 'cspell-glob';
3
- import { GlobMatcher } from 'cspell-glob';
4
- /**
5
- * This is a subset of IOptions from 'glob'.
6
- */
7
- export interface GlobOptions {
8
- cwd?: string | undefined;
9
- root?: string | undefined;
10
- dot?: boolean | undefined;
11
- nodir?: boolean | undefined;
12
- ignore?: string | Array<string> | undefined;
13
- }
14
- /**
15
- *
16
- * @param pattern - glob patterns and NOT file paths. It can be a file path turned into a glob.
17
- * @param options - search options.
18
- */
19
- export declare function globP(pattern: string | string[], options?: GlobOptions): Promise<string[]>;
20
- export declare function calcGlobs(commandLineExclude: string[] | undefined): {
21
- globs: string[];
22
- source: string;
23
- };
24
- export interface GlobSrcInfo {
25
- matcher: GlobMatcher;
26
- source: string;
27
- }
28
- interface ExtractPatternResult {
29
- glob: GlobPatternWithRoot;
30
- source: string;
31
- }
32
- export declare function extractPatterns(globs: GlobSrcInfo[]): ExtractPatternResult[];
33
- export declare function calcExcludeGlobInfo(root: string, commandLineExclude: string[] | string | undefined): GlobSrcInfo[];
34
- export declare function extractGlobExcludesFromConfig(root: string, source: string, config: CSpellUserSettings): GlobSrcInfo[];
35
- /**
36
- * Build GlobMatcher from command line or config file globs.
37
- * @param globs Glob patterns or file paths
38
- * @param root - directory to use as the root
39
- */
40
- export declare function buildGlobMatcher(globs: Glob[], root: string, isExclude: boolean): GlobMatcher;
41
- export declare function extractGlobsFromMatcher(globMatcher: GlobMatcher): string[];
42
- export declare function normalizeGlobsToRoot(globs: Glob[], root: string, isExclude: boolean): string[];
43
- export declare function normalizeFileOrGlobsToRoot(globs: Glob[], root: string): Promise<string[]>;
44
- export {};
45
- //# sourceMappingURL=glob.d.ts.map
@@ -1,175 +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
- var __importDefault = (this && this.__importDefault) || function (mod) {
26
- return (mod && mod.__esModule) ? mod : { "default": mod };
27
- };
28
- Object.defineProperty(exports, "__esModule", { value: true });
29
- exports.normalizeFileOrGlobsToRoot = exports.normalizeGlobsToRoot = exports.extractGlobsFromMatcher = exports.buildGlobMatcher = exports.extractGlobExcludesFromConfig = exports.calcExcludeGlobInfo = exports.extractPatterns = exports.calcGlobs = exports.globP = void 0;
30
- const cspell_glob_1 = require("cspell-glob");
31
- const fast_glob_1 = __importDefault(require("fast-glob"));
32
- const fs_1 = require("fs");
33
- const path = __importStar(require("path"));
34
- const path_1 = require("path");
35
- const util_js_1 = require("./util.js");
36
- const defaultExcludeGlobs = ['node_modules/**'];
37
- /**
38
- *
39
- * @param pattern - glob patterns and NOT file paths. It can be a file path turned into a glob.
40
- * @param options - search options.
41
- */
42
- async function globP(pattern, options) {
43
- const cwd = options?.root || options?.cwd || process.cwd();
44
- const ignore = typeof options?.ignore === 'string' ? [options.ignore] : options?.ignore;
45
- const onlyFiles = options?.nodir;
46
- const dot = options?.dot;
47
- const patterns = typeof pattern === 'string' ? [pattern] : pattern;
48
- const useOptions = (0, util_js_1.clean)({
49
- cwd,
50
- onlyFiles,
51
- dot,
52
- ignore,
53
- absolute: true,
54
- followSymbolicLinks: false,
55
- });
56
- const compare = new Intl.Collator('en').compare;
57
- const absolutePaths = (await (0, fast_glob_1.default)(patterns, useOptions)).sort(compare);
58
- const relativePaths = absolutePaths.map((absFilename) => path.relative(cwd, absFilename));
59
- return relativePaths;
60
- }
61
- exports.globP = globP;
62
- function calcGlobs(commandLineExclude) {
63
- const globs = new Set((commandLineExclude || []).flatMap((glob) => glob.split(/(?<!\\)\s+/g)).map((g) => g.replace(/\\ /g, ' ')));
64
- const commandLineExcludes = {
65
- globs: [...globs],
66
- source: 'arguments',
67
- };
68
- const defaultExcludes = {
69
- globs: defaultExcludeGlobs,
70
- source: 'default',
71
- };
72
- return commandLineExcludes.globs.length ? commandLineExcludes : defaultExcludes;
73
- }
74
- exports.calcGlobs = calcGlobs;
75
- function extractPatterns(globs) {
76
- const r = globs.reduce((info, g) => {
77
- const source = g.source;
78
- const patterns = g.matcher.patternsNormalizedToRoot;
79
- return info.concat(patterns.map((glob) => ({ glob, source })));
80
- }, []);
81
- return r;
82
- }
83
- exports.extractPatterns = extractPatterns;
84
- function calcExcludeGlobInfo(root, commandLineExclude) {
85
- commandLineExclude = typeof commandLineExclude === 'string' ? [commandLineExclude] : commandLineExclude;
86
- const choice = calcGlobs(commandLineExclude);
87
- const matcher = new cspell_glob_1.GlobMatcher(choice.globs, { root, dot: true });
88
- return [
89
- {
90
- matcher,
91
- source: choice.source,
92
- },
93
- ];
94
- }
95
- exports.calcExcludeGlobInfo = calcExcludeGlobInfo;
96
- function extractGlobExcludesFromConfig(root, source, config) {
97
- if (!config.ignorePaths || !config.ignorePaths.length) {
98
- return [];
99
- }
100
- const matcher = new cspell_glob_1.GlobMatcher(config.ignorePaths, { root, dot: true });
101
- return [{ source, matcher }];
102
- }
103
- exports.extractGlobExcludesFromConfig = extractGlobExcludesFromConfig;
104
- /**
105
- * Build GlobMatcher from command line or config file globs.
106
- * @param globs Glob patterns or file paths
107
- * @param root - directory to use as the root
108
- */
109
- function buildGlobMatcher(globs, root, isExclude) {
110
- const withRoots = globs.map((g) => {
111
- const source = typeof g === 'string' ? 'command line' : undefined;
112
- return { source, ...(0, cspell_glob_1.fileOrGlobToGlob)(g, root) };
113
- });
114
- return new cspell_glob_1.GlobMatcher(withRoots, { root, mode: isExclude ? 'exclude' : 'include' });
115
- }
116
- exports.buildGlobMatcher = buildGlobMatcher;
117
- function extractGlobsFromMatcher(globMatcher) {
118
- return globMatcher.patternsNormalizedToRoot.map((g) => g.glob);
119
- }
120
- exports.extractGlobsFromMatcher = extractGlobsFromMatcher;
121
- function normalizeGlobsToRoot(globs, root, isExclude) {
122
- const urls = globs.filter((g) => typeof g === 'string' && isPossibleUrlRegExp.test(g));
123
- const onlyGlobs = globs.filter((g) => typeof g !== 'string' || !isPossibleUrlRegExp.test(g));
124
- return [urls, extractGlobsFromMatcher(buildGlobMatcher(onlyGlobs, root, isExclude))].flatMap((a) => a);
125
- }
126
- exports.normalizeGlobsToRoot = normalizeGlobsToRoot;
127
- const isPossibleGlobRegExp = /[*{}()?[]/;
128
- const isPossibleUrlRegExp = /^[-a-z_0-9]{3,}:\/\//;
129
- /**
130
- * If a 'glob' is a path to a directory, then append `**` so that
131
- * directory searches work.
132
- * @param glob - a glob, file, or directory
133
- * @param root - root to use.
134
- * @returns `**` is appended directories.
135
- */
136
- async function adjustPossibleDirectory(glob, root) {
137
- const g = typeof glob === 'string'
138
- ? {
139
- glob,
140
- root,
141
- }
142
- : {
143
- glob: glob.glob,
144
- root: glob.root ?? root,
145
- };
146
- // Do not ask the file system to look up obvious glob patterns.
147
- if (isPossibleGlobRegExp.test(g.glob)) {
148
- return glob;
149
- }
150
- if (isPossibleUrlRegExp.test(g.glob)) {
151
- return glob;
152
- }
153
- const dirPath = path.resolve(g.root, g.glob);
154
- try {
155
- const stat = await fs_1.promises.stat(dirPath);
156
- if (stat.isDirectory()) {
157
- const useGlob = path_1.posix.join(posixPath(g.glob), '**');
158
- return typeof glob === 'string' ? useGlob : { ...glob, glob: useGlob };
159
- }
160
- }
161
- catch (e) {
162
- // it was not possible to access the dirPath, no problem, just let the file glob search look for it.
163
- return glob;
164
- }
165
- return glob;
166
- }
167
- function posixPath(p) {
168
- return path.sep === '\\' ? p.replace(/\\/g, '/') : p;
169
- }
170
- async function normalizeFileOrGlobsToRoot(globs, root) {
171
- const adjustedGlobs = await Promise.all(globs.map((g) => adjustPossibleDirectory(g, root)));
172
- return normalizeGlobsToRoot(adjustedGlobs, root, false);
173
- }
174
- exports.normalizeFileOrGlobsToRoot = normalizeFileOrGlobsToRoot;
175
- //# sourceMappingURL=glob.js.map
@@ -1,2 +0,0 @@
1
- export declare function prefetchIterable<T>(iterable: Iterable<T>, size: number): Iterable<T>;
2
- //# sourceMappingURL=prefetch.d.ts.map
@@ -1,23 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.prefetchIterable = void 0;
7
- const assert_1 = __importDefault(require("assert"));
8
- function* prefetchIterable(iterable, size) {
9
- (0, assert_1.default)(size >= 0);
10
- const iter = iterable[Symbol.iterator]();
11
- const buffer = [];
12
- for (let next = iter.next(); !next.done; next = iter.next()) {
13
- buffer.push(next.value);
14
- if (buffer.length >= size - 1) {
15
- const value = buffer[0];
16
- buffer.shift();
17
- yield value;
18
- }
19
- }
20
- yield* buffer;
21
- }
22
- exports.prefetchIterable = prefetchIterable;
23
- //# sourceMappingURL=prefetch.js.map
@@ -1,14 +0,0 @@
1
- import type { CSpellReporter, FileSettings, ReporterConfiguration } from '@cspell/cspell-types';
2
- export type FinalizedReporter = Required<CSpellReporter>;
3
- /**
4
- * Mergers several cspell reporters into a single one
5
- */
6
- export declare function mergeReporters(...reporters: ReadonlyArray<CSpellReporter>): FinalizedReporter;
7
- /**
8
- * Loads reporter modules configured in cspell config file
9
- */
10
- export declare function loadReporters(reporters: FileSettings['reporters'], defaultReporter: CSpellReporter, config: ReporterConfiguration): Promise<ReadonlyArray<CSpellReporter>>;
11
- export declare function finalizeReporter(reporter: undefined): undefined;
12
- export declare function finalizeReporter(reporter: CSpellReporter): FinalizedReporter;
13
- export declare function finalizeReporter(reporter: CSpellReporter | undefined): FinalizedReporter | undefined;
14
- //# sourceMappingURL=reporters.d.ts.map
@@ -1,68 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.finalizeReporter = exports.loadReporters = exports.mergeReporters = void 0;
4
- const dynamic_import_1 = require("@cspell/dynamic-import");
5
- const pkgInfo_cjs_1 = require("../../lib/pkgInfo.cjs");
6
- const errors_js_1 = require("./errors.js");
7
- function callAll(methods) {
8
- return (...p) => {
9
- for (const method of methods) {
10
- method(...p);
11
- }
12
- return;
13
- };
14
- }
15
- function extractEmitter(reporters, emitterName) {
16
- // The `bind` is used in case the reporter is a class.
17
- return reporters
18
- .map((r) => r[emitterName]?.bind(r))
19
- .filter((r) => !!r);
20
- }
21
- function mergeResultEmitters(reporters) {
22
- return async (result) => {
23
- await Promise.all(reporters.map((reporter) => reporter.result?.(result)));
24
- };
25
- }
26
- /**
27
- * Mergers several cspell reporters into a single one
28
- */
29
- function mergeReporters(...reporters) {
30
- return {
31
- issue: callAll(extractEmitter(reporters, 'issue')),
32
- info: callAll(extractEmitter(reporters, 'info')),
33
- debug: callAll(extractEmitter(reporters, 'debug')),
34
- progress: callAll(extractEmitter(reporters, 'progress')),
35
- error: callAll(extractEmitter(reporters, 'error')),
36
- result: mergeResultEmitters(reporters),
37
- };
38
- }
39
- exports.mergeReporters = mergeReporters;
40
- /**
41
- * Loads reporter modules configured in cspell config file
42
- */
43
- async function loadReporters(reporters, defaultReporter, config) {
44
- async function loadReporter(reporterSettings) {
45
- if (reporterSettings === 'default')
46
- return defaultReporter;
47
- if (!Array.isArray(reporterSettings)) {
48
- reporterSettings = [reporterSettings];
49
- }
50
- const [moduleName, settings] = reporterSettings;
51
- try {
52
- const { getReporter } = await (0, dynamic_import_1.dynamicImport)(moduleName, [process.cwd(), pkgInfo_cjs_1.pkgDir]);
53
- return getReporter(settings, config);
54
- }
55
- catch (e) {
56
- throw new errors_js_1.ApplicationError(`Failed to load reporter ${moduleName}: ${(0, errors_js_1.toError)(e).message}`);
57
- }
58
- }
59
- reporters = !reporters || !reporters.length ? ['default'] : [...reporters];
60
- const loadedReporters = await Promise.all(reporters.map(loadReporter));
61
- return loadedReporters.filter((v) => v !== undefined);
62
- }
63
- exports.loadReporters = loadReporters;
64
- function finalizeReporter(reporter) {
65
- return reporter && mergeReporters(reporter);
66
- }
67
- exports.finalizeReporter = finalizeReporter;
68
- //# sourceMappingURL=reporters.js.map
@@ -1,2 +0,0 @@
1
- export declare function readStdin(): AsyncIterable<string>;
2
- //# sourceMappingURL=stdin.d.ts.map
@@ -1,32 +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.readStdin = void 0;
27
- const readline = __importStar(require("readline"));
28
- function readStdin() {
29
- return readline.createInterface(process.stdin);
30
- }
31
- exports.readStdin = readStdin;
32
- //# sourceMappingURL=stdin.js.map
@@ -1,10 +0,0 @@
1
- export interface Table {
2
- header: string[];
3
- rows: string[][];
4
- deliminator?: string;
5
- }
6
- export declare function tableToLines(table: Table, deliminator?: string): string[];
7
- type TextDecorator = (t: string, index: number) => string;
8
- export declare function decorateRowWith(row: string[], ...decorators: TextDecorator[]): string[];
9
- export {};
10
- //# sourceMappingURL=table.d.ts.map
@@ -1,40 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.decorateRowWith = exports.tableToLines = void 0;
7
- const chalk_1 = __importDefault(require("chalk"));
8
- const strip_ansi_1 = __importDefault(require("strip-ansi"));
9
- function tableToLines(table, deliminator) {
10
- deliminator = deliminator || table.deliminator || ' | ';
11
- const columnWidths = [];
12
- const { header, rows } = table;
13
- function recordWidths(row) {
14
- row.forEach((col, idx) => {
15
- columnWidths[idx] = Math.max((0, strip_ansi_1.default)(col).length, columnWidths[idx] || 0);
16
- });
17
- }
18
- function justifyRow(c, i) {
19
- return c + ' '.repeat(columnWidths[i] - (0, strip_ansi_1.default)(c).length);
20
- }
21
- function toLine(row) {
22
- return decorateRowWith(row, justifyRow).join(deliminator);
23
- }
24
- function* process() {
25
- yield toLine(decorateRowWith(header, headerDecorator));
26
- yield* rows.map(toLine);
27
- }
28
- recordWidths(header);
29
- rows.forEach(recordWidths);
30
- return [...process()];
31
- }
32
- exports.tableToLines = tableToLines;
33
- function headerDecorator(t) {
34
- return chalk_1.default.bold(chalk_1.default.underline(t));
35
- }
36
- function decorateRowWith(row, ...decorators) {
37
- return decorators.reduce((row, decorator) => row.map(decorator), row);
38
- }
39
- exports.decorateRowWith = decorateRowWith;
40
- //# sourceMappingURL=table.js.map
@@ -1,8 +0,0 @@
1
- export interface MeasurePromiseResult {
2
- elapsedTimeMs: number;
3
- success: boolean;
4
- }
5
- export declare function getTimeMeasurer(): () => number;
6
- export declare function elapsedTimeMsFrom(relativeTo: [number, number]): number;
7
- export declare function hrTimeToMs(hrTime: [number, number]): number;
8
- //# sourceMappingURL=timer.d.ts.map
@@ -1,17 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.hrTimeToMs = exports.elapsedTimeMsFrom = exports.getTimeMeasurer = void 0;
4
- function getTimeMeasurer() {
5
- const start = process.hrtime();
6
- return () => hrTimeToMs(process.hrtime(start));
7
- }
8
- exports.getTimeMeasurer = getTimeMeasurer;
9
- function elapsedTimeMsFrom(relativeTo) {
10
- return hrTimeToMs(process.hrtime(relativeTo));
11
- }
12
- exports.elapsedTimeMsFrom = elapsedTimeMsFrom;
13
- function hrTimeToMs(hrTime) {
14
- return hrTime[0] * 1.0e3 + hrTime[1] * 1.0e-6;
15
- }
16
- exports.hrTimeToMs = hrTimeToMs;
17
- //# sourceMappingURL=timer.js.map