tz-clean 2.4.0 → 2.5.0

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/.husky/pre-commit CHANGED
@@ -1 +1,12 @@
1
1
  npx lint-staged
2
+
3
+ node -e "
4
+ const fs = require('fs');
5
+ const file = 'index.js';
6
+ const content = fs.readFileSync(file, 'utf-8');
7
+ if (!content.startsWith('#!/usr/bin/env node')) {
8
+ fs.writeFileSync(file, '#!/usr/bin/env node\n' + content);
9
+ require('child_process').execSync('git add ' + file);
10
+ console.log('Restored shebang in index.js');
11
+ }
12
+ "
package/index.js CHANGED
@@ -70,6 +70,13 @@ function parseArgs() {
70
70
  return { excludePaths, includePaths, runEslint, runPrettier, runTypecheck, tools };
71
71
  }
72
72
 
73
+ function printFileProgress(label, filePath) {
74
+ const maxLen = 60;
75
+ const relative = path.relative(targetDir, filePath) || filePath;
76
+ const display = relative.length > maxLen ? '...' + relative.slice(-(maxLen - 3)) : relative;
77
+ process.stdout.write(`\r ${label} ${display.padEnd(maxLen + 5)}`);
78
+ }
79
+
73
80
  function printTerminalSummary(reportData, fixedFiles, totalErrors, totalWarnings, typecheckResult) {
74
81
  console.log('\n--- 📊 tz-clean Summary ---');
75
82
  console.log(`Files Analyzed: ${reportData.length}`);
@@ -120,13 +127,13 @@ async function run() {
120
127
  if (excludePaths.length > 0) console.log(`🚫 Exclude: ${excludePaths.join(', ')}`);
121
128
 
122
129
  try {
123
- process.stdout.write('⏳ [1/4] Running Prettier...');
130
+ process.stdout.write('⏳ [1/4] Running Prettier...\n');
124
131
  const fixedFiles = runPrettier ? runPrettierTools(includePaths, excludePaths) : [];
125
- process.stdout.write(`\r✅ [1/4] Prettier done (${fixedFiles.length} file(s) formatted) \n`);
132
+ process.stdout.write(`✅ [1/4] Prettier done (${fixedFiles.length} file(s) formatted) \n`);
126
133
 
127
- process.stdout.write('⏳ [2/4] Stripping comments...');
134
+ process.stdout.write('⏳ [2/4] Stripping comments...\n');
128
135
  const strippedFiles = stripCommentsAndEmptyLines(includePaths, excludePaths);
129
- process.stdout.write(`\r✅ [2/4] Comments stripped (${strippedFiles.length} file(s) modified) \n`);
136
+ process.stdout.write(`\r✅ [2/4] Comments stripped (${strippedFiles.length} file(s) modified)${' '.repeat(30)}\n`);
130
137
 
131
138
  const allFixedFiles = [...new Set([...fixedFiles, ...strippedFiles])];
132
139
 
@@ -232,13 +239,21 @@ function runPrettierTools(includePaths = [], excludePaths = []) {
232
239
  fixedFiles = prettierOutput
233
240
  .split('\n')
234
241
  .filter((line) => line.trim() && !line.includes('(unchanged)'))
235
- .map((line) => line.split(' ')[0]);
242
+ .map((line) => {
243
+ const filePath = line.split(' ')[0];
244
+ printFileProgress('✏️ ', path.resolve(targetDir, filePath));
245
+ return filePath;
246
+ });
236
247
  } catch (err) {
237
248
  if (err.stdout) {
238
249
  fixedFiles = err.stdout
239
250
  .split('\n')
240
251
  .filter((line) => line.trim() && !line.includes('(unchanged)'))
241
- .map((line) => line.split(' ')[0]);
252
+ .map((line) => {
253
+ const filePath = line.split(' ')[0];
254
+ printFileProgress('✏️ ', path.resolve(targetDir, filePath));
255
+ return filePath;
256
+ });
242
257
  }
243
258
  } finally {
244
259
  if (fs.existsSync(tempIgnorePath)) fs.unlinkSync(tempIgnorePath);
@@ -326,6 +341,7 @@ function stripCommentsAndEmptyLines(includePaths = [], excludePaths = []) {
326
341
  if (entry.isDirectory()) {
327
342
  scanDir(fullPath);
328
343
  } else if (entry.isFile() && extensions.includes(path.extname(entry.name))) {
344
+ printFileProgress('✂️ ', fullPath);
329
345
  const original = fs.readFileSync(fullPath, 'utf-8');
330
346
  let cleaned = stripCommentsFromSource(original);
331
347
  cleaned = cleaned.replace(new RegExp('\\n{3,}', 'g'), '\n\n');
@@ -351,9 +367,9 @@ function stripCommentsFromSource(source) {
351
367
 
352
368
  if (source.startsWith('#!')) {
353
369
  const end = source.indexOf('\n');
354
- const shebanEnd = end === -1 ? len : end + 1;
355
- result += source.slice(0, shebanEnd);
356
- i = shebanEnd;
370
+ const shebangEnd = end === -1 ? len : end + 1;
371
+ result += source.slice(0, shebangEnd);
372
+ i = shebangEnd;
357
373
  }
358
374
 
359
375
  while (i < len) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tz-clean",
3
- "version": "2.4.0",
3
+ "version": "2.5.0",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "bin": {