cspell 5.19.2 → 5.19.3
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/app.js +1 -25
- package/dist/cli-reporter.js +2 -6
- package/dist/lint/lint.js +4 -1
- package/dist/options.d.ts +1 -1
- package/dist/util/cache/CacheOptions.d.ts +5 -0
- package/dist/util/cache/DiskCache.d.ts +4 -1
- package/dist/util/cache/DiskCache.js +10 -2
- package/dist/util/cache/createCache.d.ts +16 -1
- package/dist/util/cache/createCache.js +22 -4
- package/package.json +10 -10
package/dist/app.js
CHANGED
|
@@ -1,31 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
3
|
exports.run = exports.CheckFailed = void 0;
|
|
27
4
|
const commander_1 = require("commander");
|
|
28
|
-
const path = __importStar(require("path"));
|
|
29
5
|
const semver_1 = require("semver");
|
|
30
6
|
const commandCheck_1 = require("./commandCheck");
|
|
31
7
|
const commandLink_1 = require("./commandLink");
|
|
@@ -34,7 +10,7 @@ const commandSuggestion_1 = require("./commandSuggestion");
|
|
|
34
10
|
const commandTrace_1 = require("./commandTrace");
|
|
35
11
|
const errors_1 = require("./util/errors");
|
|
36
12
|
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
37
|
-
const npmPackage = require(
|
|
13
|
+
const npmPackage = require('../package.json');
|
|
38
14
|
var errors_2 = require("./util/errors");
|
|
39
15
|
Object.defineProperty(exports, "CheckFailed", { enumerable: true, get: function () { return errors_2.CheckFailed; } });
|
|
40
16
|
async function run(command, argv) {
|
package/dist/cli-reporter.js
CHANGED
|
@@ -82,17 +82,13 @@ function reportProgressFileBegin(p) {
|
|
|
82
82
|
const fn = (' '.repeat(fc.length) + p.fileNum).slice(-fc.length);
|
|
83
83
|
const idx = fn + '/' + fc;
|
|
84
84
|
const filename = chalk.gray(relativeFilename(p.filename));
|
|
85
|
-
process.stderr.write(`\r${idx} ${filename}
|
|
85
|
+
process.stderr.write(`\r${idx} ${filename}`);
|
|
86
86
|
}
|
|
87
87
|
function reportProgressFileComplete(p) {
|
|
88
|
-
const fc = '' + p.fileCount;
|
|
89
|
-
const fn = (' '.repeat(fc.length) + p.fileNum).slice(-fc.length);
|
|
90
|
-
const idx = fn + '/' + fc;
|
|
91
|
-
const filename = chalk.gray(relativeFilename(p.filename));
|
|
92
88
|
const time = reportTime(p.elapsedTimeMs, !!p.cached);
|
|
93
89
|
const skipped = p.processed === false ? ' skipped' : '';
|
|
94
90
|
const hasErrors = p.numErrors ? chalk.red ` X` : '';
|
|
95
|
-
console.error(
|
|
91
|
+
console.error(` ${time}${skipped}${hasErrors}`);
|
|
96
92
|
}
|
|
97
93
|
function reportTime(elapsedTimeMs, cached) {
|
|
98
94
|
if (cached)
|
package/dist/lint/lint.js
CHANGED
|
@@ -41,6 +41,9 @@ const reporters_1 = require("../util/reporters");
|
|
|
41
41
|
const timer_1 = require("../util/timer");
|
|
42
42
|
const util = __importStar(require("../util/util"));
|
|
43
43
|
const chalk = require("chalk");
|
|
44
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
45
|
+
const npmPackage = require('../../package.json');
|
|
46
|
+
const version = npmPackage.version;
|
|
44
47
|
async function runLint(cfg) {
|
|
45
48
|
let { reporter } = cfg;
|
|
46
49
|
cspell.setLogger(getLoggerFromReporter(reporter));
|
|
@@ -220,7 +223,7 @@ async function runLint(cfg) {
|
|
|
220
223
|
// Get Exclusions from the config files.
|
|
221
224
|
const { root } = cfg;
|
|
222
225
|
try {
|
|
223
|
-
const cacheSettings = await (0, cache_1.calcCacheSettings)(configInfo.config, cfg.options, root);
|
|
226
|
+
const cacheSettings = await (0, cache_1.calcCacheSettings)(configInfo.config, { ...cfg.options, version }, root);
|
|
224
227
|
const files = await determineFilesToCheck(configInfo, cfg, reporter, globInfo);
|
|
225
228
|
return await processFiles(files, configInfo, cacheSettings);
|
|
226
229
|
}
|
package/dist/options.d.ts
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
import type { CacheStrategy } from '@cspell/cspell-types';
|
|
2
2
|
export interface CacheOptions {
|
|
3
|
+
/**
|
|
4
|
+
* The version of `cspell` that made the cache entry.
|
|
5
|
+
* Cache entries must match the `major.minor` version.
|
|
6
|
+
*/
|
|
7
|
+
version: string;
|
|
3
8
|
/**
|
|
4
9
|
* Store the info about processed files in order to only operate on the changed ones.
|
|
5
10
|
*/
|
|
@@ -11,6 +11,8 @@ interface CachedData {
|
|
|
11
11
|
r: CachedFileResult;
|
|
12
12
|
/** dependencies */
|
|
13
13
|
d: string[];
|
|
14
|
+
/** meta version */
|
|
15
|
+
v: string;
|
|
14
16
|
}
|
|
15
17
|
interface CSpellCachedMetaData {
|
|
16
18
|
data?: CachedData;
|
|
@@ -20,10 +22,11 @@ export declare type CSpellCacheMeta = (FileDescriptor['meta'] & CSpellCachedMeta
|
|
|
20
22
|
* Caches cspell results on disk
|
|
21
23
|
*/
|
|
22
24
|
export declare class DiskCache implements CSpellLintResultCache {
|
|
25
|
+
readonly version: string;
|
|
23
26
|
private fileEntryCache;
|
|
24
27
|
private changedDependencies;
|
|
25
28
|
private knownDependencies;
|
|
26
|
-
constructor(cacheFileLocation: string, useCheckSum: boolean);
|
|
29
|
+
constructor(cacheFileLocation: string, useCheckSum: boolean, version: string);
|
|
27
30
|
getCachedLintResults(filename: string): Promise<FileResult | undefined>;
|
|
28
31
|
setCachedLintResults({ fileInfo, elapsedTimeMs: _, ...result }: FileResult, dependsUponFiles: string[]): void;
|
|
29
32
|
reconcile(): void;
|
|
@@ -31,7 +31,8 @@ const fileHelper_1 = require("../../util/fileHelper");
|
|
|
31
31
|
* Caches cspell results on disk
|
|
32
32
|
*/
|
|
33
33
|
class DiskCache {
|
|
34
|
-
constructor(cacheFileLocation, useCheckSum) {
|
|
34
|
+
constructor(cacheFileLocation, useCheckSum, version) {
|
|
35
|
+
this.version = version;
|
|
35
36
|
this.changedDependencies = new Set();
|
|
36
37
|
this.knownDependencies = new Set();
|
|
37
38
|
this.fileEntryCache = fileEntryCache.createFromFile((0, path_1.resolve)(cacheFileLocation), useCheckSum);
|
|
@@ -41,12 +42,18 @@ class DiskCache {
|
|
|
41
42
|
const meta = fileDescriptor.meta;
|
|
42
43
|
const data = meta === null || meta === void 0 ? void 0 : meta.data;
|
|
43
44
|
const result = data === null || data === void 0 ? void 0 : data.r;
|
|
45
|
+
const versionMatches = this.version === (data === null || data === void 0 ? void 0 : data.v);
|
|
44
46
|
// Cached lint results are valid if and only if:
|
|
45
47
|
// 1. The file is present in the filesystem
|
|
46
48
|
// 2. The file has not changed since the time it was previously linted
|
|
47
49
|
// 3. The CSpell configuration has not changed since the time the file was previously linted
|
|
48
50
|
// If any of these are not true, we will not reuse the lint results.
|
|
49
|
-
if (fileDescriptor.notFound ||
|
|
51
|
+
if (fileDescriptor.notFound ||
|
|
52
|
+
fileDescriptor.changed ||
|
|
53
|
+
!meta ||
|
|
54
|
+
!result ||
|
|
55
|
+
!versionMatches ||
|
|
56
|
+
!this.checkDependencies(data.d)) {
|
|
50
57
|
return undefined;
|
|
51
58
|
}
|
|
52
59
|
// Skip reading empty files and files without lint error
|
|
@@ -69,6 +76,7 @@ class DiskCache {
|
|
|
69
76
|
const data = {
|
|
70
77
|
r: result,
|
|
71
78
|
d: dependsUponFiles,
|
|
79
|
+
v: this.version,
|
|
72
80
|
};
|
|
73
81
|
meta.data = data;
|
|
74
82
|
this.cacheDependencies(dependsUponFiles);
|
|
@@ -2,10 +2,25 @@ import { CacheSettings, CSpellSettings } from '@cspell/cspell-types';
|
|
|
2
2
|
import { CacheOptions } from '.';
|
|
3
3
|
import { CSpellLintResultCache } from './CSpellLintResultCache';
|
|
4
4
|
export declare const DEFAULT_CACHE_LOCATION = ".cspellcache";
|
|
5
|
-
export
|
|
5
|
+
export interface CreateCacheSettings extends Required<CacheSettings> {
|
|
6
|
+
/**
|
|
7
|
+
* cspell version used to validate cache entries.
|
|
8
|
+
*/
|
|
9
|
+
version: string;
|
|
10
|
+
}
|
|
6
11
|
/**
|
|
7
12
|
* Creates CSpellLintResultCache (disk cache if caching is enabled in config or dummy otherwise)
|
|
8
13
|
*/
|
|
9
14
|
export declare function createCache(options: CreateCacheSettings): CSpellLintResultCache;
|
|
10
15
|
export declare function calcCacheSettings(config: CSpellSettings, cacheOptions: CacheOptions, root: string): Promise<CreateCacheSettings>;
|
|
16
|
+
/**
|
|
17
|
+
* Normalizes the version and return only `major.minor + versionSuffix`
|
|
18
|
+
* @param version The cspell semantic version.
|
|
19
|
+
*/
|
|
20
|
+
declare function normalizeVersion(version: string): string;
|
|
21
|
+
export declare const __testing__: {
|
|
22
|
+
normalizeVersion: typeof normalizeVersion;
|
|
23
|
+
versionSuffix: string;
|
|
24
|
+
};
|
|
25
|
+
export {};
|
|
11
26
|
//# sourceMappingURL=createCache.d.ts.map
|
|
@@ -3,20 +3,24 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.calcCacheSettings = exports.createCache = exports.DEFAULT_CACHE_LOCATION = void 0;
|
|
6
|
+
exports.__testing__ = exports.calcCacheSettings = exports.createCache = exports.DEFAULT_CACHE_LOCATION = void 0;
|
|
7
|
+
const assert_1 = __importDefault(require("assert"));
|
|
8
|
+
const fs_extra_1 = require("fs-extra");
|
|
7
9
|
const path_1 = __importDefault(require("path"));
|
|
10
|
+
const errors_1 = require("../errors");
|
|
8
11
|
const DiskCache_1 = require("./DiskCache");
|
|
9
12
|
const DummyCache_1 = require("./DummyCache");
|
|
10
|
-
const fs_extra_1 = require("fs-extra");
|
|
11
|
-
const errors_1 = require("../errors");
|
|
12
13
|
// cspell:word cspellcache
|
|
13
14
|
exports.DEFAULT_CACHE_LOCATION = '.cspellcache';
|
|
15
|
+
const versionSuffix = '';
|
|
14
16
|
/**
|
|
15
17
|
* Creates CSpellLintResultCache (disk cache if caching is enabled in config or dummy otherwise)
|
|
16
18
|
*/
|
|
17
19
|
function createCache(options) {
|
|
18
20
|
const { useCache, cacheLocation, cacheStrategy } = options;
|
|
19
|
-
return useCache
|
|
21
|
+
return useCache
|
|
22
|
+
? new DiskCache_1.DiskCache(path_1.default.resolve(cacheLocation), cacheStrategy === 'content', normalizeVersion(options.version))
|
|
23
|
+
: new DummyCache_1.DummyCache();
|
|
20
24
|
}
|
|
21
25
|
exports.createCache = createCache;
|
|
22
26
|
async function calcCacheSettings(config, cacheOptions, root) {
|
|
@@ -29,6 +33,7 @@ async function calcCacheSettings(config, cacheOptions, root) {
|
|
|
29
33
|
useCache,
|
|
30
34
|
cacheLocation,
|
|
31
35
|
cacheStrategy,
|
|
36
|
+
version: cacheOptions.version,
|
|
32
37
|
};
|
|
33
38
|
}
|
|
34
39
|
exports.calcCacheSettings = calcCacheSettings;
|
|
@@ -46,4 +51,17 @@ async function resolveCacheLocation(cacheLocation) {
|
|
|
46
51
|
throw err;
|
|
47
52
|
}
|
|
48
53
|
}
|
|
54
|
+
/**
|
|
55
|
+
* Normalizes the version and return only `major.minor + versionSuffix`
|
|
56
|
+
* @param version The cspell semantic version.
|
|
57
|
+
*/
|
|
58
|
+
function normalizeVersion(version) {
|
|
59
|
+
const parts = version.split('.').slice(0, 2);
|
|
60
|
+
(0, assert_1.default)(parts.length === 2);
|
|
61
|
+
return parts.join('.') + versionSuffix;
|
|
62
|
+
}
|
|
63
|
+
exports.__testing__ = {
|
|
64
|
+
normalizeVersion,
|
|
65
|
+
versionSuffix,
|
|
66
|
+
};
|
|
49
67
|
//# sourceMappingURL=createCache.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cspell",
|
|
3
|
-
"version": "5.19.
|
|
3
|
+
"version": "5.19.3",
|
|
4
4
|
"description": "A Spelling Checker for Code!",
|
|
5
5
|
"funding": "https://github.com/streetsidesoftware/cspell?sponsor=1",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -70,13 +70,13 @@
|
|
|
70
70
|
},
|
|
71
71
|
"homepage": "https://streetsidesoftware.github.io/cspell/",
|
|
72
72
|
"dependencies": {
|
|
73
|
-
"@cspell/cspell-pipe": "^5.19.
|
|
73
|
+
"@cspell/cspell-pipe": "^5.19.3",
|
|
74
74
|
"chalk": "^4.1.2",
|
|
75
|
-
"commander": "^9.
|
|
75
|
+
"commander": "^9.1.0",
|
|
76
76
|
"comment-json": "^4.2.2",
|
|
77
|
-
"cspell-gitignore": "^5.19.
|
|
78
|
-
"cspell-glob": "^5.19.
|
|
79
|
-
"cspell-lib": "^5.19.
|
|
77
|
+
"cspell-gitignore": "^5.19.3",
|
|
78
|
+
"cspell-glob": "^5.19.3",
|
|
79
|
+
"cspell-lib": "^5.19.3",
|
|
80
80
|
"fast-json-stable-stringify": "^2.1.0",
|
|
81
81
|
"file-entry-cache": "^6.0.1",
|
|
82
82
|
"fs-extra": "^10.0.1",
|
|
@@ -91,8 +91,8 @@
|
|
|
91
91
|
"node": ">=12.13.0"
|
|
92
92
|
},
|
|
93
93
|
"devDependencies": {
|
|
94
|
-
"@cspell/cspell-json-reporter": "^5.19.
|
|
95
|
-
"@cspell/cspell-types": "^5.19.
|
|
94
|
+
"@cspell/cspell-json-reporter": "^5.19.3",
|
|
95
|
+
"@cspell/cspell-types": "^5.19.3",
|
|
96
96
|
"@types/file-entry-cache": "^5.0.2",
|
|
97
97
|
"@types/fs-extra": "^9.0.13",
|
|
98
98
|
"@types/glob": "^7.2.0",
|
|
@@ -104,8 +104,8 @@
|
|
|
104
104
|
"micromatch": "^4.0.4",
|
|
105
105
|
"minimatch": "^5.0.1",
|
|
106
106
|
"rimraf": "^3.0.2",
|
|
107
|
-
"rollup": "^2.70.
|
|
107
|
+
"rollup": "^2.70.1",
|
|
108
108
|
"rollup-plugin-dts": "^4.2.0"
|
|
109
109
|
},
|
|
110
|
-
"gitHead": "
|
|
110
|
+
"gitHead": "df43735d8f85fddbbd0befca7d98956f50474ce7"
|
|
111
111
|
}
|