@tsslint/cli 2.0.4 → 2.0.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.
- package/index.js +36 -14
- package/package.json +4 -4
package/index.js
CHANGED
|
@@ -39,7 +39,6 @@ class Project {
|
|
|
39
39
|
constructor(tsconfig, languages) {
|
|
40
40
|
this.tsconfig = tsconfig;
|
|
41
41
|
this.languages = languages;
|
|
42
|
-
this.workers = [];
|
|
43
42
|
this.fileNames = [];
|
|
44
43
|
this.options = {};
|
|
45
44
|
this.currentFileIndex = 0;
|
|
@@ -47,7 +46,7 @@ class Project {
|
|
|
47
46
|
}
|
|
48
47
|
async init(
|
|
49
48
|
// @ts-expect-error
|
|
50
|
-
clack) {
|
|
49
|
+
clack, filesFilter) {
|
|
51
50
|
this.configFile = ts.findConfigFile(path.dirname(this.tsconfig), ts.sys.fileExists, 'tsslint.config.ts');
|
|
52
51
|
const labels = [];
|
|
53
52
|
if (this.languages.length === 0) {
|
|
@@ -79,10 +78,19 @@ class Project {
|
|
|
79
78
|
this.fileNames = commonLine.fileNames;
|
|
80
79
|
this.options = commonLine.options;
|
|
81
80
|
if (!this.fileNames.length) {
|
|
82
|
-
clack.log.
|
|
81
|
+
clack.log.message(`${label} ${gray(path.relative(process.cwd(), this.tsconfig))} ${gray('(0)')}`);
|
|
83
82
|
return this;
|
|
84
83
|
}
|
|
85
|
-
|
|
84
|
+
const originalFileNamesLength = this.fileNames.length;
|
|
85
|
+
if (filesFilter.size) {
|
|
86
|
+
this.fileNames = this.fileNames.filter(f => filesFilter.has(f));
|
|
87
|
+
if (!this.fileNames.length) {
|
|
88
|
+
clack.log.warn(`${label} ${path.relative(process.cwd(), this.tsconfig)} ${gray('(No files left after filter)')}`);
|
|
89
|
+
return this;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
const filteredLengthDiff = originalFileNamesLength - this.fileNames.length;
|
|
93
|
+
clack.log.info(`${label} ${path.relative(process.cwd(), this.tsconfig)} ${gray(`(${this.fileNames.length}${filteredLengthDiff ? `, skipped ${filteredLengthDiff}` : ''})`)}`);
|
|
86
94
|
if (!process.argv.includes('--force')) {
|
|
87
95
|
this.cache = cache.loadCache(this.tsconfig, this.configFile, ts.sys.createHash);
|
|
88
96
|
}
|
|
@@ -264,8 +272,27 @@ class Project {
|
|
|
264
272
|
}
|
|
265
273
|
}
|
|
266
274
|
}
|
|
275
|
+
// get filter glob option
|
|
276
|
+
let filterSet = new Set();
|
|
277
|
+
const filterArgIndex = process.argv.findIndex(arg => arg === '--filter');
|
|
278
|
+
if (filterArgIndex !== -1) {
|
|
279
|
+
for (let i = filterArgIndex + 1; i < process.argv.length; i++) {
|
|
280
|
+
const filterGlob = process.argv[i];
|
|
281
|
+
if (!filterGlob || filterGlob.startsWith('-')) {
|
|
282
|
+
clack.log.error(red(`Missing argument for --filter.`));
|
|
283
|
+
process.exit(1);
|
|
284
|
+
}
|
|
285
|
+
const fileNames = glob.sync(filterGlob).map(f => path.resolve(f));
|
|
286
|
+
for (const fileName of fileNames)
|
|
287
|
+
filterSet.add(fileName);
|
|
288
|
+
}
|
|
289
|
+
if (!filterSet.size) {
|
|
290
|
+
clack.log.error(red(`No files found after --filter files.`));
|
|
291
|
+
process.exit(1);
|
|
292
|
+
}
|
|
293
|
+
}
|
|
267
294
|
for (const [tsconfig, languages] of tsconfigAndLanguages) {
|
|
268
|
-
projects.push(await new Project(tsconfig, languages).init(clack));
|
|
295
|
+
projects.push(await new Project(tsconfig, languages).init(clack, filterSet));
|
|
269
296
|
}
|
|
270
297
|
spinner?.start();
|
|
271
298
|
projects = projects.filter(project => !!project.configFile);
|
|
@@ -325,17 +352,12 @@ class Project {
|
|
|
325
352
|
if (!unfinishedProjects.length) {
|
|
326
353
|
return;
|
|
327
354
|
}
|
|
328
|
-
// Select a project that
|
|
329
|
-
|
|
355
|
+
// Select a project that does not have a worker yet
|
|
356
|
+
const project = unfinishedProjects.find(project => !project.worker);
|
|
330
357
|
if (!project) {
|
|
331
|
-
|
|
332
|
-
project = unfinishedProjects.sort((a, b) => {
|
|
333
|
-
const aFilesPerWorker = (a.fileNames.length - a.currentFileIndex) / a.workers.length;
|
|
334
|
-
const bFilesPerWorker = (b.fileNames.length - b.currentFileIndex) / b.workers.length;
|
|
335
|
-
return bFilesPerWorker - aFilesPerWorker;
|
|
336
|
-
})[0];
|
|
358
|
+
return;
|
|
337
359
|
}
|
|
338
|
-
project.
|
|
360
|
+
project.worker = linterWorker;
|
|
339
361
|
const setupSuccess = await linterWorker.setup(project.tsconfig, project.languages, project.configFile, project.builtConfig, project.fileNames, project.options);
|
|
340
362
|
if (!setupSuccess) {
|
|
341
363
|
projects = projects.filter(p => p !== project);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tsslint/cli",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.5",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"bin": {
|
|
6
6
|
"tsslint": "./bin/tsslint.js"
|
|
@@ -16,8 +16,8 @@
|
|
|
16
16
|
},
|
|
17
17
|
"dependencies": {
|
|
18
18
|
"@clack/prompts": "^0.8.2",
|
|
19
|
-
"@tsslint/config": "2.0.
|
|
20
|
-
"@tsslint/core": "2.0.
|
|
19
|
+
"@tsslint/config": "2.0.5",
|
|
20
|
+
"@tsslint/core": "2.0.5",
|
|
21
21
|
"@volar/language-core": "~2.4.0",
|
|
22
22
|
"@volar/language-hub": "0.0.1",
|
|
23
23
|
"@volar/typescript": "~2.4.0",
|
|
@@ -31,5 +31,5 @@
|
|
|
31
31
|
"@vue-vine/language-service": "latest",
|
|
32
32
|
"@vue/language-core": "latest"
|
|
33
33
|
},
|
|
34
|
-
"gitHead": "
|
|
34
|
+
"gitHead": "29342ffe8a6a5cac8059107f9de4cbb45e367a39"
|
|
35
35
|
}
|