@cspell/cspell-tools 10.0.1 → 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 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, 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-C6ZfB6mS.mjs";
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
- return glob((Array.isArray(pattern) ? pattern : [pattern]).map((pattern) => pattern.replaceAll("\\", "/")), options);
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
@@ -95,7 +96,7 @@ function normalizeSource(source) {
95
96
  }
96
97
  function normalizeSourcePath(source) {
97
98
  const cwd = process.cwd();
98
- return path.relative(cwd, source).split("\\").join("/");
99
+ return path.relative(cwd, source).replaceAll("\\", "/");
99
100
  }
100
101
  //#endregion
101
102
  //#region src/config/config.ts
@@ -224,7 +225,8 @@ async function useCompile(src, options) {
224
225
  console.log("Compile:\n output: %s\n compress: %s\n files:\n %s", options.output || "default", options.compress ? "true" : "false", src.join("\n "));
225
226
  if (options.listFile && options.listFile.length) console.log(" list files:\n %s", options.listFile.join("\n "));
226
227
  console.log("\n\n");
227
- const request = createCompileRequest([...pipe(await Promise.all(src.map((s) => globP(s))), opConcatMap((a) => a))], options);
228
+ const globResults = await Promise.all(src.map((s) => globP(s)));
229
+ const request = createCompileRequest([...pipe(globResults, opConcatMap((a) => a))], options);
228
230
  return options.init ? initConfig(request) : compile(request);
229
231
  }
230
232
  async function initConfig(runConfig) {
@@ -21,7 +21,8 @@ const OSSystemIDOffset = 9;
21
21
  async function compressFile(file, os) {
22
22
  if (file.endsWith(".gz")) return file;
23
23
  const targetFile = file + ".gz";
24
- await writeFile(targetFile, await compress(await readFile(file), os));
24
+ const zBuf = await compress(await readFile(file), os);
25
+ await writeFile(targetFile, zBuf);
25
26
  return targetFile;
26
27
  }
27
28
  async function compress(buf, os) {
@@ -45,7 +46,8 @@ function isGZipped(data) {
45
46
  return data[0] === 31 && data[1] === 139;
46
47
  }
47
48
  function fixOSSystemID(zBuf, os = 3) {
48
- zBuf[OSSystemIDOffset] = os === -1 ? zBuf[OSSystemIDOffset] : os;
49
+ const osFlag = os === -1 ? zBuf[OSSystemIDOffset] : os;
50
+ zBuf[OSSystemIDOffset] = osFlag;
49
51
  return zBuf;
50
52
  }
51
53
  async function decompress(buf, encoding) {
@@ -190,7 +192,9 @@ var TrieFileReader = class TrieFileReader {
190
192
  }
191
193
  static async create(filename) {
192
194
  const rawBuffer = await readFile(filename);
193
- return new TrieFileReader(filename, decodeTrie(filename.endsWith(".gz") ? gunzipSync(rawBuffer) : rawBuffer));
195
+ const buffer = filename.endsWith(".gz") ? gunzipSync(rawBuffer) : rawBuffer;
196
+ const trie = decodeTrie(buffer);
197
+ return new TrieFileReader(filename, trie);
194
198
  }
195
199
  };
196
200
  //#endregion
@@ -246,7 +250,8 @@ function bTrieFileName(inputFilename, options) {
246
250
  return filename;
247
251
  }
248
252
  async function createBTrieFromFile(file, buildOptions) {
249
- return encodeTrieDataToBTrie((await createReader(file, {})).toTrie().data, buildOptions);
253
+ const trie = (await createReader(file, {})).toTrie();
254
+ return encodeTrieDataToBTrie(trie.data, buildOptions);
250
255
  }
251
256
  //#endregion
252
257
  //#region src/bTrie.ts
@@ -422,7 +427,7 @@ async function calcUpdateChecksumForFiles(filename, files, options) {
422
427
  ...entry,
423
428
  filename: normalizeFilename(entry.filename)
424
429
  }));
425
- const entriesToUpdate = new Set([...filesToCheck, ...currentEntries.map((e) => e.filename)]);
430
+ const entriesToUpdate = /* @__PURE__ */ new Set([...filesToCheck, ...currentEntries.map((e) => e.filename)]);
426
431
  const mustExist = new Set(filesToCheck);
427
432
  const checksumMap = new Map(currentEntries.map(({ filename, checksum }) => [filename, checksum]));
428
433
  for (const file of entriesToUpdate) try {
@@ -726,13 +731,14 @@ function normalizeTargetWords(options) {
726
731
  stripCaseAndAccentsOnForbidden: true,
727
732
  keepOptionalCompoundCharacter: true
728
733
  });
729
- return opCombine(...[
734
+ const operations = [
730
735
  opFilter((a) => !!a),
731
736
  lineParser,
732
737
  options.sort ? createInlineBufferedSort(1e4) : void 0,
733
738
  opFilter(uniqueFilter(1e4)),
734
739
  options.filter ? opFilter(options.filter) : void 0
735
- ].filter(isDefined));
740
+ ].filter(isDefined);
741
+ return opCombine(...operations);
736
742
  }
737
743
  function isDefined(v) {
738
744
  return v !== void 0;
@@ -809,7 +815,6 @@ function createParseFileLineMapper(options) {
809
815
  case "legacy":
810
816
  keepCase = false;
811
817
  legacy = true;
812
- break;
813
818
  }
814
819
  }
815
820
  return line.slice(0, idx).trim();
@@ -848,7 +853,7 @@ function createParseFileLineMapper(options) {
848
853
  yield* !allowedSplitWords.size ? words : words.flatMap((word) => splitWordIntoWords(word));
849
854
  if (!splitKeepBoth) continue;
850
855
  }
851
- yield line.replaceAll(/["]/g, "");
856
+ yield line.replaceAll("\"", "");
852
857
  }
853
858
  }
854
859
  function* unique(lines) {
@@ -958,7 +963,8 @@ function createWordListCompiler(options) {
958
963
  }
959
964
  function normalize(lines, options) {
960
965
  const filter = normalizeTargetWords(options);
961
- const iter = pipe(options.removeDuplicates ? removeDuplicates(lines) : lines, filter);
966
+ const cleanLines = options.removeDuplicates ? removeDuplicates(lines) : lines;
967
+ const iter = pipe(cleanLines, filter);
962
968
  if (!options.sort) return iter;
963
969
  return [...new Set(iter)].sort();
964
970
  }
@@ -1046,7 +1052,8 @@ function removeDuplicateForms(forms) {
1046
1052
  async function createTargetFile(destFilename, seq, compress) {
1047
1053
  const rel = path.relative(process.cwd(), destFilename).replaceAll(path.sep, "/");
1048
1054
  getLogger()(`Writing to file ${rel}${compress ? ".gz" : ""}`);
1049
- await mkdirp(path.dirname(destFilename));
1055
+ const destDir = path.dirname(destFilename);
1056
+ await mkdirp(destDir);
1050
1057
  await writeTextToFile(destFilename, seq, compress);
1051
1058
  }
1052
1059
  function createTrieCompiler(options) {
@@ -1145,7 +1152,8 @@ async function buildTargetDictionary(target, options, compileOptions, buildOptio
1145
1152
  return excludeFromFilter(word) && includeFromFilter(word) && excludeRegexFilter(word);
1146
1153
  };
1147
1154
  const compress = generateOnlyCompressedDictionary;
1148
- const filesToProcess = await toArray(pipeAsync(readSourceList(sources, rootDir), opMapAsync((src) => readFileSource(src, options)), opAwaitAsync()));
1155
+ const filesToProcessAsync = pipeAsync(readSourceList(sources, rootDir), opMapAsync((src) => readFileSource(src, options)), opAwaitAsync());
1156
+ const filesToProcess = await toArray(filesToProcessAsync);
1149
1157
  const normalizer = normalizeTargetWords({
1150
1158
  sort: useTrie || sort,
1151
1159
  generateNonStrict,
@@ -1160,7 +1168,7 @@ async function buildTargetDictionary(target, options, compileOptions, buildOptio
1160
1168
  }
1161
1169
  }
1162
1170
  async function action(words, dst) {
1163
- await createTargetFile(dst, iterableToString(pipe(words, normalizer, useTrie ? createTrieCompiler({
1171
+ const compiler = useTrie ? createTrieCompiler({
1164
1172
  base: trieBase,
1165
1173
  trie3: format === "trie3",
1166
1174
  trie4: format === "trie4"
@@ -1169,7 +1177,8 @@ async function buildTargetDictionary(target, options, compileOptions, buildOptio
1169
1177
  generateNonStrict,
1170
1178
  dictionaryDirectives,
1171
1179
  removeDuplicates
1172
- }))), compress);
1180
+ });
1181
+ await createTargetFile(dst, iterableToString(pipe(words, normalizer, compiler)), compress);
1173
1182
  }
1174
1183
  await processFiles({
1175
1184
  action,
@@ -1376,4 +1385,4 @@ function normalizeRequest(buildInfo, root) {
1376
1385
  //#endregion
1377
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 };
1378
1387
 
1379
- //# sourceMappingURL=build-C6ZfB6mS.mjs.map
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-C6ZfB6mS.mjs";
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.0.1",
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.0.1",
68
- "commander": "^14.0.3",
69
- "cosmiconfig": "9.0.1",
70
- "cspell-trie-lib": "10.0.1",
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.0.1",
72
+ "hunspell-reader": "10.1.0",
73
73
  "yaml": "^2.9.0"
74
74
  },
75
75
  "engines": {
76
76
  "node": ">=22.18.0"
77
77
  },
78
78
  "devDependencies": {
79
- "lorem-ipsum": "^2.0.10",
79
+ "lorem-ipsum": "^3.0.0",
80
80
  "ts-json-schema-generator": "2.9.0"
81
81
  },
82
82
  "module": "bin.mjs",
83
- "gitHead": "0f43abf29e5da0ecbcb08214055cdc1e3267c3ea"
83
+ "gitHead": "401518c5e37c06fb406aedadb3fc7a1c27eca8e6"
84
84
  }