@tsslint/cli 2.0.3 → 2.0.4
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 +35 -35
- package/package.json +4 -4
package/index.js
CHANGED
|
@@ -11,11 +11,11 @@ const os = require("os");
|
|
|
11
11
|
const languagePlugins = require("./lib/languagePlugins.js");
|
|
12
12
|
process.env.TSSLINT_CLI = '1';
|
|
13
13
|
const _reset = '\x1b[0m';
|
|
14
|
-
const
|
|
15
|
-
const
|
|
16
|
-
const
|
|
17
|
-
const
|
|
18
|
-
const
|
|
14
|
+
const gray = (s) => '\x1b[90m' + s + _reset;
|
|
15
|
+
const red = (s) => '\x1b[91m' + s + _reset;
|
|
16
|
+
const green = (s) => '\x1b[92m' + s + _reset;
|
|
17
|
+
const yellow = (s) => '\x1b[93m' + s + _reset;
|
|
18
|
+
const blue = (s) => '\x1b[94m' + s + _reset;
|
|
19
19
|
const purple = (s) => '\x1b[95m' + s + _reset;
|
|
20
20
|
const cyan = (s) => '\x1b[96m' + s + _reset;
|
|
21
21
|
// https://talyian.github.io/ansicolors/
|
|
@@ -30,7 +30,7 @@ if (process.argv.includes('--threads')) {
|
|
|
30
30
|
const threadsIndex = process.argv.indexOf('--threads');
|
|
31
31
|
const threadsArg = process.argv[threadsIndex + 1];
|
|
32
32
|
if (!threadsArg || threadsArg.startsWith('-')) {
|
|
33
|
-
console.error(
|
|
33
|
+
console.error(red(`Missing argument for --threads.`));
|
|
34
34
|
process.exit(1);
|
|
35
35
|
}
|
|
36
36
|
threads = Math.min(os.availableParallelism(), Number(threadsArg));
|
|
@@ -70,19 +70,19 @@ class Project {
|
|
|
70
70
|
labels.push(astroColor('Astro'));
|
|
71
71
|
}
|
|
72
72
|
}
|
|
73
|
-
const label = labels.join(
|
|
73
|
+
const label = labels.join(gray(' | '));
|
|
74
74
|
if (!this.configFile) {
|
|
75
|
-
clack.log.error(`${label} ${path.relative(process.cwd(), this.tsconfig)} ${
|
|
75
|
+
clack.log.error(`${label} ${path.relative(process.cwd(), this.tsconfig)} ${gray('(No tsslint.config.ts found)')}`);
|
|
76
76
|
return this;
|
|
77
77
|
}
|
|
78
78
|
const commonLine = await parseCommonLine(this.tsconfig, this.languages);
|
|
79
79
|
this.fileNames = commonLine.fileNames;
|
|
80
80
|
this.options = commonLine.options;
|
|
81
81
|
if (!this.fileNames.length) {
|
|
82
|
-
clack.log.warn(`${label} ${path.relative(process.cwd(), this.tsconfig)} ${
|
|
82
|
+
clack.log.warn(`${label} ${path.relative(process.cwd(), this.tsconfig)} ${gray('(No included files)')}`);
|
|
83
83
|
return this;
|
|
84
84
|
}
|
|
85
|
-
clack.log.info(`${label} ${path.relative(process.cwd(), this.tsconfig)} ${
|
|
85
|
+
clack.log.info(`${label} ${path.relative(process.cwd(), this.tsconfig)} ${gray(`(${this.fileNames.length})`)}`);
|
|
86
86
|
if (!process.argv.includes('--force')) {
|
|
87
87
|
this.cache = cache.loadCache(this.tsconfig, this.configFile, ts.sys.createHash);
|
|
88
88
|
}
|
|
@@ -112,7 +112,7 @@ class Project {
|
|
|
112
112
|
const write = process.stdout.write.bind(process.stdout);
|
|
113
113
|
process.stdout.write = (...args) => {
|
|
114
114
|
if (spinnerStopingWarn && typeof args[0] === 'string') {
|
|
115
|
-
args[0] = args[0].replace('▲',
|
|
115
|
+
args[0] = args[0].replace('▲', yellow('▲'));
|
|
116
116
|
}
|
|
117
117
|
// @ts-ignore
|
|
118
118
|
return write(...args);
|
|
@@ -177,7 +177,7 @@ class Project {
|
|
|
177
177
|
options = options.filter(option => !option.label.endsWith('(0)'));
|
|
178
178
|
}
|
|
179
179
|
if (!options.length) {
|
|
180
|
-
clack.log.error(
|
|
180
|
+
clack.log.error(red('No projects found.'));
|
|
181
181
|
process.exit(1);
|
|
182
182
|
}
|
|
183
183
|
const selectedTsconfigs = await clack.multiselect({
|
|
@@ -196,7 +196,7 @@ class Project {
|
|
|
196
196
|
else {
|
|
197
197
|
command += ` --${language}-project ` + selectedTsconfigs.join(' ');
|
|
198
198
|
}
|
|
199
|
-
clack.log.info(`${
|
|
199
|
+
clack.log.info(`${gray('Command:')} ${purple(command)}`);
|
|
200
200
|
for (let tsconfig of selectedTsconfigs) {
|
|
201
201
|
tsconfig = resolvePath(tsconfig);
|
|
202
202
|
tsconfigAndLanguages.set(tsconfig, language ? [language] : []);
|
|
@@ -245,7 +245,7 @@ class Project {
|
|
|
245
245
|
const searchGlob = process.argv[i];
|
|
246
246
|
const tsconfigs = glob.sync(searchGlob);
|
|
247
247
|
if (!tsconfigs.length) {
|
|
248
|
-
clack.log.error(
|
|
248
|
+
clack.log.error(red(`No projects found for ${projectFlag} ${searchGlob}.`));
|
|
249
249
|
process.exit(1);
|
|
250
250
|
}
|
|
251
251
|
for (let tsconfig of tsconfigs) {
|
|
@@ -259,7 +259,7 @@ class Project {
|
|
|
259
259
|
}
|
|
260
260
|
}
|
|
261
261
|
if (!foundArg) {
|
|
262
|
-
clack.log.error(
|
|
262
|
+
clack.log.error(red(`Missing argument for ${projectFlag}.`));
|
|
263
263
|
process.exit(1);
|
|
264
264
|
}
|
|
265
265
|
}
|
|
@@ -278,7 +278,7 @@ class Project {
|
|
|
278
278
|
allFilesNum += project.fileNames.length;
|
|
279
279
|
}
|
|
280
280
|
if (allFilesNum === 0) {
|
|
281
|
-
(spinner?.stop ?? clack.log.message)(
|
|
281
|
+
(spinner?.stop ?? clack.log.message)(yellow('No input files.'));
|
|
282
282
|
process.exit(1);
|
|
283
283
|
}
|
|
284
284
|
if (isTTY || threads >= 2) {
|
|
@@ -290,33 +290,33 @@ class Project {
|
|
|
290
290
|
await startWorker(worker.createLocal());
|
|
291
291
|
}
|
|
292
292
|
(spinner?.stop ?? clack.log.message)(cached
|
|
293
|
-
?
|
|
294
|
-
:
|
|
293
|
+
? gray(`Processed ${processed} files with cache. (Use `) + cyan(`--force`) + gray(` to ignore cache.)`)
|
|
294
|
+
: gray(`Processed ${processed} files.`));
|
|
295
295
|
const projectsFlag = process.argv.find(arg => arg.endsWith('-projects'));
|
|
296
296
|
if (projectsFlag) {
|
|
297
|
-
clack.log.warn(
|
|
297
|
+
clack.log.warn(gray(`Please use `)
|
|
298
298
|
+ cyan(`${projectsFlag.slice(0, -1)}`)
|
|
299
|
-
+
|
|
299
|
+
+ gray(` instead of `)
|
|
300
300
|
+ cyan(`${projectsFlag}`)
|
|
301
|
-
+
|
|
301
|
+
+ gray(` starting from version 1.5.0.`));
|
|
302
302
|
}
|
|
303
303
|
const data = [
|
|
304
|
-
[passed, 'passed',
|
|
305
|
-
[errors, 'errors',
|
|
306
|
-
[warnings, 'warnings',
|
|
307
|
-
[messages, 'messages',
|
|
308
|
-
[suggestions, 'suggestions',
|
|
309
|
-
[excluded, 'excluded',
|
|
304
|
+
[passed, 'passed', green],
|
|
305
|
+
[errors, 'errors', red],
|
|
306
|
+
[warnings, 'warnings', yellow],
|
|
307
|
+
[messages, 'messages', blue],
|
|
308
|
+
[suggestions, 'suggestions', gray],
|
|
309
|
+
[excluded, 'excluded', gray],
|
|
310
310
|
];
|
|
311
311
|
let summary = data
|
|
312
312
|
.filter(([count]) => count)
|
|
313
313
|
.map(([count, label, color]) => color(`${count} ${label}`))
|
|
314
|
-
.join(
|
|
314
|
+
.join(gray(' | '));
|
|
315
315
|
if (hasFix) {
|
|
316
|
-
summary +=
|
|
316
|
+
summary += gray(` (Use `) + cyan(`--fix`) + gray(` to apply automatic fixes.)`);
|
|
317
317
|
}
|
|
318
318
|
else if (errors || warnings || messages) {
|
|
319
|
-
summary +=
|
|
319
|
+
summary += gray(` (No fixes available.)`);
|
|
320
320
|
}
|
|
321
321
|
clack.outro(summary);
|
|
322
322
|
process.exit((errors || messages) ? 1 : 0);
|
|
@@ -423,7 +423,7 @@ class Project {
|
|
|
423
423
|
}
|
|
424
424
|
async function getBuiltConfig(configFile) {
|
|
425
425
|
if (!builtConfigs.has(configFile)) {
|
|
426
|
-
builtConfigs.set(configFile, core.buildConfig(configFile, ts.sys.createHash, spinner, (s, code) => log(
|
|
426
|
+
builtConfigs.set(configFile, core.buildConfig(configFile, ts.sys.createHash, spinner, (s, code) => log(gray(s), code)));
|
|
427
427
|
}
|
|
428
428
|
return await builtConfigs.get(configFile);
|
|
429
429
|
}
|
|
@@ -439,14 +439,14 @@ class Project {
|
|
|
439
439
|
let msg;
|
|
440
440
|
if (processFiles.size === 0) {
|
|
441
441
|
if (nextFileName) {
|
|
442
|
-
msg =
|
|
442
|
+
msg = gray(`[${processed + processFiles.size}/${allFilesNum}] ${path.relative(process.cwd(), nextFileName)}`);
|
|
443
443
|
}
|
|
444
444
|
}
|
|
445
445
|
else if (processFiles.size === 1) {
|
|
446
|
-
msg =
|
|
446
|
+
msg = gray(`[${processed + processFiles.size}/${allFilesNum}] ${path.relative(process.cwd(), [...processFiles][0])}`);
|
|
447
447
|
}
|
|
448
448
|
else {
|
|
449
|
-
msg =
|
|
449
|
+
msg = gray(`[${processed + processFiles.size}/${allFilesNum}] Processing ${processFiles.size} files`);
|
|
450
450
|
}
|
|
451
451
|
if (!spinner && isTTY) {
|
|
452
452
|
spinner = clack.spinner();
|
|
@@ -488,7 +488,7 @@ class Project {
|
|
|
488
488
|
return require.resolve(p, { paths: [process.cwd()] });
|
|
489
489
|
}
|
|
490
490
|
catch {
|
|
491
|
-
clack.log.error(
|
|
491
|
+
clack.log.error(red(`No such file: ${p}`));
|
|
492
492
|
process.exit(1);
|
|
493
493
|
}
|
|
494
494
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tsslint/cli",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.4",
|
|
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.4",
|
|
20
|
+
"@tsslint/core": "2.0.4",
|
|
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": "6006d07f0f218840a49ae281f074970eed1eddbd"
|
|
35
35
|
}
|