cspell 9.1.3 → 9.1.5

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.
Files changed (152) hide show
  1. package/README.md +29 -21
  2. package/bin.mjs +1 -1
  3. package/dist/esm/app.d.ts +19 -0
  4. package/dist/esm/app.js +1033 -0
  5. package/dist/esm/application-D-NwS6qb.js +2573 -0
  6. package/dist/esm/application-DbOQYm56.d.ts +116 -0
  7. package/dist/esm/application.d.ts +3 -0
  8. package/dist/esm/application.js +3 -0
  9. package/dist/esm/index.d.ts +55 -0
  10. package/dist/esm/index.js +5 -0
  11. package/dist/esm/options-ChaXtdFn.d.ts +387 -0
  12. package/package.json +27 -25
  13. package/dist/esm/app.d.mts +0 -5
  14. package/dist/esm/app.mjs +0 -34
  15. package/dist/esm/application.d.mts +0 -17
  16. package/dist/esm/application.mjs +0 -99
  17. package/dist/esm/cli-reporter.d.ts +0 -38
  18. package/dist/esm/cli-reporter.js +0 -386
  19. package/dist/esm/commandCheck.d.ts +0 -3
  20. package/dist/esm/commandCheck.js +0 -52
  21. package/dist/esm/commandConfig.d.ts +0 -3
  22. package/dist/esm/commandConfig.js +0 -18
  23. package/dist/esm/commandDictionaries.d.ts +0 -3
  24. package/dist/esm/commandDictionaries.js +0 -40
  25. package/dist/esm/commandHelpers.d.ts +0 -18
  26. package/dist/esm/commandHelpers.js +0 -30
  27. package/dist/esm/commandInit.d.ts +0 -3
  28. package/dist/esm/commandInit.js +0 -25
  29. package/dist/esm/commandLink.d.ts +0 -3
  30. package/dist/esm/commandLink.js +0 -48
  31. package/dist/esm/commandLint.d.ts +0 -3
  32. package/dist/esm/commandLint.js +0 -226
  33. package/dist/esm/commandSuggestion.d.ts +0 -3
  34. package/dist/esm/commandSuggestion.js +0 -61
  35. package/dist/esm/commandTrace.d.ts +0 -3
  36. package/dist/esm/commandTrace.js +0 -91
  37. package/dist/esm/config/adjustConfig.d.ts +0 -7
  38. package/dist/esm/config/adjustConfig.js +0 -137
  39. package/dist/esm/config/config.d.ts +0 -5
  40. package/dist/esm/config/config.js +0 -18
  41. package/dist/esm/config/configInit.d.ts +0 -3
  42. package/dist/esm/config/configInit.js +0 -104
  43. package/dist/esm/config/constants.d.ts +0 -17
  44. package/dist/esm/config/constants.js +0 -23
  45. package/dist/esm/config/index.d.ts +0 -3
  46. package/dist/esm/config/index.js +0 -2
  47. package/dist/esm/config/options.d.ts +0 -62
  48. package/dist/esm/config/options.js +0 -2
  49. package/dist/esm/config/updateConfig.d.ts +0 -3
  50. package/dist/esm/config/updateConfig.js +0 -2
  51. package/dist/esm/console.d.ts +0 -25
  52. package/dist/esm/console.js +0 -53
  53. package/dist/esm/dictionaries/index.d.ts +0 -3
  54. package/dist/esm/dictionaries/index.js +0 -2
  55. package/dist/esm/dictionaries/listDictionaries.d.ts +0 -33
  56. package/dist/esm/dictionaries/listDictionaries.js +0 -131
  57. package/dist/esm/dirname.d.ts +0 -2
  58. package/dist/esm/dirname.js +0 -13
  59. package/dist/esm/emitters/DictionaryPathFormat.d.ts +0 -3
  60. package/dist/esm/emitters/DictionaryPathFormat.js +0 -12
  61. package/dist/esm/emitters/dictionaryListEmitter.d.ts +0 -19
  62. package/dist/esm/emitters/dictionaryListEmitter.js +0 -82
  63. package/dist/esm/emitters/helpers.d.ts +0 -14
  64. package/dist/esm/emitters/helpers.js +0 -67
  65. package/dist/esm/emitters/suggestionsEmitter.d.ts +0 -13
  66. package/dist/esm/emitters/suggestionsEmitter.js +0 -79
  67. package/dist/esm/emitters/traceEmitter.d.ts +0 -19
  68. package/dist/esm/emitters/traceEmitter.js +0 -87
  69. package/dist/esm/environment.d.ts +0 -39
  70. package/dist/esm/environment.js +0 -30
  71. package/dist/esm/featureFlags/featureFlags.d.ts +0 -4
  72. package/dist/esm/featureFlags/featureFlags.js +0 -21
  73. package/dist/esm/featureFlags/index.d.ts +0 -2
  74. package/dist/esm/featureFlags/index.js +0 -2
  75. package/dist/esm/index.d.mts +0 -6
  76. package/dist/esm/index.mjs +0 -4
  77. package/dist/esm/link.d.ts +0 -8
  78. package/dist/esm/link.js +0 -39
  79. package/dist/esm/lint/LintRequest.d.ts +0 -26
  80. package/dist/esm/lint/LintRequest.js +0 -83
  81. package/dist/esm/lint/index.d.ts +0 -3
  82. package/dist/esm/lint/index.js +0 -3
  83. package/dist/esm/lint/lint.d.ts +0 -8
  84. package/dist/esm/lint/lint.js +0 -515
  85. package/dist/esm/models.d.ts +0 -15
  86. package/dist/esm/models.js +0 -2
  87. package/dist/esm/options.d.ts +0 -353
  88. package/dist/esm/options.js +0 -9
  89. package/dist/esm/pkgInfo.d.ts +0 -14
  90. package/dist/esm/pkgInfo.js +0 -7
  91. package/dist/esm/repl/index.d.ts +0 -18
  92. package/dist/esm/repl/index.js +0 -52
  93. package/dist/esm/util/InMemoryReporter.d.ts +0 -31
  94. package/dist/esm/util/InMemoryReporter.js +0 -49
  95. package/dist/esm/util/LintFileResult.d.ts +0 -14
  96. package/dist/esm/util/LintFileResult.js +0 -2
  97. package/dist/esm/util/async.d.ts +0 -3
  98. package/dist/esm/util/async.js +0 -4
  99. package/dist/esm/util/cache/CSpellLintResultCache.d.ts +0 -20
  100. package/dist/esm/util/cache/CSpellLintResultCache.js +0 -2
  101. package/dist/esm/util/cache/CacheOptions.d.ts +0 -34
  102. package/dist/esm/util/cache/CacheOptions.js +0 -2
  103. package/dist/esm/util/cache/DiskCache.d.ts +0 -63
  104. package/dist/esm/util/cache/DiskCache.js +0 -214
  105. package/dist/esm/util/cache/DummyCache.d.ts +0 -11
  106. package/dist/esm/util/cache/DummyCache.js +0 -18
  107. package/dist/esm/util/cache/ObjectCollection.d.ts +0 -17
  108. package/dist/esm/util/cache/ObjectCollection.js +0 -127
  109. package/dist/esm/util/cache/createCache.d.ts +0 -31
  110. package/dist/esm/util/cache/createCache.js +0 -69
  111. package/dist/esm/util/cache/file-entry-cache.d.mts +0 -4
  112. package/dist/esm/util/cache/file-entry-cache.mjs +0 -5
  113. package/dist/esm/util/cache/fileEntryCache.d.ts +0 -9
  114. package/dist/esm/util/cache/fileEntryCache.js +0 -79
  115. package/dist/esm/util/cache/index.d.ts +0 -4
  116. package/dist/esm/util/cache/index.js +0 -2
  117. package/dist/esm/util/canUseColor.d.ts +0 -2
  118. package/dist/esm/util/canUseColor.js +0 -10
  119. package/dist/esm/util/configFileHelper.d.ts +0 -15
  120. package/dist/esm/util/configFileHelper.js +0 -43
  121. package/dist/esm/util/constants.d.ts +0 -6
  122. package/dist/esm/util/constants.js +0 -6
  123. package/dist/esm/util/errors.d.ts +0 -24
  124. package/dist/esm/util/errors.js +0 -60
  125. package/dist/esm/util/extractContext.d.ts +0 -5
  126. package/dist/esm/util/extractContext.js +0 -75
  127. package/dist/esm/util/fileHelper.d.ts +0 -44
  128. package/dist/esm/util/fileHelper.js +0 -165
  129. package/dist/esm/util/glob.d.ts +0 -45
  130. package/dist/esm/util/glob.js +0 -147
  131. package/dist/esm/util/pad.d.ts +0 -45
  132. package/dist/esm/util/pad.js +0 -191
  133. package/dist/esm/util/prefetch.d.ts +0 -2
  134. package/dist/esm/util/prefetch.js +0 -15
  135. package/dist/esm/util/reporters.d.ts +0 -30
  136. package/dist/esm/util/reporters.js +0 -209
  137. package/dist/esm/util/stdin.d.ts +0 -2
  138. package/dist/esm/util/stdin.js +0 -5
  139. package/dist/esm/util/stdinUrl.d.ts +0 -9
  140. package/dist/esm/util/stdinUrl.js +0 -26
  141. package/dist/esm/util/table.d.ts +0 -41
  142. package/dist/esm/util/table.js +0 -115
  143. package/dist/esm/util/timer.d.ts +0 -4
  144. package/dist/esm/util/timer.js +0 -9
  145. package/dist/esm/util/types.d.ts +0 -7
  146. package/dist/esm/util/types.js +0 -5
  147. package/dist/esm/util/unindent.d.ts +0 -14
  148. package/dist/esm/util/unindent.js +0 -55
  149. package/dist/esm/util/util.d.ts +0 -14
  150. package/dist/esm/util/util.js +0 -30
  151. package/dist/esm/util/writeFile.d.ts +0 -3
  152. package/dist/esm/util/writeFile.js +0 -30
@@ -1,63 +0,0 @@
1
- import type { LintFileResult } from '../../util/LintFileResult.js';
2
- import type { CSpellLintResultCache } from './CSpellLintResultCache.js';
3
- import type { FileDescriptor } from './fileEntryCache.js';
4
- export type CachedFileResult = Omit<LintFileResult, 'fileInfo' | 'elapsedTimeMs' | 'cached'>;
5
- /**
6
- * This is the data cached.
7
- * Property names are short to help keep the cache file size small.
8
- */
9
- interface CachedData {
10
- /** meta version + suffix */
11
- v?: string | undefined;
12
- /** results */
13
- r?: CachedFileResult | undefined;
14
- /** dependencies */
15
- d?: Dependency[] | undefined;
16
- }
17
- interface Dependency {
18
- /** filename */
19
- f: string;
20
- /** hash of file contents */
21
- h?: string | undefined;
22
- }
23
- interface CSpellCachedMetaData {
24
- data?: CachedData;
25
- }
26
- type Meta = FileDescriptor['meta'];
27
- export type CSpellCacheMeta = (Meta & CSpellCachedMetaData) | undefined;
28
- /**
29
- * Caches cspell results on disk
30
- */
31
- export declare class DiskCache implements CSpellLintResultCache {
32
- readonly useCheckSum: boolean;
33
- readonly cspellVersion: string;
34
- readonly useUniversalCache: boolean;
35
- readonly cacheFileLocation: string;
36
- private cacheDir;
37
- private fileEntryCache;
38
- private dependencyCache;
39
- private dependencyCacheTree;
40
- private objectCollection;
41
- private ocCacheFileResult;
42
- readonly version: string;
43
- constructor(cacheFileLocation: string, useCheckSum: boolean, cspellVersion: string, useUniversalCache: boolean);
44
- getCachedLintResults(filename: string): Promise<LintFileResult | undefined>;
45
- setCachedLintResults({ fileInfo, elapsedTimeMs: _, cached: __, ...result }: LintFileResult, dependsUponFiles: string[]): void;
46
- reconcile(): void;
47
- reset(): void;
48
- private normalizeResult;
49
- private calcDependencyHashes;
50
- private checkDependency;
51
- private getDependency;
52
- private getFileDep;
53
- private checkDependencies;
54
- private getHash;
55
- private resolveFile;
56
- private toRelFile;
57
- }
58
- declare function calcVersion(version: string): string;
59
- export declare const __testing__: {
60
- calcVersion: typeof calcVersion;
61
- };
62
- export {};
63
- //# sourceMappingURL=DiskCache.d.ts.map
@@ -1,214 +0,0 @@
1
- import assert from 'node:assert';
2
- import * as crypto from 'node:crypto';
3
- import * as fs from 'node:fs';
4
- import { dirname, isAbsolute as isAbsolutePath, relative as relativePath, resolve as resolvePath } from 'node:path';
5
- import { readFileInfo } from '../../util/fileHelper.js';
6
- import { createFromFile, normalizePath } from './fileEntryCache.js';
7
- import { ShallowObjectCollection } from './ObjectCollection.js';
8
- const cacheDataKeys = {
9
- v: 'v',
10
- r: 'r',
11
- d: 'd',
12
- };
13
- /**
14
- * Meta Data Version is used to detect if the structure of the meta data has changed.
15
- * This is used in combination with the Suffix and the version of CSpell.
16
- */
17
- const META_DATA_BASE_VERSION = '1';
18
- const META_DATA_VERSION_SUFFIX = '-' + META_DATA_BASE_VERSION + '-' + Object.keys(cacheDataKeys).join('|');
19
- /**
20
- * Caches cspell results on disk
21
- */
22
- export class DiskCache {
23
- useCheckSum;
24
- cspellVersion;
25
- useUniversalCache;
26
- cacheFileLocation;
27
- cacheDir;
28
- fileEntryCache;
29
- dependencyCache = new Map();
30
- dependencyCacheTree = {};
31
- objectCollection = new ShallowObjectCollection();
32
- ocCacheFileResult = new ShallowObjectCollection();
33
- version;
34
- constructor(cacheFileLocation, useCheckSum, cspellVersion, useUniversalCache) {
35
- this.useCheckSum = useCheckSum;
36
- this.cspellVersion = cspellVersion;
37
- this.useUniversalCache = useUniversalCache;
38
- this.cacheFileLocation = resolvePath(cacheFileLocation);
39
- this.cacheDir = dirname(this.cacheFileLocation);
40
- this.fileEntryCache = createFromFile(this.cacheFileLocation, useCheckSum, useUniversalCache);
41
- this.version = calcVersion(cspellVersion);
42
- }
43
- async getCachedLintResults(filename) {
44
- filename = normalizePath(filename);
45
- const fileDescriptor = this.fileEntryCache.getFileDescriptor(filename);
46
- const meta = fileDescriptor.meta;
47
- const data = meta?.data;
48
- const result = data?.r;
49
- const versionMatches = this.version === data?.v;
50
- // Cached lint results are valid if and only if:
51
- // 1. The file is present in the filesystem
52
- // 2. The file has not changed since the time it was previously linted
53
- // 3. The CSpell configuration has not changed since the time the file was previously linted
54
- // If any of these are not true, we will not reuse the lint results.
55
- if (fileDescriptor.notFound ||
56
- fileDescriptor.changed ||
57
- !meta ||
58
- !result ||
59
- !versionMatches ||
60
- !this.checkDependencies(data.d)) {
61
- return undefined;
62
- }
63
- const dd = { ...data };
64
- if (dd.d) {
65
- dd.d = setTreeEntry(this.dependencyCacheTree, dd.d);
66
- }
67
- dd.r = dd.r && this.normalizeResult(dd.r);
68
- meta.data = this.objectCollection.get(dd);
69
- // Skip reading empty files and files without lint error
70
- const hasErrors = !!result && (result.errors > 0 || result.configErrors > 0 || result.issues.length > 0);
71
- const cached = true;
72
- const shouldReadFile = cached && hasErrors;
73
- return {
74
- ...result,
75
- elapsedTimeMs: undefined,
76
- fileInfo: shouldReadFile ? await readFileInfo(filename) : { filename },
77
- cached,
78
- };
79
- }
80
- setCachedLintResults({ fileInfo, elapsedTimeMs: _, cached: __, ...result }, dependsUponFiles) {
81
- const fileDescriptor = this.fileEntryCache.getFileDescriptor(fileInfo.filename);
82
- const meta = fileDescriptor.meta;
83
- if (fileDescriptor.notFound || !meta) {
84
- return;
85
- }
86
- const data = this.objectCollection.get({
87
- v: this.version,
88
- r: this.normalizeResult(result),
89
- d: this.calcDependencyHashes(dependsUponFiles),
90
- });
91
- meta.data = data;
92
- }
93
- reconcile() {
94
- this.fileEntryCache.reconcile();
95
- }
96
- reset() {
97
- this.fileEntryCache.destroy();
98
- this.dependencyCache.clear();
99
- this.dependencyCacheTree = {};
100
- this.objectCollection = new ShallowObjectCollection();
101
- this.ocCacheFileResult = new ShallowObjectCollection();
102
- }
103
- normalizeResult(result) {
104
- const { issues, processed, errors, configErrors, ...rest } = result;
105
- if (!Object.keys(rest).length) {
106
- return this.ocCacheFileResult.get(result);
107
- }
108
- return this.ocCacheFileResult.get({ issues, processed, errors, configErrors });
109
- }
110
- calcDependencyHashes(dependsUponFiles) {
111
- dependsUponFiles.sort();
112
- const c = getTreeEntry(this.dependencyCacheTree, dependsUponFiles);
113
- if (c?.d) {
114
- return c.d;
115
- }
116
- const dependencies = dependsUponFiles.map((f) => this.getDependency(f));
117
- return setTreeEntry(this.dependencyCacheTree, dependencies);
118
- }
119
- checkDependency(dep) {
120
- const depFile = this.resolveFile(dep.f);
121
- const cDep = this.dependencyCache.get(depFile);
122
- if (cDep && compDep(dep, cDep))
123
- return true;
124
- if (cDep)
125
- return false;
126
- const d = this.getFileDep(depFile);
127
- if (compDep(dep, d)) {
128
- this.dependencyCache.set(depFile, dep);
129
- return true;
130
- }
131
- this.dependencyCache.set(depFile, d);
132
- return false;
133
- }
134
- getDependency(file) {
135
- const dep = this.dependencyCache.get(file);
136
- if (dep)
137
- return dep;
138
- const d = this.getFileDep(file);
139
- this.dependencyCache.set(file, d);
140
- return d;
141
- }
142
- getFileDep(file) {
143
- assert(isAbsolutePath(file), `Dependency must be absolute "${file}"`);
144
- const f = this.toRelFile(file);
145
- let h;
146
- try {
147
- const buffer = fs.readFileSync(file);
148
- h = this.getHash(buffer);
149
- }
150
- catch {
151
- return { f };
152
- }
153
- return { f, h };
154
- }
155
- checkDependencies(dependencies) {
156
- if (!dependencies)
157
- return false;
158
- for (const dep of dependencies) {
159
- if (!this.checkDependency(dep)) {
160
- return false;
161
- }
162
- }
163
- return true;
164
- }
165
- getHash(buffer) {
166
- return crypto.createHash('md5').update(buffer).digest('hex');
167
- }
168
- resolveFile(file) {
169
- return normalizePath(resolvePath(this.cacheDir, file));
170
- }
171
- toRelFile(file) {
172
- return normalizePath(this.useUniversalCache ? relativePath(this.cacheDir, file) : file);
173
- }
174
- }
175
- function getTreeEntry(tree, keys) {
176
- let r = tree;
177
- for (const k of keys) {
178
- r = r.c?.get(k);
179
- if (!r)
180
- return r;
181
- }
182
- return r;
183
- }
184
- function setTreeEntry(tree, deps, update = false) {
185
- let r = tree;
186
- for (const d of deps) {
187
- const k = d.f;
188
- if (!r.c) {
189
- r.c = new Map();
190
- }
191
- const cn = r.c.get(k);
192
- const n = cn ?? {};
193
- if (!cn) {
194
- r.c.set(k, n);
195
- }
196
- r = n;
197
- }
198
- let d = r.d;
199
- if (!d || (r.d && update)) {
200
- r.d = deps;
201
- d = deps;
202
- }
203
- return d;
204
- }
205
- function compDep(a, b) {
206
- return a.f === b.f && a.h === b.h;
207
- }
208
- function calcVersion(version) {
209
- return version + META_DATA_VERSION_SUFFIX;
210
- }
211
- export const __testing__ = {
212
- calcVersion,
213
- };
214
- //# sourceMappingURL=DiskCache.js.map
@@ -1,11 +0,0 @@
1
- import type { CSpellLintResultCache } from './CSpellLintResultCache.js';
2
- /**
3
- * Dummy cache implementation that should be usd if caching option is disabled.
4
- */
5
- export declare class DummyCache implements CSpellLintResultCache {
6
- getCachedLintResults(): Promise<undefined>;
7
- setCachedLintResults(): void;
8
- reconcile(): void;
9
- reset(): void;
10
- }
11
- //# sourceMappingURL=DummyCache.d.ts.map
@@ -1,18 +0,0 @@
1
- /**
2
- * Dummy cache implementation that should be usd if caching option is disabled.
3
- */
4
- export class DummyCache {
5
- getCachedLintResults() {
6
- return Promise.resolve(undefined);
7
- }
8
- setCachedLintResults() {
9
- return;
10
- }
11
- reconcile() {
12
- return;
13
- }
14
- reset() {
15
- return;
16
- }
17
- }
18
- //# sourceMappingURL=DummyCache.js.map
@@ -1,17 +0,0 @@
1
- export declare class ShallowObjectCollection<T extends object> {
2
- private tree;
3
- get(v: T): T;
4
- }
5
- export declare class Collection {
6
- private col;
7
- /**
8
- * Add a plain object to the collection.
9
- * The actual object used is returned.
10
- * By adding the object to the collection, it is now owned by the collection.
11
- * Do not add class objects.
12
- * @param v any object or primitive
13
- * @returns v or the matching object.
14
- */
15
- add<T>(v: T): T;
16
- }
17
- //# sourceMappingURL=ObjectCollection.d.ts.map
@@ -1,127 +0,0 @@
1
- /* eslint-disable @typescript-eslint/no-explicit-any */
2
- const compare = Intl.Collator().compare;
3
- export class ShallowObjectCollection {
4
- tree = {};
5
- get(v) {
6
- if (typeof v !== 'object' || v === null) {
7
- return v;
8
- }
9
- const keys = Object.entries(v)
10
- .filter((entry) => entry[1] !== undefined)
11
- .sort((a, b) => compare(a[0], b[0]));
12
- let t = this.tree;
13
- for (const [key, obj] of keys) {
14
- if (!t.c) {
15
- t.c = new Map();
16
- }
17
- const c0 = t.c.get(key);
18
- const cc = c0 || new Map();
19
- if (!c0) {
20
- t.c.set(key, cc);
21
- }
22
- const c1 = cc.get(obj);
23
- const ccc = c1 || {};
24
- if (!c1) {
25
- cc.set(obj, ccc);
26
- }
27
- t = ccc;
28
- }
29
- if (t.v)
30
- return t.v;
31
- t.v = v;
32
- return v;
33
- }
34
- }
35
- export class Collection {
36
- col = { contains: new Map() };
37
- /**
38
- * Add a plain object to the collection.
39
- * The actual object used is returned.
40
- * By adding the object to the collection, it is now owned by the collection.
41
- * Do not add class objects.
42
- * @param v any object or primitive
43
- * @returns v or the matching object.
44
- */
45
- add(v) {
46
- return addToCollection(this.col, v);
47
- }
48
- }
49
- // const objectLike: TypeMask = {
50
- // array: true,
51
- // object: true,
52
- // };
53
- function addToCollection(root, v) {
54
- const known = root.contains;
55
- function addValToCol(c, v) {
56
- const t = toValueType(v);
57
- const val = c.v || Object.create(null);
58
- const r = val[t] ?? v;
59
- val[t] = r;
60
- c.v = val;
61
- return val[t];
62
- }
63
- function walk(col, path) {
64
- path = path.filter((entry) => entry[1] !== undefined).sort((a, b) => compare(a[0], b[0]));
65
- for (const [k, v] of path) {
66
- const c = col.c || Object.create(null);
67
- col.c = c;
68
- const m = c[k] || new Map();
69
- c[k] = m;
70
- const has = m.get(v);
71
- col = has || Object.create(null);
72
- if (!has) {
73
- m.set(v, col);
74
- }
75
- }
76
- return col;
77
- }
78
- function normalizeObjectEntries(entries) {
79
- for (const entry of entries) {
80
- entry[1] = add(entry[1]);
81
- }
82
- return entries;
83
- }
84
- function normalizeToPath(v) {
85
- if (typeof v !== 'object' || !v) {
86
- return [['', v]];
87
- }
88
- const entries = normalizeObjectEntries(Object.entries(v));
89
- const obj = v;
90
- if (!Object.isFrozen(v)) {
91
- for (const [k, v] of entries) {
92
- obj[k] = v;
93
- }
94
- Object.freeze(obj);
95
- }
96
- return entries;
97
- }
98
- function add(v) {
99
- const isObjectLike = typeof v === 'object' && !!v;
100
- if (isObjectLike) {
101
- const cached = known.get(v);
102
- if (cached !== undefined) {
103
- return cached;
104
- }
105
- known.set(v, v);
106
- }
107
- const path = normalizeToPath(v);
108
- const c = walk(root, path);
109
- const r = addValToCol(c, v);
110
- if (isObjectLike) {
111
- known.set(v, r);
112
- }
113
- return r;
114
- }
115
- return add(v);
116
- }
117
- function toValueType(v) {
118
- const t = typeof v;
119
- if (t !== 'object')
120
- return t;
121
- if (Array.isArray(v))
122
- return 'array';
123
- if (v === null)
124
- return 'null';
125
- return t;
126
- }
127
- //# sourceMappingURL=ObjectCollection.js.map
@@ -1,31 +0,0 @@
1
- import type { CacheSettings, CSpellSettings } from '@cspell/cspell-types';
2
- import type { CacheOptions } from './CacheOptions.js';
3
- import type { CSpellLintResultCache } from './CSpellLintResultCache.js';
4
- export declare const DEFAULT_CACHE_LOCATION = ".cspellcache";
5
- export interface CreateCacheSettings extends Required<CacheSettings> {
6
- /**
7
- * cspell version used to validate cache entries.
8
- */
9
- version: string;
10
- /**
11
- * When true, causes the cache to be reset, removing any entries
12
- * or cache files.
13
- */
14
- reset?: true;
15
- }
16
- /**
17
- * Creates CSpellLintResultCache (disk cache if caching is enabled in config or dummy otherwise)
18
- */
19
- export declare function createCache(options: CreateCacheSettings): CSpellLintResultCache;
20
- export declare function calcCacheSettings(config: CSpellSettings, cacheOptions: CacheOptions, root: string): Promise<CreateCacheSettings>;
21
- /**
22
- * Normalizes the version and return only `major.minor + versionSuffix`
23
- * @param version The cspell semantic version.
24
- */
25
- declare function normalizeVersion(version: string): string;
26
- export declare const __testing__: {
27
- normalizeVersion: typeof normalizeVersion;
28
- versionSuffix: string;
29
- };
30
- export {};
31
- //# sourceMappingURL=createCache.d.ts.map
@@ -1,69 +0,0 @@
1
- import assert from 'node:assert';
2
- import { stat } from 'node:fs/promises';
3
- import path from 'node:path';
4
- import { isErrorLike } from '../errors.js';
5
- import { DiskCache } from './DiskCache.js';
6
- import { DummyCache } from './DummyCache.js';
7
- // cspell:word cspellcache
8
- export const DEFAULT_CACHE_LOCATION = '.cspellcache';
9
- const versionSuffix = '';
10
- /**
11
- * Creates CSpellLintResultCache (disk cache if caching is enabled in config or dummy otherwise)
12
- */
13
- export function createCache(options) {
14
- const { useCache, cacheLocation, cacheStrategy, reset } = options;
15
- const location = path.resolve(cacheLocation);
16
- const useChecksum = cacheStrategy === 'content';
17
- const version = normalizeVersion(options.version);
18
- const useUniversal = options.cacheFormat === 'universal';
19
- const cache = useCache ? new DiskCache(location, useChecksum, version, useUniversal) : new DummyCache();
20
- reset && cache.reset();
21
- return cache;
22
- }
23
- export async function calcCacheSettings(config, cacheOptions, root) {
24
- const cs = config.cache ?? {};
25
- const useCache = cacheOptions.cache ?? cs.useCache ?? false;
26
- const cacheLocation = await resolveCacheLocation(path.resolve(root, cacheOptions.cacheLocation ?? cs.cacheLocation ?? DEFAULT_CACHE_LOCATION));
27
- const cacheStrategy = cacheOptions.cacheStrategy ?? cs.cacheStrategy ?? 'content';
28
- const cacheFormat = cacheOptions.cacheFormat ?? cs.cacheFormat ?? 'universal';
29
- const optionals = {};
30
- if (cacheOptions.cacheReset) {
31
- optionals.reset = true;
32
- }
33
- return {
34
- ...optionals,
35
- useCache,
36
- cacheLocation,
37
- cacheStrategy,
38
- version: cacheOptions.version,
39
- cacheFormat,
40
- };
41
- }
42
- async function resolveCacheLocation(cacheLocation) {
43
- try {
44
- const s = await stat(cacheLocation);
45
- if (s.isFile())
46
- return cacheLocation;
47
- return path.join(cacheLocation, DEFAULT_CACHE_LOCATION);
48
- }
49
- catch (err) {
50
- if (isErrorLike(err) && err.code === 'ENOENT') {
51
- return cacheLocation;
52
- }
53
- throw err;
54
- }
55
- }
56
- /**
57
- * Normalizes the version and return only `major.minor + versionSuffix`
58
- * @param version The cspell semantic version.
59
- */
60
- function normalizeVersion(version) {
61
- const parts = version.split('.').slice(0, 2);
62
- assert(parts.length === 2);
63
- return parts.join('.') + versionSuffix;
64
- }
65
- export const __testing__ = {
66
- normalizeVersion,
67
- versionSuffix,
68
- };
69
- //# sourceMappingURL=createCache.js.map
@@ -1,4 +0,0 @@
1
- import type { FileEntryCache } from 'file-entry-cache';
2
- export type { FileDescriptor, FileEntryCache } from 'file-entry-cache';
3
- export declare function createFromFile(pathToCache: string, useChecksum?: boolean): FileEntryCache;
4
- //# sourceMappingURL=file-entry-cache.d.mts.map
@@ -1,5 +0,0 @@
1
- import fileEntryCache from 'file-entry-cache';
2
- export function createFromFile(pathToCache, useChecksum) {
3
- return fileEntryCache.createFromFile(pathToCache, useChecksum);
4
- }
5
- //# sourceMappingURL=file-entry-cache.mjs.map
@@ -1,9 +0,0 @@
1
- /**
2
- * This is a wrapper for 'file-entry-cache'
3
- */
4
- export type { FileDescriptor } from './file-entry-cache.mjs';
5
- import type { FileEntryCache as FecFileEntryCache } from './file-entry-cache.mjs';
6
- export type FileEntryCache = FecFileEntryCache;
7
- export declare function createFromFile(pathToCache: string, useCheckSum: boolean, useRelative: boolean): FileEntryCache;
8
- export declare function normalizePath(filePath: string): string;
9
- //# sourceMappingURL=fileEntryCache.d.ts.map
@@ -1,79 +0,0 @@
1
- /**
2
- * This is a wrapper for 'file-entry-cache'
3
- */
4
- import { mkdirSync } from 'node:fs';
5
- import * as path from 'node:path';
6
- import { isMainThread } from 'node:worker_threads';
7
- import * as fec from './file-entry-cache.mjs';
8
- export function createFromFile(pathToCache, useCheckSum, useRelative) {
9
- const absPathToCache = path.resolve(pathToCache);
10
- const relDir = path.dirname(absPathToCache);
11
- mkdirSync(relDir, { recursive: true });
12
- const create = wrap(() => fec.createFromFile(absPathToCache, useCheckSum));
13
- const feCache = create();
14
- const cacheWrapper = {
15
- get cache() {
16
- return feCache.cache;
17
- },
18
- getHash(buffer) {
19
- return feCache.getHash(buffer);
20
- },
21
- hasFileChanged: wrap((cwd, file) => {
22
- // console.log(file);
23
- return feCache.hasFileChanged(resolveFile(cwd, file));
24
- }),
25
- analyzeFiles: wrap((cwd, files) => {
26
- return feCache.analyzeFiles(resolveFiles(cwd, files));
27
- }),
28
- getFileDescriptor: wrap((cwd, file) => {
29
- return feCache.getFileDescriptor(resolveFile(cwd, file));
30
- }),
31
- getUpdatedFiles: wrap((cwd, files) => {
32
- return feCache.getUpdatedFiles(resolveFiles(cwd, files));
33
- }),
34
- normalizeEntries: wrap((cwd, files) => {
35
- return feCache.normalizeEntries(resolveFiles(cwd, files));
36
- }),
37
- removeEntry: wrap((cwd, file) => {
38
- // console.log(file);
39
- return feCache.removeEntry(resolveFile(cwd, file));
40
- }),
41
- deleteCacheFile() {
42
- feCache.deleteCacheFile();
43
- },
44
- destroy() {
45
- feCache.destroy();
46
- },
47
- reconcile: wrap((_cwd, noPrune) => {
48
- feCache.reconcile(noPrune);
49
- }),
50
- };
51
- return cacheWrapper;
52
- function resolveFile(cwd, file) {
53
- if (!useRelative)
54
- return normalizePath(file);
55
- const r = path.relative(relDir, path.resolve(cwd, file));
56
- return normalizePath(r);
57
- }
58
- function resolveFiles(cwd, files) {
59
- return files?.map((file) => resolveFile(cwd, file));
60
- }
61
- function wrap(fn) {
62
- return (...params) => {
63
- const cwd = process.cwd();
64
- try {
65
- isMainThread && process.chdir(relDir);
66
- return fn(cwd, ...params);
67
- }
68
- finally {
69
- isMainThread && process.chdir(cwd);
70
- }
71
- };
72
- }
73
- }
74
- export function normalizePath(filePath) {
75
- if (path.sep === '/')
76
- return filePath;
77
- return filePath.split(path.sep).join('/');
78
- }
79
- //# sourceMappingURL=fileEntryCache.js.map
@@ -1,4 +0,0 @@
1
- export type { CacheOptions } from './CacheOptions.js';
2
- export { calcCacheSettings, createCache, type CreateCacheSettings, DEFAULT_CACHE_LOCATION } from './createCache.js';
3
- export type { CSpellLintResultCache } from './CSpellLintResultCache.js';
4
- //# sourceMappingURL=index.d.ts.map
@@ -1,2 +0,0 @@
1
- export { calcCacheSettings, createCache, DEFAULT_CACHE_LOCATION } from './createCache.js';
2
- //# sourceMappingURL=index.js.map
@@ -1,2 +0,0 @@
1
- export declare function canUseColor(colorOption: boolean | undefined): boolean | undefined;
2
- //# sourceMappingURL=canUseColor.d.ts.map
@@ -1,10 +0,0 @@
1
- export function canUseColor(colorOption) {
2
- if (colorOption !== undefined)
3
- return colorOption;
4
- if (!('NO_COLOR' in process.env))
5
- return undefined;
6
- if (!process.env['NO_COLOR'] || process.env['NO_COLOR'] === 'false')
7
- return undefined;
8
- return false;
9
- }
10
- //# sourceMappingURL=canUseColor.js.map