@cspell/cspell-tools 9.4.0 → 9.6.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 (110) hide show
  1. package/bin.mjs +1 -1
  2. package/cspell-tools.config.schema.json +50 -24
  3. package/dist/app.d.mts +35 -0
  4. package/dist/app.mjs +292 -0
  5. package/dist/build-OgMPaXPZ.mjs +1403 -0
  6. package/dist/index.d.mts +35 -0
  7. package/dist/index.mjs +3 -0
  8. package/package.json +10 -9
  9. package/dist/AppOptions.d.ts +0 -31
  10. package/dist/AppOptions.js +0 -2
  11. package/dist/FeatureFlags/FeatureFlags.d.ts +0 -34
  12. package/dist/FeatureFlags/FeatureFlags.js +0 -94
  13. package/dist/FeatureFlags/index.d.ts +0 -3
  14. package/dist/FeatureFlags/index.js +0 -3
  15. package/dist/FeatureFlags/parseFlags.d.ts +0 -3
  16. package/dist/FeatureFlags/parseFlags.js +0 -20
  17. package/dist/app.d.ts +0 -4
  18. package/dist/app.js +0 -86
  19. package/dist/build.d.ts +0 -12
  20. package/dist/build.js +0 -36
  21. package/dist/compile.d.ts +0 -5
  22. package/dist/compile.js +0 -41
  23. package/dist/compiler/CompileOptions.d.ts +0 -35
  24. package/dist/compiler/CompileOptions.js +0 -2
  25. package/dist/compiler/Reader.d.ts +0 -3
  26. package/dist/compiler/Reader.js +0 -24
  27. package/dist/compiler/SourceReader.d.ts +0 -28
  28. package/dist/compiler/SourceReader.js +0 -44
  29. package/dist/compiler/WordsCollection.d.ts +0 -20
  30. package/dist/compiler/WordsCollection.js +0 -3
  31. package/dist/compiler/compile.d.ts +0 -26
  32. package/dist/compiler/compile.js +0 -263
  33. package/dist/compiler/createCompileRequest.d.ts +0 -4
  34. package/dist/compiler/createCompileRequest.js +0 -84
  35. package/dist/compiler/createWordsCollection.d.ts +0 -9
  36. package/dist/compiler/createWordsCollection.js +0 -108
  37. package/dist/compiler/fileWriter.d.ts +0 -3
  38. package/dist/compiler/fileWriter.js +0 -6
  39. package/dist/compiler/index.d.ts +0 -5
  40. package/dist/compiler/index.js +0 -4
  41. package/dist/compiler/legacyLineToWords.d.ts +0 -4
  42. package/dist/compiler/legacyLineToWords.js +0 -20
  43. package/dist/compiler/logWithTimestamp.d.ts +0 -3
  44. package/dist/compiler/logWithTimestamp.js +0 -5
  45. package/dist/compiler/logger.d.ts +0 -4
  46. package/dist/compiler/logger.js +0 -9
  47. package/dist/compiler/readers/ReaderOptions.d.ts +0 -19
  48. package/dist/compiler/readers/ReaderOptions.js +0 -2
  49. package/dist/compiler/readers/readHunspellFiles.d.ts +0 -3
  50. package/dist/compiler/readers/readHunspellFiles.js +0 -57
  51. package/dist/compiler/readers/readTextFile.d.ts +0 -3
  52. package/dist/compiler/readers/readTextFile.js +0 -20
  53. package/dist/compiler/readers/regHunspellFile.d.ts +0 -2
  54. package/dist/compiler/readers/regHunspellFile.js +0 -2
  55. package/dist/compiler/readers/textFileReader.d.ts +0 -3
  56. package/dist/compiler/readers/textFileReader.js +0 -11
  57. package/dist/compiler/readers/trieFileReader.d.ts +0 -3
  58. package/dist/compiler/readers/trieFileReader.js +0 -16
  59. package/dist/compiler/splitCamelCaseIfAllowed.d.ts +0 -5
  60. package/dist/compiler/splitCamelCaseIfAllowed.js +0 -65
  61. package/dist/compiler/streamSourceWordsFromFile.d.ts +0 -3
  62. package/dist/compiler/streamSourceWordsFromFile.js +0 -6
  63. package/dist/compiler/text.d.ts +0 -10
  64. package/dist/compiler/text.js +0 -28
  65. package/dist/compiler/wordListCompiler.d.ts +0 -17
  66. package/dist/compiler/wordListCompiler.js +0 -199
  67. package/dist/compiler/wordListParser.d.ts +0 -61
  68. package/dist/compiler/wordListParser.js +0 -184
  69. package/dist/compiler/writeTextToFile.d.ts +0 -3
  70. package/dist/compiler/writeTextToFile.js +0 -15
  71. package/dist/config/config.d.ts +0 -194
  72. package/dist/config/config.js +0 -2
  73. package/dist/config/configDefaults.d.ts +0 -9
  74. package/dist/config/configDefaults.js +0 -9
  75. package/dist/config/configUtils.d.ts +0 -5
  76. package/dist/config/configUtils.js +0 -14
  77. package/dist/config/index.d.ts +0 -4
  78. package/dist/config/index.js +0 -3
  79. package/dist/config/normalizeConfig.d.ts +0 -8
  80. package/dist/config/normalizeConfig.js +0 -13
  81. package/dist/gzip/compressFiles.d.ts +0 -16
  82. package/dist/gzip/compressFiles.js +0 -42
  83. package/dist/gzip/gzip.d.ts +0 -3
  84. package/dist/gzip/gzip.js +0 -10
  85. package/dist/gzip/index.d.ts +0 -3
  86. package/dist/gzip/index.js +0 -3
  87. package/dist/shasum/checksum.d.ts +0 -7
  88. package/dist/shasum/checksum.js +0 -19
  89. package/dist/shasum/index.d.ts +0 -3
  90. package/dist/shasum/index.js +0 -3
  91. package/dist/shasum/shasum.d.ts +0 -38
  92. package/dist/shasum/shasum.js +0 -150
  93. package/dist/test/TestHelper.d.ts +0 -53
  94. package/dist/test/TestHelper.js +0 -121
  95. package/dist/test/console.d.ts +0 -9
  96. package/dist/test/console.js +0 -34
  97. package/dist/test/escapeRegEx.d.ts +0 -7
  98. package/dist/test/escapeRegEx.js +0 -9
  99. package/dist/test/normalizeOutput.d.ts +0 -3
  100. package/dist/test/normalizeOutput.js +0 -20
  101. package/dist/types.d.ts +0 -7
  102. package/dist/types.js +0 -2
  103. package/dist/util/errors.d.ts +0 -6
  104. package/dist/util/errors.js +0 -11
  105. package/dist/util/globP.d.ts +0 -7
  106. package/dist/util/globP.js +0 -7
  107. package/dist/util/index.d.ts +0 -2
  108. package/dist/util/index.js +0 -4
  109. package/dist/util/textRegex.d.ts +0 -3
  110. package/dist/util/textRegex.js +0 -109
@@ -1,121 +0,0 @@
1
- import assert from 'node:assert';
2
- import { mkdirSync, promises as fs, readFileSync, rmSync, statSync, writeFileSync } from 'node:fs';
3
- import * as path from 'node:path';
4
- import { fileURLToPath } from 'node:url';
5
- import { expect } from 'vitest';
6
- const _dirname = test_dirname(import.meta.url);
7
- const packageRoot = path.join(_dirname, '../..');
8
- const repoRoot = path.join(packageRoot, '../..');
9
- const tempDirBase = path.join(packageRoot, 'temp');
10
- const repoSamples = path.join(repoRoot, 'packages/Samples');
11
- export function createTestHelper(testFilenameUrl) {
12
- testFilenameUrl && assert(testFilenameUrl.startsWith('file:'));
13
- const testFilename = testFilenameUrl && test_filename(testFilenameUrl);
14
- return new TestHelperImpl(testFilename || expect.getState().testPath || 'test');
15
- }
16
- const fixtureDir = path.join(packageRoot, 'fixtures');
17
- class TestHelperImpl {
18
- packageRoot = packageRoot;
19
- repoRoot = repoRoot;
20
- tempDir;
21
- fixtureDir;
22
- testCounter = new Map();
23
- constructor(testFilename) {
24
- this.tempDir = path.join(tempDirBase, path.relative(packageRoot, testFilename));
25
- this.fixtureDir = fixtureDir;
26
- }
27
- beginTest() {
28
- const currentTestName = this.getRawTestName();
29
- const prev = this.testCounter.get(currentTestName) || 0;
30
- this.testCounter.set(currentTestName, prev + 1);
31
- }
32
- getRawTestName() {
33
- return expect.getState().currentTestName || '';
34
- }
35
- getCurrentTestName() {
36
- const currentTestName = this.getRawTestName();
37
- const counter = this.testCounter.get(currentTestName);
38
- return `${currentTestName}${counter ? ' ' + counter : ''}`;
39
- }
40
- /**
41
- * delete the contents of the temp directory for the current test.
42
- */
43
- clearTempDir() {
44
- rmSync(this.resolveTemp(), { force: true, recursive: true });
45
- }
46
- /**
47
- * resolve a path relative to the
48
- * @param parts
49
- * @returns
50
- */
51
- resolveTemp(...parts) {
52
- const currentTestName = this.getCurrentTestName();
53
- const testName = currentTestName.replaceAll(/[^\w_.-]/g, '_');
54
- return path.resolve(this.tempDir, testName, ...parts);
55
- }
56
- /**
57
- * make a directory. It is ok to make the same directory multiple times.
58
- * @param parts
59
- */
60
- mkdir(...parts) {
61
- const pTemp = this.resolveTemp(...parts);
62
- mkdirSync(pTemp, { recursive: true });
63
- }
64
- /**
65
- * Copy files from src to dest
66
- * @param src - glob
67
- * @param dest - directory or file
68
- */
69
- cpFileSync(src, dest) {
70
- const srcT = this.resolveTemp(src);
71
- const dstT = this.resolveTemp(dest);
72
- cpFileSync(srcT, dstT);
73
- }
74
- /**
75
- * resolve a path to the fixtures.
76
- * @param parts
77
- * @returns
78
- */
79
- resolveFixture(...parts) {
80
- return path.resolve(this.fixtureDir, ...parts);
81
- }
82
- resolveSample(...parts) {
83
- return path.resolve(repoSamples, ...parts);
84
- }
85
- /**
86
- * calc a path relative to the package temp directory.
87
- * @param parts - optional path segments
88
- * @returns
89
- */
90
- packageTemp(...parts) {
91
- return path.resolve(tempDirBase, ...parts);
92
- }
93
- createTempDir = this.mkdir;
94
- async fileExists(path) {
95
- try {
96
- await fs.stat(path);
97
- return true;
98
- }
99
- catch {
100
- return false;
101
- }
102
- }
103
- }
104
- export function resolvePathToFixture(...segments) {
105
- return path.resolve(fixtureDir, ...segments);
106
- }
107
- export function test_dirname(importMetaUrl) {
108
- return fileURLToPath(new URL('.', importMetaUrl));
109
- }
110
- export function test_filename(importMetaUrl) {
111
- return fileURLToPath(importMetaUrl);
112
- }
113
- function cpFileSync(srcFile, dst) {
114
- const statDst = statSync(dst, { throwIfNoEntry: false });
115
- if (statDst && statDst.isDirectory()) {
116
- dst = path.join(dst, path.basename(srcFile));
117
- }
118
- const buf = readFileSync(srcFile);
119
- writeFileSync(dst, buf);
120
- }
121
- //# sourceMappingURL=TestHelper.js.map
@@ -1,9 +0,0 @@
1
- export declare function spyOnConsole(): {
2
- consoleOutput: () => {
3
- log: string;
4
- error: string;
5
- };
6
- attach: () => void;
7
- reset: () => void;
8
- };
9
- //# sourceMappingURL=console.d.ts.map
@@ -1,34 +0,0 @@
1
- import { vi } from 'vitest';
2
- import { normalizeOutput } from './normalizeOutput.js';
3
- export function spyOnConsole() {
4
- const con = {
5
- log: vi.spyOn(console, 'log').mockImplementation(() => undefined),
6
- error: vi.spyOn(console, 'error').mockImplementation(() => undefined),
7
- consoleOutput,
8
- attach,
9
- reset,
10
- };
11
- function consoleOutput() {
12
- const _error = con.error.mock.calls.map((c) => c.join(',')).join('\n');
13
- const _log = con.log.mock.calls.map((c) => c.join(',')).join('\n');
14
- return {
15
- log: normalizeOutput(_log),
16
- error: normalizeOutput(_error),
17
- };
18
- }
19
- function attach() {
20
- reset();
21
- con.log = vi.spyOn(console, 'log').mockImplementation(() => undefined);
22
- con.error = vi.spyOn(console, 'error').mockImplementation(() => undefined);
23
- }
24
- function reset() {
25
- con.log.mockRestore();
26
- con.error.mockRestore();
27
- }
28
- return {
29
- consoleOutput,
30
- attach,
31
- reset,
32
- };
33
- }
34
- //# sourceMappingURL=console.js.map
@@ -1,7 +0,0 @@
1
- /**
2
- * Escape a string so it can be used as an exact match within a RegExp.
3
- * @param s - string to escape
4
- * @returns - the escaped string.
5
- */
6
- export declare function escapeRegEx(s: string): string;
7
- //# sourceMappingURL=escapeRegEx.d.ts.map
@@ -1,9 +0,0 @@
1
- /**
2
- * Escape a string so it can be used as an exact match within a RegExp.
3
- * @param s - string to escape
4
- * @returns - the escaped string.
5
- */
6
- export function escapeRegEx(s) {
7
- return s.replaceAll(/[|\\{}()[\]^$+*?.]/g, '\\$&').replaceAll('-', '\\x2d');
8
- }
9
- //# sourceMappingURL=escapeRegEx.js.map
@@ -1,3 +0,0 @@
1
- export declare function normalizeOutput(output: string, cwd?: string): string;
2
- export declare function normalizeDirectorySeparator(path: string): string;
3
- //# sourceMappingURL=normalizeOutput.d.ts.map
@@ -1,20 +0,0 @@
1
- import * as path from 'node:path';
2
- import { escapeRegEx } from './escapeRegEx.js';
3
- import { test_dirname } from './TestHelper.js';
4
- const _dirname = test_dirname(import.meta.url);
5
- const rootCspellTools = path.join(_dirname, '../..');
6
- const rootRepo = path.join(rootCspellTools, '../..');
7
- /**
8
- * Example: `2022-10-02T17:10:04.681Z`
9
- */
10
- const regexpDate = /\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(\.\d+)?Z/gi;
11
- const rxRootRepo = new RegExp(escapeRegEx(rootRepo) + '|' + escapeRegEx(normalizeDirectorySeparator(rootRepo)), 'gi');
12
- export function normalizeOutput(output, cwd = process.cwd()) {
13
- const rxCwd = new RegExp(escapeRegEx(cwd) + '|' + escapeRegEx(normalizeDirectorySeparator(cwd)), 'gi');
14
- const normalizeDirs = normalizeDirectorySeparator(output.replace(rxCwd, '{cwd}').replace(rxRootRepo, '{repo-root}'));
15
- return normalizeDirs.replaceAll(regexpDate, '2022-01-01T00:00:00.000Z');
16
- }
17
- export function normalizeDirectorySeparator(path) {
18
- return path.replaceAll('\\', '/');
19
- }
20
- //# sourceMappingURL=normalizeOutput.js.map
package/dist/types.d.ts DELETED
@@ -1,7 +0,0 @@
1
- /**
2
- * Make all properties in T required, but keep the original optionality of the properties.
3
- */
4
- export type RequireFields<T> = {
5
- [P in keyof Required<T>]: T[P];
6
- };
7
- //# sourceMappingURL=types.d.ts.map
package/dist/types.js DELETED
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=types.js.map
@@ -1,6 +0,0 @@
1
- export interface NodeError extends Error {
2
- code?: string;
3
- }
4
- export declare function toError(err: unknown): NodeError;
5
- export declare function isError(err: unknown): err is Error;
6
- //# sourceMappingURL=errors.d.ts.map
@@ -1,11 +0,0 @@
1
- export function toError(err) {
2
- if (isError(err))
3
- return err;
4
- return new Error(`${err}`);
5
- }
6
- export function isError(err) {
7
- if (err instanceof Error)
8
- return true;
9
- return false;
10
- }
11
- //# sourceMappingURL=errors.js.map
@@ -1,7 +0,0 @@
1
- interface Options {
2
- cwd?: string | URL;
3
- nodir?: boolean;
4
- }
5
- export declare function globP(pattern: string | string[], options?: Options): Promise<string[]>;
6
- export {};
7
- //# sourceMappingURL=globP.d.ts.map
@@ -1,7 +0,0 @@
1
- import { glob } from 'glob';
2
- export function globP(pattern, options) {
3
- // Convert windows separators.
4
- const globs = (Array.isArray(pattern) ? pattern : [pattern]).map((pattern) => pattern.replaceAll('\\', '/'));
5
- return glob(globs, options);
6
- }
7
- //# sourceMappingURL=globP.js.map
@@ -1,2 +0,0 @@
1
- export declare function isDefined<T>(a: T | undefined | null): a is T;
2
- //# sourceMappingURL=index.d.ts.map
@@ -1,4 +0,0 @@
1
- export function isDefined(a) {
2
- return !!a || (a !== null && a !== undefined);
3
- }
4
- //# sourceMappingURL=index.js.map
@@ -1,3 +0,0 @@
1
- export declare const regExMatchRegExParts: RegExp;
2
- export declare function stringToRegExp(pattern: string | RegExp, defaultFlags?: string, forceFlags?: string): RegExp | undefined;
3
- //# sourceMappingURL=textRegex.d.ts.map
@@ -1,109 +0,0 @@
1
- // cspell:ignore gimuxy
2
- export const regExMatchRegExParts = /^\s*\/([\s\S]*?)\/([gimuxy]*)\s*$/;
3
- export function stringToRegExp(pattern, defaultFlags = '', forceFlags = '') {
4
- if (pattern instanceof RegExp) {
5
- return pattern;
6
- }
7
- try {
8
- const [, pat, flag] = [
9
- ...(pattern.match(regExMatchRegExParts) || ['', pattern.trim(), defaultFlags]),
10
- forceFlags,
11
- ];
12
- if (pat) {
13
- const regPattern = flag.includes('x') ? removeVerboseFromRegExp(pat) : pat;
14
- // Make sure the flags are unique.
15
- const flags = [...new Set(forceFlags + flag)].join('').replaceAll(/[^gimuy]/g, '');
16
- const regex = new RegExp(regPattern, flags);
17
- return regex;
18
- }
19
- }
20
- catch {
21
- /* empty */
22
- }
23
- return undefined;
24
- }
25
- const SPACES = {
26
- ' ': true,
27
- '\n': true,
28
- '\r': true,
29
- '\t': true,
30
- };
31
- /**
32
- * Remove all whitespace and comments from a regexp string. The format follows Pythons Verbose.
33
- * Note: this is a best attempt. Special cases for comments: `#` and spaces should be proceeded with a `\`
34
- *
35
- * All space must be proceeded by a `\` or in a character class `[]`
36
- *
37
- * @param pattern - the pattern to clean
38
- */
39
- function removeVerboseFromRegExp(pattern) {
40
- function escape(acc) {
41
- const char = pattern[acc.idx];
42
- if (char !== '\\')
43
- return undefined;
44
- const next = pattern[++acc.idx];
45
- acc.idx++;
46
- if (next === '#') {
47
- acc.result += '#';
48
- return acc;
49
- }
50
- if (!(next in SPACES)) {
51
- acc.result += '\\' + next;
52
- return acc;
53
- }
54
- acc.result += next;
55
- if (next === '\r' && pattern[acc.idx] === '\n') {
56
- acc.result += '\n';
57
- acc.idx++;
58
- }
59
- return acc;
60
- }
61
- function braces(acc) {
62
- const char = pattern[acc.idx];
63
- if (char !== '[')
64
- return undefined;
65
- acc.result += char;
66
- acc.idx++;
67
- let escCount = 0;
68
- while (acc.idx < pattern.length) {
69
- const char = pattern[acc.idx];
70
- acc.result += char;
71
- acc.idx++;
72
- if (char === ']' && !(escCount & 1))
73
- break;
74
- escCount = char === '\\' ? escCount + 1 : 0;
75
- }
76
- return acc;
77
- }
78
- function spaces(acc) {
79
- const char = pattern[acc.idx];
80
- if (!(char in SPACES))
81
- return undefined;
82
- acc.idx++;
83
- return acc;
84
- }
85
- function comments(acc) {
86
- const char = pattern[acc.idx];
87
- if (char !== '#')
88
- return undefined;
89
- while (acc.idx < pattern.length && pattern[acc.idx] !== '\n') {
90
- acc.idx++;
91
- }
92
- return acc;
93
- }
94
- function copy(acc) {
95
- const char = pattern[acc.idx++];
96
- acc.result += char;
97
- return acc;
98
- }
99
- const reducers = [escape, braces, spaces, comments, copy];
100
- const result = { idx: 0, result: '' };
101
- while (result.idx < pattern.length) {
102
- for (const r of reducers) {
103
- if (r(result))
104
- break;
105
- }
106
- }
107
- return result.result;
108
- }
109
- //# sourceMappingURL=textRegex.js.map