@cspell/cspell-tools 7.0.0-alpha.2 → 7.0.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/bin.js +2 -0
- package/cspell-tools.config.schema.json +12 -0
- package/dist/AppOptions.d.ts +4 -1
- package/dist/app.js +40 -4
- package/dist/build.d.ts +2 -0
- package/dist/build.js +6 -5
- package/dist/compile.d.ts +1 -0
- package/dist/compile.js +25 -4
- package/dist/compiler/compile.d.ts +12 -2
- package/dist/compiler/compile.js +57 -4
- package/dist/compiler/createCompileRequest.d.ts +1 -1
- package/dist/compiler/createCompileRequest.js +35 -10
- package/dist/config/config.d.ts +10 -0
- package/dist/config/config.js +1 -1
- package/dist/gzip/compressFiles.d.ts +2 -0
- package/dist/gzip/compressFiles.js +14 -0
- package/dist/gzip/gzip.d.ts +2 -0
- package/dist/gzip/gzip.js +10 -0
- package/dist/gzip/index.d.ts +3 -0
- package/dist/gzip/index.js +3 -0
- package/dist/shasum/checksum.d.ts +8 -0
- package/dist/shasum/checksum.js +19 -0
- package/dist/shasum/index.d.ts +3 -0
- package/dist/shasum/index.js +3 -0
- package/dist/shasum/shasum.d.ts +38 -0
- package/dist/shasum/shasum.js +148 -0
- package/dist/util/errors.d.ts +6 -0
- package/dist/util/errors.js +11 -0
- package/dist/util/globP.d.ts +7 -0
- package/dist/util/globP.js +7 -0
- package/dist/util/index.d.ts +2 -0
- package/dist/util/index.js +4 -0
- package/package.json +11 -13
- package/dist/compiler/globP.d.ts +0 -2
- package/dist/compiler/globP.js +0 -9
- package/dist/compiler/inlineSettings.d.ts +0 -7
- package/dist/compiler/inlineSettings.js +0 -35
package/bin.js
CHANGED
|
@@ -195,6 +195,11 @@
|
|
|
195
195
|
}
|
|
196
196
|
},
|
|
197
197
|
"properties": {
|
|
198
|
+
"$schema": {
|
|
199
|
+
"default": "https://raw.githubusercontent.com/streetsidesoftware/cspell/main/packages/cspell-tools/cspell-tools.config.schema.json",
|
|
200
|
+
"description": "Url to JSON Schema",
|
|
201
|
+
"type": "string"
|
|
202
|
+
},
|
|
198
203
|
"allowedSplitWords": {
|
|
199
204
|
"anyOf": [
|
|
200
205
|
{
|
|
@@ -209,6 +214,13 @@
|
|
|
209
214
|
],
|
|
210
215
|
"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."
|
|
211
216
|
},
|
|
217
|
+
"checksumFile": {
|
|
218
|
+
"description": "Path to checksum file. `true` - defaults to `./checksum.txt`.",
|
|
219
|
+
"type": [
|
|
220
|
+
"string",
|
|
221
|
+
"boolean"
|
|
222
|
+
]
|
|
223
|
+
},
|
|
212
224
|
"generateNonStrict": {
|
|
213
225
|
"default": true,
|
|
214
226
|
"description": "Generate lower case / accent free versions of words.",
|
package/dist/AppOptions.d.ts
CHANGED
|
@@ -7,7 +7,7 @@ export interface CompileCommonAppOptions {
|
|
|
7
7
|
max_depth?: string;
|
|
8
8
|
maxDepth?: string;
|
|
9
9
|
merge?: string;
|
|
10
|
-
experimental
|
|
10
|
+
experimental?: string[];
|
|
11
11
|
split?: boolean;
|
|
12
12
|
sort?: boolean;
|
|
13
13
|
keepRawCase?: boolean;
|
|
@@ -15,7 +15,10 @@ export interface CompileCommonAppOptions {
|
|
|
15
15
|
trie3?: boolean;
|
|
16
16
|
trie4?: boolean;
|
|
17
17
|
trieBase?: string;
|
|
18
|
+
listFile?: string[];
|
|
18
19
|
useLegacySplitter?: boolean;
|
|
20
|
+
/** Indicate that a config file should be created instead of building. */
|
|
21
|
+
init?: boolean;
|
|
19
22
|
}
|
|
20
23
|
export interface CompileAppOptions extends CompileCommonAppOptions {
|
|
21
24
|
sort: boolean;
|
package/dist/app.js
CHANGED
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
// For large dictionaries, it is necessary to increase the memory limit.
|
|
2
|
+
import { CommanderError, Option } from 'commander';
|
|
2
3
|
import { readFileSync } from 'fs';
|
|
3
4
|
import { build } from './build.js';
|
|
4
5
|
import { processCompileAction } from './compile.js';
|
|
5
6
|
import * as compiler from './compiler/index.js';
|
|
6
7
|
import { logWithTimestamp } from './compiler/logWithTimestamp.js';
|
|
8
|
+
import { gzip } from './gzip/index.js';
|
|
9
|
+
import { reportCheckChecksumFile, reportChecksumForFiles, updateChecksumForFiles } from './shasum/shasum.js';
|
|
10
|
+
import { toError } from './util/errors.js';
|
|
7
11
|
const npmPackageRaw = readFileSync(new URL('../package.json', import.meta.url), 'utf8');
|
|
8
12
|
const npmPackage = JSON.parse(npmPackageRaw);
|
|
9
13
|
compiler.setLogger(logWithTimestamp);
|
|
@@ -23,28 +27,60 @@ function addCompileOptions(compileCommand) {
|
|
|
23
27
|
.option('-x, --experimental <flag>', 'Experimental flags, used for testing new concepts. Flags: compound', collect, [])
|
|
24
28
|
.option('--trie3', 'Use file format trie3', false)
|
|
25
29
|
.option('--trie4', 'Use file format trie4', false)
|
|
26
|
-
.option('--trie-base <number>', 'Advanced: Set the trie base number. A value between 10 and 36')
|
|
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.');
|
|
27
33
|
}
|
|
28
34
|
export async function run(program, argv, flags) {
|
|
35
|
+
async function handleGzip(files) {
|
|
36
|
+
try {
|
|
37
|
+
await gzip(files);
|
|
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
|
+
}
|
|
29
55
|
program.exitOverride();
|
|
30
56
|
program.version(npmPackage.version);
|
|
31
|
-
addCompileOptions(program.command('compile
|
|
57
|
+
addCompileOptions(program.command('compile [src...]').description('Compile words into a cspell dictionary files.'))
|
|
32
58
|
.option('--trie', 'Compile into a trie file.', false)
|
|
33
59
|
.option('--no-sort', 'Do not sort the result')
|
|
34
60
|
.action((src, options) => {
|
|
35
61
|
return processCompileAction(src, options, flags);
|
|
36
62
|
});
|
|
37
63
|
addCompileOptions(program
|
|
38
|
-
.command('compile-trie
|
|
64
|
+
.command('compile-trie [src...]')
|
|
39
65
|
.description('Compile words lists or Hunspell dictionary into trie files used by cspell.\nAlias of `compile --trie`')).action((src, options) => {
|
|
40
66
|
return processCompileAction(src, { ...options, trie: true }, flags);
|
|
41
67
|
});
|
|
42
68
|
program
|
|
43
|
-
.command('build [targets]')
|
|
69
|
+
.command('build [targets...]')
|
|
44
70
|
.description('Build the targets defined in the run configuration.')
|
|
45
71
|
.option('-c, --config <path to run configuration>', 'Specify the run configuration file.')
|
|
72
|
+
.option('--conditional', 'Conditional build.')
|
|
46
73
|
.option('-r, --root <directory>', 'Specify the run directory')
|
|
47
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);
|
|
48
84
|
await program.parseAsync(argv);
|
|
49
85
|
}
|
|
50
86
|
//# sourceMappingURL=app.js.map
|
package/dist/build.d.ts
CHANGED
|
@@ -5,6 +5,8 @@ export interface BuildOptions {
|
|
|
5
5
|
root?: string | undefined;
|
|
6
6
|
/** Current working directory */
|
|
7
7
|
cwd?: string | undefined;
|
|
8
|
+
/** Conditional build based upon the targets matching the `checksum.txt` file. */
|
|
9
|
+
conditional?: boolean;
|
|
8
10
|
}
|
|
9
11
|
export declare function build(targets: string[] | undefined, options: BuildOptions): Promise<void>;
|
|
10
12
|
//# sourceMappingURL=build.d.ts.map
|
package/dist/build.js
CHANGED
|
@@ -12,7 +12,7 @@ const searchPlaces = [
|
|
|
12
12
|
export async function build(targets, options) {
|
|
13
13
|
const allowedTargets = new Set(targets || []);
|
|
14
14
|
function filter(target) {
|
|
15
|
-
return !
|
|
15
|
+
return !allowedTargets.size || allowedTargets.has(target.name);
|
|
16
16
|
}
|
|
17
17
|
const searchDir = path.resolve(options.root || options.cwd || '.');
|
|
18
18
|
const explorer = cosmiconfig(moduleName, {
|
|
@@ -25,11 +25,12 @@ export async function build(targets, options) {
|
|
|
25
25
|
console.error('root: %s', options.root);
|
|
26
26
|
throw 'cspell-tools.config not found.';
|
|
27
27
|
}
|
|
28
|
-
const
|
|
29
|
-
|
|
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 });
|
|
30
31
|
}
|
|
31
32
|
function normalizeRequest(buildInfo, root) {
|
|
32
|
-
const { rootDir = root, targets = [] } = buildInfo;
|
|
33
|
-
return { rootDir, targets };
|
|
33
|
+
const { rootDir = root, targets = [], checksumFile } = buildInfo;
|
|
34
|
+
return { rootDir: path.resolve(rootDir), targets, checksumFile };
|
|
34
35
|
}
|
|
35
36
|
//# sourceMappingURL=build.js.map
|
package/dist/compile.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { CompileCommonAppOptions } from './AppOptions.js';
|
|
2
2
|
import type { FeatureFlags } from './FeatureFlags/index.js';
|
|
3
|
+
export declare const configFileHeader: string;
|
|
3
4
|
export declare function processCompileAction(src: string[], options: CompileCommonAppOptions, featureFlags: FeatureFlags | undefined): Promise<void>;
|
|
4
5
|
//# sourceMappingURL=compile.d.ts.map
|
package/dist/compile.js
CHANGED
|
@@ -1,20 +1,41 @@
|
|
|
1
|
+
import { writeFile } from 'node:fs/promises';
|
|
1
2
|
import { opConcatMap, pipe } from '@cspell/cspell-pipe/sync';
|
|
3
|
+
import YAML from 'yaml';
|
|
2
4
|
import { compile } from './compiler/compile.js';
|
|
3
5
|
import { createCompileRequest } from './compiler/createCompileRequest.js';
|
|
4
|
-
import {
|
|
6
|
+
import { configFileSchemaURL } from './config/config.js';
|
|
5
7
|
import { getSystemFeatureFlags, parseFlags } from './FeatureFlags/index.js';
|
|
8
|
+
import { globP } from './util/globP.js';
|
|
6
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`;
|
|
7
12
|
export async function processCompileAction(src, options, featureFlags) {
|
|
8
13
|
const ff = featureFlags || getSystemFeatureFlags();
|
|
9
|
-
parseFlags(ff, options.experimental);
|
|
14
|
+
parseFlags(ff, options.experimental || []);
|
|
10
15
|
return useCompile(src, options);
|
|
11
16
|
}
|
|
12
17
|
async function useCompile(src, options) {
|
|
13
|
-
console.log('Compile:\n output: %s\n compress: %s\n files:\n %s
|
|
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');
|
|
14
23
|
const globResults = await Promise.all(src.map((s) => globP(s)));
|
|
15
24
|
const sources = [
|
|
16
25
|
...pipe(globResults, opConcatMap((a) => a)),
|
|
17
26
|
];
|
|
18
|
-
|
|
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, null, 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
|
+
`);
|
|
19
40
|
}
|
|
20
41
|
//# sourceMappingURL=compile.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { CompileRequest, CompileSourceOptions, Target } from '../config/index.js';
|
|
1
|
+
import type { CompileRequest, CompileSourceOptions as CompileSourceConfig, Target } from '../config/index.js';
|
|
2
2
|
interface CompileOptions {
|
|
3
3
|
/**
|
|
4
4
|
* Optional filter function to filter targets.
|
|
@@ -8,8 +8,18 @@ interface CompileOptions {
|
|
|
8
8
|
* The current working directory. Defaults to process.cwd()
|
|
9
9
|
*/
|
|
10
10
|
cwd?: string;
|
|
11
|
+
/**
|
|
12
|
+
* `true` - only build if files do not match checksum.
|
|
13
|
+
*/
|
|
14
|
+
conditionalBuild: boolean;
|
|
11
15
|
}
|
|
12
16
|
export declare function compile(request: CompileRequest, options?: CompileOptions): Promise<void>;
|
|
13
|
-
|
|
17
|
+
interface CompileTargetOptions {
|
|
18
|
+
rootDir: string;
|
|
19
|
+
cwd: string | undefined;
|
|
20
|
+
conditional: boolean;
|
|
21
|
+
checksumFile: string | undefined;
|
|
22
|
+
}
|
|
23
|
+
export declare function compileTarget(target: Target, options: CompileSourceConfig, compileOptions: CompileTargetOptions): Promise<string[]>;
|
|
14
24
|
export {};
|
|
15
25
|
//# sourceMappingURL=compile.d.ts.map
|
package/dist/compiler/compile.js
CHANGED
|
@@ -3,6 +3,7 @@ import { opAwaitAsync, opMapAsync } from '@cspell/cspell-pipe/operators';
|
|
|
3
3
|
import { opConcatMap, opMap, pipe } from '@cspell/cspell-pipe/sync';
|
|
4
4
|
import * as path from 'path';
|
|
5
5
|
import { isFileListSource, isFilePath, isFileSource } from '../config/index.js';
|
|
6
|
+
import { checkShasumFile, updateChecksumForFiles } from '../shasum/index.js';
|
|
6
7
|
import { createAllowedSplitWordsFromFiles } from './createWordsCollection.js';
|
|
7
8
|
import { logWithTimestamp } from './logWithTimestamp.js';
|
|
8
9
|
import { readTextFile } from './readers/readTextFile.js';
|
|
@@ -18,17 +19,33 @@ export async function compile(request, options) {
|
|
|
18
19
|
sort: request.sort,
|
|
19
20
|
generateNonStrict: request.generateNonStrict,
|
|
20
21
|
};
|
|
22
|
+
const conditional = options?.conditionalBuild || false;
|
|
23
|
+
const checksumFile = resolveChecksumFile(request.checksumFile || conditional, rootDir);
|
|
24
|
+
const dependencies = new Set();
|
|
21
25
|
for (const target of targets) {
|
|
22
26
|
const keep = options?.filter?.(target) ?? true;
|
|
23
27
|
if (!keep)
|
|
24
28
|
continue;
|
|
25
29
|
const adjustedTarget = { ...targetOptions, ...target };
|
|
26
|
-
await compileTarget(adjustedTarget, request, rootDir, cwd);
|
|
30
|
+
const deps = await compileTarget(adjustedTarget, request, { rootDir, cwd, conditional, checksumFile });
|
|
31
|
+
deps.forEach((dep) => dependencies.add(dep));
|
|
32
|
+
}
|
|
33
|
+
if (checksumFile && dependencies.size) {
|
|
34
|
+
logWithTimestamp('%s', `Update checksum: ${checksumFile}`);
|
|
35
|
+
await updateChecksumForFiles(checksumFile, [...dependencies], { root: path.dirname(checksumFile) });
|
|
27
36
|
}
|
|
28
37
|
logWithTimestamp(`Complete.`);
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
function resolveChecksumFile(checksumFile, root) {
|
|
41
|
+
const cFilename = (typeof checksumFile === 'string' && checksumFile) || (checksumFile && './checksum.txt') || undefined;
|
|
42
|
+
const file = cFilename && path.resolve(root, cFilename);
|
|
43
|
+
// console.warn('%o', { checksumFile, cFilename, file });
|
|
44
|
+
return file;
|
|
29
45
|
}
|
|
30
|
-
export async function compileTarget(target, options,
|
|
46
|
+
export async function compileTarget(target, options, compileOptions) {
|
|
31
47
|
logWithTimestamp(`Start compile: ${target.name}`);
|
|
48
|
+
const { rootDir, cwd, checksumFile, conditional } = compileOptions;
|
|
32
49
|
const { format, sources, trieBase, sort = true, generateNonStrict = false } = target;
|
|
33
50
|
const targetDirectory = path.resolve(rootDir, target.targetDirectory ?? cwd ?? process.cwd());
|
|
34
51
|
const generateNonStrictTrie = target.generateNonStrict ?? true;
|
|
@@ -38,6 +55,15 @@ export async function compileTarget(target, options, rootDir, cwd) {
|
|
|
38
55
|
const filesToProcessAsync = pipeAsync(readSourceList(sources, rootDir), opMapAsync((src) => readFileSource(src, options)), opAwaitAsync());
|
|
39
56
|
const filesToProcess = await toArray(filesToProcessAsync);
|
|
40
57
|
const normalizer = normalizeTargetWords({ sort: useTrie || sort, generateNonStrict });
|
|
58
|
+
const checksumRoot = (checksumFile && path.dirname(checksumFile)) || rootDir;
|
|
59
|
+
const deps = [...calculateDependencies(filename, filesToProcess, checksumRoot)];
|
|
60
|
+
if (conditional && checksumFile) {
|
|
61
|
+
const check = await checkShasumFile(checksumFile, deps, checksumRoot).catch(() => undefined);
|
|
62
|
+
if (check?.passed) {
|
|
63
|
+
logWithTimestamp(`Skip ${target.name}, nothing changed.`);
|
|
64
|
+
return [];
|
|
65
|
+
}
|
|
66
|
+
}
|
|
41
67
|
const action = useTrie
|
|
42
68
|
? async (words, dst) => {
|
|
43
69
|
return compileTrie(pipe(words, normalizer), dst, {
|
|
@@ -53,6 +79,19 @@ export async function compileTarget(target, options, rootDir, cwd) {
|
|
|
53
79
|
};
|
|
54
80
|
await processFiles(action, filesToProcess, filename);
|
|
55
81
|
logWithTimestamp(`Done compile: ${target.name}`);
|
|
82
|
+
return deps;
|
|
83
|
+
}
|
|
84
|
+
function calculateDependencies(targetFile, filesToProcess, rootDir) {
|
|
85
|
+
const dependencies = new Set();
|
|
86
|
+
addDependency(targetFile);
|
|
87
|
+
filesToProcess.forEach((f) => addDependency(f.src));
|
|
88
|
+
return dependencies;
|
|
89
|
+
function addDependency(filename) {
|
|
90
|
+
const rel = path.relative(rootDir, filename);
|
|
91
|
+
dependencies.add(rel);
|
|
92
|
+
dependencies.add(rel.replace(/\.aff$/, '.dic'));
|
|
93
|
+
dependencies.add(rel.replace(/\.dic$/, '.aff'));
|
|
94
|
+
}
|
|
56
95
|
}
|
|
57
96
|
function rel(filePath) {
|
|
58
97
|
return path.relative(process.cwd(), filePath);
|
|
@@ -67,9 +106,9 @@ async function processFiles(action, filesToProcess, mergeTarget) {
|
|
|
67
106
|
}), opConcatMap(function* (ftp) {
|
|
68
107
|
yield* ftp.words;
|
|
69
108
|
logWithTimestamp('Done processing %s', rel(ftp.src));
|
|
70
|
-
})
|
|
109
|
+
}),
|
|
71
110
|
// opMap((a) => (console.warn(a), a))
|
|
72
|
-
);
|
|
111
|
+
logProgress());
|
|
73
112
|
await action(words, dst);
|
|
74
113
|
logWithTimestamp('Done "%s"', rel(dst));
|
|
75
114
|
}
|
|
@@ -134,4 +173,18 @@ async function readFileSource(fileSource, sourceOptions) {
|
|
|
134
173
|
function normalizeTargetName(name) {
|
|
135
174
|
return name.replace(/((\.txt|\.dic|\.aff|\.trie)(\.gz)?)?$/, '').replace(/[^\p{L}\p{M}.\w\\/-]/gu, '_');
|
|
136
175
|
}
|
|
176
|
+
function logProgress(freq = 100000) {
|
|
177
|
+
function* logProgress(iter) {
|
|
178
|
+
const _freq = freq;
|
|
179
|
+
let count = 0;
|
|
180
|
+
for (const v of iter) {
|
|
181
|
+
++count;
|
|
182
|
+
if (!(count % _freq)) {
|
|
183
|
+
logWithTimestamp('Progress: Words Processed - %s', count.toLocaleString());
|
|
184
|
+
}
|
|
185
|
+
yield v;
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
return logProgress;
|
|
189
|
+
}
|
|
137
190
|
//# sourceMappingURL=compile.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { CompileCommonAppOptions } from '../AppOptions.js';
|
|
2
2
|
import type { CompileRequest } from '../config/index.js';
|
|
3
|
-
export declare function createCompileRequest(
|
|
3
|
+
export declare function createCompileRequest(sourceFiles: string[], options: CompileCommonAppOptions): CompileRequest;
|
|
4
4
|
//# sourceMappingURL=createCompileRequest.d.ts.map
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import * as path from 'path';
|
|
2
|
-
export function createCompileRequest(
|
|
3
|
-
|
|
2
|
+
export function createCompileRequest(sourceFiles, options) {
|
|
3
|
+
options = { ...options };
|
|
4
|
+
options.maxDepth ??= options.max_depth;
|
|
5
|
+
const { maxDepth, split, keepRawCase, useLegacySplitter } = options;
|
|
6
|
+
const sources = [...sourceFiles, ...(options.listFile || []).map((listFile) => ({ listFile }))];
|
|
4
7
|
const targets = calcTargets(sources, options);
|
|
5
|
-
const generateNonStrict = experimental.includes('compound') || undefined;
|
|
6
8
|
const req = {
|
|
7
9
|
targets,
|
|
8
|
-
|
|
9
|
-
maxDepth: parseNumber(maxDepth) ?? parseNumber(max_depth),
|
|
10
|
+
maxDepth: parseNumber(maxDepth),
|
|
10
11
|
split: useLegacySplitter ? 'legacy' : split,
|
|
11
12
|
/**
|
|
12
13
|
* Do not generate lower case / accent free versions of words.
|
|
@@ -17,30 +18,35 @@ export function createCompileRequest(sources, options) {
|
|
|
17
18
|
return req;
|
|
18
19
|
}
|
|
19
20
|
function calcTargets(sources, options) {
|
|
20
|
-
const { merge, output = '.' } = options;
|
|
21
|
+
const { merge, output = '.', experimental = [] } = options;
|
|
22
|
+
const generateNonStrict = experimental.includes('compound') || undefined;
|
|
23
|
+
// console.log('%o', sources);
|
|
21
24
|
const format = calcFormat(options);
|
|
25
|
+
const sort = (format === 'plaintext' && options.sort) || undefined;
|
|
22
26
|
if (merge) {
|
|
23
27
|
const target = {
|
|
24
28
|
name: merge,
|
|
25
29
|
targetDirectory: output,
|
|
26
30
|
compress: options.compress,
|
|
27
31
|
format,
|
|
28
|
-
sources,
|
|
29
|
-
sort
|
|
32
|
+
sources: sources.map(normalizeSource),
|
|
33
|
+
sort,
|
|
30
34
|
trieBase: parseNumber(options.trieBase),
|
|
35
|
+
generateNonStrict,
|
|
31
36
|
};
|
|
32
37
|
return [target];
|
|
33
38
|
}
|
|
34
39
|
const targets = sources.map((source) => {
|
|
35
|
-
const name = toTargetName(
|
|
40
|
+
const name = toTargetName(baseNameOfSource(source));
|
|
36
41
|
const target = {
|
|
37
42
|
name,
|
|
38
43
|
targetDirectory: output,
|
|
39
44
|
compress: options.compress,
|
|
40
45
|
format,
|
|
41
|
-
sources: [source],
|
|
46
|
+
sources: [normalizeSource(source)],
|
|
42
47
|
sort: options.sort,
|
|
43
48
|
trieBase: parseNumber(options.trieBase),
|
|
49
|
+
generateNonStrict,
|
|
44
50
|
};
|
|
45
51
|
return target;
|
|
46
52
|
});
|
|
@@ -56,4 +62,23 @@ function parseNumber(s) {
|
|
|
56
62
|
const n = parseInt(s ?? '');
|
|
57
63
|
return isNaN(n) ? undefined : n;
|
|
58
64
|
}
|
|
65
|
+
function baseNameOfSource(source) {
|
|
66
|
+
return typeof source === 'string' ? source : isFileSource(source) ? source.filename : source.listFile;
|
|
67
|
+
}
|
|
68
|
+
function isFileSource(source) {
|
|
69
|
+
return typeof source !== 'string' && source.filename !== undefined;
|
|
70
|
+
}
|
|
71
|
+
function normalizeSource(source) {
|
|
72
|
+
if (typeof source === 'string') {
|
|
73
|
+
return normalizeSourcePath(source);
|
|
74
|
+
}
|
|
75
|
+
if (isFileSource(source))
|
|
76
|
+
return { ...source, filename: normalizeSourcePath(source.filename) };
|
|
77
|
+
return { ...source, listFile: normalizeSourcePath(source.listFile) };
|
|
78
|
+
}
|
|
79
|
+
function normalizeSourcePath(source) {
|
|
80
|
+
const cwd = process.cwd();
|
|
81
|
+
const rel = path.relative(cwd, source);
|
|
82
|
+
return rel.split('\\').join('/');
|
|
83
|
+
}
|
|
59
84
|
//# sourceMappingURL=createCompileRequest.js.map
|
package/dist/config/config.d.ts
CHANGED
|
@@ -1,4 +1,9 @@
|
|
|
1
1
|
export interface RunConfig extends Partial<CompileRequest> {
|
|
2
|
+
/**
|
|
3
|
+
* Url to JSON Schema
|
|
4
|
+
* @default "https://raw.githubusercontent.com/streetsidesoftware/cspell/main/packages/cspell-tools/cspell-tools.config.schema.json"
|
|
5
|
+
*/
|
|
6
|
+
$schema?: string;
|
|
2
7
|
/**
|
|
3
8
|
* Optional Target Dictionaries to create.
|
|
4
9
|
*/
|
|
@@ -20,6 +25,10 @@ export interface CompileRequest extends CompileTargetOptions, CompileSourceOptio
|
|
|
20
25
|
* Target Dictionaries to create.
|
|
21
26
|
*/
|
|
22
27
|
targets: Target[];
|
|
28
|
+
/**
|
|
29
|
+
* Path to checksum file. `true` - defaults to `./checksum.txt`.
|
|
30
|
+
*/
|
|
31
|
+
checksumFile?: string | boolean;
|
|
23
32
|
}
|
|
24
33
|
export interface Experimental {
|
|
25
34
|
/**
|
|
@@ -119,4 +128,5 @@ export interface CompileSourceOptions {
|
|
|
119
128
|
keepRawCase?: boolean | undefined;
|
|
120
129
|
allowedSplitWords?: FilePath | FilePath[] | undefined;
|
|
121
130
|
}
|
|
131
|
+
export declare const configFileSchemaURL = "https://raw.githubusercontent.com/streetsidesoftware/cspell/main/packages/cspell-tools/cspell-tools.config.schema.json";
|
|
122
132
|
//# sourceMappingURL=config.d.ts.map
|
package/dist/config/config.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export
|
|
1
|
+
export const configFileSchemaURL = 'https://raw.githubusercontent.com/streetsidesoftware/cspell/main/packages/cspell-tools/cspell-tools.config.schema.json';
|
|
2
2
|
//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { readFile, writeFile } from 'node:fs/promises';
|
|
2
|
+
import { promisify } from 'node:util';
|
|
3
|
+
import { gzip as gz } from 'node:zlib';
|
|
4
|
+
const gzip = promisify(gz);
|
|
5
|
+
export async function compressFile(file) {
|
|
6
|
+
if (file.endsWith('.gz'))
|
|
7
|
+
return file;
|
|
8
|
+
const targetFile = file + '.gz';
|
|
9
|
+
const buf = await readFile(file);
|
|
10
|
+
const zBuf = await gzip(buf);
|
|
11
|
+
await writeFile(targetFile, zBuf);
|
|
12
|
+
return targetFile;
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=compressFiles.js.map
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { globP } from '../util/globP.js';
|
|
2
|
+
import { compressFile } from './compressFiles.js';
|
|
3
|
+
// cspell:ignore nodir
|
|
4
|
+
export async function gzip(globs) {
|
|
5
|
+
const files = await globP(globs, { nodir: true });
|
|
6
|
+
for (const fileName of files) {
|
|
7
|
+
await compressFile(fileName);
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=gzip.js.map
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/// <reference types="node" resolution-mode="require"/>
|
|
2
|
+
type HashAlgorithm = 'SHA1';
|
|
3
|
+
export declare function calcChecksum(buf: Buffer, alg?: HashAlgorithm): string;
|
|
4
|
+
export declare function checkChecksum(checksum: string, buf: Buffer, alg?: HashAlgorithm): boolean;
|
|
5
|
+
export declare function calcFileChecksum(filename: string, alg?: HashAlgorithm): Promise<string>;
|
|
6
|
+
export declare function checkFile(checksum: string, filename: string, alg?: HashAlgorithm): Promise<boolean>;
|
|
7
|
+
export {};
|
|
8
|
+
//# sourceMappingURL=checksum.d.ts.map
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { createHash } from 'node:crypto';
|
|
2
|
+
import { readFile } from 'node:fs/promises';
|
|
3
|
+
export function calcChecksum(buf, alg = 'SHA1') {
|
|
4
|
+
const hash = createHash(alg);
|
|
5
|
+
hash.update(buf);
|
|
6
|
+
return hash.digest('hex');
|
|
7
|
+
}
|
|
8
|
+
export function checkChecksum(checksum, buf, alg) {
|
|
9
|
+
const value = calcChecksum(buf, alg);
|
|
10
|
+
return value === checksum;
|
|
11
|
+
}
|
|
12
|
+
export async function calcFileChecksum(filename, alg) {
|
|
13
|
+
const buf = await readFile(filename);
|
|
14
|
+
return calcChecksum(buf, alg);
|
|
15
|
+
}
|
|
16
|
+
export async function checkFile(checksum, filename, alg) {
|
|
17
|
+
return (await calcFileChecksum(filename, alg)) === checksum;
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=checksum.js.map
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
export interface CheckShasumFileResult {
|
|
2
|
+
passed: boolean;
|
|
3
|
+
results: CheckFileResult[];
|
|
4
|
+
}
|
|
5
|
+
export interface CheckFileResult {
|
|
6
|
+
filename: string;
|
|
7
|
+
passed: boolean;
|
|
8
|
+
error?: Error;
|
|
9
|
+
}
|
|
10
|
+
export declare function shasumFile(filename: string, root: string | undefined): Promise<string>;
|
|
11
|
+
/**
|
|
12
|
+
*
|
|
13
|
+
* @param filename - name of checksum file
|
|
14
|
+
* @param files - optional list of files to check
|
|
15
|
+
* @param root - optional root, default cwd.
|
|
16
|
+
*/
|
|
17
|
+
export declare function checkShasumFile(filename: string, files: string[] | undefined, root?: string): Promise<CheckShasumFileResult>;
|
|
18
|
+
export interface ChecksumEntry {
|
|
19
|
+
filename: string;
|
|
20
|
+
checksum: string;
|
|
21
|
+
lineNumber: number;
|
|
22
|
+
}
|
|
23
|
+
export declare function readAndParseShasumFile(filename: string): Promise<ChecksumEntry[]>;
|
|
24
|
+
export declare function parseShasumFile(content: string): ChecksumEntry[];
|
|
25
|
+
interface ReportResult {
|
|
26
|
+
report: string;
|
|
27
|
+
passed: boolean;
|
|
28
|
+
}
|
|
29
|
+
interface ReportOptions {
|
|
30
|
+
root?: string | undefined;
|
|
31
|
+
listFile?: string[];
|
|
32
|
+
}
|
|
33
|
+
export declare function reportChecksumForFiles(files: string[], options: ReportOptions): Promise<ReportResult>;
|
|
34
|
+
export declare function reportCheckChecksumFile(filename: string, files: string[] | undefined, options: ReportOptions): Promise<ReportResult>;
|
|
35
|
+
export declare function calcUpdateChecksumForFiles(filename: string, files: string[], options: ReportOptions): Promise<string>;
|
|
36
|
+
export declare function updateChecksumForFiles(filename: string, files: string[], options: ReportOptions): Promise<ReportResult>;
|
|
37
|
+
export {};
|
|
38
|
+
//# sourceMappingURL=shasum.d.ts.map
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
import { readFile, writeFile } from 'node:fs/promises';
|
|
2
|
+
import { resolve, sep as pathSep } from 'node:path';
|
|
3
|
+
import { toError } from '../util/errors.js';
|
|
4
|
+
import { isDefined } from '../util/index.js';
|
|
5
|
+
import { calcFileChecksum, checkFile } from './checksum.js';
|
|
6
|
+
export async function shasumFile(filename, root) {
|
|
7
|
+
try {
|
|
8
|
+
const file = resolve(root || '.', filename);
|
|
9
|
+
const checksum = await calcFileChecksum(file);
|
|
10
|
+
return `${checksum} ${filename}`;
|
|
11
|
+
}
|
|
12
|
+
catch (error) {
|
|
13
|
+
// const err = toError(error);
|
|
14
|
+
return Promise.reject(`shasum: ${filename}: Unable to read file.`);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
*
|
|
19
|
+
* @param filename - name of checksum file
|
|
20
|
+
* @param files - optional list of files to check
|
|
21
|
+
* @param root - optional root, default cwd.
|
|
22
|
+
*/
|
|
23
|
+
export async function checkShasumFile(filename, files, root) {
|
|
24
|
+
files = !files ? files : files.length ? files : undefined;
|
|
25
|
+
const shaFiles = await readAndParseShasumFile(filename);
|
|
26
|
+
const filesToCheck = !files ? shaFiles.map(({ filename }) => filename) : files;
|
|
27
|
+
const mapNameToChecksum = new Map(shaFiles.map((r) => [normalizeFilename(r.filename), r.checksum]));
|
|
28
|
+
const resolvedRoot = resolve(root || '.');
|
|
29
|
+
const results = await Promise.all(filesToCheck.map(normalizeFilename).map((filename) => {
|
|
30
|
+
return tryToCheckFile(filename, resolvedRoot, mapNameToChecksum.get(filename));
|
|
31
|
+
}));
|
|
32
|
+
const passed = !results.find((v) => !v.passed);
|
|
33
|
+
return { passed, results };
|
|
34
|
+
}
|
|
35
|
+
async function tryToCheckFile(filename, root, checksum) {
|
|
36
|
+
if (!checksum) {
|
|
37
|
+
return { filename, passed: false, error: Error('Missing Checksum.') };
|
|
38
|
+
}
|
|
39
|
+
const file = resolve(root, filename);
|
|
40
|
+
try {
|
|
41
|
+
const passed = await checkFile(checksum, file);
|
|
42
|
+
return { filename, passed };
|
|
43
|
+
}
|
|
44
|
+
catch (error) {
|
|
45
|
+
return { filename, passed: false, error: Error('Failed to read file.') };
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
const regLine = /([a-f0-9]{40,}) {2}(.*)/;
|
|
49
|
+
export async function readAndParseShasumFile(filename) {
|
|
50
|
+
const content = await readFile(resolve(filename), 'utf8');
|
|
51
|
+
const shaFiles = parseShasumFile(content);
|
|
52
|
+
return shaFiles;
|
|
53
|
+
}
|
|
54
|
+
export function parseShasumFile(content) {
|
|
55
|
+
const lines = content.split(/\r?\n|\r/g);
|
|
56
|
+
return lines.map(parseLine).filter(isDefined);
|
|
57
|
+
function parseLine(line, index) {
|
|
58
|
+
const m = line.match(regLine);
|
|
59
|
+
const lineNumber = index + 1;
|
|
60
|
+
if (!m) {
|
|
61
|
+
if (line.trim()) {
|
|
62
|
+
throw new Error(`Failed to parse line ${lineNumber} of checksum file.`);
|
|
63
|
+
}
|
|
64
|
+
return undefined;
|
|
65
|
+
}
|
|
66
|
+
const checksum = m[1];
|
|
67
|
+
const filename = m[2];
|
|
68
|
+
return { checksum, filename, lineNumber };
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
export async function reportChecksumForFiles(files, options) {
|
|
72
|
+
const root = options.root;
|
|
73
|
+
const filesToCheck = await resolveFileList(files, options.listFile);
|
|
74
|
+
let numFailed = 0;
|
|
75
|
+
const result = await Promise.all(filesToCheck.map((file) => shasumFile(file, root).catch((e) => {
|
|
76
|
+
++numFailed;
|
|
77
|
+
if (typeof e !== 'string')
|
|
78
|
+
throw e;
|
|
79
|
+
return e;
|
|
80
|
+
})));
|
|
81
|
+
const report = result.join('\n');
|
|
82
|
+
const passed = !numFailed;
|
|
83
|
+
return { report, passed };
|
|
84
|
+
}
|
|
85
|
+
export async function reportCheckChecksumFile(filename, files, options) {
|
|
86
|
+
const root = options.root;
|
|
87
|
+
const filesToCheck = await resolveFileList(files, options.listFile);
|
|
88
|
+
const checkResult = await checkShasumFile(filename, filesToCheck, root);
|
|
89
|
+
const results = checkResult.results;
|
|
90
|
+
const lines = results.map(({ filename, passed, error }) => `${filename}: ${passed ? 'OK' : 'FAILED'} ${error ? '- ' + error.message : ''}`.trim());
|
|
91
|
+
const withErrors = results.filter((a) => !a.passed);
|
|
92
|
+
const passed = !withErrors.length;
|
|
93
|
+
if (!passed) {
|
|
94
|
+
lines.push(`shasum: WARNING: ${withErrors.length} computed checksum${withErrors.length > 1 ? 's' : ''} did NOT match`);
|
|
95
|
+
}
|
|
96
|
+
return { report: lines.join('\n'), passed };
|
|
97
|
+
}
|
|
98
|
+
async function resolveFileList(files, listFile) {
|
|
99
|
+
files = files || [];
|
|
100
|
+
listFile = listFile || [];
|
|
101
|
+
const setOfFiles = new Set(files);
|
|
102
|
+
const pending = listFile.map((filename) => readFile(filename, 'utf8'));
|
|
103
|
+
for await (const content of pending) {
|
|
104
|
+
content
|
|
105
|
+
.split('\n')
|
|
106
|
+
.map((a) => a.trim())
|
|
107
|
+
.filter((a) => a)
|
|
108
|
+
.forEach((file) => setOfFiles.add(file));
|
|
109
|
+
}
|
|
110
|
+
return [...setOfFiles].map(normalizeFilename);
|
|
111
|
+
}
|
|
112
|
+
export async function calcUpdateChecksumForFiles(filename, files, options) {
|
|
113
|
+
const root = options.root || '.';
|
|
114
|
+
const filesToCheck = await resolveFileList(files, options.listFile);
|
|
115
|
+
const currentEntries = (await readAndParseShasumFile(filename).catch((err) => {
|
|
116
|
+
const e = toError(err);
|
|
117
|
+
if (e.code !== 'ENOENT')
|
|
118
|
+
throw e;
|
|
119
|
+
return [];
|
|
120
|
+
})).map((entry) => ({ ...entry, filename: normalizeFilename(entry.filename) }));
|
|
121
|
+
const entriesToUpdate = new Set([...filesToCheck, ...currentEntries.map((e) => e.filename)]);
|
|
122
|
+
const mustExist = new Set(filesToCheck);
|
|
123
|
+
const checksumMap = new Map(currentEntries.map(({ filename, checksum }) => [filename, checksum]));
|
|
124
|
+
for (const file of entriesToUpdate) {
|
|
125
|
+
try {
|
|
126
|
+
const checksum = await calcFileChecksum(resolve(root, file));
|
|
127
|
+
checksumMap.set(file, checksum);
|
|
128
|
+
}
|
|
129
|
+
catch (e) {
|
|
130
|
+
if (mustExist.has(file) || toError(e).code !== 'ENOENT')
|
|
131
|
+
throw e;
|
|
132
|
+
checksumMap.delete(file);
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
const updatedEntries = [...checksumMap]
|
|
136
|
+
.map(([filename, checksum]) => ({ filename, checksum }))
|
|
137
|
+
.sort((a, b) => (a.filename < b.filename ? -1 : 1));
|
|
138
|
+
return updatedEntries.map((e) => `${e.checksum} ${e.filename}`).join('\n') + '\n';
|
|
139
|
+
}
|
|
140
|
+
export async function updateChecksumForFiles(filename, files, options) {
|
|
141
|
+
const content = await calcUpdateChecksumForFiles(filename, files, options);
|
|
142
|
+
await writeFile(filename, content);
|
|
143
|
+
return { passed: true, report: content };
|
|
144
|
+
}
|
|
145
|
+
function normalizeFilename(filename) {
|
|
146
|
+
return filename.split(pathSep).join('/');
|
|
147
|
+
}
|
|
148
|
+
//# sourceMappingURL=shasum.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { glob } from 'glob';
|
|
2
|
+
export function globP(pattern, options) {
|
|
3
|
+
// Convert windows separators.
|
|
4
|
+
const globs = (Array.isArray(pattern) ? pattern : [pattern]).map((pattern) => pattern.replace(/\\/g, '/'));
|
|
5
|
+
return glob(globs, options);
|
|
6
|
+
}
|
|
7
|
+
//# sourceMappingURL=globP.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cspell/cspell-tools",
|
|
3
|
-
"version": "7.0.0
|
|
3
|
+
"version": "7.0.0",
|
|
4
4
|
"description": "Tools to assist with the development of cSpell",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -16,12 +16,11 @@
|
|
|
16
16
|
"watch": "tsc -p . -w",
|
|
17
17
|
"clean-build": "pnpm run clean && pnpm run build",
|
|
18
18
|
"clean": "shx rm -rf dist temp coverage \"*.tsbuildInfo\"",
|
|
19
|
-
"coverage": "pnpm coverage:vitest
|
|
19
|
+
"coverage": "pnpm coverage:vitest",
|
|
20
20
|
"coverage:vitest": "vitest run --coverage",
|
|
21
|
-
"
|
|
22
|
-
"test-watch": "jest --watch",
|
|
21
|
+
"test:watch": "vitest",
|
|
23
22
|
"test": "vitest run",
|
|
24
|
-
"update-snapshot": "
|
|
23
|
+
"update-snapshot": "vitest run -u"
|
|
25
24
|
},
|
|
26
25
|
"repository": {
|
|
27
26
|
"type": "git",
|
|
@@ -50,26 +49,25 @@
|
|
|
50
49
|
},
|
|
51
50
|
"homepage": "https://github.com/streetsidesoftware/cspell#readme",
|
|
52
51
|
"dependencies": {
|
|
53
|
-
"@cspell/cspell-pipe": "7.0.0
|
|
54
|
-
"commander": "^
|
|
52
|
+
"@cspell/cspell-pipe": "7.0.0",
|
|
53
|
+
"commander": "^11.0.0",
|
|
55
54
|
"cosmiconfig": "8.0.0",
|
|
56
|
-
"cspell-trie-lib": "7.0.0
|
|
55
|
+
"cspell-trie-lib": "7.0.0",
|
|
57
56
|
"gensequence": "^5.0.2",
|
|
58
|
-
"glob": "^
|
|
59
|
-
"hunspell-reader": "7.0.0
|
|
57
|
+
"glob": "^10.3.3",
|
|
58
|
+
"hunspell-reader": "7.0.0",
|
|
59
|
+
"yaml": "^2.3.1"
|
|
60
60
|
},
|
|
61
61
|
"engines": {
|
|
62
62
|
"node": ">=16"
|
|
63
63
|
},
|
|
64
64
|
"devDependencies": {
|
|
65
65
|
"@types/glob": "^8.1.0",
|
|
66
|
-
"@types/jest": "^29.5.1",
|
|
67
66
|
"@types/shelljs": "^0.8.12",
|
|
68
|
-
"jest": "^29.5.0",
|
|
69
67
|
"lorem-ipsum": "^2.0.8",
|
|
70
68
|
"shelljs": "^0.8.5",
|
|
71
69
|
"ts-json-schema-generator": "^1.2.0"
|
|
72
70
|
},
|
|
73
71
|
"main": "bin.js",
|
|
74
|
-
"gitHead": "
|
|
72
|
+
"gitHead": "52960d5ed75655978f9b633f44fd106937a63cd7"
|
|
75
73
|
}
|
package/dist/compiler/globP.d.ts
DELETED
package/dist/compiler/globP.js
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import glob from 'glob';
|
|
2
|
-
import { promisify } from 'util';
|
|
3
|
-
const pGlob = promisify(glob);
|
|
4
|
-
export function globP(pattern) {
|
|
5
|
-
// Convert windows separators.
|
|
6
|
-
pattern = pattern.replace(/\\/g, '/');
|
|
7
|
-
return pGlob(pattern);
|
|
8
|
-
}
|
|
9
|
-
//# sourceMappingURL=globP.js.map
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
const allowedSettings = ['split', 'no-split', 'keep-case', 'no-keep-case', 'case-sensitive'];
|
|
2
|
-
export function extractInlineSettings(line) {
|
|
3
|
-
const m = line.match(/cspell-tools:(.*)/);
|
|
4
|
-
if (!m)
|
|
5
|
-
return undefined;
|
|
6
|
-
const flags = m[1].split(/\s+/g).filter((a) => !!a);
|
|
7
|
-
const settings = {};
|
|
8
|
-
for (const flag of flags) {
|
|
9
|
-
switch (flag) {
|
|
10
|
-
case 'split':
|
|
11
|
-
settings.split = true;
|
|
12
|
-
break;
|
|
13
|
-
case 'no-split':
|
|
14
|
-
settings.split = false;
|
|
15
|
-
break;
|
|
16
|
-
case 'keep-case':
|
|
17
|
-
settings.keepRawCase = true;
|
|
18
|
-
break;
|
|
19
|
-
case 'no-keep-case':
|
|
20
|
-
settings.keepRawCase = false;
|
|
21
|
-
break;
|
|
22
|
-
case 'case-sensitive':
|
|
23
|
-
settings.caseSensitive = true;
|
|
24
|
-
break;
|
|
25
|
-
case 'flag':
|
|
26
|
-
case 'flags':
|
|
27
|
-
// Ignore flags
|
|
28
|
-
break;
|
|
29
|
-
default:
|
|
30
|
-
throw new Error(`Unknown inline setting: "${flag}" allowed values are ${allowedSettings.join(', ')}`);
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
return settings;
|
|
34
|
-
}
|
|
35
|
-
//# sourceMappingURL=inlineSettings.js.map
|