@cspell/cspell-tools 8.10.0 → 8.10.2
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.
|
@@ -144,6 +144,13 @@
|
|
|
144
144
|
"description": "gzip the file?",
|
|
145
145
|
"type": "boolean"
|
|
146
146
|
},
|
|
147
|
+
"dictionaryDirectives": {
|
|
148
|
+
"description": "Injects `cspell-dictionary` directives into the dictionary header.\n\nExample:\n\n```ini # cspell-dictionary: no-generate-alternatives ```\n\nKnown Directives: ```yaml\n- split # Tell the dictionary loader to split words\n- no-split # Tell the dictionary loader to not split words (default)\n- generate-alternatives # Tell the dictionary loader to generate alternate spellings (default)\n- no-generate-alternatives # Tell the dictionary loader to not generate alternate spellings ```",
|
|
149
|
+
"items": {
|
|
150
|
+
"type": "string"
|
|
151
|
+
},
|
|
152
|
+
"type": "array"
|
|
153
|
+
},
|
|
147
154
|
"excludeWordsFrom": {
|
|
148
155
|
"description": "Words from the sources that are found in `excludeWordsFrom` files will not be added to the dictionary.",
|
|
149
156
|
"items": {
|
|
@@ -156,7 +163,7 @@
|
|
|
156
163
|
"description": "Format of the dictionary."
|
|
157
164
|
},
|
|
158
165
|
"generateNonStrict": {
|
|
159
|
-
"default":
|
|
166
|
+
"default": false,
|
|
160
167
|
"description": "Generate lower case / accent free versions of words.",
|
|
161
168
|
"type": "boolean"
|
|
162
169
|
},
|
|
@@ -165,7 +172,7 @@
|
|
|
165
172
|
"type": "string"
|
|
166
173
|
},
|
|
167
174
|
"sort": {
|
|
168
|
-
"default":
|
|
175
|
+
"default": true,
|
|
169
176
|
"description": "Sort the words in the resulting dictionary. Does not apply to `trie` based formats.",
|
|
170
177
|
"type": "boolean"
|
|
171
178
|
},
|
|
@@ -221,8 +228,15 @@
|
|
|
221
228
|
"boolean"
|
|
222
229
|
]
|
|
223
230
|
},
|
|
231
|
+
"dictionaryDirectives": {
|
|
232
|
+
"description": "Injects `cspell-dictionary` directives into the dictionary header.\n\nExample:\n\n```ini # cspell-dictionary: no-generate-alternatives ```\n\nKnown Directives: ```yaml\n- split # Tell the dictionary loader to split words\n- no-split # Tell the dictionary loader to not split words (default)\n- generate-alternatives # Tell the dictionary loader to generate alternate spellings (default)\n- no-generate-alternatives # Tell the dictionary loader to not generate alternate spellings ```",
|
|
233
|
+
"items": {
|
|
234
|
+
"type": "string"
|
|
235
|
+
},
|
|
236
|
+
"type": "array"
|
|
237
|
+
},
|
|
224
238
|
"generateNonStrict": {
|
|
225
|
-
"default":
|
|
239
|
+
"default": false,
|
|
226
240
|
"description": "Generate lower case / accent free versions of words.",
|
|
227
241
|
"type": "boolean"
|
|
228
242
|
},
|
|
@@ -240,7 +254,7 @@
|
|
|
240
254
|
"type": "string"
|
|
241
255
|
},
|
|
242
256
|
"sort": {
|
|
243
|
-
"default":
|
|
257
|
+
"default": true,
|
|
244
258
|
"description": "Sort the words in the resulting dictionary. Does not apply to `trie` based formats.",
|
|
245
259
|
"type": "boolean"
|
|
246
260
|
},
|
|
@@ -14,5 +14,16 @@ export interface CompileOptions {
|
|
|
14
14
|
* @returns `true` to keep the word, `false` to exclude it.
|
|
15
15
|
*/
|
|
16
16
|
filter?: (word: string) => boolean;
|
|
17
|
+
/**
|
|
18
|
+
* Injects `cspell-dictionary` directives into the dictionary header.
|
|
19
|
+
*
|
|
20
|
+
* Example:
|
|
21
|
+
*
|
|
22
|
+
* ```ini
|
|
23
|
+
* # cspell-dictionary: no-generate-alternatives
|
|
24
|
+
* ```
|
|
25
|
+
*
|
|
26
|
+
*/
|
|
27
|
+
dictionaryDirectives?: string[] | undefined;
|
|
17
28
|
}
|
|
18
29
|
//# sourceMappingURL=CompileOptions.d.ts.map
|
|
@@ -19,6 +19,7 @@ interface CompileTargetOptions {
|
|
|
19
19
|
cwd: string | undefined;
|
|
20
20
|
conditional: boolean;
|
|
21
21
|
checksumFile: string | undefined;
|
|
22
|
+
dictionaryDirectives: string[] | undefined;
|
|
22
23
|
}
|
|
23
24
|
export declare function compileTarget(target: Target, options: CompileSourceConfig, compileOptions: CompileTargetOptions): Promise<string[]>;
|
|
24
25
|
export {};
|
package/dist/compiler/compile.js
CHANGED
|
@@ -21,13 +21,20 @@ export async function compile(request, options) {
|
|
|
21
21
|
};
|
|
22
22
|
const conditional = options?.conditionalBuild || false;
|
|
23
23
|
const checksumFile = resolveChecksumFile(request.checksumFile || conditional, rootDir);
|
|
24
|
+
const dictionaryDirectives = request.dictionaryDirectives;
|
|
24
25
|
const dependencies = new Set();
|
|
25
26
|
for (const target of targets) {
|
|
26
27
|
const keep = options?.filter?.(target) ?? true;
|
|
27
28
|
if (!keep)
|
|
28
29
|
continue;
|
|
29
30
|
const adjustedTarget = { ...targetOptions, ...target };
|
|
30
|
-
const deps = await compileTarget(adjustedTarget, request, {
|
|
31
|
+
const deps = await compileTarget(adjustedTarget, request, {
|
|
32
|
+
rootDir,
|
|
33
|
+
cwd,
|
|
34
|
+
conditional,
|
|
35
|
+
checksumFile,
|
|
36
|
+
dictionaryDirectives,
|
|
37
|
+
});
|
|
31
38
|
deps.forEach((dep) => dependencies.add(dep));
|
|
32
39
|
}
|
|
33
40
|
if (checksumFile && dependencies.size) {
|
|
@@ -48,6 +55,7 @@ export async function compileTarget(target, options, compileOptions) {
|
|
|
48
55
|
const { rootDir, cwd, checksumFile, conditional } = compileOptions;
|
|
49
56
|
const { format, sources, trieBase, sort = true, generateNonStrict = false, excludeWordsFrom } = target;
|
|
50
57
|
const targetDirectory = path.resolve(rootDir, target.targetDirectory ?? cwd ?? process.cwd());
|
|
58
|
+
const dictionaryDirectives = compileOptions.dictionaryDirectives;
|
|
51
59
|
const excludeFilter = await createExcludeFilter(excludeWordsFrom);
|
|
52
60
|
const generateNonStrictTrie = target.generateNonStrict ?? true;
|
|
53
61
|
const name = normalizeTargetName(target.name);
|
|
@@ -55,7 +63,12 @@ export async function compileTarget(target, options, compileOptions) {
|
|
|
55
63
|
const filename = resolveTarget(name, targetDirectory, useTrie, target.compress ?? false);
|
|
56
64
|
const filesToProcessAsync = pipeAsync(readSourceList(sources, rootDir), opMapAsync((src) => readFileSource(src, options)), opAwaitAsync());
|
|
57
65
|
const filesToProcess = await toArray(filesToProcessAsync);
|
|
58
|
-
const normalizer = normalizeTargetWords({
|
|
66
|
+
const normalizer = normalizeTargetWords({
|
|
67
|
+
sort: useTrie || sort,
|
|
68
|
+
generateNonStrict,
|
|
69
|
+
filter: excludeFilter,
|
|
70
|
+
dictionaryDirectives,
|
|
71
|
+
});
|
|
59
72
|
const checksumRoot = (checksumFile && path.dirname(checksumFile)) || rootDir;
|
|
60
73
|
const deps = [...calculateDependencies(filename, filesToProcess, excludeWordsFrom, checksumRoot)];
|
|
61
74
|
if (conditional && checksumFile) {
|
|
@@ -73,10 +86,11 @@ export async function compileTarget(target, options, compileOptions) {
|
|
|
73
86
|
trie3: format === 'trie3',
|
|
74
87
|
trie4: format === 'trie4',
|
|
75
88
|
generateNonStrict: generateNonStrictTrie,
|
|
89
|
+
dictionaryDirectives: undefined,
|
|
76
90
|
});
|
|
77
91
|
}
|
|
78
92
|
: async (words, dst) => {
|
|
79
|
-
return compileWordList(pipe(words, normalizer), dst, { sort, generateNonStrict });
|
|
93
|
+
return compileWordList(pipe(words, normalizer), dst, { sort, generateNonStrict, dictionaryDirectives });
|
|
80
94
|
};
|
|
81
95
|
await processFiles(action, filesToProcess, filename);
|
|
82
96
|
logWithTimestamp(`Done compile: ${target.name}`);
|
|
@@ -10,12 +10,13 @@ const mkdirp = async (p) => {
|
|
|
10
10
|
};
|
|
11
11
|
// Indicate that a word list has already been processed.
|
|
12
12
|
const wordListHeader = `
|
|
13
|
-
# cspell-tools: keep-case no-split
|
|
14
|
-
`;
|
|
13
|
+
# cspell-tools: keep-case no-split`;
|
|
15
14
|
const wordListHeaderLines = wordListHeader.split('\n').map((a) => a.trim());
|
|
16
15
|
export async function compileWordList(lines, destFilename, options) {
|
|
17
16
|
const finalLines = normalize(lines, options);
|
|
18
|
-
const
|
|
17
|
+
const directives = options.dictionaryDirectives ?? [];
|
|
18
|
+
const directivesLines = directives.map((a) => `# cspell-dictionary: ${a}`);
|
|
19
|
+
const finalSeq = pipe([...wordListHeaderLines, ...directivesLines, ''], opAppend(finalLines));
|
|
19
20
|
return createWordListTarget(destFilename)(finalSeq);
|
|
20
21
|
}
|
|
21
22
|
function normalize(lines, options) {
|
package/dist/config/config.d.ts
CHANGED
|
@@ -39,13 +39,13 @@ export interface Experimental {
|
|
|
39
39
|
export interface CompileTargetOptions {
|
|
40
40
|
/**
|
|
41
41
|
* Generate lower case / accent free versions of words.
|
|
42
|
-
* @default
|
|
42
|
+
* @default false
|
|
43
43
|
*/
|
|
44
44
|
generateNonStrict?: boolean | undefined;
|
|
45
45
|
/**
|
|
46
46
|
* Sort the words in the resulting dictionary.
|
|
47
47
|
* Does not apply to `trie` based formats.
|
|
48
|
-
* @default
|
|
48
|
+
* @default true
|
|
49
49
|
*/
|
|
50
50
|
sort?: boolean | undefined;
|
|
51
51
|
/**
|
|
@@ -58,6 +58,24 @@ export interface CompileTargetOptions {
|
|
|
58
58
|
* dictionary.
|
|
59
59
|
*/
|
|
60
60
|
allowedSplitWords?: FilePath | FilePath[] | undefined;
|
|
61
|
+
/**
|
|
62
|
+
* Injects `cspell-dictionary` directives into the dictionary header.
|
|
63
|
+
*
|
|
64
|
+
* Example:
|
|
65
|
+
*
|
|
66
|
+
* ```ini
|
|
67
|
+
* # cspell-dictionary: no-generate-alternatives
|
|
68
|
+
* ```
|
|
69
|
+
*
|
|
70
|
+
* Known Directives:
|
|
71
|
+
* ```yaml
|
|
72
|
+
* - split # Tell the dictionary loader to split words
|
|
73
|
+
* - no-split # Tell the dictionary loader to not split words (default)
|
|
74
|
+
* - generate-alternatives # Tell the dictionary loader to generate alternate spellings (default)
|
|
75
|
+
* - no-generate-alternatives # Tell the dictionary loader to not generate alternate spellings
|
|
76
|
+
* ```
|
|
77
|
+
*/
|
|
78
|
+
dictionaryDirectives?: string[] | undefined;
|
|
61
79
|
}
|
|
62
80
|
export interface Target extends CompileTargetOptions {
|
|
63
81
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cspell/cspell-tools",
|
|
3
|
-
"version": "8.10.
|
|
3
|
+
"version": "8.10.2",
|
|
4
4
|
"description": "Tools to assist with the development of cSpell",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -50,13 +50,13 @@
|
|
|
50
50
|
},
|
|
51
51
|
"homepage": "https://github.com/streetsidesoftware/cspell#readme",
|
|
52
52
|
"dependencies": {
|
|
53
|
-
"@cspell/cspell-pipe": "8.10.
|
|
53
|
+
"@cspell/cspell-pipe": "8.10.2",
|
|
54
54
|
"commander": "^12.1.0",
|
|
55
55
|
"cosmiconfig": "9.0.0",
|
|
56
|
-
"cspell-trie-lib": "8.10.
|
|
56
|
+
"cspell-trie-lib": "8.10.2",
|
|
57
57
|
"gensequence": "^7.0.0",
|
|
58
58
|
"glob": "^10.4.2",
|
|
59
|
-
"hunspell-reader": "8.10.
|
|
59
|
+
"hunspell-reader": "8.10.2",
|
|
60
60
|
"yaml": "^2.4.5"
|
|
61
61
|
},
|
|
62
62
|
"engines": {
|
|
@@ -68,5 +68,5 @@
|
|
|
68
68
|
"ts-json-schema-generator": "^2.3.0"
|
|
69
69
|
},
|
|
70
70
|
"module": "bin.mjs",
|
|
71
|
-
"gitHead": "
|
|
71
|
+
"gitHead": "1a1f15b593a0b25419c1e74eeb53d0b2839762cc"
|
|
72
72
|
}
|