@cspell/cspell-tools 7.0.1-alpha.6 → 7.0.1-alpha.8
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/cspell-tools.config.schema.json +7 -0
- package/dist/app.js +1 -0
- package/dist/build.d.ts +2 -0
- package/dist/build.js +5 -4
- package/dist/compile.d.ts +1 -0
- package/dist/compile.js +2 -1
- package/dist/compiler/compile.d.ts +12 -2
- package/dist/compiler/compile.js +57 -4
- package/dist/compiler/createCompileRequest.js +26 -8
- package/dist/config/config.d.ts +4 -0
- package/dist/shasum/index.d.ts +1 -1
- package/dist/shasum/index.js +1 -1
- package/dist/shasum/shasum.d.ts +5 -1
- package/dist/shasum/shasum.js +15 -10
- package/package.json +8 -9
- package/dist/compiler/inlineSettings.d.ts +0 -7
- package/dist/compiler/inlineSettings.js +0 -35
|
@@ -209,6 +209,13 @@
|
|
|
209
209
|
],
|
|
210
210
|
"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
211
|
},
|
|
212
|
+
"checksumFile": {
|
|
213
|
+
"description": "Path to checksum file. `true` - defaults to `./checksum.txt`.",
|
|
214
|
+
"type": [
|
|
215
|
+
"string",
|
|
216
|
+
"boolean"
|
|
217
|
+
]
|
|
218
|
+
},
|
|
212
219
|
"generateNonStrict": {
|
|
213
220
|
"default": true,
|
|
214
221
|
"description": "Generate lower case / accent free versions of words.",
|
package/dist/app.js
CHANGED
|
@@ -69,6 +69,7 @@ export async function run(program, argv, flags) {
|
|
|
69
69
|
.command('build [targets...]')
|
|
70
70
|
.description('Build the targets defined in the run configuration.')
|
|
71
71
|
.option('-c, --config <path to run configuration>', 'Specify the run configuration file.')
|
|
72
|
+
.option('--conditional', 'Conditional build.')
|
|
72
73
|
.option('-r, --root <directory>', 'Specify the run directory')
|
|
73
74
|
.action(build);
|
|
74
75
|
program.command('gzip <files...>').description('GZip files while keeping the original.').action(handleGzip);
|
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
|
@@ -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 = "# yaml-language-server: $schema=https://raw.githubusercontent.com/streetsidesoftware/cspell/main/packages/cspell-tools/cspell-tools.config.schema.json\n\n";
|
|
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
|
@@ -7,6 +7,7 @@ import { getSystemFeatureFlags, parseFlags } from './FeatureFlags/index.js';
|
|
|
7
7
|
import { globP } from './util/globP.js';
|
|
8
8
|
getSystemFeatureFlags().register('compound', 'Enable compound dictionary sources.');
|
|
9
9
|
const defaultConfigFile = 'cspell-tools.config.yaml';
|
|
10
|
+
export const configFileHeader = '# yaml-language-server: $schema=https://raw.githubusercontent.com/streetsidesoftware/cspell/main/packages/cspell-tools/cspell-tools.config.schema.json\n\n';
|
|
10
11
|
export async function processCompileAction(src, options, featureFlags) {
|
|
11
12
|
const ff = featureFlags || getSystemFeatureFlags();
|
|
12
13
|
parseFlags(ff, options.experimental || []);
|
|
@@ -26,7 +27,7 @@ async function useCompile(src, options) {
|
|
|
26
27
|
return options.init ? initConfig(request) : compile(request);
|
|
27
28
|
}
|
|
28
29
|
async function initConfig(request) {
|
|
29
|
-
const content = YAML.stringify(request, null, 2);
|
|
30
|
+
const content = configFileHeader + YAML.stringify(request, null, 2);
|
|
30
31
|
console.log('Writing config file: %s', defaultConfigFile);
|
|
31
32
|
await writeFile(defaultConfigFile, content);
|
|
32
33
|
console.log(`Init complete.
|
|
@@ -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,13 +1,13 @@
|
|
|
1
1
|
import * as path from 'path';
|
|
2
2
|
export function createCompileRequest(sourceFiles, options) {
|
|
3
|
-
|
|
3
|
+
options = { ...options };
|
|
4
|
+
options.maxDepth ??= options.max_depth;
|
|
5
|
+
const { maxDepth, split, keepRawCase, useLegacySplitter } = options;
|
|
4
6
|
const sources = [...sourceFiles, ...(options.listFile || []).map((listFile) => ({ listFile }))];
|
|
5
7
|
const targets = calcTargets(sources, options);
|
|
6
|
-
const generateNonStrict = experimental.includes('compound') || undefined;
|
|
7
8
|
const req = {
|
|
8
9
|
targets,
|
|
9
|
-
|
|
10
|
-
maxDepth: parseNumber(maxDepth) ?? parseNumber(max_depth),
|
|
10
|
+
maxDepth: parseNumber(maxDepth),
|
|
11
11
|
split: useLegacySplitter ? 'legacy' : split,
|
|
12
12
|
/**
|
|
13
13
|
* Do not generate lower case / accent free versions of words.
|
|
@@ -18,17 +18,21 @@ export function createCompileRequest(sourceFiles, options) {
|
|
|
18
18
|
return req;
|
|
19
19
|
}
|
|
20
20
|
function calcTargets(sources, options) {
|
|
21
|
-
const { merge, output = '.' } = options;
|
|
21
|
+
const { merge, output = '.', experimental = [] } = options;
|
|
22
|
+
const generateNonStrict = experimental.includes('compound') || undefined;
|
|
23
|
+
// console.log('%o', sources);
|
|
22
24
|
const format = calcFormat(options);
|
|
25
|
+
const sort = (format === 'plaintext' && options.sort) || undefined;
|
|
23
26
|
if (merge) {
|
|
24
27
|
const target = {
|
|
25
28
|
name: merge,
|
|
26
29
|
targetDirectory: output,
|
|
27
30
|
compress: options.compress,
|
|
28
31
|
format,
|
|
29
|
-
sources,
|
|
30
|
-
sort
|
|
32
|
+
sources: sources.map(normalizeSource),
|
|
33
|
+
sort,
|
|
31
34
|
trieBase: parseNumber(options.trieBase),
|
|
35
|
+
generateNonStrict,
|
|
32
36
|
};
|
|
33
37
|
return [target];
|
|
34
38
|
}
|
|
@@ -39,9 +43,10 @@ function calcTargets(sources, options) {
|
|
|
39
43
|
targetDirectory: output,
|
|
40
44
|
compress: options.compress,
|
|
41
45
|
format,
|
|
42
|
-
sources: [source],
|
|
46
|
+
sources: [normalizeSource(source)],
|
|
43
47
|
sort: options.sort,
|
|
44
48
|
trieBase: parseNumber(options.trieBase),
|
|
49
|
+
generateNonStrict,
|
|
45
50
|
};
|
|
46
51
|
return target;
|
|
47
52
|
});
|
|
@@ -63,4 +68,17 @@ function baseNameOfSource(source) {
|
|
|
63
68
|
function isFileSource(source) {
|
|
64
69
|
return typeof source !== 'string' && source.filename !== undefined;
|
|
65
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
|
+
}
|
|
66
84
|
//# sourceMappingURL=createCompileRequest.js.map
|
package/dist/config/config.d.ts
CHANGED
|
@@ -20,6 +20,10 @@ export interface CompileRequest extends CompileTargetOptions, CompileSourceOptio
|
|
|
20
20
|
* Target Dictionaries to create.
|
|
21
21
|
*/
|
|
22
22
|
targets: Target[];
|
|
23
|
+
/**
|
|
24
|
+
* Path to checksum file. `true` - defaults to `./checksum.txt`.
|
|
25
|
+
*/
|
|
26
|
+
checksumFile?: string | boolean;
|
|
23
27
|
}
|
|
24
28
|
export interface Experimental {
|
|
25
29
|
/**
|
package/dist/shasum/index.d.ts
CHANGED
package/dist/shasum/index.js
CHANGED
package/dist/shasum/shasum.d.ts
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
export interface CheckShasumFileResult {
|
|
2
|
+
passed: boolean;
|
|
3
|
+
results: CheckFileResult[];
|
|
4
|
+
}
|
|
5
|
+
export interface CheckFileResult {
|
|
2
6
|
filename: string;
|
|
3
7
|
passed: boolean;
|
|
4
8
|
error?: Error;
|
|
@@ -10,7 +14,7 @@ export declare function shasumFile(filename: string, root: string | undefined):
|
|
|
10
14
|
* @param files - optional list of files to check
|
|
11
15
|
* @param root - optional root, default cwd.
|
|
12
16
|
*/
|
|
13
|
-
export declare function checkShasumFile(filename: string, files: string[] | undefined, root?: string): Promise<CheckShasumFileResult
|
|
17
|
+
export declare function checkShasumFile(filename: string, files: string[] | undefined, root?: string): Promise<CheckShasumFileResult>;
|
|
14
18
|
export interface ChecksumEntry {
|
|
15
19
|
filename: string;
|
|
16
20
|
checksum: string;
|
package/dist/shasum/shasum.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { readFile, writeFile } from 'node:fs/promises';
|
|
2
|
-
import { resolve } from 'node:path';
|
|
2
|
+
import { resolve, sep as pathSep } from 'node:path';
|
|
3
3
|
import { toError } from '../util/errors.js';
|
|
4
4
|
import { isDefined } from '../util/index.js';
|
|
5
5
|
import { calcFileChecksum, checkFile } from './checksum.js';
|
|
@@ -24,12 +24,13 @@ export async function checkShasumFile(filename, files, root) {
|
|
|
24
24
|
files = !files ? files : files.length ? files : undefined;
|
|
25
25
|
const shaFiles = await readAndParseShasumFile(filename);
|
|
26
26
|
const filesToCheck = !files ? shaFiles.map(({ filename }) => filename) : files;
|
|
27
|
-
const mapNameToChecksum = new Map(shaFiles.map((r) => [r.filename, r.checksum]));
|
|
27
|
+
const mapNameToChecksum = new Map(shaFiles.map((r) => [normalizeFilename(r.filename), r.checksum]));
|
|
28
28
|
const resolvedRoot = resolve(root || '.');
|
|
29
|
-
const results = await Promise.all(filesToCheck.map((filename) => {
|
|
29
|
+
const results = await Promise.all(filesToCheck.map(normalizeFilename).map((filename) => {
|
|
30
30
|
return tryToCheckFile(filename, resolvedRoot, mapNameToChecksum.get(filename));
|
|
31
31
|
}));
|
|
32
|
-
|
|
32
|
+
const passed = !results.find((v) => !v.passed);
|
|
33
|
+
return { passed, results };
|
|
33
34
|
}
|
|
34
35
|
async function tryToCheckFile(filename, root, checksum) {
|
|
35
36
|
if (!checksum) {
|
|
@@ -84,9 +85,10 @@ export async function reportChecksumForFiles(files, options) {
|
|
|
84
85
|
export async function reportCheckChecksumFile(filename, files, options) {
|
|
85
86
|
const root = options.root;
|
|
86
87
|
const filesToCheck = await resolveFileList(files, options.listFile);
|
|
87
|
-
const
|
|
88
|
-
const
|
|
89
|
-
const
|
|
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);
|
|
90
92
|
const passed = !withErrors.length;
|
|
91
93
|
if (!passed) {
|
|
92
94
|
lines.push(`shasum: WARNING: ${withErrors.length} computed checksum${withErrors.length > 1 ? 's' : ''} did NOT match`);
|
|
@@ -105,17 +107,17 @@ async function resolveFileList(files, listFile) {
|
|
|
105
107
|
.filter((a) => a)
|
|
106
108
|
.forEach((file) => setOfFiles.add(file));
|
|
107
109
|
}
|
|
108
|
-
return [...setOfFiles];
|
|
110
|
+
return [...setOfFiles].map(normalizeFilename);
|
|
109
111
|
}
|
|
110
112
|
export async function calcUpdateChecksumForFiles(filename, files, options) {
|
|
111
113
|
const root = options.root || '.';
|
|
112
114
|
const filesToCheck = await resolveFileList(files, options.listFile);
|
|
113
|
-
const currentEntries = await readAndParseShasumFile(filename).catch((err) => {
|
|
115
|
+
const currentEntries = (await readAndParseShasumFile(filename).catch((err) => {
|
|
114
116
|
const e = toError(err);
|
|
115
117
|
if (e.code !== 'ENOENT')
|
|
116
118
|
throw e;
|
|
117
119
|
return [];
|
|
118
|
-
});
|
|
120
|
+
})).map((entry) => ({ ...entry, filename: normalizeFilename(entry.filename) }));
|
|
119
121
|
const entriesToUpdate = new Set([...filesToCheck, ...currentEntries.map((e) => e.filename)]);
|
|
120
122
|
const mustExist = new Set(filesToCheck);
|
|
121
123
|
const checksumMap = new Map(currentEntries.map(({ filename, checksum }) => [filename, checksum]));
|
|
@@ -140,4 +142,7 @@ export async function updateChecksumForFiles(filename, files, options) {
|
|
|
140
142
|
await writeFile(filename, content);
|
|
141
143
|
return { passed: true, report: content };
|
|
142
144
|
}
|
|
145
|
+
function normalizeFilename(filename) {
|
|
146
|
+
return filename.split(pathSep).join('/');
|
|
147
|
+
}
|
|
143
148
|
//# sourceMappingURL=shasum.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cspell/cspell-tools",
|
|
3
|
-
"version": "7.0.1-alpha.
|
|
3
|
+
"version": "7.0.1-alpha.8",
|
|
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,13 +49,13 @@
|
|
|
50
49
|
},
|
|
51
50
|
"homepage": "https://github.com/streetsidesoftware/cspell#readme",
|
|
52
51
|
"dependencies": {
|
|
53
|
-
"@cspell/cspell-pipe": "7.0.1-alpha.
|
|
52
|
+
"@cspell/cspell-pipe": "7.0.1-alpha.8",
|
|
54
53
|
"commander": "^11.0.0",
|
|
55
54
|
"cosmiconfig": "8.0.0",
|
|
56
|
-
"cspell-trie-lib": "7.0.1-alpha.
|
|
55
|
+
"cspell-trie-lib": "7.0.1-alpha.8",
|
|
57
56
|
"gensequence": "^5.0.2",
|
|
58
57
|
"glob": "^10.3.3",
|
|
59
|
-
"hunspell-reader": "7.0.1-alpha.
|
|
58
|
+
"hunspell-reader": "7.0.1-alpha.8",
|
|
60
59
|
"yaml": "^2.3.1"
|
|
61
60
|
},
|
|
62
61
|
"engines": {
|
|
@@ -72,5 +71,5 @@
|
|
|
72
71
|
"ts-json-schema-generator": "^1.2.0"
|
|
73
72
|
},
|
|
74
73
|
"main": "bin.js",
|
|
75
|
-
"gitHead": "
|
|
74
|
+
"gitHead": "2c2d4db95da9d1cb7868d5de68e7c43776de06e7"
|
|
76
75
|
}
|
|
@@ -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
|