@cspell/cspell-tools 9.5.0 → 9.6.1
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/bin.mjs +1 -1
- package/cspell-tools.config.schema.json +29 -0
- package/dist/app.d.mts +35 -0
- package/dist/app.mjs +292 -0
- package/dist/build-OgMPaXPZ.mjs +1403 -0
- package/dist/index.d.mts +35 -0
- package/dist/index.mjs +3 -0
- package/package.json +10 -9
- package/dist/AppOptions.d.ts +0 -31
- package/dist/AppOptions.js +0 -2
- package/dist/FeatureFlags/FeatureFlags.d.ts +0 -34
- package/dist/FeatureFlags/FeatureFlags.js +0 -94
- package/dist/FeatureFlags/index.d.ts +0 -3
- package/dist/FeatureFlags/index.js +0 -3
- package/dist/FeatureFlags/parseFlags.d.ts +0 -3
- package/dist/FeatureFlags/parseFlags.js +0 -20
- package/dist/app.d.ts +0 -4
- package/dist/app.js +0 -86
- package/dist/build.d.ts +0 -12
- package/dist/build.js +0 -36
- package/dist/compile.d.ts +0 -5
- package/dist/compile.js +0 -41
- package/dist/compiler/CompileOptions.d.ts +0 -35
- package/dist/compiler/CompileOptions.js +0 -2
- package/dist/compiler/CompilerDefinitions.d.ts +0 -2
- package/dist/compiler/CompilerDefinitions.js +0 -2
- package/dist/compiler/Reader.d.ts +0 -3
- package/dist/compiler/Reader.js +0 -24
- package/dist/compiler/SourceReader.d.ts +0 -28
- package/dist/compiler/SourceReader.js +0 -44
- package/dist/compiler/WordsCollection.d.ts +0 -20
- package/dist/compiler/WordsCollection.js +0 -3
- package/dist/compiler/compile.d.ts +0 -26
- package/dist/compiler/compile.js +0 -270
- package/dist/compiler/createCompileRequest.d.ts +0 -4
- package/dist/compiler/createCompileRequest.js +0 -84
- package/dist/compiler/createWordsCollection.d.ts +0 -10
- package/dist/compiler/createWordsCollection.js +0 -111
- package/dist/compiler/index.d.ts +0 -4
- package/dist/compiler/index.js +0 -3
- package/dist/compiler/legacyLineToWords.d.ts +0 -4
- package/dist/compiler/legacyLineToWords.js +0 -20
- package/dist/compiler/logWithTimestamp.d.ts +0 -3
- package/dist/compiler/logWithTimestamp.js +0 -5
- package/dist/compiler/logger.d.ts +0 -4
- package/dist/compiler/logger.js +0 -9
- package/dist/compiler/readers/ReaderOptions.d.ts +0 -19
- package/dist/compiler/readers/ReaderOptions.js +0 -2
- package/dist/compiler/readers/readHunspellFiles.d.ts +0 -3
- package/dist/compiler/readers/readHunspellFiles.js +0 -57
- package/dist/compiler/readers/readTextFile.d.ts +0 -3
- package/dist/compiler/readers/readTextFile.js +0 -20
- package/dist/compiler/readers/regHunspellFile.d.ts +0 -2
- package/dist/compiler/readers/regHunspellFile.js +0 -2
- package/dist/compiler/readers/textFileReader.d.ts +0 -3
- package/dist/compiler/readers/textFileReader.js +0 -11
- package/dist/compiler/readers/trieFileReader.d.ts +0 -3
- package/dist/compiler/readers/trieFileReader.js +0 -16
- package/dist/compiler/splitCamelCaseIfAllowed.d.ts +0 -5
- package/dist/compiler/splitCamelCaseIfAllowed.js +0 -65
- package/dist/compiler/streamSourceWordsFromFile.d.ts +0 -3
- package/dist/compiler/streamSourceWordsFromFile.js +0 -6
- package/dist/compiler/text.d.ts +0 -10
- package/dist/compiler/text.js +0 -28
- package/dist/compiler/wordListCompiler.d.ts +0 -21
- package/dist/compiler/wordListCompiler.js +0 -205
- package/dist/compiler/wordListParser.d.ts +0 -61
- package/dist/compiler/wordListParser.js +0 -184
- package/dist/compiler/writeTextToFile.d.ts +0 -2
- package/dist/compiler/writeTextToFile.js +0 -16
- package/dist/config/config.d.ts +0 -200
- package/dist/config/config.js +0 -2
- package/dist/config/configDefaults.d.ts +0 -9
- package/dist/config/configDefaults.js +0 -9
- package/dist/config/configUtils.d.ts +0 -5
- package/dist/config/configUtils.js +0 -14
- package/dist/config/index.d.ts +0 -4
- package/dist/config/index.js +0 -3
- package/dist/config/normalizeConfig.d.ts +0 -8
- package/dist/config/normalizeConfig.js +0 -13
- package/dist/gzip/compressFiles.d.ts +0 -16
- package/dist/gzip/compressFiles.js +0 -42
- package/dist/gzip/gzip.d.ts +0 -3
- package/dist/gzip/gzip.js +0 -10
- package/dist/gzip/index.d.ts +0 -3
- package/dist/gzip/index.js +0 -3
- package/dist/shasum/checksum.d.ts +0 -7
- package/dist/shasum/checksum.js +0 -19
- package/dist/shasum/index.d.ts +0 -3
- package/dist/shasum/index.js +0 -3
- package/dist/shasum/shasum.d.ts +0 -38
- package/dist/shasum/shasum.js +0 -150
- package/dist/test/TestHelper.d.ts +0 -53
- package/dist/test/TestHelper.js +0 -121
- package/dist/test/console.d.ts +0 -9
- package/dist/test/console.js +0 -34
- package/dist/test/escapeRegEx.d.ts +0 -7
- package/dist/test/escapeRegEx.js +0 -9
- package/dist/test/normalizeOutput.d.ts +0 -3
- package/dist/test/normalizeOutput.js +0 -20
- package/dist/types.d.ts +0 -7
- package/dist/types.js +0 -2
- package/dist/util/errors.d.ts +0 -6
- package/dist/util/errors.js +0 -11
- package/dist/util/globP.d.ts +0 -7
- package/dist/util/globP.js +0 -7
- package/dist/util/index.d.ts +0 -2
- package/dist/util/index.js +0 -4
- package/dist/util/textRegex.d.ts +0 -3
- package/dist/util/textRegex.js +0 -109
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
//#region src/config/config.d.ts
|
|
2
|
+
|
|
3
|
+
interface BTrieOptions {
|
|
4
|
+
/** compress the resulting file */
|
|
5
|
+
compress?: boolean | undefined;
|
|
6
|
+
/** optimize the trie into a DAWG */
|
|
7
|
+
optimize?: boolean | undefined;
|
|
8
|
+
/** use a string table to reduce size */
|
|
9
|
+
useStringTable?: boolean | undefined;
|
|
10
|
+
}
|
|
11
|
+
//#endregion
|
|
12
|
+
//#region src/compiler/bTrie.d.ts
|
|
13
|
+
interface GenerateBTrieOptions extends BTrieOptions {
|
|
14
|
+
/** output directory */
|
|
15
|
+
output?: string;
|
|
16
|
+
}
|
|
17
|
+
//#endregion
|
|
18
|
+
//#region src/bTrie.d.ts
|
|
19
|
+
declare function generateBTrie(files: string[], options: GenerateBTrieOptions): Promise<void>;
|
|
20
|
+
//#endregion
|
|
21
|
+
//#region src/build.d.ts
|
|
22
|
+
interface BuildOptions {
|
|
23
|
+
/** Optional path to config file */
|
|
24
|
+
config?: string | undefined;
|
|
25
|
+
/** Used to resolve relative paths in the config. */
|
|
26
|
+
root?: string | undefined;
|
|
27
|
+
/** Current working directory */
|
|
28
|
+
cwd?: string | undefined;
|
|
29
|
+
/** Conditional build based upon the targets matching the `checksum.txt` file. */
|
|
30
|
+
conditional?: boolean;
|
|
31
|
+
}
|
|
32
|
+
declare function build(targets: string[] | undefined, options: BuildOptions): Promise<void>;
|
|
33
|
+
//#endregion
|
|
34
|
+
export { build, generateBTrie };
|
|
35
|
+
//# sourceMappingURL=index.d.mts.map
|
package/dist/index.mjs
ADDED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cspell/cspell-tools",
|
|
3
|
-
"version": "9.
|
|
3
|
+
"version": "9.6.1",
|
|
4
4
|
"description": "Tools to assist with the development of cSpell",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public",
|
|
@@ -13,10 +13,11 @@
|
|
|
13
13
|
"cspell-tools-cli": "bin.mjs"
|
|
14
14
|
},
|
|
15
15
|
"scripts": {
|
|
16
|
-
"build": "pnpm run build-schema && pnpm run compile",
|
|
16
|
+
"build": "pnpm run build-schema && pnpm run compile && pnpm build:check",
|
|
17
17
|
"build-schema": "ts-json-schema-generator --no-top-ref --path src/config/config.ts --type RunConfig --validation-keywords deprecated -o ./cspell-tools.config.schema.json",
|
|
18
|
-
"compile": "
|
|
19
|
-
"
|
|
18
|
+
"compile": "tsdown",
|
|
19
|
+
"build:check": "tsc -p .",
|
|
20
|
+
"watch": "tsdown -w",
|
|
20
21
|
"clean-build": "pnpm run clean && pnpm run build",
|
|
21
22
|
"clean": "shx rm -rf dist temp coverage \"*.tsbuildInfo\"",
|
|
22
23
|
"coverage": "vitest run --coverage",
|
|
@@ -37,7 +38,7 @@
|
|
|
37
38
|
],
|
|
38
39
|
"exports": {
|
|
39
40
|
".": {
|
|
40
|
-
"import": "./dist/
|
|
41
|
+
"import": "./dist/index.mjs"
|
|
41
42
|
},
|
|
42
43
|
"./bin": {
|
|
43
44
|
"import": "./bin.mjs"
|
|
@@ -63,12 +64,12 @@
|
|
|
63
64
|
},
|
|
64
65
|
"homepage": "https://github.com/streetsidesoftware/cspell/tree/main/packages/cspell-tools#readme",
|
|
65
66
|
"dependencies": {
|
|
66
|
-
"@cspell/cspell-pipe": "9.
|
|
67
|
+
"@cspell/cspell-pipe": "9.6.1",
|
|
67
68
|
"commander": "^14.0.2",
|
|
68
69
|
"cosmiconfig": "9.0.0",
|
|
69
|
-
"cspell-trie-lib": "9.
|
|
70
|
+
"cspell-trie-lib": "9.6.1",
|
|
70
71
|
"glob": "^13.0.0",
|
|
71
|
-
"hunspell-reader": "9.
|
|
72
|
+
"hunspell-reader": "9.6.1",
|
|
72
73
|
"yaml": "^2.8.2"
|
|
73
74
|
},
|
|
74
75
|
"engines": {
|
|
@@ -79,5 +80,5 @@
|
|
|
79
80
|
"ts-json-schema-generator": "^2.4.0"
|
|
80
81
|
},
|
|
81
82
|
"module": "bin.mjs",
|
|
82
|
-
"gitHead": "
|
|
83
|
+
"gitHead": "666fb79096d25c53af9519cad07030e7aca597e1"
|
|
83
84
|
}
|
package/dist/AppOptions.d.ts
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
export interface CompileCommonAppOptions {
|
|
2
|
-
output?: string | undefined;
|
|
3
|
-
compress: boolean;
|
|
4
|
-
/**
|
|
5
|
-
* @deprecated Use maxDepth
|
|
6
|
-
*/
|
|
7
|
-
max_depth?: string | undefined;
|
|
8
|
-
maxDepth?: string | undefined;
|
|
9
|
-
merge?: string | undefined;
|
|
10
|
-
experimental?: string[] | undefined;
|
|
11
|
-
split?: boolean | undefined;
|
|
12
|
-
sort?: boolean | undefined;
|
|
13
|
-
keepRawCase?: boolean | undefined;
|
|
14
|
-
trie?: boolean | undefined;
|
|
15
|
-
trie3?: boolean | undefined;
|
|
16
|
-
trie4?: boolean | undefined;
|
|
17
|
-
trieBase?: string | undefined;
|
|
18
|
-
listFile?: string[] | undefined;
|
|
19
|
-
useLegacySplitter?: boolean | undefined;
|
|
20
|
-
/** Indicate that a config file should be created instead of building. */
|
|
21
|
-
init?: boolean | undefined;
|
|
22
|
-
}
|
|
23
|
-
export interface CompileAppOptions extends CompileCommonAppOptions {
|
|
24
|
-
sort: boolean;
|
|
25
|
-
keepRawCase: boolean;
|
|
26
|
-
}
|
|
27
|
-
export interface CompileTrieAppOptions extends CompileCommonAppOptions {
|
|
28
|
-
trie3: boolean;
|
|
29
|
-
trie4: boolean;
|
|
30
|
-
}
|
|
31
|
-
//# sourceMappingURL=AppOptions.d.ts.map
|
package/dist/AppOptions.js
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
export interface FeatureFlag {
|
|
2
|
-
name: string;
|
|
3
|
-
description: string;
|
|
4
|
-
}
|
|
5
|
-
type FlagTypes = string | boolean;
|
|
6
|
-
/**
|
|
7
|
-
* Feature Flags are used to turn on/off features.
|
|
8
|
-
* These are primarily used before a feature has been fully released.
|
|
9
|
-
*/
|
|
10
|
-
export declare class FeatureFlags {
|
|
11
|
-
private flags;
|
|
12
|
-
private flagValues;
|
|
13
|
-
constructor(flags?: FeatureFlag[]);
|
|
14
|
-
register(flag: FeatureFlag): this;
|
|
15
|
-
register(name: string, description: string): this;
|
|
16
|
-
registerFeatures(flags: FeatureFlag[]): this;
|
|
17
|
-
getFlag(flag: string): FlagTypes | undefined;
|
|
18
|
-
getFlagBool(flag: string): boolean | undefined;
|
|
19
|
-
setFlag(flag: string, value?: FlagTypes): this;
|
|
20
|
-
getFlagInfo(flag: string): FeatureFlag | undefined;
|
|
21
|
-
getFlags(): FeatureFlag[];
|
|
22
|
-
getFlagValues(): Map<string, FlagTypes>;
|
|
23
|
-
reset(): this;
|
|
24
|
-
help(): string;
|
|
25
|
-
fork(): FeatureFlags;
|
|
26
|
-
}
|
|
27
|
-
export declare class UnknownFeatureFlagError extends Error {
|
|
28
|
-
readonly flag: string;
|
|
29
|
-
constructor(flag: string);
|
|
30
|
-
}
|
|
31
|
-
export declare function getSystemFeatureFlags(): FeatureFlags;
|
|
32
|
-
export declare function createFeatureFlags(): FeatureFlags;
|
|
33
|
-
export {};
|
|
34
|
-
//# sourceMappingURL=FeatureFlags.d.ts.map
|
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
let systemFeatureFlags;
|
|
2
|
-
/**
|
|
3
|
-
* Feature Flags are used to turn on/off features.
|
|
4
|
-
* These are primarily used before a feature has been fully released.
|
|
5
|
-
*/
|
|
6
|
-
export class FeatureFlags {
|
|
7
|
-
flags;
|
|
8
|
-
flagValues = new Map();
|
|
9
|
-
constructor(flags = []) {
|
|
10
|
-
this.flags = new Map(flags.map((f) => [f.name, f]));
|
|
11
|
-
}
|
|
12
|
-
register(flagOrName, description) {
|
|
13
|
-
if (typeof flagOrName === 'string') {
|
|
14
|
-
return this.register({ name: flagOrName, description: description || '' });
|
|
15
|
-
}
|
|
16
|
-
this.flags.set(flagOrName.name, flagOrName);
|
|
17
|
-
return this;
|
|
18
|
-
}
|
|
19
|
-
registerFeatures(flags) {
|
|
20
|
-
flags.forEach((flag) => this.register(flag));
|
|
21
|
-
return this;
|
|
22
|
-
}
|
|
23
|
-
getFlag(flag) {
|
|
24
|
-
return this.flagValues.get(flag);
|
|
25
|
-
}
|
|
26
|
-
getFlagBool(flag) {
|
|
27
|
-
return toBool(this.getFlag(flag));
|
|
28
|
-
}
|
|
29
|
-
setFlag(flag, value = true) {
|
|
30
|
-
if (!this.flags.has(flag)) {
|
|
31
|
-
throw new UnknownFeatureFlagError(flag);
|
|
32
|
-
}
|
|
33
|
-
this.flagValues.set(flag, toBool(value) ?? value);
|
|
34
|
-
return this;
|
|
35
|
-
}
|
|
36
|
-
getFlagInfo(flag) {
|
|
37
|
-
return this.flags.get(flag);
|
|
38
|
-
}
|
|
39
|
-
getFlags() {
|
|
40
|
-
return [...this.flags.values()];
|
|
41
|
-
}
|
|
42
|
-
getFlagValues() {
|
|
43
|
-
return new Map(this.flagValues);
|
|
44
|
-
}
|
|
45
|
-
reset() {
|
|
46
|
-
this.flagValues.clear();
|
|
47
|
-
return this;
|
|
48
|
-
}
|
|
49
|
-
help() {
|
|
50
|
-
const flags = [{ name: 'Name', description: 'Description' }, ...this.flags.values()].sort((a, b) => a.name < b.name ? -1 : 1);
|
|
51
|
-
const nameColWidth = flags.map((f) => f.name.length).reduce((a, b) => Math.max(a, b), 0) + 1;
|
|
52
|
-
const entries = flags.map((f) => `- ${f.name}${' '.repeat(nameColWidth - f.name.length)} ${f.description}`);
|
|
53
|
-
const text = `Valid Flags:\n${entries.join('\n')}`;
|
|
54
|
-
return text;
|
|
55
|
-
}
|
|
56
|
-
fork() {
|
|
57
|
-
const fork = new FeatureFlags([...this.flags.values()]);
|
|
58
|
-
for (const [key, value] of this.flagValues) {
|
|
59
|
-
fork.flagValues.set(key, value);
|
|
60
|
-
}
|
|
61
|
-
return fork;
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
export class UnknownFeatureFlagError extends Error {
|
|
65
|
-
flag;
|
|
66
|
-
constructor(flag) {
|
|
67
|
-
super(`Unknown feature flag: ${flag}`);
|
|
68
|
-
this.flag = flag;
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
export function getSystemFeatureFlags() {
|
|
72
|
-
return systemFeatureFlags || (systemFeatureFlags = createFeatureFlags());
|
|
73
|
-
}
|
|
74
|
-
export function createFeatureFlags() {
|
|
75
|
-
return new FeatureFlags();
|
|
76
|
-
}
|
|
77
|
-
const boolValues = {
|
|
78
|
-
0: false,
|
|
79
|
-
1: true,
|
|
80
|
-
f: false,
|
|
81
|
-
false: false,
|
|
82
|
-
n: false,
|
|
83
|
-
no: false,
|
|
84
|
-
t: true,
|
|
85
|
-
true: true,
|
|
86
|
-
y: true,
|
|
87
|
-
yes: true,
|
|
88
|
-
};
|
|
89
|
-
function toBool(value) {
|
|
90
|
-
if (typeof value !== 'string')
|
|
91
|
-
return value;
|
|
92
|
-
return boolValues[value.toLowerCase()];
|
|
93
|
-
}
|
|
94
|
-
//# sourceMappingURL=FeatureFlags.js.map
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { UnknownFeatureFlagError } from './FeatureFlags.js';
|
|
2
|
-
const splitFlag = /[:=]/;
|
|
3
|
-
const leadingEql = /^=/;
|
|
4
|
-
export function parseFlags(ff, flags) {
|
|
5
|
-
for (const flag of flags) {
|
|
6
|
-
const [name, value] = flag.replace(leadingEql, '').split(splitFlag, 2);
|
|
7
|
-
try {
|
|
8
|
-
ff.setFlag(name, value);
|
|
9
|
-
}
|
|
10
|
-
catch (e) {
|
|
11
|
-
if (e instanceof UnknownFeatureFlagError) {
|
|
12
|
-
console.error(e.message);
|
|
13
|
-
console.error(ff.help());
|
|
14
|
-
}
|
|
15
|
-
throw e;
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
return ff;
|
|
19
|
-
}
|
|
20
|
-
//# sourceMappingURL=parseFlags.js.map
|
package/dist/app.d.ts
DELETED
package/dist/app.js
DELETED
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
// For large dictionaries, it is necessary to increase the memory limit.
|
|
2
|
-
import { readFileSync } from 'node:fs';
|
|
3
|
-
import { CommanderError, Option } from 'commander';
|
|
4
|
-
import { build } from './build.js';
|
|
5
|
-
import { processCompileAction } from './compile.js';
|
|
6
|
-
import * as compiler from './compiler/index.js';
|
|
7
|
-
import { logWithTimestamp } from './compiler/logWithTimestamp.js';
|
|
8
|
-
import { gzip, OSFlags } from './gzip/index.js';
|
|
9
|
-
import { reportCheckChecksumFile, reportChecksumForFiles, updateChecksumForFiles } from './shasum/shasum.js';
|
|
10
|
-
import { toError } from './util/errors.js';
|
|
11
|
-
const npmPackageRaw = readFileSync(new URL('../package.json', import.meta.url), 'utf8');
|
|
12
|
-
const npmPackage = JSON.parse(npmPackageRaw);
|
|
13
|
-
compiler.setLogger(logWithTimestamp);
|
|
14
|
-
function collect(value, previous) {
|
|
15
|
-
return [...previous, value];
|
|
16
|
-
}
|
|
17
|
-
function addCompileOptions(compileCommand) {
|
|
18
|
-
return compileCommand
|
|
19
|
-
.option('-o, --output <path>', 'Specify the output directory, otherwise files are written back to the same location.')
|
|
20
|
-
.option('-n, --no-compress', 'By default the files are Gzipped, this will turn off GZ compression.')
|
|
21
|
-
.option('-m, --max_depth <limit>', 'Maximum depth to apply suffix rules.')
|
|
22
|
-
.option('-M, --merge <target>', 'Merge all files into a single target file (extensions are applied)')
|
|
23
|
-
.option('--split', 'Split each line', undefined)
|
|
24
|
-
.option('--no-split', 'Treat each line as a dictionary entry, do not split')
|
|
25
|
-
.option('--use-legacy-splitter', 'Do not use legacy line splitter logic.')
|
|
26
|
-
.option('--keep-raw-case', 'Do not normalize words before adding them to dictionary.')
|
|
27
|
-
.option('-x, --experimental <flag>', 'Experimental flags, used for testing new concepts. Flags: compound', collect, [])
|
|
28
|
-
.option('--trie3', 'Use file format trie3', false)
|
|
29
|
-
.option('--trie4', 'Use file format trie4', false)
|
|
30
|
-
.option('--trie-base <number>', 'Advanced: Set the trie base number. A value between 10 and 36')
|
|
31
|
-
.option('--list-file <filename...>', 'Path to a file that contains the list of files to compile. A list file contains one file per line.')
|
|
32
|
-
.option('--init', 'Create a build command `cspell-tools.config.yaml` file based upon the options given instead of building.');
|
|
33
|
-
}
|
|
34
|
-
export async function run(program, argv, flags) {
|
|
35
|
-
async function handleGzip(files) {
|
|
36
|
-
try {
|
|
37
|
-
await gzip(files, OSFlags.Unix);
|
|
38
|
-
}
|
|
39
|
-
catch (error) {
|
|
40
|
-
const err = toError(error);
|
|
41
|
-
program.error(err.message);
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
async function shasum(files, options) {
|
|
45
|
-
const report = options.check
|
|
46
|
-
? await reportCheckChecksumFile(options.check, files, options)
|
|
47
|
-
: options.update
|
|
48
|
-
? await updateChecksumForFiles(options.update, files, options)
|
|
49
|
-
: await reportChecksumForFiles(files, options);
|
|
50
|
-
console.log('%s', report.report);
|
|
51
|
-
if (!report.passed) {
|
|
52
|
-
throw new CommanderError(1, 'Failed Checksum', 'One or more files had issues.');
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
program.exitOverride();
|
|
56
|
-
program.version(npmPackage.version);
|
|
57
|
-
addCompileOptions(program.command('compile [src...]').description('Compile words into a cspell dictionary files.'))
|
|
58
|
-
.option('--trie', 'Compile into a trie file.', false)
|
|
59
|
-
.option('--no-sort', 'Do not sort the result')
|
|
60
|
-
.action((src, options) => {
|
|
61
|
-
return processCompileAction(src, options, flags);
|
|
62
|
-
});
|
|
63
|
-
addCompileOptions(program
|
|
64
|
-
.command('compile-trie [src...]')
|
|
65
|
-
.description('Compile words lists or Hunspell dictionary into trie files used by cspell.\nAlias of `compile --trie`')).action((src, options) => {
|
|
66
|
-
return processCompileAction(src, { ...options, trie: true }, flags);
|
|
67
|
-
});
|
|
68
|
-
program
|
|
69
|
-
.command('build [targets...]')
|
|
70
|
-
.description('Build the targets defined in the run configuration.')
|
|
71
|
-
.option('-c, --config <path to run configuration>', 'Specify the run configuration file.')
|
|
72
|
-
.option('--conditional', 'Conditional build.')
|
|
73
|
-
.option('-r, --root <directory>', 'Specify the run directory')
|
|
74
|
-
.action(build);
|
|
75
|
-
program.command('gzip <files...>').description('GZip files while keeping the original.').action(handleGzip);
|
|
76
|
-
program
|
|
77
|
-
.command('shasum [files...]')
|
|
78
|
-
.description('Calculate the checksum for files.')
|
|
79
|
-
.option('--list-file <list-file.txt...>', 'Specify one or more files that contain paths of files to check.')
|
|
80
|
-
.option('-c, --check <checksum.txt>', 'Verify the checksum of files against those stored in the checksum.txt file.')
|
|
81
|
-
.addOption(new Option('-u, --update <checksum.txt>', 'Update checksums found in the file.').conflicts('--check'))
|
|
82
|
-
.option('-r, --root <root>', 'Specify the root to use for relative paths. The current working directory is used by default.')
|
|
83
|
-
.action(shasum);
|
|
84
|
-
await program.parseAsync(argv);
|
|
85
|
-
}
|
|
86
|
-
//# sourceMappingURL=app.js.map
|
package/dist/build.d.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
export interface BuildOptions {
|
|
2
|
-
/** Optional path to config file */
|
|
3
|
-
config?: string | undefined;
|
|
4
|
-
/** Used to resolve relative paths in the config. */
|
|
5
|
-
root?: string | undefined;
|
|
6
|
-
/** Current working directory */
|
|
7
|
-
cwd?: string | undefined;
|
|
8
|
-
/** Conditional build based upon the targets matching the `checksum.txt` file. */
|
|
9
|
-
conditional?: boolean;
|
|
10
|
-
}
|
|
11
|
-
export declare function build(targets: string[] | undefined, options: BuildOptions): Promise<void>;
|
|
12
|
-
//# sourceMappingURL=build.d.ts.map
|
package/dist/build.js
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import * as path from 'node:path';
|
|
2
|
-
import { cosmiconfig } from 'cosmiconfig';
|
|
3
|
-
import { compile } from './compiler/index.js';
|
|
4
|
-
import { normalizeConfig } from './config/index.js';
|
|
5
|
-
const moduleName = 'cspell-tools';
|
|
6
|
-
const searchPlaces = [
|
|
7
|
-
`${moduleName}.config.json`,
|
|
8
|
-
`${moduleName}.config.yaml`,
|
|
9
|
-
`${moduleName}.config.yml`,
|
|
10
|
-
'package.json',
|
|
11
|
-
];
|
|
12
|
-
export async function build(targets, options) {
|
|
13
|
-
const allowedTargets = new Set(targets || []);
|
|
14
|
-
function filter(target) {
|
|
15
|
-
return !allowedTargets.size || allowedTargets.has(target.name);
|
|
16
|
-
}
|
|
17
|
-
const searchDir = path.resolve(options.root || options.cwd || '.');
|
|
18
|
-
const explorer = cosmiconfig(moduleName, {
|
|
19
|
-
searchPlaces,
|
|
20
|
-
stopDir: searchDir,
|
|
21
|
-
transform: normalizeConfig,
|
|
22
|
-
});
|
|
23
|
-
const config = await (options.config ? explorer.load(options.config) : explorer.search(searchDir));
|
|
24
|
-
if (!config?.config) {
|
|
25
|
-
console.error('root: %s', options.root);
|
|
26
|
-
throw 'cspell-tools.config not found.';
|
|
27
|
-
}
|
|
28
|
-
const configDir = path.dirname(config.filepath);
|
|
29
|
-
const buildInfo = normalizeRequest(config.config, path.resolve(configDir, options.root || configDir));
|
|
30
|
-
await compile(buildInfo, { filter, cwd: options.cwd, conditionalBuild: options.conditional || false });
|
|
31
|
-
}
|
|
32
|
-
function normalizeRequest(buildInfo, root) {
|
|
33
|
-
const { rootDir = root, targets = [], checksumFile } = buildInfo;
|
|
34
|
-
return { rootDir: path.resolve(rootDir), targets, checksumFile };
|
|
35
|
-
}
|
|
36
|
-
//# sourceMappingURL=build.js.map
|
package/dist/compile.d.ts
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import type { CompileCommonAppOptions } from './AppOptions.js';
|
|
2
|
-
import type { FeatureFlags } from './FeatureFlags/index.js';
|
|
3
|
-
export declare const configFileHeader: string;
|
|
4
|
-
export declare function processCompileAction(src: string[], options: CompileCommonAppOptions, featureFlags: FeatureFlags | undefined): Promise<void>;
|
|
5
|
-
//# sourceMappingURL=compile.d.ts.map
|
package/dist/compile.js
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import { writeFile } from 'node:fs/promises';
|
|
2
|
-
import { opConcatMap, pipe } from '@cspell/cspell-pipe/sync';
|
|
3
|
-
import YAML from 'yaml';
|
|
4
|
-
import { compile } from './compiler/compile.js';
|
|
5
|
-
import { createCompileRequest } from './compiler/createCompileRequest.js';
|
|
6
|
-
import { configFileSchemaURL } from './config/config.js';
|
|
7
|
-
import { getSystemFeatureFlags, parseFlags } from './FeatureFlags/index.js';
|
|
8
|
-
import { globP } from './util/globP.js';
|
|
9
|
-
getSystemFeatureFlags().register('compound', 'Enable compound dictionary sources.');
|
|
10
|
-
const defaultConfigFile = 'cspell-tools.config.yaml';
|
|
11
|
-
export const configFileHeader = `# yaml-language-server: $schema=${configFileSchemaURL}\n\n`;
|
|
12
|
-
export async function processCompileAction(src, options, featureFlags) {
|
|
13
|
-
const ff = featureFlags || getSystemFeatureFlags();
|
|
14
|
-
parseFlags(ff, options.experimental || []);
|
|
15
|
-
return useCompile(src, options);
|
|
16
|
-
}
|
|
17
|
-
async function useCompile(src, options) {
|
|
18
|
-
console.log('Compile:\n output: %s\n compress: %s\n files:\n %s', options.output || 'default', options.compress ? 'true' : 'false', src.join('\n '));
|
|
19
|
-
if (options.listFile && options.listFile.length) {
|
|
20
|
-
console.log(' list files:\n %s', options.listFile.join('\n '));
|
|
21
|
-
}
|
|
22
|
-
console.log('\n\n');
|
|
23
|
-
const globResults = await Promise.all(src.map((s) => globP(s)));
|
|
24
|
-
const sources = [
|
|
25
|
-
...pipe(globResults, opConcatMap((a) => a)),
|
|
26
|
-
];
|
|
27
|
-
const request = createCompileRequest(sources, options);
|
|
28
|
-
return options.init ? initConfig(request) : compile(request);
|
|
29
|
-
}
|
|
30
|
-
async function initConfig(runConfig) {
|
|
31
|
-
const { $schema = configFileSchemaURL, ...cfg } = runConfig;
|
|
32
|
-
const config = { $schema, ...cfg };
|
|
33
|
-
const content = configFileHeader + YAML.stringify(config, undefined, 2);
|
|
34
|
-
console.log('Writing config file: %s', defaultConfigFile);
|
|
35
|
-
await writeFile(defaultConfigFile, content);
|
|
36
|
-
console.log(`Init complete.
|
|
37
|
-
To build, use:
|
|
38
|
-
cspell-tools-cli build
|
|
39
|
-
`);
|
|
40
|
-
}
|
|
41
|
-
//# sourceMappingURL=compile.js.map
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
export interface CompileOptions {
|
|
2
|
-
/**
|
|
3
|
-
* Sort the words in the resulting dictionary.
|
|
4
|
-
* Does not apply to `trie` based formats.
|
|
5
|
-
*/
|
|
6
|
-
sort: boolean;
|
|
7
|
-
/**
|
|
8
|
-
* Generate lower case / accent free versions of words.
|
|
9
|
-
*/
|
|
10
|
-
generateNonStrict: boolean;
|
|
11
|
-
/**
|
|
12
|
-
* Optional filter function to filter out words.
|
|
13
|
-
* @param word the word to test
|
|
14
|
-
* @returns `true` to keep the word, `false` to exclude it.
|
|
15
|
-
*/
|
|
16
|
-
filter?: ((word: string) => boolean) | undefined;
|
|
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;
|
|
28
|
-
/**
|
|
29
|
-
* Remove duplicate words, favor lower case words over mixed case words.
|
|
30
|
-
* Combine compound prefixes where possible.
|
|
31
|
-
* @default false
|
|
32
|
-
*/
|
|
33
|
-
removeDuplicates?: boolean | undefined;
|
|
34
|
-
}
|
|
35
|
-
//# sourceMappingURL=CompileOptions.d.ts.map
|
package/dist/compiler/Reader.js
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { readHunspellFiles } from './readers/readHunspellFiles.js';
|
|
2
|
-
import { regHunspellFile } from './readers/regHunspellFile.js';
|
|
3
|
-
import { textFileReader } from './readers/textFileReader.js';
|
|
4
|
-
import { trieFileReader } from './readers/trieFileReader.js';
|
|
5
|
-
// Readers first match wins
|
|
6
|
-
const readers = [
|
|
7
|
-
{ test: /\.trie\b/, method: trieFileReader },
|
|
8
|
-
{ test: regHunspellFile, method: readHunspellFiles },
|
|
9
|
-
];
|
|
10
|
-
function findMatchingReader(filename, options) {
|
|
11
|
-
for (const reader of readers) {
|
|
12
|
-
if (reader.test.test(filename)) {
|
|
13
|
-
return reader.method(filename, options);
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
return textFileReader(filename);
|
|
17
|
-
}
|
|
18
|
-
export async function createReader(filename, options) {
|
|
19
|
-
const baseReader = await findMatchingReader(filename, options);
|
|
20
|
-
return Object.assign(baseReader, {
|
|
21
|
-
[Symbol.iterator]: () => baseReader.lines[Symbol.iterator](),
|
|
22
|
-
});
|
|
23
|
-
}
|
|
24
|
-
//# sourceMappingURL=Reader.js.map
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import type { AllowedSplitWordsCollection } from './WordsCollection.js';
|
|
2
|
-
export interface SourceReaderOptions {
|
|
3
|
-
/**
|
|
4
|
-
* Max Hunspell recursive depth.
|
|
5
|
-
*/
|
|
6
|
-
maxDepth?: number | undefined;
|
|
7
|
-
/**
|
|
8
|
-
* split words if necessary.
|
|
9
|
-
*/
|
|
10
|
-
splitWords: boolean;
|
|
11
|
-
/**
|
|
12
|
-
* Indicate that it is an unformatted file and needs to be cleaned
|
|
13
|
-
* before processing. Applies only to text file sources.
|
|
14
|
-
* @default false
|
|
15
|
-
*/
|
|
16
|
-
legacy?: boolean | undefined;
|
|
17
|
-
keepCase?: boolean | undefined;
|
|
18
|
-
allowedSplitWords: AllowedSplitWordsCollection;
|
|
19
|
-
storeSplitWordsAsCompounds: boolean | undefined;
|
|
20
|
-
minCompoundLength?: number | undefined;
|
|
21
|
-
}
|
|
22
|
-
export type AnnotatedWord = string;
|
|
23
|
-
export interface SourceReader {
|
|
24
|
-
size: number;
|
|
25
|
-
words: Iterable<AnnotatedWord>;
|
|
26
|
-
}
|
|
27
|
-
export declare function createSourceReader(filename: string, options: SourceReaderOptions): Promise<SourceReader>;
|
|
28
|
-
//# sourceMappingURL=SourceReader.d.ts.map
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import { createReader } from './Reader.js';
|
|
2
|
-
import { parseFileLines } from './wordListParser.js';
|
|
3
|
-
export async function createSourceReader(filename, options) {
|
|
4
|
-
const reader = await createReader(filename, options);
|
|
5
|
-
if (reader.type !== 'TextFile') {
|
|
6
|
-
return {
|
|
7
|
-
words: splitLines(reader.lines, options),
|
|
8
|
-
get size() {
|
|
9
|
-
return reader.size;
|
|
10
|
-
},
|
|
11
|
-
};
|
|
12
|
-
}
|
|
13
|
-
return textFileReader(reader, options);
|
|
14
|
-
}
|
|
15
|
-
function splitLines(lines, options) {
|
|
16
|
-
if (!options.splitWords)
|
|
17
|
-
return lines;
|
|
18
|
-
function* split() {
|
|
19
|
-
const regNonWordOrDigit = /[^\p{L}\p{M}'\w-]+/giu;
|
|
20
|
-
for (const line of lines) {
|
|
21
|
-
const words = line.split(regNonWordOrDigit);
|
|
22
|
-
yield* words;
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
return split();
|
|
26
|
-
}
|
|
27
|
-
async function textFileReader(reader, options) {
|
|
28
|
-
const { legacy, splitWords: split, allowedSplitWords, storeSplitWordsAsCompounds, minCompoundLength } = options;
|
|
29
|
-
const parseOptions = {
|
|
30
|
-
legacy,
|
|
31
|
-
split,
|
|
32
|
-
splitKeepBoth: undefined,
|
|
33
|
-
keepCase: undefined,
|
|
34
|
-
allowedSplitWords,
|
|
35
|
-
storeSplitWordsAsCompounds,
|
|
36
|
-
minCompoundLength,
|
|
37
|
-
};
|
|
38
|
-
const words = [...parseFileLines(reader.lines, parseOptions)];
|
|
39
|
-
return {
|
|
40
|
-
size: words.length,
|
|
41
|
-
words,
|
|
42
|
-
};
|
|
43
|
-
}
|
|
44
|
-
//# sourceMappingURL=SourceReader.js.map
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
export interface WordsCollection {
|
|
2
|
-
size: number;
|
|
3
|
-
has(words: string, caseSensitive: boolean): boolean;
|
|
4
|
-
type?: string;
|
|
5
|
-
}
|
|
6
|
-
/**
|
|
7
|
-
* Collection of words to be allowed after splitting.
|
|
8
|
-
*/
|
|
9
|
-
export interface AllowedSplitWordsCollection extends WordsCollection {
|
|
10
|
-
type?: 'AllowedSplitWordsCollection';
|
|
11
|
-
}
|
|
12
|
-
export declare const defaultAllowedSplitWords: AllowedSplitWordsCollection;
|
|
13
|
-
/**
|
|
14
|
-
* Collection of words to be excluded.
|
|
15
|
-
*/
|
|
16
|
-
export interface ExcludeWordsCollection extends WordsCollection {
|
|
17
|
-
type?: 'ExcludeWordsCollection';
|
|
18
|
-
}
|
|
19
|
-
export declare const defaultExcludeWordsCollection: ExcludeWordsCollection;
|
|
20
|
-
//# sourceMappingURL=WordsCollection.d.ts.map
|