@cspell/cspell-tools 6.11.1 → 6.13.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/AppOptions.d.ts +28 -0
- package/dist/AppOptions.js +3 -0
- package/dist/FeatureFlags/FeatureFlags.d.ts +34 -0
- package/dist/FeatureFlags/FeatureFlags.js +99 -0
- package/dist/FeatureFlags/index.d.ts +3 -0
- package/dist/FeatureFlags/index.js +10 -0
- package/dist/FeatureFlags/parseFlags.d.ts +3 -0
- package/dist/FeatureFlags/parseFlags.js +24 -0
- package/dist/app.d.ts +2 -21
- package/dist/app.js +25 -144
- package/dist/build.d.ts +7 -0
- package/dist/build.js +59 -0
- package/dist/compile.d.ts +4 -0
- package/dist/compile.js +24 -0
- package/dist/compiler/CompileOptions.d.ts +12 -0
- package/dist/compiler/CompileOptions.js +3 -0
- package/dist/compiler/Reader.d.ts +16 -11
- package/dist/compiler/Reader.js +38 -91
- package/dist/compiler/compile.d.ts +11 -0
- package/dist/compiler/compile.js +157 -0
- package/dist/compiler/createCompileRequest.d.ts +4 -0
- package/dist/compiler/createCompileRequest.js +86 -0
- package/dist/compiler/fileWriter.d.ts +2 -3
- package/dist/compiler/fileWriter.js +5 -7
- package/dist/compiler/globP.d.ts +2 -0
- package/dist/compiler/globP.js +16 -0
- package/dist/compiler/index.d.ts +4 -1
- package/dist/compiler/index.js +9 -15
- package/dist/compiler/iterateWordsFromFile.d.ts +1 -2
- package/dist/compiler/iterateWordsFromFile.js +1 -1
- package/dist/compiler/legacyLineToWords.d.ts +3 -0
- package/dist/compiler/legacyLineToWords.js +54 -0
- package/dist/compiler/logWithTimestamp.d.ts +3 -0
- package/dist/compiler/logWithTimestamp.js +9 -0
- package/dist/compiler/logger.d.ts +4 -0
- package/dist/compiler/logger.js +14 -0
- package/dist/compiler/readTextFile.d.ts +3 -0
- package/dist/compiler/readTextFile.js +45 -0
- package/dist/compiler/wordListCompiler.d.ts +3 -33
- package/dist/compiler/wordListCompiler.js +13 -169
- package/dist/compiler/wordListParser.d.ts +46 -0
- package/dist/compiler/wordListParser.js +171 -0
- package/dist/compiler/writeTextToFile.d.ts +3 -0
- package/dist/compiler/writeTextToFile.js +44 -0
- package/dist/config/config.d.ts +109 -0
- package/dist/config/config.js +3 -0
- package/dist/config/configUtils.d.ts +5 -0
- package/dist/config/configUtils.js +20 -0
- package/dist/config/index.d.ts +4 -0
- package/dist/config/index.js +10 -0
- package/dist/config/normalizeConfig.d.ts +8 -0
- package/dist/config/normalizeConfig.js +40 -0
- package/dist/test/TestHelper.d.ts +42 -0
- package/dist/test/TestHelper.js +131 -0
- package/dist/test/console.d.ts +10 -0
- package/dist/test/console.js +23 -0
- package/dist/test/escapeRegEx.d.ts +7 -0
- package/dist/test/escapeRegEx.js +13 -0
- package/dist/test/normalizeOutput.d.ts +3 -0
- package/dist/test/normalizeOutput.js +46 -0
- package/package.json +15 -11
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export interface CompileCommonAppOptions {
|
|
2
|
+
output?: string;
|
|
3
|
+
compress: boolean;
|
|
4
|
+
/**
|
|
5
|
+
* @deprecated Use maxDepth
|
|
6
|
+
*/
|
|
7
|
+
max_depth?: string;
|
|
8
|
+
maxDepth?: string;
|
|
9
|
+
merge?: string;
|
|
10
|
+
experimental: string[];
|
|
11
|
+
split?: boolean;
|
|
12
|
+
sort?: boolean;
|
|
13
|
+
keepRawCase?: boolean;
|
|
14
|
+
trie?: boolean;
|
|
15
|
+
trie3?: boolean;
|
|
16
|
+
trie4?: boolean;
|
|
17
|
+
trieBase?: string;
|
|
18
|
+
useLegacySplitter?: boolean;
|
|
19
|
+
}
|
|
20
|
+
export interface CompileAppOptions extends CompileCommonAppOptions {
|
|
21
|
+
sort: boolean;
|
|
22
|
+
keepRawCase: boolean;
|
|
23
|
+
}
|
|
24
|
+
export interface CompileTrieAppOptions extends CompileCommonAppOptions {
|
|
25
|
+
trie3: boolean;
|
|
26
|
+
trie4: boolean;
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=AppOptions.d.ts.map
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
export interface FeatureFlag {
|
|
2
|
+
name: string;
|
|
3
|
+
description: string;
|
|
4
|
+
}
|
|
5
|
+
declare 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
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createFeatureFlags = exports.getSystemFeatureFlags = exports.UnknownFeatureFlagError = exports.FeatureFlags = void 0;
|
|
4
|
+
let systemFeatureFlags;
|
|
5
|
+
/**
|
|
6
|
+
* Feature Flags are used to turn on/off features.
|
|
7
|
+
* These are primarily used before a feature has been fully released.
|
|
8
|
+
*/
|
|
9
|
+
class FeatureFlags {
|
|
10
|
+
constructor(flags = []) {
|
|
11
|
+
this.flagValues = new Map();
|
|
12
|
+
this.flags = new Map(flags.map((f) => [f.name, f]));
|
|
13
|
+
}
|
|
14
|
+
register(flagOrName, description) {
|
|
15
|
+
if (typeof flagOrName === 'string') {
|
|
16
|
+
return this.register({ name: flagOrName, description: description || '' });
|
|
17
|
+
}
|
|
18
|
+
this.flags.set(flagOrName.name, flagOrName);
|
|
19
|
+
return this;
|
|
20
|
+
}
|
|
21
|
+
registerFeatures(flags) {
|
|
22
|
+
flags.forEach((flag) => this.register(flag));
|
|
23
|
+
return this;
|
|
24
|
+
}
|
|
25
|
+
getFlag(flag) {
|
|
26
|
+
return this.flagValues.get(flag);
|
|
27
|
+
}
|
|
28
|
+
getFlagBool(flag) {
|
|
29
|
+
return toBool(this.getFlag(flag));
|
|
30
|
+
}
|
|
31
|
+
setFlag(flag, value = true) {
|
|
32
|
+
if (!this.flags.has(flag)) {
|
|
33
|
+
throw new UnknownFeatureFlagError(flag);
|
|
34
|
+
}
|
|
35
|
+
this.flagValues.set(flag, toBool(value) ?? value);
|
|
36
|
+
return this;
|
|
37
|
+
}
|
|
38
|
+
getFlagInfo(flag) {
|
|
39
|
+
return this.flags.get(flag);
|
|
40
|
+
}
|
|
41
|
+
getFlags() {
|
|
42
|
+
return [...this.flags.values()];
|
|
43
|
+
}
|
|
44
|
+
getFlagValues() {
|
|
45
|
+
return new Map(this.flagValues);
|
|
46
|
+
}
|
|
47
|
+
reset() {
|
|
48
|
+
this.flagValues.clear();
|
|
49
|
+
return this;
|
|
50
|
+
}
|
|
51
|
+
help() {
|
|
52
|
+
const flags = [{ name: 'Name', description: 'Description' }, ...this.flags.values()].sort((a, b) => a.name < b.name ? -1 : 1);
|
|
53
|
+
const nameColWidth = flags.map((f) => f.name.length).reduce((a, b) => Math.max(a, b), 0) + 1;
|
|
54
|
+
const entries = flags.map((f) => `- ${f.name}${' '.repeat(nameColWidth - f.name.length)} ${f.description}`);
|
|
55
|
+
const text = `Valid Flags:\n${entries.join('\n')}`;
|
|
56
|
+
return text;
|
|
57
|
+
}
|
|
58
|
+
fork() {
|
|
59
|
+
const fork = new FeatureFlags([...this.flags.values()]);
|
|
60
|
+
for (const [key, value] of this.flagValues) {
|
|
61
|
+
fork.flagValues.set(key, value);
|
|
62
|
+
}
|
|
63
|
+
return fork;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
exports.FeatureFlags = FeatureFlags;
|
|
67
|
+
class UnknownFeatureFlagError extends Error {
|
|
68
|
+
constructor(flag) {
|
|
69
|
+
super(`Unknown feature flag: ${flag}`);
|
|
70
|
+
this.flag = flag;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
exports.UnknownFeatureFlagError = UnknownFeatureFlagError;
|
|
74
|
+
function getSystemFeatureFlags() {
|
|
75
|
+
return systemFeatureFlags || (systemFeatureFlags = createFeatureFlags());
|
|
76
|
+
}
|
|
77
|
+
exports.getSystemFeatureFlags = getSystemFeatureFlags;
|
|
78
|
+
function createFeatureFlags() {
|
|
79
|
+
return new FeatureFlags();
|
|
80
|
+
}
|
|
81
|
+
exports.createFeatureFlags = createFeatureFlags;
|
|
82
|
+
const boolValues = {
|
|
83
|
+
0: false,
|
|
84
|
+
1: true,
|
|
85
|
+
f: false,
|
|
86
|
+
false: false,
|
|
87
|
+
n: false,
|
|
88
|
+
no: false,
|
|
89
|
+
t: true,
|
|
90
|
+
true: true,
|
|
91
|
+
y: true,
|
|
92
|
+
yes: true,
|
|
93
|
+
};
|
|
94
|
+
function toBool(value) {
|
|
95
|
+
if (typeof value !== 'string')
|
|
96
|
+
return value;
|
|
97
|
+
return boolValues[value.toLowerCase()];
|
|
98
|
+
}
|
|
99
|
+
//# sourceMappingURL=FeatureFlags.js.map
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.parseFlags = exports.UnknownFeatureFlagError = exports.getSystemFeatureFlags = exports.FeatureFlags = void 0;
|
|
4
|
+
var FeatureFlags_1 = require("./FeatureFlags");
|
|
5
|
+
Object.defineProperty(exports, "FeatureFlags", { enumerable: true, get: function () { return FeatureFlags_1.FeatureFlags; } });
|
|
6
|
+
Object.defineProperty(exports, "getSystemFeatureFlags", { enumerable: true, get: function () { return FeatureFlags_1.getSystemFeatureFlags; } });
|
|
7
|
+
Object.defineProperty(exports, "UnknownFeatureFlagError", { enumerable: true, get: function () { return FeatureFlags_1.UnknownFeatureFlagError; } });
|
|
8
|
+
var parseFlags_1 = require("./parseFlags");
|
|
9
|
+
Object.defineProperty(exports, "parseFlags", { enumerable: true, get: function () { return parseFlags_1.parseFlags; } });
|
|
10
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.parseFlags = void 0;
|
|
4
|
+
const FeatureFlags_1 = require("./FeatureFlags");
|
|
5
|
+
const splitFlag = /[:=]/;
|
|
6
|
+
const leadingEql = /^=/;
|
|
7
|
+
function parseFlags(ff, flags) {
|
|
8
|
+
for (const flag of flags) {
|
|
9
|
+
const [name, value] = flag.replace(leadingEql, '').split(splitFlag, 2);
|
|
10
|
+
try {
|
|
11
|
+
ff.setFlag(name, value);
|
|
12
|
+
}
|
|
13
|
+
catch (e) {
|
|
14
|
+
if (e instanceof FeatureFlags_1.UnknownFeatureFlagError) {
|
|
15
|
+
console.error(e.message);
|
|
16
|
+
console.error(ff.help());
|
|
17
|
+
}
|
|
18
|
+
throw e;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
return ff;
|
|
22
|
+
}
|
|
23
|
+
exports.parseFlags = parseFlags;
|
|
24
|
+
//# sourceMappingURL=parseFlags.js.map
|
package/dist/app.d.ts
CHANGED
|
@@ -1,23 +1,4 @@
|
|
|
1
1
|
import * as program from 'commander';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
compress: boolean;
|
|
5
|
-
max_depth?: string;
|
|
6
|
-
merge?: string;
|
|
7
|
-
experimental: string[];
|
|
8
|
-
split?: boolean;
|
|
9
|
-
sort?: boolean;
|
|
10
|
-
keepRawCase?: boolean;
|
|
11
|
-
trie?: boolean;
|
|
12
|
-
trie3?: boolean;
|
|
13
|
-
trie4?: boolean;
|
|
14
|
-
trieBase?: string;
|
|
15
|
-
useLegacySplitter?: boolean;
|
|
16
|
-
}
|
|
17
|
-
export declare function run(program: program.Command, argv: string[]): Promise<void>;
|
|
18
|
-
declare function processAction(src: string[], options: CompileCommonOptions): Promise<void>;
|
|
19
|
-
export declare const __testing__: {
|
|
20
|
-
processAction: typeof processAction;
|
|
21
|
-
};
|
|
22
|
-
export {};
|
|
2
|
+
import { FeatureFlags } from './FeatureFlags';
|
|
3
|
+
export declare function run(program: program.Command, argv: string[], flags?: FeatureFlags): Promise<void>;
|
|
23
4
|
//# sourceMappingURL=app.d.ts.map
|
package/dist/app.js
CHANGED
|
@@ -23,33 +23,16 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
23
23
|
__setModuleDefault(result, mod);
|
|
24
24
|
return result;
|
|
25
25
|
};
|
|
26
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
27
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
28
|
-
};
|
|
29
26
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
30
|
-
exports.
|
|
31
|
-
const compiler_1 = require("./compiler");
|
|
32
|
-
const compiler = __importStar(require("./compiler"));
|
|
27
|
+
exports.run = void 0;
|
|
33
28
|
const path = __importStar(require("path"));
|
|
34
|
-
const
|
|
35
|
-
const
|
|
36
|
-
const
|
|
29
|
+
const compiler = __importStar(require("./compiler"));
|
|
30
|
+
const logWithTimestamp_1 = require("./compiler/logWithTimestamp");
|
|
31
|
+
const compile_1 = require("./compile");
|
|
32
|
+
const build_1 = require("./build");
|
|
37
33
|
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
38
34
|
const npmPackage = require(path.join(__dirname, '..', 'package.json'));
|
|
39
|
-
|
|
40
|
-
// Convert windows separators.
|
|
41
|
-
pattern = pattern.replace(/\\/g, '/');
|
|
42
|
-
return new Promise((resolve, reject) => {
|
|
43
|
-
(0, glob_1.default)(pattern, (err, result) => {
|
|
44
|
-
err ? reject(err) : resolve(result);
|
|
45
|
-
});
|
|
46
|
-
});
|
|
47
|
-
}
|
|
48
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
49
|
-
const log = (message, ...optionalParams) => {
|
|
50
|
-
console.log(`${new Date().toISOString()} ${message}`, ...optionalParams);
|
|
51
|
-
};
|
|
52
|
-
compiler.setLogger(log);
|
|
35
|
+
compiler.setLogger(logWithTimestamp_1.logWithTimestamp);
|
|
53
36
|
function collect(value, previous) {
|
|
54
37
|
return previous.concat([value]);
|
|
55
38
|
}
|
|
@@ -68,129 +51,27 @@ function addCompileOptions(compileCommand) {
|
|
|
68
51
|
.option('--trie4', 'Use file format trie4', false)
|
|
69
52
|
.option('--trie-base <number>', 'Advanced: Set the trie base number. A value between 10 and 36');
|
|
70
53
|
}
|
|
71
|
-
function run(program, argv) {
|
|
54
|
+
async function run(program, argv, flags) {
|
|
72
55
|
program.exitOverride();
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
const result = processAction(src, options);
|
|
80
|
-
resolve(result);
|
|
81
|
-
});
|
|
82
|
-
addCompileOptions(program
|
|
83
|
-
.command('compile-trie <src...>')
|
|
84
|
-
.description('Compile words lists or Hunspell dictionary into trie files used by cspell.\nAlias of `compile --trie`')).action((src, options) => {
|
|
85
|
-
const result = processAction(src, { ...options, trie: true });
|
|
86
|
-
resolve(result);
|
|
87
|
-
});
|
|
88
|
-
try {
|
|
89
|
-
program.parse(argv);
|
|
90
|
-
if (!argv.slice(2).length) {
|
|
91
|
-
program.help();
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
catch (e) {
|
|
95
|
-
reject(e);
|
|
96
|
-
}
|
|
97
|
-
resolve();
|
|
98
|
-
});
|
|
99
|
-
}
|
|
100
|
-
exports.run = run;
|
|
101
|
-
function parseNumber(s) {
|
|
102
|
-
const n = parseInt(s ?? '');
|
|
103
|
-
return isNaN(n) ? undefined : n;
|
|
104
|
-
}
|
|
105
|
-
async function processAction(src, options) {
|
|
106
|
-
const useTrie = options.trie || options.trie3 || options.trie4 || false;
|
|
107
|
-
const fileExt = useTrie ? '.trie' : '.txt';
|
|
108
|
-
console.log('Compile:\n output: %s\n compress: %s\n files:\n %s \n\n', options.output || 'default', options.compress ? 'true' : 'false', src.join('\n '));
|
|
109
|
-
const experimental = new Set(options.experimental);
|
|
110
|
-
const skipNormalization = experimental.has('compound');
|
|
111
|
-
const { keepRawCase = false, split: splitWords = false, sort = true, useLegacySplitter: legacy } = options;
|
|
112
|
-
const action = useTrie
|
|
113
|
-
? async (words, dst) => {
|
|
114
|
-
return (0, compiler_1.compileTrie)(words, dst, {
|
|
115
|
-
...options,
|
|
116
|
-
skipNormalization,
|
|
117
|
-
splitWords,
|
|
118
|
-
keepRawCase,
|
|
119
|
-
legacy,
|
|
120
|
-
base: parseNumber(options.trieBase),
|
|
121
|
-
sort: false,
|
|
122
|
-
});
|
|
123
|
-
}
|
|
124
|
-
: async (src, dst) => {
|
|
125
|
-
return (0, compiler_1.compileWordList)(src, dst, {
|
|
126
|
-
splitWords,
|
|
127
|
-
sort,
|
|
128
|
-
skipNormalization,
|
|
129
|
-
keepRawCase,
|
|
130
|
-
legacy,
|
|
131
|
-
}).then(() => src);
|
|
132
|
-
};
|
|
133
|
-
const ext = fileExt + (options.compress ? '.gz' : '');
|
|
134
|
-
const maxDepth = parseNumber(options.max_depth);
|
|
135
|
-
const useAnnotation = experimental.has('compound');
|
|
136
|
-
const readerOptions = { maxDepth, useAnnotation };
|
|
137
|
-
const globResults = await Promise.all(src.map((s) => globP(s)));
|
|
138
|
-
const filesToProcess = (0, gensequence_1.genSequence)(globResults)
|
|
139
|
-
.concatMap((files) => files)
|
|
140
|
-
.map(async (filename) => {
|
|
141
|
-
log(`Reading ${path.basename(filename)}`);
|
|
142
|
-
const words = await (0, iterateWordsFromFile_1.streamWordsFromFile)(filename, readerOptions);
|
|
143
|
-
log(`Done reading ${path.basename(filename)}`);
|
|
144
|
-
const f = {
|
|
145
|
-
src: filename,
|
|
146
|
-
words,
|
|
147
|
-
};
|
|
148
|
-
return f;
|
|
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 (0, compile_1.processCompileAction)(src, options, flags);
|
|
149
62
|
});
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
log(`Complete.`);
|
|
155
|
-
}
|
|
156
|
-
function toFilename(name, ext) {
|
|
157
|
-
return path.basename(name).replace(/((\.txt|\.dic|\.aff|\.trie)(\.gz)?)?$/, '') + ext;
|
|
158
|
-
}
|
|
159
|
-
function toTargetFile(filename, destination, ext) {
|
|
160
|
-
const outFileName = toFilename(filename, ext);
|
|
161
|
-
const dir = destination ?? path.dirname(filename);
|
|
162
|
-
return path.join(dir, outFileName);
|
|
163
|
-
}
|
|
164
|
-
function toMergeTargetFile(filename, destination, ext) {
|
|
165
|
-
const outFileName = path.join(path.dirname(filename), toFilename(filename, ext));
|
|
166
|
-
return path.resolve(destination ?? '.', outFileName);
|
|
167
|
-
}
|
|
168
|
-
async function processFilesIndividually(action, filesToProcess, srcToTarget) {
|
|
169
|
-
const toProcess = filesToProcess.map(async (pFtp) => {
|
|
170
|
-
const { src, words } = await pFtp;
|
|
171
|
-
const dst = srcToTarget(src);
|
|
172
|
-
log('Process "%s" to "%s"', src, dst);
|
|
173
|
-
await action(words, dst);
|
|
174
|
-
log('Done "%s" to "%s"', src, dst);
|
|
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 (0, compile_1.processCompileAction)(src, { ...options, trie: true }, flags);
|
|
175
67
|
});
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
const words = (0, gensequence_1.genSequence)(toProcess)
|
|
184
|
-
.map((ftp) => {
|
|
185
|
-
const { src } = ftp;
|
|
186
|
-
log('Process "%s" to "%s"', src, dst);
|
|
187
|
-
return ftp;
|
|
188
|
-
})
|
|
189
|
-
.concatMap((ftp) => ftp.words);
|
|
190
|
-
await action(words, dst);
|
|
191
|
-
log('Done "%s"', dst);
|
|
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('-r, --root <directory>', 'Specify the run directory')
|
|
73
|
+
.action(build_1.build);
|
|
74
|
+
await program.parseAsync(argv);
|
|
192
75
|
}
|
|
193
|
-
exports.
|
|
194
|
-
processAction,
|
|
195
|
-
};
|
|
76
|
+
exports.run = run;
|
|
196
77
|
//# sourceMappingURL=app.js.map
|
package/dist/build.d.ts
ADDED
package/dist/build.js
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.build = void 0;
|
|
27
|
+
const cosmiconfig_1 = require("cosmiconfig");
|
|
28
|
+
const compiler_1 = require("./compiler");
|
|
29
|
+
const config_1 = require("./config");
|
|
30
|
+
const path = __importStar(require("path"));
|
|
31
|
+
const moduleName = 'cspell-tools';
|
|
32
|
+
const searchPlaces = [
|
|
33
|
+
`${moduleName}.config.json`,
|
|
34
|
+
`${moduleName}.config.yaml`,
|
|
35
|
+
`${moduleName}.config.yml`,
|
|
36
|
+
'package.json',
|
|
37
|
+
];
|
|
38
|
+
async function build(targets, options) {
|
|
39
|
+
const allowedTargets = new Set(targets || []);
|
|
40
|
+
function filter(target) {
|
|
41
|
+
return !targets || allowedTargets.has(target.name);
|
|
42
|
+
}
|
|
43
|
+
if (options.root) {
|
|
44
|
+
process.chdir(path.resolve(options.root));
|
|
45
|
+
}
|
|
46
|
+
const explorer = (0, cosmiconfig_1.cosmiconfig)(moduleName, {
|
|
47
|
+
searchPlaces,
|
|
48
|
+
stopDir: path.resolve('.'),
|
|
49
|
+
transform: config_1.normalizeConfig,
|
|
50
|
+
});
|
|
51
|
+
const config = await (options.config ? explorer.load(options.config) : explorer.search('.'));
|
|
52
|
+
if (!config?.config) {
|
|
53
|
+
console.error('root: %s', options.root);
|
|
54
|
+
throw 'cspell-tools.config not found.';
|
|
55
|
+
}
|
|
56
|
+
await (0, compiler_1.compile)(config.config, { filter });
|
|
57
|
+
}
|
|
58
|
+
exports.build = build;
|
|
59
|
+
//# sourceMappingURL=build.js.map
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { CompileCommonAppOptions } from './AppOptions';
|
|
2
|
+
import { FeatureFlags } from './FeatureFlags';
|
|
3
|
+
export declare function processCompileAction(src: string[], options: CompileCommonAppOptions, featureFlags: FeatureFlags | undefined): Promise<void>;
|
|
4
|
+
//# sourceMappingURL=compile.d.ts.map
|
package/dist/compile.js
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.processCompileAction = void 0;
|
|
4
|
+
const sync_1 = require("@cspell/cspell-pipe/sync");
|
|
5
|
+
const FeatureFlags_1 = require("./FeatureFlags");
|
|
6
|
+
const compile_1 = require("./compiler/compile");
|
|
7
|
+
const createCompileRequest_1 = require("./compiler/createCompileRequest");
|
|
8
|
+
const globP_1 = require("./compiler/globP");
|
|
9
|
+
(0, FeatureFlags_1.getSystemFeatureFlags)().register('compound', 'Enable compound dictionary sources.');
|
|
10
|
+
async function processCompileAction(src, options, featureFlags) {
|
|
11
|
+
const ff = featureFlags || (0, FeatureFlags_1.getSystemFeatureFlags)();
|
|
12
|
+
(0, FeatureFlags_1.parseFlags)(ff, options.experimental);
|
|
13
|
+
return useCompile(src, options);
|
|
14
|
+
}
|
|
15
|
+
exports.processCompileAction = processCompileAction;
|
|
16
|
+
async function useCompile(src, options) {
|
|
17
|
+
console.log('Compile:\n output: %s\n compress: %s\n files:\n %s \n\n', options.output || 'default', options.compress ? 'true' : 'false', src.join('\n '));
|
|
18
|
+
const globResults = await Promise.all(src.map((s) => (0, globP_1.globP)(s)));
|
|
19
|
+
const sources = [
|
|
20
|
+
...(0, sync_1.pipe)(globResults, (0, sync_1.opConcatMap)((a) => a)),
|
|
21
|
+
];
|
|
22
|
+
return (0, compile_1.compile)((0, createCompileRequest_1.createCompileRequest)(sources, options));
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=compile.js.map
|
|
@@ -0,0 +1,12 @@
|
|
|
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
|
+
//# sourceMappingURL=CompileOptions.d.ts.map
|
|
@@ -1,23 +1,28 @@
|
|
|
1
|
-
import { Sequence } from 'gensequence';
|
|
2
1
|
export interface ReaderOptions {
|
|
3
|
-
|
|
2
|
+
/**
|
|
3
|
+
* Max Hunspell recursive depth.
|
|
4
|
+
*/
|
|
4
5
|
maxDepth?: number;
|
|
6
|
+
/**
|
|
7
|
+
* split words if necessary.
|
|
8
|
+
*/
|
|
9
|
+
splitWords: boolean;
|
|
10
|
+
/**
|
|
11
|
+
* Indicate that it is an unformatted file and needs to be cleaned
|
|
12
|
+
* before processing. Applies only to text file sources.
|
|
13
|
+
* @default false
|
|
14
|
+
*/
|
|
15
|
+
legacy?: boolean;
|
|
16
|
+
keepCase?: boolean;
|
|
5
17
|
}
|
|
6
18
|
export declare type AnnotatedWord = string;
|
|
7
19
|
interface BaseReader {
|
|
8
20
|
size: number;
|
|
9
|
-
|
|
10
|
-
rawWords: () => Sequence<string>;
|
|
21
|
+
words: Iterable<AnnotatedWord>;
|
|
11
22
|
}
|
|
12
|
-
export interface Reader extends BaseReader {
|
|
13
|
-
[Symbol.iterator]: () => Sequence<string>;
|
|
23
|
+
export interface Reader extends BaseReader, Iterable<string> {
|
|
14
24
|
}
|
|
15
25
|
export declare function createReader(filename: string, options: ReaderOptions): Promise<Reader>;
|
|
16
|
-
export declare function createArrayReader(lines: string[]): BaseReader;
|
|
17
26
|
export declare function readHunspellFiles(filename: string, options: ReaderOptions): Promise<BaseReader>;
|
|
18
|
-
declare function _stripCaseAndAccents(words: Iterable<AnnotatedWord>): Generator<AnnotatedWord>;
|
|
19
|
-
export declare const __testing__: {
|
|
20
|
-
_stripCaseAndAccents: typeof _stripCaseAndAccents;
|
|
21
|
-
};
|
|
22
27
|
export {};
|
|
23
28
|
//# sourceMappingURL=Reader.d.ts.map
|