@cspell/cspell-tools 9.4.0 → 9.6.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.
Files changed (110) hide show
  1. package/bin.mjs +1 -1
  2. package/cspell-tools.config.schema.json +50 -24
  3. package/dist/app.d.mts +35 -0
  4. package/dist/app.mjs +292 -0
  5. package/dist/build-OgMPaXPZ.mjs +1403 -0
  6. package/dist/index.d.mts +35 -0
  7. package/dist/index.mjs +3 -0
  8. package/package.json +10 -9
  9. package/dist/AppOptions.d.ts +0 -31
  10. package/dist/AppOptions.js +0 -2
  11. package/dist/FeatureFlags/FeatureFlags.d.ts +0 -34
  12. package/dist/FeatureFlags/FeatureFlags.js +0 -94
  13. package/dist/FeatureFlags/index.d.ts +0 -3
  14. package/dist/FeatureFlags/index.js +0 -3
  15. package/dist/FeatureFlags/parseFlags.d.ts +0 -3
  16. package/dist/FeatureFlags/parseFlags.js +0 -20
  17. package/dist/app.d.ts +0 -4
  18. package/dist/app.js +0 -86
  19. package/dist/build.d.ts +0 -12
  20. package/dist/build.js +0 -36
  21. package/dist/compile.d.ts +0 -5
  22. package/dist/compile.js +0 -41
  23. package/dist/compiler/CompileOptions.d.ts +0 -35
  24. package/dist/compiler/CompileOptions.js +0 -2
  25. package/dist/compiler/Reader.d.ts +0 -3
  26. package/dist/compiler/Reader.js +0 -24
  27. package/dist/compiler/SourceReader.d.ts +0 -28
  28. package/dist/compiler/SourceReader.js +0 -44
  29. package/dist/compiler/WordsCollection.d.ts +0 -20
  30. package/dist/compiler/WordsCollection.js +0 -3
  31. package/dist/compiler/compile.d.ts +0 -26
  32. package/dist/compiler/compile.js +0 -263
  33. package/dist/compiler/createCompileRequest.d.ts +0 -4
  34. package/dist/compiler/createCompileRequest.js +0 -84
  35. package/dist/compiler/createWordsCollection.d.ts +0 -9
  36. package/dist/compiler/createWordsCollection.js +0 -108
  37. package/dist/compiler/fileWriter.d.ts +0 -3
  38. package/dist/compiler/fileWriter.js +0 -6
  39. package/dist/compiler/index.d.ts +0 -5
  40. package/dist/compiler/index.js +0 -4
  41. package/dist/compiler/legacyLineToWords.d.ts +0 -4
  42. package/dist/compiler/legacyLineToWords.js +0 -20
  43. package/dist/compiler/logWithTimestamp.d.ts +0 -3
  44. package/dist/compiler/logWithTimestamp.js +0 -5
  45. package/dist/compiler/logger.d.ts +0 -4
  46. package/dist/compiler/logger.js +0 -9
  47. package/dist/compiler/readers/ReaderOptions.d.ts +0 -19
  48. package/dist/compiler/readers/ReaderOptions.js +0 -2
  49. package/dist/compiler/readers/readHunspellFiles.d.ts +0 -3
  50. package/dist/compiler/readers/readHunspellFiles.js +0 -57
  51. package/dist/compiler/readers/readTextFile.d.ts +0 -3
  52. package/dist/compiler/readers/readTextFile.js +0 -20
  53. package/dist/compiler/readers/regHunspellFile.d.ts +0 -2
  54. package/dist/compiler/readers/regHunspellFile.js +0 -2
  55. package/dist/compiler/readers/textFileReader.d.ts +0 -3
  56. package/dist/compiler/readers/textFileReader.js +0 -11
  57. package/dist/compiler/readers/trieFileReader.d.ts +0 -3
  58. package/dist/compiler/readers/trieFileReader.js +0 -16
  59. package/dist/compiler/splitCamelCaseIfAllowed.d.ts +0 -5
  60. package/dist/compiler/splitCamelCaseIfAllowed.js +0 -65
  61. package/dist/compiler/streamSourceWordsFromFile.d.ts +0 -3
  62. package/dist/compiler/streamSourceWordsFromFile.js +0 -6
  63. package/dist/compiler/text.d.ts +0 -10
  64. package/dist/compiler/text.js +0 -28
  65. package/dist/compiler/wordListCompiler.d.ts +0 -17
  66. package/dist/compiler/wordListCompiler.js +0 -199
  67. package/dist/compiler/wordListParser.d.ts +0 -61
  68. package/dist/compiler/wordListParser.js +0 -184
  69. package/dist/compiler/writeTextToFile.d.ts +0 -3
  70. package/dist/compiler/writeTextToFile.js +0 -15
  71. package/dist/config/config.d.ts +0 -194
  72. package/dist/config/config.js +0 -2
  73. package/dist/config/configDefaults.d.ts +0 -9
  74. package/dist/config/configDefaults.js +0 -9
  75. package/dist/config/configUtils.d.ts +0 -5
  76. package/dist/config/configUtils.js +0 -14
  77. package/dist/config/index.d.ts +0 -4
  78. package/dist/config/index.js +0 -3
  79. package/dist/config/normalizeConfig.d.ts +0 -8
  80. package/dist/config/normalizeConfig.js +0 -13
  81. package/dist/gzip/compressFiles.d.ts +0 -16
  82. package/dist/gzip/compressFiles.js +0 -42
  83. package/dist/gzip/gzip.d.ts +0 -3
  84. package/dist/gzip/gzip.js +0 -10
  85. package/dist/gzip/index.d.ts +0 -3
  86. package/dist/gzip/index.js +0 -3
  87. package/dist/shasum/checksum.d.ts +0 -7
  88. package/dist/shasum/checksum.js +0 -19
  89. package/dist/shasum/index.d.ts +0 -3
  90. package/dist/shasum/index.js +0 -3
  91. package/dist/shasum/shasum.d.ts +0 -38
  92. package/dist/shasum/shasum.js +0 -150
  93. package/dist/test/TestHelper.d.ts +0 -53
  94. package/dist/test/TestHelper.js +0 -121
  95. package/dist/test/console.d.ts +0 -9
  96. package/dist/test/console.js +0 -34
  97. package/dist/test/escapeRegEx.d.ts +0 -7
  98. package/dist/test/escapeRegEx.js +0 -9
  99. package/dist/test/normalizeOutput.d.ts +0 -3
  100. package/dist/test/normalizeOutput.js +0 -20
  101. package/dist/types.d.ts +0 -7
  102. package/dist/types.js +0 -2
  103. package/dist/util/errors.d.ts +0 -6
  104. package/dist/util/errors.js +0 -11
  105. package/dist/util/globP.d.ts +0 -7
  106. package/dist/util/globP.js +0 -7
  107. package/dist/util/index.d.ts +0 -2
  108. package/dist/util/index.js +0 -4
  109. package/dist/util/textRegex.d.ts +0 -3
  110. package/dist/util/textRegex.js +0 -109
package/bin.mjs CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  import { CommanderError, program } from 'commander';
4
4
 
5
- import { run } from './dist/app.js';
5
+ import { run } from './dist/app.mjs';
6
6
 
7
7
  run(program, process.argv).catch((e) => {
8
8
  if (!(e instanceof CommanderError)) {
@@ -2,6 +2,24 @@
2
2
  "$schema": "http://json-schema.org/draft-07/schema#",
3
3
  "additionalProperties": false,
4
4
  "definitions": {
5
+ "BTrieOptions": {
6
+ "additionalProperties": false,
7
+ "properties": {
8
+ "compress": {
9
+ "description": "compress the resulting file",
10
+ "type": "boolean"
11
+ },
12
+ "optimize": {
13
+ "description": "optimize the trie into a DAWG",
14
+ "type": "boolean"
15
+ },
16
+ "useStringTable": {
17
+ "description": "use a string table to reduce size",
18
+ "type": "boolean"
19
+ }
20
+ },
21
+ "type": "object"
22
+ },
5
23
  "DictionaryFormats": {
6
24
  "enum": [
7
25
  "plaintext",
@@ -28,17 +46,7 @@
28
46
  "additionalProperties": false,
29
47
  "properties": {
30
48
  "allowedSplitWords": {
31
- "anyOf": [
32
- {
33
- "$ref": "#/definitions/FilePath"
34
- },
35
- {
36
- "items": {
37
- "$ref": "#/definitions/FilePath"
38
- },
39
- "type": "array"
40
- }
41
- ],
49
+ "$ref": "#/definitions/FilePathOrFilePathArray",
42
50
  "description": "Words in the `allowedSplitWords` are considered correct and can be used as a basis for splitting compound words.\n\nIf entries can be split so that all the words in the entry are allowed, then only the individual words are added, otherwise the entire entry is added. This is to prevent misspellings in CamelCase words from being introduced into the dictionary."
43
51
  },
44
52
  "keepRawCase": {
@@ -86,21 +94,24 @@
86
94
  "description": "Note: All relative paths are relative to the config file location.",
87
95
  "type": "string"
88
96
  },
97
+ "FilePathOrFilePathArray": {
98
+ "anyOf": [
99
+ {
100
+ "$ref": "#/definitions/FilePath"
101
+ },
102
+ {
103
+ "items": {
104
+ "$ref": "#/definitions/FilePath"
105
+ },
106
+ "type": "array"
107
+ }
108
+ ]
109
+ },
89
110
  "FileSource": {
90
111
  "additionalProperties": false,
91
112
  "properties": {
92
113
  "allowedSplitWords": {
93
- "anyOf": [
94
- {
95
- "$ref": "#/definitions/FilePath"
96
- },
97
- {
98
- "items": {
99
- "$ref": "#/definitions/FilePath"
100
- },
101
- "type": "array"
102
- }
103
- ],
114
+ "$ref": "#/definitions/FilePathOrFilePathArray",
104
115
  "description": "Words in the `allowedSplitWords` are considered correct and can be used as a basis for splitting compound words.\n\nIf entries can be split so that all the words in the entry are allowed, then only the individual words are added, otherwise the entire entry is added. This is to prevent misspellings in CamelCase words from being introduced into the dictionary."
105
116
  },
106
117
  "filename": {
@@ -161,9 +172,20 @@
161
172
  ],
162
173
  "description": "Words in the `allowedSplitWords` are considered correct and can be used as a basis for splitting compound words.\n\nIf entries can be split so that all the words in the entry are allowed, then only the individual words are added, otherwise the entire entry is added. This is to prevent misspellings in CamelCase words from being introduced into the dictionary."
163
174
  },
175
+ "bTrie": {
176
+ "anyOf": [
177
+ {
178
+ "type": "boolean"
179
+ },
180
+ {
181
+ "$ref": "#/definitions/BTrieOptions"
182
+ }
183
+ ],
184
+ "description": "Generate a `.btrie.gz` for the target."
185
+ },
164
186
  "compress": {
165
- "default": ": false",
166
- "description": "gzip the file?",
187
+ "default": false,
188
+ "description": "Setting this value to true will create a `.gz` dictionary file. Use `keepUncompressed` to also keep an uncompressed version.",
167
189
  "type": "boolean"
168
190
  },
169
191
  "dictionaryDirectives": {
@@ -203,6 +225,10 @@
203
225
  "description": "Generate lower case / accent free versions of words.",
204
226
  "type": "boolean"
205
227
  },
228
+ "keepUncompressed": {
229
+ "description": "If `compress` is true, setting this value to true will also keep an uncompressed version of the dictionary.",
230
+ "type": "boolean"
231
+ },
206
232
  "name": {
207
233
  "description": "Name of target, used as the basis of target file name.",
208
234
  "type": "string"
package/dist/app.d.mts ADDED
@@ -0,0 +1,35 @@
1
+ import { Command } from "commander";
2
+
3
+ //#region src/FeatureFlags/FeatureFlags.d.ts
4
+ interface FeatureFlag {
5
+ name: string;
6
+ description: string;
7
+ }
8
+ type FlagTypes = string | boolean;
9
+ /**
10
+ * Feature Flags are used to turn on/off features.
11
+ * These are primarily used before a feature has been fully released.
12
+ */
13
+ declare class FeatureFlags {
14
+ private flags;
15
+ private flagValues;
16
+ constructor(flags?: FeatureFlag[]);
17
+ register(flag: FeatureFlag): this;
18
+ register(name: string, description: string): this;
19
+ registerFeatures(flags: FeatureFlag[]): this;
20
+ getFlag(flag: string): FlagTypes | undefined;
21
+ getFlagBool(flag: string): boolean | undefined;
22
+ setFlag(flag: string, value?: FlagTypes): this;
23
+ getFlagInfo(flag: string): FeatureFlag | undefined;
24
+ getFlags(): FeatureFlag[];
25
+ getFlagValues(): Map<string, FlagTypes>;
26
+ reset(): this;
27
+ help(): string;
28
+ fork(): FeatureFlags;
29
+ }
30
+ //#endregion
31
+ //#region src/app.d.ts
32
+ declare function run(program: Command, argv: string[], flags?: FeatureFlags): Promise<void>;
33
+ //#endregion
34
+ export { run };
35
+ //# sourceMappingURL=app.d.mts.map
package/dist/app.mjs ADDED
@@ -0,0 +1,292 @@
1
+ import { a as reportCheckChecksumFile, c as toError, d as compressFile, i as logWithTimestamp, l as generateBTrie, n as compile, o as reportChecksumForFiles, r as setLogger, s as updateChecksumForFiles, t as build, u as OSFlags } from "./build-OgMPaXPZ.mjs";
2
+ import { readFileSync } from "node:fs";
3
+ import { CommanderError, Option } from "commander";
4
+ import { writeFile } from "node:fs/promises";
5
+ import * as path from "node:path";
6
+ import { glob } from "glob";
7
+ import { opConcatMap, pipe } from "@cspell/cspell-pipe/sync";
8
+ import YAML from "yaml";
9
+
10
+ //#region src/util/globP.ts
11
+ function globP(pattern, options) {
12
+ return glob((Array.isArray(pattern) ? pattern : [pattern]).map((pattern$1) => pattern$1.replaceAll("\\", "/")), options);
13
+ }
14
+
15
+ //#endregion
16
+ //#region src/gzip/gzip.ts
17
+ /**
18
+ * GZip files matching the given globs.
19
+ * @param globs - array of globs to gzip
20
+ * @param os - optional OS flag for the gzip file
21
+ */
22
+ async function gzipFiles(globs, os) {
23
+ const files = await globP(globs, { nodir: true });
24
+ for (const fileName of files) await compressFile(fileName, os);
25
+ }
26
+
27
+ //#endregion
28
+ //#region src/compiler/createCompileRequest.ts
29
+ function createCompileRequest(sourceFiles, options) {
30
+ options = { ...options };
31
+ options.maxDepth ??= options.max_depth;
32
+ const { maxDepth, split, keepRawCase, useLegacySplitter } = options;
33
+ return {
34
+ targets: calcTargets([...sourceFiles, ...(options.listFile || []).map((listFile) => ({ listFile }))], options),
35
+ maxDepth: parseNumber(maxDepth),
36
+ split: useLegacySplitter ? "legacy" : split,
37
+ keepRawCase
38
+ };
39
+ }
40
+ function calcTargets(sources, options) {
41
+ const { merge, output = ".", experimental = [] } = options;
42
+ const generateNonStrict = experimental.includes("compound") || void 0;
43
+ const format = calcFormat(options);
44
+ const sort = format === "plaintext" && options.sort || void 0;
45
+ if (merge) return [{
46
+ name: merge,
47
+ targetDirectory: output,
48
+ compress: options.compress,
49
+ format,
50
+ sources: sources.map(normalizeSource),
51
+ sort,
52
+ trieBase: parseNumber(options.trieBase),
53
+ generateNonStrict
54
+ }];
55
+ return sources.map((source) => {
56
+ return {
57
+ name: toTargetName(baseNameOfSource(source)),
58
+ targetDirectory: output,
59
+ compress: options.compress,
60
+ format,
61
+ sources: [normalizeSource(source)],
62
+ sort: options.sort,
63
+ trieBase: parseNumber(options.trieBase),
64
+ generateNonStrict
65
+ };
66
+ });
67
+ }
68
+ function calcFormat(options) {
69
+ return options.trie4 && "trie4" || options.trie3 && "trie3" || options.trie && "trie" || "plaintext";
70
+ }
71
+ function toTargetName(sourceFile) {
72
+ return path.basename(sourceFile).replace(/((\.txt|\.dic|\.aff|\.trie)(\.gz)?)?$/, "");
73
+ }
74
+ function parseNumber(s) {
75
+ const n = Number.parseInt(s ?? "");
76
+ return Number.isNaN(n) ? void 0 : n;
77
+ }
78
+ function baseNameOfSource(source) {
79
+ return typeof source === "string" ? source : isFileSource(source) ? source.filename : source.listFile;
80
+ }
81
+ function isFileSource(source) {
82
+ return typeof source !== "string" && source.filename !== void 0;
83
+ }
84
+ function normalizeSource(source) {
85
+ if (typeof source === "string") return normalizeSourcePath(source);
86
+ if (isFileSource(source)) return {
87
+ ...source,
88
+ filename: normalizeSourcePath(source.filename)
89
+ };
90
+ return {
91
+ ...source,
92
+ listFile: normalizeSourcePath(source.listFile)
93
+ };
94
+ }
95
+ function normalizeSourcePath(source) {
96
+ const cwd = process.cwd();
97
+ return path.relative(cwd, source).split("\\").join("/");
98
+ }
99
+
100
+ //#endregion
101
+ //#region src/config/config.ts
102
+ const configFileSchemaURL = "https://raw.githubusercontent.com/streetsidesoftware/cspell/main/packages/cspell-tools/cspell-tools.config.schema.json";
103
+
104
+ //#endregion
105
+ //#region src/FeatureFlags/FeatureFlags.ts
106
+ let systemFeatureFlags;
107
+ /**
108
+ * Feature Flags are used to turn on/off features.
109
+ * These are primarily used before a feature has been fully released.
110
+ */
111
+ var FeatureFlags = class FeatureFlags {
112
+ flags;
113
+ flagValues = /* @__PURE__ */ new Map();
114
+ constructor(flags = []) {
115
+ this.flags = new Map(flags.map((f) => [f.name, f]));
116
+ }
117
+ register(flagOrName, description) {
118
+ if (typeof flagOrName === "string") return this.register({
119
+ name: flagOrName,
120
+ description: description || ""
121
+ });
122
+ this.flags.set(flagOrName.name, flagOrName);
123
+ return this;
124
+ }
125
+ registerFeatures(flags) {
126
+ flags.forEach((flag) => this.register(flag));
127
+ return this;
128
+ }
129
+ getFlag(flag) {
130
+ return this.flagValues.get(flag);
131
+ }
132
+ getFlagBool(flag) {
133
+ return toBool(this.getFlag(flag));
134
+ }
135
+ setFlag(flag, value = true) {
136
+ if (!this.flags.has(flag)) throw new UnknownFeatureFlagError(flag);
137
+ this.flagValues.set(flag, toBool(value) ?? value);
138
+ return this;
139
+ }
140
+ getFlagInfo(flag) {
141
+ return this.flags.get(flag);
142
+ }
143
+ getFlags() {
144
+ return [...this.flags.values()];
145
+ }
146
+ getFlagValues() {
147
+ return new Map(this.flagValues);
148
+ }
149
+ reset() {
150
+ this.flagValues.clear();
151
+ return this;
152
+ }
153
+ help() {
154
+ const flags = [{
155
+ name: "Name",
156
+ description: "Description"
157
+ }, ...this.flags.values()].sort((a, b) => a.name < b.name ? -1 : 1);
158
+ const nameColWidth = flags.map((f) => f.name.length).reduce((a, b) => Math.max(a, b), 0) + 1;
159
+ return `Valid Flags:\n${flags.map((f) => `- ${f.name}${" ".repeat(nameColWidth - f.name.length)} ${f.description}`).join("\n")}`;
160
+ }
161
+ fork() {
162
+ const fork = new FeatureFlags([...this.flags.values()]);
163
+ for (const [key, value] of this.flagValues) fork.flagValues.set(key, value);
164
+ return fork;
165
+ }
166
+ };
167
+ var UnknownFeatureFlagError = class extends Error {
168
+ constructor(flag) {
169
+ super(`Unknown feature flag: ${flag}`);
170
+ this.flag = flag;
171
+ }
172
+ };
173
+ function getSystemFeatureFlags() {
174
+ return systemFeatureFlags || (systemFeatureFlags = createFeatureFlags());
175
+ }
176
+ function createFeatureFlags() {
177
+ return new FeatureFlags();
178
+ }
179
+ const boolValues = {
180
+ 0: false,
181
+ 1: true,
182
+ f: false,
183
+ false: false,
184
+ n: false,
185
+ no: false,
186
+ t: true,
187
+ true: true,
188
+ y: true,
189
+ yes: true
190
+ };
191
+ function toBool(value) {
192
+ if (typeof value !== "string") return value;
193
+ return boolValues[value.toLowerCase()];
194
+ }
195
+
196
+ //#endregion
197
+ //#region src/FeatureFlags/parseFlags.ts
198
+ const splitFlag = /[:=]/;
199
+ const leadingEql = /^=/;
200
+ function parseFlags(ff, flags) {
201
+ for (const flag of flags) {
202
+ const [name, value] = flag.replace(leadingEql, "").split(splitFlag, 2);
203
+ try {
204
+ ff.setFlag(name, value);
205
+ } catch (e) {
206
+ if (e instanceof UnknownFeatureFlagError) {
207
+ console.error(e.message);
208
+ console.error(ff.help());
209
+ }
210
+ throw e;
211
+ }
212
+ }
213
+ return ff;
214
+ }
215
+
216
+ //#endregion
217
+ //#region src/compile.ts
218
+ getSystemFeatureFlags().register("compound", "Enable compound dictionary sources.");
219
+ const defaultConfigFile = "cspell-tools.config.yaml";
220
+ const configFileHeader = `# yaml-language-server: $schema=${configFileSchemaURL}\n\n`;
221
+ async function processCompileAction(src, options, featureFlags) {
222
+ parseFlags(featureFlags || getSystemFeatureFlags(), options.experimental || []);
223
+ return useCompile(src, options);
224
+ }
225
+ async function useCompile(src, options) {
226
+ console.log("Compile:\n output: %s\n compress: %s\n files:\n %s", options.output || "default", options.compress ? "true" : "false", src.join("\n "));
227
+ if (options.listFile && options.listFile.length) console.log(" list files:\n %s", options.listFile.join("\n "));
228
+ console.log("\n\n");
229
+ const request = createCompileRequest([...pipe(await Promise.all(src.map((s) => globP(s))), opConcatMap((a) => a))], options);
230
+ return options.init ? initConfig(request) : compile(request);
231
+ }
232
+ async function initConfig(runConfig) {
233
+ const { $schema = configFileSchemaURL, ...cfg } = runConfig;
234
+ const config = {
235
+ $schema,
236
+ ...cfg
237
+ };
238
+ const content = configFileHeader + YAML.stringify(config, void 0, 2);
239
+ console.log("Writing config file: %s", defaultConfigFile);
240
+ await writeFile(defaultConfigFile, content);
241
+ console.log(`Init complete.
242
+ To build, use:
243
+ cspell-tools-cli build
244
+ `);
245
+ }
246
+
247
+ //#endregion
248
+ //#region src/app.ts
249
+ const npmPackageRaw = readFileSync(new URL("../package.json", import.meta.url), "utf8");
250
+ const npmPackage = JSON.parse(npmPackageRaw);
251
+ setLogger(logWithTimestamp);
252
+ function collect(value, previous) {
253
+ return [...previous, value];
254
+ }
255
+ function addCompileOptions(compileCommand) {
256
+ return compileCommand.option("-o, --output <path>", "Specify the output directory, otherwise files are written back to the same location.").option("-n, --no-compress", "By default the files are GZipped, this will turn off GZ compression.").option("-m, --max_depth <limit>", "Maximum depth to apply suffix rules.").option("-M, --merge <target>", "Merge all files into a single target file (extensions are applied)").option("--split", "Split each line", void 0).option("--no-split", "Treat each line as a dictionary entry, do not split").option("--use-legacy-splitter", "Do not use legacy line splitter logic.").option("--keep-raw-case", "Do not normalize words before adding them to dictionary.").option("-x, --experimental <flag>", "Experimental flags, used for testing new concepts. Flags: compound", collect, []).option("--trie3", "Use file format trie3", false).option("--trie4", "Use file format trie4", false).option("--trie-base <number>", "Advanced: Set the trie base number. A value between 10 and 36").option("--list-file <filename...>", "Path to a file that contains the list of files to compile. A list file contains one file per line.").option("--init", "Create a build command `cspell-tools.config.yaml` file based upon the options given instead of building.");
257
+ }
258
+ async function run(program, argv, flags) {
259
+ async function handleGzip(files) {
260
+ try {
261
+ await gzipFiles(files, OSFlags.Unix);
262
+ } catch (error) {
263
+ const err = toError(error);
264
+ program.error(err.message);
265
+ }
266
+ }
267
+ async function shasum(files, options) {
268
+ const report = options.check ? await reportCheckChecksumFile(options.check, files, options) : options.update ? await updateChecksumForFiles(options.update, files, options) : await reportChecksumForFiles(files, options);
269
+ console.log("%s", report.report);
270
+ if (!report.passed) throw new CommanderError(1, "Failed Checksum", "One or more files had issues.");
271
+ }
272
+ program.exitOverride();
273
+ program.version(npmPackage.version);
274
+ addCompileOptions(program.command("compile [src...]").description("Compile words into a cspell dictionary files.")).option("--trie", "Compile into a trie file.", false).option("--no-sort", "Do not sort the result").action((src, options) => {
275
+ return processCompileAction(src, options, flags);
276
+ });
277
+ addCompileOptions(program.command("compile-trie [src...]").description("Compile words lists or Hunspell dictionary into trie files used by cspell.\nAlias of `compile --trie`")).action((src, options) => {
278
+ return processCompileAction(src, {
279
+ ...options,
280
+ trie: true
281
+ }, flags);
282
+ });
283
+ program.command("build [targets...]").description("Build the targets defined in the run configuration.").option("-c, --config <path to run configuration>", "Specify the run configuration file.").option("--conditional", "Conditional build.").option("-r, --root <directory>", "Specify the run directory").action(build);
284
+ program.command("gzip <files...>").description("GZip files while keeping the original.").action(handleGzip);
285
+ program.command("btrie [files...]").description("Generate BTrie files from word list files.").option("-n, --no-compress", "By default the files are GZipped, this will turn off GZ compression.").option("--no-optimize", "Do not try to optimize.").option("--no-use-string-table", "Do not use a string table in the BTrie.").option("-o, --output <path>", "Specify the output directory, otherwise files are written back to the same location.").action(generateBTrie);
286
+ program.command("shasum [files...]").description("Calculate the checksum for files.").option("--list-file <list-file.txt...>", "Specify one or more files that contain paths of files to check.").option("-c, --check <checksum.txt>", "Verify the checksum of files against those stored in the checksum.txt file.").addOption(new Option("-u, --update <checksum.txt>", "Update checksums found in the file.").conflicts("--check")).option("-r, --root <root>", "Specify the root to use for relative paths. The current working directory is used by default.").action(shasum);
287
+ await program.parseAsync(argv);
288
+ }
289
+
290
+ //#endregion
291
+ export { run };
292
+ //# sourceMappingURL=app.mjs.map