@cspell/cspell-tools 8.3.1 → 8.4.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/app.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import type { Command } from 'commander';
|
|
2
2
|
import type { FeatureFlags } from './FeatureFlags/index.js';
|
|
3
|
-
export declare function run(program:
|
|
3
|
+
export declare function run(program: Command, argv: string[], flags?: FeatureFlags): Promise<void>;
|
|
4
4
|
//# sourceMappingURL=app.d.ts.map
|
|
@@ -8,5 +8,11 @@ export interface CompileOptions {
|
|
|
8
8
|
* Generate lower case / accent free versions of words.
|
|
9
9
|
*/
|
|
10
10
|
generateNonStrict: boolean;
|
|
11
|
+
/**
|
|
12
|
+
* Optional filter function to filter out words.
|
|
13
|
+
* @param word the word to test
|
|
14
|
+
* @returns `true` to keep the word, `false` to exclude it.
|
|
15
|
+
*/
|
|
16
|
+
filter?: (word: string) => boolean;
|
|
11
17
|
}
|
|
12
18
|
//# sourceMappingURL=CompileOptions.d.ts.map
|
package/dist/compiler/compile.js
CHANGED
|
@@ -4,7 +4,7 @@ import { opConcatMap, opMap, pipe } from '@cspell/cspell-pipe/sync';
|
|
|
4
4
|
import * as path from 'path';
|
|
5
5
|
import { isFileListSource, isFilePath, isFileSource } from '../config/index.js';
|
|
6
6
|
import { checkShasumFile, updateChecksumForFiles } from '../shasum/index.js';
|
|
7
|
-
import { createAllowedSplitWordsFromFiles } from './createWordsCollection.js';
|
|
7
|
+
import { createAllowedSplitWordsFromFiles, createWordsCollectionFromFiles } from './createWordsCollection.js';
|
|
8
8
|
import { logWithTimestamp } from './logWithTimestamp.js';
|
|
9
9
|
import { readTextFile } from './readers/readTextFile.js';
|
|
10
10
|
import { streamSourceWordsFromFile } from './streamSourceWordsFromFile.js';
|
|
@@ -46,17 +46,18 @@ function resolveChecksumFile(checksumFile, root) {
|
|
|
46
46
|
export async function compileTarget(target, options, compileOptions) {
|
|
47
47
|
logWithTimestamp(`Start compile: ${target.name}`);
|
|
48
48
|
const { rootDir, cwd, checksumFile, conditional } = compileOptions;
|
|
49
|
-
const { format, sources, trieBase, sort = true, generateNonStrict = false } = target;
|
|
49
|
+
const { format, sources, trieBase, sort = true, generateNonStrict = false, excludeWordsFrom } = target;
|
|
50
50
|
const targetDirectory = path.resolve(rootDir, target.targetDirectory ?? cwd ?? process.cwd());
|
|
51
|
+
const excludeFilter = await createExcludeFilter(excludeWordsFrom);
|
|
51
52
|
const generateNonStrictTrie = target.generateNonStrict ?? true;
|
|
52
53
|
const name = normalizeTargetName(target.name);
|
|
53
54
|
const useTrie = format.startsWith('trie');
|
|
54
55
|
const filename = resolveTarget(name, targetDirectory, useTrie, target.compress ?? false);
|
|
55
56
|
const filesToProcessAsync = pipeAsync(readSourceList(sources, rootDir), opMapAsync((src) => readFileSource(src, options)), opAwaitAsync());
|
|
56
57
|
const filesToProcess = await toArray(filesToProcessAsync);
|
|
57
|
-
const normalizer = normalizeTargetWords({ sort: useTrie || sort, generateNonStrict });
|
|
58
|
+
const normalizer = normalizeTargetWords({ sort: useTrie || sort, generateNonStrict, filter: excludeFilter });
|
|
58
59
|
const checksumRoot = (checksumFile && path.dirname(checksumFile)) || rootDir;
|
|
59
|
-
const deps = [...calculateDependencies(filename, filesToProcess, checksumRoot)];
|
|
60
|
+
const deps = [...calculateDependencies(filename, filesToProcess, excludeWordsFrom, checksumRoot)];
|
|
60
61
|
if (conditional && checksumFile) {
|
|
61
62
|
const check = await checkShasumFile(checksumFile, deps, checksumRoot).catch(() => undefined);
|
|
62
63
|
if (check?.passed) {
|
|
@@ -81,9 +82,10 @@ export async function compileTarget(target, options, compileOptions) {
|
|
|
81
82
|
logWithTimestamp(`Done compile: ${target.name}`);
|
|
82
83
|
return deps;
|
|
83
84
|
}
|
|
84
|
-
function calculateDependencies(targetFile, filesToProcess, rootDir) {
|
|
85
|
+
function calculateDependencies(targetFile, filesToProcess, excludeFiles, rootDir) {
|
|
85
86
|
const dependencies = new Set();
|
|
86
87
|
addDependency(targetFile);
|
|
88
|
+
excludeFiles?.forEach((f) => addDependency(f));
|
|
87
89
|
filesToProcess.forEach((f) => addDependency(f.src));
|
|
88
90
|
return dependencies;
|
|
89
91
|
function addDependency(filename) {
|
|
@@ -187,4 +189,10 @@ function logProgress(freq = 100000) {
|
|
|
187
189
|
}
|
|
188
190
|
return logProgress;
|
|
189
191
|
}
|
|
192
|
+
async function createExcludeFilter(excludeWordsFrom) {
|
|
193
|
+
if (!excludeWordsFrom || !excludeWordsFrom.length)
|
|
194
|
+
return () => true;
|
|
195
|
+
const excludeWords = await createWordsCollectionFromFiles(excludeWordsFrom);
|
|
196
|
+
return (word) => !excludeWords.has(word);
|
|
197
|
+
}
|
|
190
198
|
//# sourceMappingURL=compile.js.map
|
|
@@ -13,6 +13,7 @@ export function normalizeTargetWords(options) {
|
|
|
13
13
|
lineParser,
|
|
14
14
|
options.sort ? createInlineBufferedSort(10000) : undefined,
|
|
15
15
|
opFilter(uniqueFilter(10000)),
|
|
16
|
+
options.filter ? opFilter(options.filter) : undefined,
|
|
16
17
|
].filter(isDefined);
|
|
17
18
|
return opCombine(...operations);
|
|
18
19
|
}
|
package/dist/config/config.d.ts
CHANGED
|
@@ -86,7 +86,7 @@ export interface Target extends CompileTargetOptions {
|
|
|
86
86
|
* Words from the sources that are found in `excludeWordsFrom` files
|
|
87
87
|
* will not be added to the dictionary.
|
|
88
88
|
*
|
|
89
|
-
* @version
|
|
89
|
+
* @version 8.3.2
|
|
90
90
|
*/
|
|
91
91
|
excludeWordsFrom?: FilePath[] | undefined;
|
|
92
92
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cspell/cspell-tools",
|
|
3
|
-
"version": "8.
|
|
3
|
+
"version": "8.4.0",
|
|
4
4
|
"description": "Tools to assist with the development of cSpell",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -49,13 +49,13 @@
|
|
|
49
49
|
},
|
|
50
50
|
"homepage": "https://github.com/streetsidesoftware/cspell#readme",
|
|
51
51
|
"dependencies": {
|
|
52
|
-
"@cspell/cspell-pipe": "8.
|
|
53
|
-
"commander": "^
|
|
52
|
+
"@cspell/cspell-pipe": "8.4.0",
|
|
53
|
+
"commander": "^12.0.0",
|
|
54
54
|
"cosmiconfig": "9.0.0",
|
|
55
|
-
"cspell-trie-lib": "8.
|
|
55
|
+
"cspell-trie-lib": "8.4.0",
|
|
56
56
|
"gensequence": "^6.0.0",
|
|
57
57
|
"glob": "^10.3.10",
|
|
58
|
-
"hunspell-reader": "8.
|
|
58
|
+
"hunspell-reader": "8.4.0",
|
|
59
59
|
"yaml": "^2.3.4"
|
|
60
60
|
},
|
|
61
61
|
"engines": {
|
|
@@ -67,5 +67,5 @@
|
|
|
67
67
|
"ts-json-schema-generator": "^1.5.0"
|
|
68
68
|
},
|
|
69
69
|
"module": "bin.mjs",
|
|
70
|
-
"gitHead": "
|
|
70
|
+
"gitHead": "f9ad457ca2102c6642c377417a95a4415f5ec3d8"
|
|
71
71
|
}
|