@cspell/cspell-tools 10.3.0 → 10.3.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.
|
@@ -155,6 +155,13 @@
|
|
|
155
155
|
],
|
|
156
156
|
"type": "object"
|
|
157
157
|
},
|
|
158
|
+
"Replacements": {
|
|
159
|
+
"additionalProperties": {
|
|
160
|
+
"type": "string"
|
|
161
|
+
},
|
|
162
|
+
"description": "Replacement rules to apply to the words in the dictionary. The key is the pattern to match, and the value is the replacement string.",
|
|
163
|
+
"type": "object"
|
|
164
|
+
},
|
|
158
165
|
"Target": {
|
|
159
166
|
"additionalProperties": false,
|
|
160
167
|
"properties": {
|
|
@@ -238,6 +245,10 @@
|
|
|
238
245
|
"description": "Remove duplicate words, favor lower case words over mixed case words. Combine compound prefixes where possible.",
|
|
239
246
|
"type": "boolean"
|
|
240
247
|
},
|
|
248
|
+
"replacements": {
|
|
249
|
+
"$ref": "#/definitions/Replacements",
|
|
250
|
+
"description": "Replacement rules to apply to the words in the dictionary. The key is the pattern to match, and the value is the replacement string."
|
|
251
|
+
},
|
|
241
252
|
"sort": {
|
|
242
253
|
"default": true,
|
|
243
254
|
"description": "Sort the words in the resulting dictionary. Does not apply to `trie` based formats.",
|
package/dist/app.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as reportCheckChecksumFile, c as toError, i as logWithTimestamp, l as generateBTrie, n as compile, o as reportChecksumForFiles, r as setLogger, s as updateChecksumForFiles, t as build, u as compressFile } from "./build-
|
|
1
|
+
import { a as reportCheckChecksumFile, c as toError, i as logWithTimestamp, l as generateBTrie, n as compile, o as reportChecksumForFiles, r as setLogger, s as updateChecksumForFiles, t as build, u as compressFile } from "./build-53OrzuaV.mjs";
|
|
2
2
|
import { readFileSync } from "node:fs";
|
|
3
3
|
import { CommanderError, Option } from "commander";
|
|
4
4
|
import { writeFile } from "node:fs/promises";
|
|
@@ -52,7 +52,8 @@ function calcTargets(sources, options) {
|
|
|
52
52
|
sources: sources.map(normalizeSource),
|
|
53
53
|
sort,
|
|
54
54
|
trieBase: parseNumber(options.trieBase),
|
|
55
|
-
generateNonStrict
|
|
55
|
+
generateNonStrict,
|
|
56
|
+
replacements: void 0
|
|
56
57
|
}];
|
|
57
58
|
return sources.map((source) => {
|
|
58
59
|
return {
|
|
@@ -63,7 +64,8 @@ function calcTargets(sources, options) {
|
|
|
63
64
|
sources: [normalizeSource(source)],
|
|
64
65
|
sort: options.sort,
|
|
65
66
|
trieBase: parseNumber(options.trieBase),
|
|
66
|
-
generateNonStrict
|
|
67
|
+
generateNonStrict,
|
|
68
|
+
replacements: void 0
|
|
67
69
|
};
|
|
68
70
|
});
|
|
69
71
|
}
|
|
@@ -736,7 +736,8 @@ function normalizeTargetWords(options) {
|
|
|
736
736
|
lineParser,
|
|
737
737
|
options.sort ? createInlineBufferedSort(1e4) : void 0,
|
|
738
738
|
opFilter(uniqueFilter(1e4)),
|
|
739
|
-
options.filter ? opFilter(options.filter) : void 0
|
|
739
|
+
options.filter ? opFilter(options.filter) : void 0,
|
|
740
|
+
replacementsToMapOperator(options.replacements)
|
|
740
741
|
].filter(isDefined);
|
|
741
742
|
return opCombine(...operations);
|
|
742
743
|
}
|
|
@@ -879,6 +880,13 @@ function createParseFileLineMapper(options) {
|
|
|
879
880
|
function parseFileLines(lines, options) {
|
|
880
881
|
return createParseFileLineMapper(options)(typeof lines === "string" ? [lines] : lines);
|
|
881
882
|
}
|
|
883
|
+
function replacementsToMapOperator(replacements) {
|
|
884
|
+
if (!replacements) return void 0;
|
|
885
|
+
return opMap((word) => {
|
|
886
|
+
for (const [pattern, replacement] of Object.entries(replacements)) word = word.replaceAll(pattern, replacement);
|
|
887
|
+
return word;
|
|
888
|
+
});
|
|
889
|
+
}
|
|
882
890
|
//#endregion
|
|
883
891
|
//#region src/compiler/SourceReader.ts
|
|
884
892
|
async function createSourceReader(filename, options) {
|
|
@@ -1082,7 +1090,8 @@ async function compile(request, options) {
|
|
|
1082
1090
|
const targetOptions = {
|
|
1083
1091
|
sort: request.sort,
|
|
1084
1092
|
generateNonStrict: request.generateNonStrict,
|
|
1085
|
-
removeDuplicates: request.removeDuplicates
|
|
1093
|
+
removeDuplicates: request.removeDuplicates,
|
|
1094
|
+
replacements: void 0
|
|
1086
1095
|
};
|
|
1087
1096
|
const conditional = options?.conditionalBuild || false;
|
|
1088
1097
|
const checksumFile = resolveChecksumFile(request.checksumFile || conditional, rootDir);
|
|
@@ -1141,7 +1150,7 @@ function genBuildTargetDictionaryOptions(target, compileOptions) {
|
|
|
1141
1150
|
}
|
|
1142
1151
|
async function buildTargetDictionary(target, options, compileOptions, buildOptions) {
|
|
1143
1152
|
const { rootDir, checksumFile, conditional } = compileOptions;
|
|
1144
|
-
const { format, sources, trieBase, sort = true, generateNonStrict = false, excludeWordsFrom = [], excludeWordsNotFoundIn = [], excludeWordsMatchingRegex } = target;
|
|
1153
|
+
const { format, sources, trieBase, sort = true, generateNonStrict = false, excludeWordsFrom = [], excludeWordsNotFoundIn = [], excludeWordsMatchingRegex, replacements } = target;
|
|
1145
1154
|
const { filename, useTrie, generateOnlyCompressedDictionary, checksumRoot } = buildOptions;
|
|
1146
1155
|
const dictionaryDirectives = target.dictionaryDirectives ?? compileOptions.dictionaryDirectives;
|
|
1147
1156
|
const removeDuplicates = target.removeDuplicates ?? false;
|
|
@@ -1158,7 +1167,8 @@ async function buildTargetDictionary(target, options, compileOptions, buildOptio
|
|
|
1158
1167
|
sort: useTrie || sort,
|
|
1159
1168
|
generateNonStrict,
|
|
1160
1169
|
filter: excludeFilter,
|
|
1161
|
-
dictionaryDirectives
|
|
1170
|
+
dictionaryDirectives,
|
|
1171
|
+
replacements
|
|
1162
1172
|
});
|
|
1163
1173
|
const deps = [...calculateDependencies(filename + (compress ? ".gz" : ""), filesToProcess, [...excludeWordsFrom, ...excludeWordsNotFoundIn], checksumRoot)];
|
|
1164
1174
|
if (conditional && checksumFile) {
|
|
@@ -1176,7 +1186,8 @@ async function buildTargetDictionary(target, options, compileOptions, buildOptio
|
|
|
1176
1186
|
sort,
|
|
1177
1187
|
generateNonStrict,
|
|
1178
1188
|
dictionaryDirectives,
|
|
1179
|
-
removeDuplicates
|
|
1189
|
+
removeDuplicates,
|
|
1190
|
+
replacements
|
|
1180
1191
|
});
|
|
1181
1192
|
await createTargetFile(dst, iterableToString(pipe(words, normalizer, compiler)), compress);
|
|
1182
1193
|
}
|
|
@@ -1385,4 +1396,4 @@ function normalizeRequest(buildInfo, root) {
|
|
|
1385
1396
|
//#endregion
|
|
1386
1397
|
export { reportCheckChecksumFile as a, toError as c, logWithTimestamp as i, generateBTrie as l, compile as n, reportChecksumForFiles as o, setLogger as r, updateChecksumForFiles as s, build as t, compressFile as u };
|
|
1387
1398
|
|
|
1388
|
-
//# sourceMappingURL=build-
|
|
1399
|
+
//# sourceMappingURL=build-53OrzuaV.mjs.map
|
package/dist/index.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { l as generateBTrie, t as build } from "./build-
|
|
1
|
+
import { l as generateBTrie, t as build } from "./build-53OrzuaV.mjs";
|
|
2
2
|
export { build, generateBTrie };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cspell/cspell-tools",
|
|
3
|
-
"version": "10.3.0",
|
|
3
|
+
"version": "10.3.1-alpha.0",
|
|
4
4
|
"description": "Tools to assist with the development of cSpell",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public",
|
|
@@ -65,12 +65,12 @@
|
|
|
65
65
|
},
|
|
66
66
|
"homepage": "https://github.com/streetsidesoftware/cspell/tree/main/packages/cspell-tools#readme",
|
|
67
67
|
"dependencies": {
|
|
68
|
-
"@cspell/cspell-pipe": "10.3.0",
|
|
68
|
+
"@cspell/cspell-pipe": "10.3.1-alpha.0",
|
|
69
69
|
"commander": "^15.0.0",
|
|
70
70
|
"cosmiconfig": "10.0.1",
|
|
71
|
-
"cspell-trie-lib": "10.3.0",
|
|
71
|
+
"cspell-trie-lib": "10.3.1-alpha.0",
|
|
72
72
|
"glob": "^13.0.6",
|
|
73
|
-
"hunspell-reader": "10.3.0",
|
|
73
|
+
"hunspell-reader": "10.3.1-alpha.0",
|
|
74
74
|
"yaml": "^2.9.0"
|
|
75
75
|
},
|
|
76
76
|
"engines": {
|
|
@@ -80,5 +80,5 @@
|
|
|
80
80
|
"lorem-ipsum": "^3.0.0",
|
|
81
81
|
"ts-json-schema-generator": "2.9.0"
|
|
82
82
|
},
|
|
83
|
-
"gitHead": "
|
|
83
|
+
"gitHead": "1fee574fa870bffd6296aef8a9c68115b9589933"
|
|
84
84
|
}
|