@cspell/cspell-tools 7.0.1-alpha.6 → 7.0.1-alpha.7

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/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.
@@ -67,9 +67,9 @@ async function processFiles(action, filesToProcess, mergeTarget) {
67
67
  }), opConcatMap(function* (ftp) {
68
68
  yield* ftp.words;
69
69
  logWithTimestamp('Done processing %s', rel(ftp.src));
70
- })
70
+ }),
71
71
  // opMap((a) => (console.warn(a), a))
72
- );
72
+ logProgress());
73
73
  await action(words, dst);
74
74
  logWithTimestamp('Done "%s"', rel(dst));
75
75
  }
@@ -134,4 +134,18 @@ async function readFileSource(fileSource, sourceOptions) {
134
134
  function normalizeTargetName(name) {
135
135
  return name.replace(/((\.txt|\.dic|\.aff|\.trie)(\.gz)?)?$/, '').replace(/[^\p{L}\p{M}.\w\\/-]/gu, '_');
136
136
  }
137
+ function logProgress(freq = 100000) {
138
+ function* logProgress(iter) {
139
+ const _freq = freq;
140
+ let count = 0;
141
+ for (const v of iter) {
142
+ ++count;
143
+ if (!(count % _freq)) {
144
+ logWithTimestamp('Progress: Words Processed - %s', count.toLocaleString());
145
+ }
146
+ yield v;
147
+ }
148
+ }
149
+ return logProgress;
150
+ }
137
151
  //# sourceMappingURL=compile.js.map
@@ -1,13 +1,13 @@
1
1
  import * as path from 'path';
2
2
  export function createCompileRequest(sourceFiles, options) {
3
- const { max_depth, maxDepth, experimental = [], split, keepRawCase, useLegacySplitter } = options;
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
- generateNonStrict,
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: options.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cspell/cspell-tools",
3
- "version": "7.0.1-alpha.6",
3
+ "version": "7.0.1-alpha.7",
4
4
  "description": "Tools to assist with the development of cSpell",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -50,13 +50,13 @@
50
50
  },
51
51
  "homepage": "https://github.com/streetsidesoftware/cspell#readme",
52
52
  "dependencies": {
53
- "@cspell/cspell-pipe": "7.0.1-alpha.6",
53
+ "@cspell/cspell-pipe": "7.0.1-alpha.7",
54
54
  "commander": "^11.0.0",
55
55
  "cosmiconfig": "8.0.0",
56
- "cspell-trie-lib": "7.0.1-alpha.6",
56
+ "cspell-trie-lib": "7.0.1-alpha.7",
57
57
  "gensequence": "^5.0.2",
58
58
  "glob": "^10.3.3",
59
- "hunspell-reader": "7.0.1-alpha.6",
59
+ "hunspell-reader": "7.0.1-alpha.7",
60
60
  "yaml": "^2.3.1"
61
61
  },
62
62
  "engines": {
@@ -72,5 +72,5 @@
72
72
  "ts-json-schema-generator": "^1.2.0"
73
73
  },
74
74
  "main": "bin.js",
75
- "gitHead": "42a31c7216a9af068ae4b7c3921f8edd327f756f"
75
+ "gitHead": "719c2f9f55c79d35074f8493a37de6f40077325d"
76
76
  }