@cspell/cspell-tools 10.0.0 → 10.1.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.mts +3 -4
- package/dist/app.mjs +12 -5
- package/dist/{build-JrGA5AHH.mjs → build-DPX1iG-1.mjs} +47 -63
- package/dist/index.mjs +1 -1
- package/package.json +9 -9
package/dist/app.d.mts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { Command } from "commander";
|
|
2
|
-
|
|
3
2
|
//#region src/FeatureFlags/FeatureFlags.d.ts
|
|
4
3
|
interface FeatureFlag {
|
|
5
4
|
name: string;
|
|
@@ -7,9 +6,9 @@ interface FeatureFlag {
|
|
|
7
6
|
}
|
|
8
7
|
type FlagTypes = string | boolean;
|
|
9
8
|
/**
|
|
10
|
-
* Feature Flags are used to turn on/off features.
|
|
11
|
-
* These are primarily used before a feature has been fully released.
|
|
12
|
-
*/
|
|
9
|
+
* Feature Flags are used to turn on/off features.
|
|
10
|
+
* These are primarily used before a feature has been fully released.
|
|
11
|
+
*/
|
|
13
12
|
declare class FeatureFlags {
|
|
14
13
|
private flags;
|
|
15
14
|
private flagValues;
|
package/dist/app.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as reportCheckChecksumFile, c as toError,
|
|
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-DPX1iG-1.mjs";
|
|
2
2
|
import { readFileSync } from "node:fs";
|
|
3
3
|
import { CommanderError, Option } from "commander";
|
|
4
4
|
import { writeFile } from "node:fs/promises";
|
|
@@ -8,7 +8,8 @@ import { opConcatMap, pipe } from "@cspell/cspell-pipe/sync";
|
|
|
8
8
|
import YAML from "yaml";
|
|
9
9
|
//#region src/util/globP.ts
|
|
10
10
|
function globP(pattern, options) {
|
|
11
|
-
|
|
11
|
+
const globs = (Array.isArray(pattern) ? pattern : [pattern]).map((pattern) => pattern.replaceAll("\\", "/"));
|
|
12
|
+
return glob(globs, options);
|
|
12
13
|
}
|
|
13
14
|
//#endregion
|
|
14
15
|
//#region src/gzip/gzip.ts
|
|
@@ -31,6 +32,10 @@ function createCompileRequest(sourceFiles, options) {
|
|
|
31
32
|
targets: calcTargets([...sourceFiles, ...(options.listFile || []).map((listFile) => ({ listFile }))], options),
|
|
32
33
|
maxDepth: parseNumber(maxDepth),
|
|
33
34
|
split: useLegacySplitter ? "legacy" : split,
|
|
35
|
+
/**
|
|
36
|
+
* Do not generate lower case / accent free versions of words.
|
|
37
|
+
* @default false
|
|
38
|
+
*/
|
|
34
39
|
keepRawCase
|
|
35
40
|
};
|
|
36
41
|
}
|
|
@@ -91,7 +96,7 @@ function normalizeSource(source) {
|
|
|
91
96
|
}
|
|
92
97
|
function normalizeSourcePath(source) {
|
|
93
98
|
const cwd = process.cwd();
|
|
94
|
-
return path.relative(cwd, source).
|
|
99
|
+
return path.relative(cwd, source).replaceAll("\\", "/");
|
|
95
100
|
}
|
|
96
101
|
//#endregion
|
|
97
102
|
//#region src/config/config.ts
|
|
@@ -160,6 +165,7 @@ var FeatureFlags = class FeatureFlags {
|
|
|
160
165
|
}
|
|
161
166
|
};
|
|
162
167
|
var UnknownFeatureFlagError = class extends Error {
|
|
168
|
+
flag;
|
|
163
169
|
constructor(flag) {
|
|
164
170
|
super(`Unknown feature flag: ${flag}`);
|
|
165
171
|
this.flag = flag;
|
|
@@ -219,7 +225,8 @@ async function useCompile(src, options) {
|
|
|
219
225
|
console.log("Compile:\n output: %s\n compress: %s\n files:\n %s", options.output || "default", options.compress ? "true" : "false", src.join("\n "));
|
|
220
226
|
if (options.listFile && options.listFile.length) console.log(" list files:\n %s", options.listFile.join("\n "));
|
|
221
227
|
console.log("\n\n");
|
|
222
|
-
const
|
|
228
|
+
const globResults = await Promise.all(src.map((s) => globP(s)));
|
|
229
|
+
const request = createCompileRequest([...pipe(globResults, opConcatMap((a) => a))], options);
|
|
223
230
|
return options.init ? initConfig(request) : compile(request);
|
|
224
231
|
}
|
|
225
232
|
async function initConfig(runConfig) {
|
|
@@ -250,7 +257,7 @@ function addCompileOptions(compileCommand) {
|
|
|
250
257
|
async function run(program, argv, flags) {
|
|
251
258
|
async function handleGzip(files) {
|
|
252
259
|
try {
|
|
253
|
-
await gzipFiles(files,
|
|
260
|
+
await gzipFiles(files, 3);
|
|
254
261
|
} catch (error) {
|
|
255
262
|
const err = toError(error);
|
|
256
263
|
program.error(err.message);
|
|
@@ -17,20 +17,12 @@ import { Buffer } from "node:buffer";
|
|
|
17
17
|
//#region src/gzip/compressFiles.ts
|
|
18
18
|
const gzip$1 = promisify(gzip);
|
|
19
19
|
const gunzip$1 = promisify(gunzip);
|
|
20
|
-
let OSFlags = /* @__PURE__ */ function(OSFlags) {
|
|
21
|
-
OSFlags[OSFlags["auto"] = -1] = "auto";
|
|
22
|
-
OSFlags[OSFlags["FAT"] = 0] = "FAT";
|
|
23
|
-
OSFlags[OSFlags["Unix"] = 3] = "Unix";
|
|
24
|
-
OSFlags[OSFlags["HPFS"] = 6] = "HPFS";
|
|
25
|
-
OSFlags[OSFlags["MACOS"] = 7] = "MACOS";
|
|
26
|
-
OSFlags[OSFlags["NTFS"] = 11] = "NTFS";
|
|
27
|
-
return OSFlags;
|
|
28
|
-
}({});
|
|
29
20
|
const OSSystemIDOffset = 9;
|
|
30
21
|
async function compressFile(file, os) {
|
|
31
22
|
if (file.endsWith(".gz")) return file;
|
|
32
23
|
const targetFile = file + ".gz";
|
|
33
|
-
|
|
24
|
+
const zBuf = await compress(await readFile(file), os);
|
|
25
|
+
await writeFile(targetFile, zBuf);
|
|
34
26
|
return targetFile;
|
|
35
27
|
}
|
|
36
28
|
async function compress(buf, os) {
|
|
@@ -53,8 +45,9 @@ function isGZipped(data) {
|
|
|
53
45
|
if (typeof data === "string") return false;
|
|
54
46
|
return data[0] === 31 && data[1] === 139;
|
|
55
47
|
}
|
|
56
|
-
function fixOSSystemID(zBuf, os =
|
|
57
|
-
|
|
48
|
+
function fixOSSystemID(zBuf, os = 3) {
|
|
49
|
+
const osFlag = os === -1 ? zBuf[OSSystemIDOffset] : os;
|
|
50
|
+
zBuf[OSSystemIDOffset] = osFlag;
|
|
58
51
|
return zBuf;
|
|
59
52
|
}
|
|
60
53
|
async function decompress(buf, encoding) {
|
|
@@ -199,7 +192,9 @@ var TrieFileReader = class TrieFileReader {
|
|
|
199
192
|
}
|
|
200
193
|
static async create(filename) {
|
|
201
194
|
const rawBuffer = await readFile(filename);
|
|
202
|
-
|
|
195
|
+
const buffer = filename.endsWith(".gz") ? gunzipSync(rawBuffer) : rawBuffer;
|
|
196
|
+
const trie = decodeTrie(buffer);
|
|
197
|
+
return new TrieFileReader(filename, trie);
|
|
203
198
|
}
|
|
204
199
|
};
|
|
205
200
|
//#endregion
|
|
@@ -255,7 +250,8 @@ function bTrieFileName(inputFilename, options) {
|
|
|
255
250
|
return filename;
|
|
256
251
|
}
|
|
257
252
|
async function createBTrieFromFile(file, buildOptions) {
|
|
258
|
-
|
|
253
|
+
const trie = (await createReader(file, {})).toTrie();
|
|
254
|
+
return encodeTrieDataToBTrie(trie.data, buildOptions);
|
|
259
255
|
}
|
|
260
256
|
//#endregion
|
|
261
257
|
//#region src/bTrie.ts
|
|
@@ -431,7 +427,7 @@ async function calcUpdateChecksumForFiles(filename, files, options) {
|
|
|
431
427
|
...entry,
|
|
432
428
|
filename: normalizeFilename(entry.filename)
|
|
433
429
|
}));
|
|
434
|
-
const entriesToUpdate = new Set([...filesToCheck, ...currentEntries.map((e) => e.filename)]);
|
|
430
|
+
const entriesToUpdate = /* @__PURE__ */ new Set([...filesToCheck, ...currentEntries.map((e) => e.filename)]);
|
|
435
431
|
const mustExist = new Set(filesToCheck);
|
|
436
432
|
const checksumMap = new Map(currentEntries.map(({ filename, checksum }) => [filename, checksum]));
|
|
437
433
|
for (const file of entriesToUpdate) try {
|
|
@@ -735,13 +731,14 @@ function normalizeTargetWords(options) {
|
|
|
735
731
|
stripCaseAndAccentsOnForbidden: true,
|
|
736
732
|
keepOptionalCompoundCharacter: true
|
|
737
733
|
});
|
|
738
|
-
|
|
734
|
+
const operations = [
|
|
739
735
|
opFilter((a) => !!a),
|
|
740
736
|
lineParser,
|
|
741
737
|
options.sort ? createInlineBufferedSort(1e4) : void 0,
|
|
742
738
|
opFilter(uniqueFilter(1e4)),
|
|
743
739
|
options.filter ? opFilter(options.filter) : void 0
|
|
744
|
-
].filter(isDefined)
|
|
740
|
+
].filter(isDefined);
|
|
741
|
+
return opCombine(...operations);
|
|
745
742
|
}
|
|
746
743
|
function isDefined(v) {
|
|
747
744
|
return v !== void 0;
|
|
@@ -818,7 +815,6 @@ function createParseFileLineMapper(options) {
|
|
|
818
815
|
case "legacy":
|
|
819
816
|
keepCase = false;
|
|
820
817
|
legacy = true;
|
|
821
|
-
break;
|
|
822
818
|
}
|
|
823
819
|
}
|
|
824
820
|
return line.slice(0, idx).trim();
|
|
@@ -857,7 +853,7 @@ function createParseFileLineMapper(options) {
|
|
|
857
853
|
yield* !allowedSplitWords.size ? words : words.flatMap((word) => splitWordIntoWords(word));
|
|
858
854
|
if (!splitKeepBoth) continue;
|
|
859
855
|
}
|
|
860
|
-
yield line.replaceAll(
|
|
856
|
+
yield line.replaceAll("\"", "");
|
|
861
857
|
}
|
|
862
858
|
}
|
|
863
859
|
function* unique(lines) {
|
|
@@ -967,7 +963,8 @@ function createWordListCompiler(options) {
|
|
|
967
963
|
}
|
|
968
964
|
function normalize(lines, options) {
|
|
969
965
|
const filter = normalizeTargetWords(options);
|
|
970
|
-
const
|
|
966
|
+
const cleanLines = options.removeDuplicates ? removeDuplicates(lines) : lines;
|
|
967
|
+
const iter = pipe(cleanLines, filter);
|
|
971
968
|
if (!options.sort) return iter;
|
|
972
969
|
return [...new Set(iter)].sort();
|
|
973
970
|
}
|
|
@@ -1009,37 +1006,21 @@ function* removeDuplicates(words) {
|
|
|
1009
1006
|
}
|
|
1010
1007
|
}
|
|
1011
1008
|
}
|
|
1012
|
-
/**
|
|
1013
|
-
* solo
|
|
1014
|
-
* optional_prefix*
|
|
1015
|
-
* optional_suffix*
|
|
1016
|
-
* required_prefix+
|
|
1017
|
-
* required_suffix+
|
|
1018
|
-
*/
|
|
1019
|
-
var Flags = /* @__PURE__ */ function(Flags) {
|
|
1020
|
-
Flags[Flags["base"] = 0] = "base";
|
|
1021
|
-
Flags[Flags["none"] = 1] = "none";
|
|
1022
|
-
Flags[Flags["both"] = 2] = "both";
|
|
1023
|
-
Flags[Flags["pfx"] = 4] = "pfx";
|
|
1024
|
-
Flags[Flags["sfx"] = 8] = "sfx";
|
|
1025
|
-
Flags[Flags["all"] = 15] = "all";
|
|
1026
|
-
return Flags;
|
|
1027
|
-
}(Flags || {});
|
|
1028
1009
|
function applyFlags(word, flags) {
|
|
1029
|
-
if (flags ===
|
|
1030
|
-
if (flags ===
|
|
1031
|
-
if (flags ===
|
|
1032
|
-
if (flags ===
|
|
1033
|
-
if (flags ===
|
|
1034
|
-
if (flags ===
|
|
1035
|
-
if (flags ===
|
|
1036
|
-
if (flags ===
|
|
1037
|
-
if (flags ===
|
|
1038
|
-
if (flags ===
|
|
1039
|
-
if (flags ===
|
|
1040
|
-
if (flags ===
|
|
1041
|
-
if (flags ===
|
|
1042
|
-
if (flags ===
|
|
1010
|
+
if (flags === 1) return [word];
|
|
1011
|
+
if (flags === 15) return ["*" + word + "*"];
|
|
1012
|
+
if (flags === 2) return ["+" + word + "+"];
|
|
1013
|
+
if (flags === 4) return [word + "+"];
|
|
1014
|
+
if (flags === 8) return ["+" + word];
|
|
1015
|
+
if (flags === 9) return ["*" + word];
|
|
1016
|
+
if (flags === 5) return [word + "*"];
|
|
1017
|
+
if (flags === 13) return [word + "*", "*" + word];
|
|
1018
|
+
if (flags === 3) return ["*" + word + "*"];
|
|
1019
|
+
if (flags === 11) return [word, "+" + word + "*"];
|
|
1020
|
+
if (flags === 7) return [word, "*" + word + "+"];
|
|
1021
|
+
if (flags === 6) return ["*" + word + "+"];
|
|
1022
|
+
if (flags === 10) return ["+" + word + "*"];
|
|
1023
|
+
if (flags === 14) return ["+" + word + "*", "*" + word + "+"];
|
|
1043
1024
|
return ["+" + word, word + "+"];
|
|
1044
1025
|
}
|
|
1045
1026
|
function removeDuplicateForms(forms) {
|
|
@@ -1050,13 +1031,13 @@ function removeDuplicateForms(forms) {
|
|
|
1050
1031
|
const canBeSuffix = word.startsWith("*");
|
|
1051
1032
|
const mustBeSuffix = !canBeSuffix && word.startsWith("+");
|
|
1052
1033
|
const isSuffix = canBeSuffix || mustBeSuffix;
|
|
1053
|
-
if (canBePrefix && canBeSuffix) return flag |
|
|
1054
|
-
if (mustBePrefix && mustBeSuffix) return flag |
|
|
1055
|
-
if (!isPrefix && !isSuffix) return flag |
|
|
1056
|
-
flag |= isPrefix && !isSuffix ?
|
|
1057
|
-
flag |= isSuffix && !isPrefix ?
|
|
1058
|
-
flag |= canBePrefix && !mustBeSuffix ?
|
|
1059
|
-
flag |= canBeSuffix && !mustBePrefix ?
|
|
1034
|
+
if (canBePrefix && canBeSuffix) return flag | 15;
|
|
1035
|
+
if (mustBePrefix && mustBeSuffix) return flag | 2;
|
|
1036
|
+
if (!isPrefix && !isSuffix) return flag | 1;
|
|
1037
|
+
flag |= isPrefix && !isSuffix ? 4 : 0;
|
|
1038
|
+
flag |= isSuffix && !isPrefix ? 8 : 0;
|
|
1039
|
+
flag |= canBePrefix && !mustBeSuffix ? 1 : 0;
|
|
1040
|
+
flag |= canBeSuffix && !mustBePrefix ? 1 : 0;
|
|
1060
1041
|
return flag;
|
|
1061
1042
|
}
|
|
1062
1043
|
const m = /* @__PURE__ */ new Map();
|
|
@@ -1071,7 +1052,8 @@ function removeDuplicateForms(forms) {
|
|
|
1071
1052
|
async function createTargetFile(destFilename, seq, compress) {
|
|
1072
1053
|
const rel = path.relative(process.cwd(), destFilename).replaceAll(path.sep, "/");
|
|
1073
1054
|
getLogger()(`Writing to file ${rel}${compress ? ".gz" : ""}`);
|
|
1074
|
-
|
|
1055
|
+
const destDir = path.dirname(destFilename);
|
|
1056
|
+
await mkdirp(destDir);
|
|
1075
1057
|
await writeTextToFile(destFilename, seq, compress);
|
|
1076
1058
|
}
|
|
1077
1059
|
function createTrieCompiler(options) {
|
|
@@ -1170,7 +1152,8 @@ async function buildTargetDictionary(target, options, compileOptions, buildOptio
|
|
|
1170
1152
|
return excludeFromFilter(word) && includeFromFilter(word) && excludeRegexFilter(word);
|
|
1171
1153
|
};
|
|
1172
1154
|
const compress = generateOnlyCompressedDictionary;
|
|
1173
|
-
const
|
|
1155
|
+
const filesToProcessAsync = pipeAsync(readSourceList(sources, rootDir), opMapAsync((src) => readFileSource(src, options)), opAwaitAsync());
|
|
1156
|
+
const filesToProcess = await toArray(filesToProcessAsync);
|
|
1174
1157
|
const normalizer = normalizeTargetWords({
|
|
1175
1158
|
sort: useTrie || sort,
|
|
1176
1159
|
generateNonStrict,
|
|
@@ -1185,7 +1168,7 @@ async function buildTargetDictionary(target, options, compileOptions, buildOptio
|
|
|
1185
1168
|
}
|
|
1186
1169
|
}
|
|
1187
1170
|
async function action(words, dst) {
|
|
1188
|
-
|
|
1171
|
+
const compiler = useTrie ? createTrieCompiler({
|
|
1189
1172
|
base: trieBase,
|
|
1190
1173
|
trie3: format === "trie3",
|
|
1191
1174
|
trie4: format === "trie4"
|
|
@@ -1194,7 +1177,8 @@ async function buildTargetDictionary(target, options, compileOptions, buildOptio
|
|
|
1194
1177
|
generateNonStrict,
|
|
1195
1178
|
dictionaryDirectives,
|
|
1196
1179
|
removeDuplicates
|
|
1197
|
-
})
|
|
1180
|
+
});
|
|
1181
|
+
await createTargetFile(dst, iterableToString(pipe(words, normalizer, compiler)), compress);
|
|
1198
1182
|
}
|
|
1199
1183
|
await processFiles({
|
|
1200
1184
|
action,
|
|
@@ -1399,6 +1383,6 @@ function normalizeRequest(buildInfo, root) {
|
|
|
1399
1383
|
};
|
|
1400
1384
|
}
|
|
1401
1385
|
//#endregion
|
|
1402
|
-
export { reportCheckChecksumFile as a, toError as c,
|
|
1386
|
+
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 };
|
|
1403
1387
|
|
|
1404
|
-
//# sourceMappingURL=build-
|
|
1388
|
+
//# sourceMappingURL=build-DPX1iG-1.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-DPX1iG-1.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
|
+
"version": "10.1.0",
|
|
4
4
|
"description": "Tools to assist with the development of cSpell",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public",
|
|
@@ -64,21 +64,21 @@
|
|
|
64
64
|
},
|
|
65
65
|
"homepage": "https://github.com/streetsidesoftware/cspell/tree/main/packages/cspell-tools#readme",
|
|
66
66
|
"dependencies": {
|
|
67
|
-
"@cspell/cspell-pipe": "10.
|
|
68
|
-
"commander": "^
|
|
69
|
-
"cosmiconfig": "
|
|
70
|
-
"cspell-trie-lib": "10.
|
|
67
|
+
"@cspell/cspell-pipe": "10.1.0",
|
|
68
|
+
"commander": "^15.0.0",
|
|
69
|
+
"cosmiconfig": "10.0.0",
|
|
70
|
+
"cspell-trie-lib": "10.1.0",
|
|
71
71
|
"glob": "^13.0.6",
|
|
72
|
-
"hunspell-reader": "10.
|
|
73
|
-
"yaml": "^2.
|
|
72
|
+
"hunspell-reader": "10.1.0",
|
|
73
|
+
"yaml": "^2.9.0"
|
|
74
74
|
},
|
|
75
75
|
"engines": {
|
|
76
76
|
"node": ">=22.18.0"
|
|
77
77
|
},
|
|
78
78
|
"devDependencies": {
|
|
79
|
-
"lorem-ipsum": "^
|
|
79
|
+
"lorem-ipsum": "^3.0.0",
|
|
80
80
|
"ts-json-schema-generator": "2.9.0"
|
|
81
81
|
},
|
|
82
82
|
"module": "bin.mjs",
|
|
83
|
-
"gitHead": "
|
|
83
|
+
"gitHead": "401518c5e37c06fb406aedadb3fc7a1c27eca8e6"
|
|
84
84
|
}
|