@tsslint/cli 1.3.2 → 1.3.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 CHANGED
@@ -6,12 +6,18 @@ const core = require("@tsslint/core");
6
6
  const cache = require("./lib/cache");
7
7
  const glob = require("glob");
8
8
  const fs = require("fs");
9
+ const gray = '\x1b[90m';
10
+ const purple = '\x1b[35m';
11
+ const green = '\x1b[32m';
12
+ const red = '\x1b[31m';
13
+ const yellow = '\x1b[33m';
14
+ const reset = '\x1b[0m';
9
15
  (async () => {
10
16
  let hasError = false;
11
17
  let projectVersion = 0;
12
18
  let typeRootsVersion = 0;
13
19
  let parsed;
14
- const { log, text } = await import('@clack/prompts');
20
+ const clack = await import('@clack/prompts');
15
21
  const snapshots = new Map();
16
22
  const versions = new Map();
17
23
  const configs = new Map();
@@ -73,21 +79,20 @@ const fs = require("fs");
73
79
  process.exit(hasError ? 1 : 0);
74
80
  async function projectWorker(tsconfigOption) {
75
81
  const tsconfig = await getTsconfigPath(tsconfigOption);
82
+ clack.intro(`${purple}[project]${reset} ${path.relative(process.cwd(), tsconfig)}`);
83
+ parsed = parseCommonLine(tsconfig);
84
+ if (!parsed.fileNames.length) {
85
+ clack.outro(`${yellow}No input files found.${reset}`);
86
+ return;
87
+ }
76
88
  const configFile = ts.findConfigFile(path.dirname(tsconfig), ts.sys.fileExists, 'tsslint.config.ts');
77
89
  if (!configFile) {
78
- log.step(`Project: ${path.relative(process.cwd(), tsconfig)}`);
79
- log.error('No tsslint.config.ts file found!');
90
+ clack.outro(`${yellow}No tsslint.config.ts found!${reset}`);
80
91
  return;
81
92
  }
82
- parsed = parseCommonLine(tsconfig);
83
- log.step(`Project: ${path.relative(process.cwd(), tsconfig)} (${parsed.fileNames.length} files)`);
84
93
  if (!configs.has(configFile)) {
85
94
  try {
86
- configs.set(configFile, await core.buildConfigFile(configFile, ts.sys.createHash, {
87
- log: log.info,
88
- warn: log.warn,
89
- error: log.error,
90
- }));
95
+ configs.set(configFile, await core.buildConfigFile(configFile, ts.sys.createHash, clack));
91
96
  }
92
97
  catch (err) {
93
98
  configs.set(configFile, undefined);
@@ -113,10 +118,17 @@ const fs = require("fs");
113
118
  typescript: ts,
114
119
  tsconfig: ts.server.toNormalizedPath(tsconfig),
115
120
  };
116
- const linter = core.createLinter(projectContext, tsslintConfig, 'cli');
121
+ const linter = core.createLinter(projectContext, tsslintConfig, 'cli', clack);
122
+ const lintSpinner = clack.spinner();
117
123
  let hasFix = false;
124
+ let passed = 0;
125
+ let errors = 0;
126
+ let warnings = 0;
118
127
  let cached = 0;
119
- for (const fileName of parsed.fileNames) {
128
+ lintSpinner.start();
129
+ for (let i = 0; i < parsed.fileNames.length; i++) {
130
+ const fileName = parsed.fileNames[i];
131
+ lintSpinner.message(`${gray}[${i + 1}/${parsed.fileNames.length}] ${path.relative(process.cwd(), fileName)}${reset}`);
120
132
  const fileMtime = fs.statSync(fileName).mtimeMs;
121
133
  let fileCache = lintCache[fileName];
122
134
  if (fileCache) {
@@ -177,28 +189,46 @@ const fs = require("fs");
177
189
  });
178
190
  output = output.replace(`TS${diagnostic.code}`, `TSSLint(${diagnostic.code})`);
179
191
  if (diagnostic.category === ts.DiagnosticCategory.Error) {
180
- log.error(output);
192
+ errors++;
193
+ clack.log.error(output);
181
194
  }
182
195
  else if (diagnostic.category === ts.DiagnosticCategory.Warning) {
183
- log.warn(output);
196
+ warnings++;
197
+ clack.log.warn(output);
184
198
  }
185
199
  else {
186
- log.info(output);
200
+ clack.log.info(output);
187
201
  }
188
202
  }
189
203
  if (diagnostics.length) {
190
204
  hasFix ||= linter.hasCodeFixes(fileName);
191
205
  hasError ||= diagnostics.some(diagnostic => diagnostic.category === ts.DiagnosticCategory.Error);
192
206
  }
207
+ else {
208
+ passed++;
209
+ }
193
210
  }
194
211
  }
195
- cache.saveCache(configFile, lintCache, ts.sys.createHash);
196
212
  if (cached) {
197
- log.info(`Linted ${parsed.fileNames.length - cached} files. (Cached ${cached} files result, use --force to re-lint all files.)`);
213
+ lintSpinner.stop(`${gray}Checked ${parsed.fileNames.length} files with cache.${reset} ${gray}(Use --force to ignore cache.)${reset}`);
214
+ }
215
+ else {
216
+ lintSpinner.stop(`${gray}Checked ${parsed.fileNames.length} files.${reset}`);
198
217
  }
199
218
  if (hasFix) {
200
- log.info(`Use --fix to apply fixes.`);
219
+ clack.log.message(`${gray}Use --fix to apply fixes.${reset}`);
201
220
  }
221
+ const data = [
222
+ [passed, 'passed', green],
223
+ [errors, 'errors', red],
224
+ [warnings, 'warnings', yellow],
225
+ ];
226
+ const summary = data
227
+ .filter(([count]) => count)
228
+ .map(([count, label, color]) => `${color}${count} ${label}${reset}`)
229
+ .join(` ${gray}|${reset} `);
230
+ clack.outro(summary);
231
+ cache.saveCache(configFile, lintCache, ts.sys.createHash);
202
232
  }
203
233
  async function getTsconfigPath(tsconfig) {
204
234
  if (!tsconfig) {
@@ -207,7 +237,7 @@ const fs = require("fs");
207
237
  if (!shortTsconfig?.startsWith('.')) {
208
238
  shortTsconfig = `./${shortTsconfig}`;
209
239
  }
210
- tsconfig = await text({
240
+ tsconfig = await clack.text({
211
241
  message: 'Select the tsconfig project. (Use --project or --projects to skip this prompt.)',
212
242
  placeholder: shortTsconfig ? `${shortTsconfig} (${parseCommonLine(tsconfig).fileNames.length} files)` : 'No tsconfig.json/jsconfig.json found, please enter the path to the tsconfig.json/jsconfig.json file.',
213
243
  defaultValue: shortTsconfig,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tsslint/cli",
3
- "version": "1.3.2",
3
+ "version": "1.3.4",
4
4
  "license": "MIT",
5
5
  "bin": {
6
6
  "tsslint": "./bin/tsslint.js"
@@ -15,13 +15,13 @@
15
15
  "directory": "packages/cli"
16
16
  },
17
17
  "dependencies": {
18
- "@clack/prompts": "^0.7.0",
19
- "@tsslint/config": "1.3.2",
20
- "@tsslint/core": "1.3.2",
18
+ "@clack/prompts": "^0.8.2",
19
+ "@tsslint/config": "1.3.4",
20
+ "@tsslint/core": "1.3.4",
21
21
  "glob": "^10.4.1"
22
22
  },
23
23
  "peerDependencies": {
24
24
  "typescript": "*"
25
25
  },
26
- "gitHead": "5685591d29322054ecb4f8b94eb35eab370d8288"
26
+ "gitHead": "695d85b225a333106ecdc476d096c88b1f77ecee"
27
27
  }
package/lib/worker.d.ts DELETED
@@ -1 +0,0 @@
1
- export {};
package/lib/worker.js DELETED
@@ -1,8 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const worker_threads = require("worker_threads");
4
- worker_threads.parentPort.on('message', message => {
5
- console.log('Message from main thread:', message);
6
- worker_threads.parentPort.postMessage('Hello, main thread' + JSON.stringify(worker_threads.workerData));
7
- });
8
- //# sourceMappingURL=worker.js.map