dir-analysis-tool 1.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.
Files changed (56) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +195 -278
  3. package/dist/index.js +1310 -0
  4. package/package.json +45 -28
  5. package/bin/advanced-analysis.d.ts +0 -43
  6. package/bin/advanced-analysis.d.ts.map +0 -1
  7. package/bin/advanced-analysis.js +0 -187
  8. package/bin/advanced-analysis.js.map +0 -1
  9. package/bin/analyzer.d.ts +0 -40
  10. package/bin/analyzer.d.ts.map +0 -1
  11. package/bin/analyzer.js +0 -215
  12. package/bin/analyzer.js.map +0 -1
  13. package/bin/classifier.d.ts +0 -27
  14. package/bin/classifier.d.ts.map +0 -1
  15. package/bin/classifier.js +0 -63
  16. package/bin/classifier.js.map +0 -1
  17. package/bin/cli.d.ts +0 -2
  18. package/bin/cli.d.ts.map +0 -1
  19. package/bin/cli.js +0 -421
  20. package/bin/cli.js.map +0 -1
  21. package/bin/config.d.ts +0 -10
  22. package/bin/config.d.ts.map +0 -1
  23. package/bin/config.js +0 -94
  24. package/bin/config.js.map +0 -1
  25. package/bin/export.d.ts +0 -20
  26. package/bin/export.d.ts.map +0 -1
  27. package/bin/export.js +0 -56
  28. package/bin/export.js.map +0 -1
  29. package/bin/html-report.d.ts +0 -12
  30. package/bin/html-report.d.ts.map +0 -1
  31. package/bin/html-report.js +0 -695
  32. package/bin/html-report.js.map +0 -1
  33. package/bin/index.d.ts +0 -3
  34. package/bin/index.d.ts.map +0 -1
  35. package/bin/index.js +0 -5
  36. package/bin/index.js.map +0 -1
  37. package/bin/interactive.d.ts +0 -27
  38. package/bin/interactive.d.ts.map +0 -1
  39. package/bin/interactive.js +0 -637
  40. package/bin/interactive.js.map +0 -1
  41. package/bin/progress.d.ts +0 -9
  42. package/bin/progress.d.ts.map +0 -1
  43. package/bin/progress.js +0 -42
  44. package/bin/progress.js.map +0 -1
  45. package/bin/tree-view.d.ts +0 -21
  46. package/bin/tree-view.d.ts.map +0 -1
  47. package/bin/tree-view.js +0 -140
  48. package/bin/tree-view.js.map +0 -1
  49. package/bin/types.d.ts +0 -43
  50. package/bin/types.d.ts.map +0 -1
  51. package/bin/types.js +0 -3
  52. package/bin/types.js.map +0 -1
  53. package/bin/utils.d.ts +0 -24
  54. package/bin/utils.d.ts.map +0 -1
  55. package/bin/utils.js +0 -59
  56. package/bin/utils.js.map +0 -1
@@ -1,695 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.HTMLReportGenerator = void 0;
4
- const utils_1 = require("./utils");
5
- const fs_1 = require("fs");
6
- class HTMLReportGenerator {
7
- static async generateReport(result, filename) {
8
- let outputFile = filename || `directory-analysis-${new Date().toISOString().slice(0, 10)}.html`;
9
- // Check if the provided filename is actually a directory
10
- if (filename) {
11
- try {
12
- const stats = await fs_1.promises.stat(filename);
13
- if (stats.isDirectory()) {
14
- // If it's a directory, generate a filename inside that directory
15
- const path = require('path');
16
- outputFile = path.join(filename, `directory-analysis-${new Date().toISOString().slice(0, 10)}.html`);
17
- }
18
- }
19
- catch (error) {
20
- // If stat fails, assume it's a valid filename (file doesn't exist yet)
21
- outputFile = filename;
22
- }
23
- }
24
- const html = this.generateHTML(result);
25
- await fs_1.promises.writeFile(outputFile, html);
26
- return outputFile;
27
- }
28
- static generateHTML(result) {
29
- return `<!DOCTYPE html>
30
- <html lang="en">
31
- <head>
32
- <meta charset="UTF-8">
33
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
34
- <title>Directory Analysis Report - ${result.path}</title>
35
- <script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
36
- <style>
37
- ${this.getCSS()}
38
- </style>
39
- </head>
40
- <body>
41
- <div class="container">
42
- <header class="header">
43
- <h1>📂 Directory Analysis Report</h1>
44
- <p class="path">📍 ${result.path}</p>
45
- <p class="timestamp">📅 Generated on ${new Date().toLocaleString()}</p>
46
- </header>
47
-
48
- <div class="summary-grid">
49
- <div class="summary-card">
50
- <div class="summary-icon">📦</div>
51
- <div class="summary-content">
52
- <h3>Total Size</h3>
53
- <p class="summary-value">${(0, utils_1.formatSize)(result.totalSizeBytes)}</p>
54
- </div>
55
- </div>
56
- <div class="summary-card">
57
- <div class="summary-icon">📄</div>
58
- <div class="summary-content">
59
- <h3>Files</h3>
60
- <p class="summary-value">${result.files.toLocaleString()}</p>
61
- </div>
62
- </div>
63
- <div class="summary-card">
64
- <div class="summary-icon">📁</div>
65
- <div class="summary-content">
66
- <h3>Folders</h3>
67
- <p class="summary-value">${result.folders.toLocaleString()}</p>
68
- </div>
69
- </div>
70
- <div class="summary-card">
71
- <div class="summary-icon">🗂️</div>
72
- <div class="summary-content">
73
- <h3>File Types</h3>
74
- <p class="summary-value">${this.countNonZeroTypes(result.types)}</p>
75
- </div>
76
- </div>
77
- </div>
78
-
79
- <div class="charts-container">
80
- <div class="chart-section">
81
- <h2>📊 File Type Distribution</h2>
82
- <div class="chart-wrapper">
83
- <canvas id="fileTypeChart"></canvas>
84
- </div>
85
- </div>
86
-
87
- ${result.topLargestFiles && result.topLargestFiles.length > 0 ? `
88
- <div class="chart-section">
89
- <h2>📈 Largest Files</h2>
90
- <div class="chart-wrapper">
91
- <canvas id="largestFilesChart"></canvas>
92
- </div>
93
- </div>
94
- ` : ''}
95
- </div>
96
-
97
- ${result.largeFiles && result.largeFiles.length > 0 ? `
98
- <div class="section">
99
- <h2>🚨 Large Files</h2>
100
- <div class="table-wrapper">
101
- <table class="data-table">
102
- <thead>
103
- <tr>
104
- <th>File Path</th>
105
- <th>Size</th>
106
- </tr>
107
- </thead>
108
- <tbody>
109
- ${result.largeFiles.slice(0, 20).map(file => `
110
- <tr>
111
- <td class="file-path">${this.escapeHtml(file.path)}</td>
112
- <td class="file-size">${file.sizeFormatted}</td>
113
- </tr>
114
- `).join('')}
115
- </tbody>
116
- </table>
117
- </div>
118
- </div>
119
- ` : ''}
120
-
121
- ${result.duplicateGroups && result.duplicateGroups.length > 0 ? `
122
- <div class="section">
123
- <h2>🔄 Duplicate Files</h2>
124
- <div class="duplicate-stats">
125
- <p>📊 Total Groups: <strong>${result.duplicateGroups.length}</strong></p>
126
- ${result.duplicateStats ? `
127
- <p>💾 Wasted Space: <strong>${result.duplicateStats.totalWastedSpaceFormatted}</strong></p>
128
- ` : ''}
129
- </div>
130
- <div class="duplicate-groups">
131
- ${result.duplicateGroups.slice(0, 10).map((group, index) => `
132
- <div class="duplicate-group">
133
- <h4>Group ${index + 1} - ${group.sizeFormatted} each × ${group.files.length} files</h4>
134
- <ul class="duplicate-files">
135
- ${group.files.slice(0, 5).map(file => `
136
- <li class="duplicate-file">${this.escapeHtml(file)}</li>
137
- `).join('')}
138
- ${group.files.length > 5 ? `
139
- <li class="more-files">... and ${group.files.length - 5} more files</li>
140
- ` : ''}
141
- </ul>
142
- </div>
143
- `).join('')}
144
- </div>
145
- </div>
146
- ` : ''}
147
-
148
- ${result.emptyFiles && result.emptyFiles.length > 0 ? `
149
- <div class="section">
150
- <h2>📭 Empty Files</h2>
151
- <div class="table-wrapper">
152
- <table class="data-table">
153
- <thead>
154
- <tr>
155
- <th>File Path</th>
156
- <th>Modified Date</th>
157
- </tr>
158
- </thead>
159
- <tbody>
160
- ${result.emptyFiles.slice(0, 20).map(file => `
161
- <tr>
162
- <td class="file-path">${this.escapeHtml(file.path)}</td>
163
- <td class="file-date">${file.modifiedDate.toLocaleDateString()}</td>
164
- </tr>
165
- `).join('')}
166
- </tbody>
167
- </table>
168
- </div>
169
- </div>
170
- ` : ''}
171
-
172
- <footer class="footer">
173
- <p>Generated by Dir Analyzer v1.0.0</p>
174
- </footer>
175
- </div>
176
-
177
- <script>
178
- ${this.getJavaScript(result)}
179
- </script>
180
- </body>
181
- </html>`;
182
- }
183
- static getCSS() {
184
- return `
185
- * {
186
- margin: 0;
187
- padding: 0;
188
- box-sizing: border-box;
189
- }
190
-
191
- body {
192
- font-family: 'Fira Code', 'Consolas', 'Monaco', 'Courier New', monospace;
193
- line-height: 1.6;
194
- color: #00ff00;
195
- background: #0a0a0a;
196
- min-height: 100vh;
197
- background-image:
198
- linear-gradient(90deg, rgba(0,255,0,0.03) 1px, transparent 1px),
199
- linear-gradient(rgba(0,255,0,0.03) 1px, transparent 1px);
200
- background-size: 20px 20px;
201
- }
202
-
203
- .container {
204
- max-width: 1200px;
205
- margin: 0 auto;
206
- padding: 20px;
207
- }
208
-
209
- .header {
210
- background: #1a1a1a;
211
- padding: 30px;
212
- border: 2px solid #00ff00;
213
- border-radius: 8px;
214
- box-shadow: 0 0 20px rgba(0,255,0,0.3);
215
- margin-bottom: 30px;
216
- text-align: center;
217
- position: relative;
218
- }
219
-
220
- .header::before {
221
- content: '> ';
222
- position: absolute;
223
- left: 15px;
224
- top: 15px;
225
- color: #00ff00;
226
- font-weight: bold;
227
- }
228
-
229
- .header h1 {
230
- font-size: 2.5em;
231
- margin-bottom: 10px;
232
- color: #00ff00;
233
- text-shadow: 0 0 10px rgba(0,255,0,0.5);
234
- font-weight: bold;
235
- }
236
-
237
- .path {
238
- font-size: 1.2em;
239
- color: #00cccc;
240
- margin-bottom: 5px;
241
- font-family: 'Fira Code', monospace;
242
- }
243
-
244
- .timestamp {
245
- color: #666;
246
- font-family: 'Fira Code', monospace;
247
- }
248
-
249
- .summary-grid {
250
- display: grid;
251
- grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
252
- gap: 20px;
253
- margin-bottom: 30px;
254
- }
255
-
256
- .summary-card {
257
- background: #1a1a1a;
258
- padding: 25px;
259
- border: 1px solid #333;
260
- border-radius: 8px;
261
- box-shadow: 0 0 15px rgba(0,255,0,0.1);
262
- display: flex;
263
- align-items: center;
264
- transition: all 0.3s ease;
265
- position: relative;
266
- }
267
-
268
- .summary-card::before {
269
- content: '$ ';
270
- position: absolute;
271
- left: 10px;
272
- top: 10px;
273
- color: #00ff00;
274
- font-size: 0.9em;
275
- }
276
-
277
- .summary-card:hover {
278
- border-color: #00ff00;
279
- box-shadow: 0 0 25px rgba(0,255,0,0.3);
280
- transform: translateY(-2px);
281
- }
282
-
283
- .summary-icon {
284
- font-size: 3em;
285
- margin-right: 20px;
286
- filter: grayscale(1) brightness(1.5);
287
- }
288
-
289
- .summary-content h3 {
290
- color: #00cccc;
291
- margin-bottom: 5px;
292
- text-transform: uppercase;
293
- letter-spacing: 1px;
294
- }
295
-
296
- .summary-value {
297
- font-size: 2em;
298
- font-weight: bold;
299
- color: #00ff00;
300
- text-shadow: 0 0 5px rgba(0,255,0,0.5);
301
- }
302
-
303
- .charts-container {
304
- display: grid;
305
- grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
306
- gap: 30px;
307
- margin-bottom: 30px;
308
- }
309
-
310
- .chart-section {
311
- background: #1a1a1a;
312
- padding: 25px;
313
- border: 1px solid #333;
314
- border-radius: 8px;
315
- box-shadow: 0 0 15px rgba(0,255,0,0.1);
316
- position: relative;
317
- }
318
-
319
- .chart-section::before {
320
- content: '>> ';
321
- position: absolute;
322
- left: 10px;
323
- top: 10px;
324
- color: #00ff00;
325
- font-size: 0.9em;
326
- }
327
-
328
- .chart-section h2 {
329
- margin-bottom: 20px;
330
- color: #00ff00;
331
- text-transform: uppercase;
332
- letter-spacing: 1px;
333
- border-bottom: 2px solid #00ff00;
334
- padding-bottom: 10px;
335
- }
336
-
337
- .chart-wrapper {
338
- position: relative;
339
- height: 300px;
340
- }
341
-
342
- .section {
343
- background: #1a1a1a;
344
- padding: 25px;
345
- border: 1px solid #333;
346
- border-radius: 8px;
347
- box-shadow: 0 0 15px rgba(0,255,0,0.1);
348
- margin-bottom: 30px;
349
- position: relative;
350
- }
351
-
352
- .section::before {
353
- content: '>>> ';
354
- position: absolute;
355
- left: 10px;
356
- top: 10px;
357
- color: #00ff00;
358
- font-size: 0.9em;
359
- }
360
-
361
- .section h2 {
362
- margin-bottom: 20px;
363
- color: #00ff00;
364
- border-bottom: 2px solid #00ff00;
365
- padding-bottom: 10px;
366
- text-transform: uppercase;
367
- letter-spacing: 1px;
368
- }
369
-
370
- .table-wrapper {
371
- overflow-x: auto;
372
- }
373
-
374
- .data-table {
375
- width: 100%;
376
- border-collapse: collapse;
377
- margin-top: 10px;
378
- border: 1px solid #333;
379
- }
380
-
381
- .data-table th,
382
- .data-table td {
383
- padding: 12px;
384
- text-align: left;
385
- border-bottom: 1px solid #333;
386
- border-right: 1px solid #333;
387
- }
388
-
389
- .data-table th {
390
- background: #0d0d0d;
391
- font-weight: 600;
392
- color: #00cccc;
393
- text-transform: uppercase;
394
- letter-spacing: 1px;
395
- }
396
-
397
- .data-table tr:hover {
398
- background: #2a2a2a;
399
- }
400
-
401
- .file-path {
402
- font-family: 'Fira Code', 'Consolas', monospace;
403
- font-size: 0.9em;
404
- color: #00ff00;
405
- }
406
-
407
- .file-size {
408
- font-weight: 600;
409
- color: #ff6b6b;
410
- font-family: 'Fira Code', monospace;
411
- }
412
-
413
- .file-date {
414
- color: #666;
415
- font-family: 'Fira Code', monospace;
416
- }
417
-
418
- .duplicate-stats {
419
- background: #0d0d0d;
420
- padding: 15px;
421
- border: 1px solid #333;
422
- border-radius: 4px;
423
- margin-bottom: 20px;
424
- }
425
-
426
- .duplicate-group {
427
- border: 1px solid #333;
428
- border-radius: 4px;
429
- margin-bottom: 15px;
430
- padding: 15px;
431
- background: #0d0d0d;
432
- }
433
-
434
- .duplicate-group h4 {
435
- color: #00cccc;
436
- margin-bottom: 10px;
437
- font-family: 'Fira Code', monospace;
438
- }
439
-
440
- .duplicate-files {
441
- list-style: none;
442
- }
443
-
444
- .duplicate-file {
445
- padding: 5px 0;
446
- font-family: 'Fira Code', monospace;
447
- font-size: 0.9em;
448
- color: #00ff00;
449
- }
450
-
451
- .duplicate-file::before {
452
- content: ' - ';
453
- color: #666;
454
- }
455
-
456
- .more-files {
457
- padding: 5px 0;
458
- color: #666;
459
- font-style: italic;
460
- font-family: 'Fira Code', monospace;
461
- }
462
-
463
- .footer {
464
- text-align: center;
465
- padding: 20px;
466
- color: #666;
467
- font-size: 0.9em;
468
- font-family: 'Fira Code', monospace;
469
- border-top: 1px solid #333;
470
- margin-top: 30px;
471
- }
472
-
473
- .footer::before {
474
- content: '~$ ';
475
- color: #00ff00;
476
- }
477
-
478
- @media (max-width: 768px) {
479
- .container {
480
- padding: 10px;
481
- }
482
-
483
- .header h1 {
484
- font-size: 2em;
485
- }
486
-
487
- .summary-grid {
488
- grid-template-columns: 1fr;
489
- }
490
-
491
- .charts-container {
492
- grid-template-columns: 1fr;
493
- }
494
-
495
- .summary-card {
496
- text-align: center;
497
- flex-direction: column;
498
- }
499
-
500
- .summary-icon {
501
- margin-right: 0;
502
- margin-bottom: 10px;
503
- }
504
- }
505
- `;
506
- }
507
- static getJavaScript(result) {
508
- const fileTypeData = this.getFileTypeChartData(result.types);
509
- const largestFilesData = this.getLargestFilesChartData(result.topLargestFiles);
510
- return ` // File Type Chart
511
- const fileTypeCtx = document.getElementById('fileTypeChart').getContext('2d');
512
- new Chart(fileTypeCtx, {
513
- type: 'doughnut',
514
- data: {
515
- labels: ${JSON.stringify(fileTypeData.labels)},
516
- datasets: [{
517
- data: ${JSON.stringify(fileTypeData.data)},
518
- backgroundColor: [
519
- '#00ff00', '#00cccc', '#ffff00', '#ff6b6b',
520
- '#9966ff', '#ff9900', '#66ff66', '#ff3366'
521
- ],
522
- borderColor: '#0a0a0a',
523
- borderWidth: 2
524
- }]
525
- },
526
- options: {
527
- responsive: true,
528
- maintainAspectRatio: false,
529
- plugins: {
530
- legend: {
531
- position: 'bottom',
532
- labels: {
533
- padding: 20,
534
- usePointStyle: true,
535
- color: '#00ff00',
536
- font: {
537
- family: 'Fira Code, Consolas, Monaco, monospace',
538
- size: 12
539
- }
540
- }
541
- },
542
- tooltip: {
543
- backgroundColor: '#1a1a1a',
544
- titleColor: '#00ff00',
545
- bodyColor: '#00cccc',
546
- borderColor: '#333',
547
- borderWidth: 1,
548
- titleFont: {
549
- family: 'Fira Code, Consolas, Monaco, monospace'
550
- },
551
- bodyFont: {
552
- family: 'Fira Code, Consolas, Monaco, monospace'
553
- },
554
- callbacks: {
555
- label: function(context) {
556
- const label = context.label || '';
557
- const value = context.parsed;
558
- const total = context.dataset.data.reduce((a, b) => a + b, 0);
559
- const percentage = ((value / total) * 100).toFixed(1);
560
- return label + ': ' + value + ' files (' + percentage + '%)';
561
- }
562
- }
563
- }
564
- }
565
- }
566
- });
567
-
568
- ${result.topLargestFiles && result.topLargestFiles.length > 0 ? `
569
- // Largest Files Chart
570
- const largestFilesCtx = document.getElementById('largestFilesChart').getContext('2d');
571
- new Chart(largestFilesCtx, {
572
- type: 'bar',
573
- data: {
574
- labels: ${JSON.stringify(largestFilesData.labels)},
575
- datasets: [{
576
- label: 'File Size',
577
- data: ${JSON.stringify(largestFilesData.data)},
578
- backgroundColor: '#00ff00',
579
- borderColor: '#00cccc',
580
- borderWidth: 1
581
- }]
582
- },
583
- options: {
584
- responsive: true,
585
- maintainAspectRatio: false,
586
- scales: {
587
- y: {
588
- beginAtZero: true,
589
- ticks: {
590
- color: '#00ff00',
591
- font: {
592
- family: 'Fira Code, Consolas, Monaco, monospace'
593
- },
594
- callback: function(value) {
595
- return formatBytes(value);
596
- }
597
- },
598
- grid: {
599
- color: '#333'
600
- }
601
- },
602
- x: {
603
- ticks: {
604
- color: '#00ff00',
605
- font: {
606
- family: 'Fira Code, Consolas, Monaco, monospace'
607
- },
608
- maxRotation: 45,
609
- minRotation: 45
610
- },
611
- grid: {
612
- color: '#333'
613
- }
614
- }
615
- },
616
- plugins: {
617
- legend: {
618
- display: false
619
- },
620
- tooltip: {
621
- backgroundColor: '#1a1a1a',
622
- titleColor: '#00ff00',
623
- bodyColor: '#00cccc',
624
- borderColor: '#333',
625
- borderWidth: 1,
626
- titleFont: {
627
- family: 'Fira Code, Consolas, Monaco, monospace'
628
- },
629
- bodyFont: {
630
- family: 'Fira Code, Consolas, Monaco, monospace'
631
- },
632
- callbacks: {
633
- label: function(context) {
634
- return 'Size: ' + formatBytes(context.parsed.y);
635
- }
636
- }
637
- }
638
- }
639
- }
640
- });
641
- ` : ''}
642
-
643
- function formatBytes(bytes) {
644
- if (bytes === 0) return '0 Bytes';
645
- const k = 1024;
646
- const sizes = ['Bytes', 'KB', 'MB', 'GB'];
647
- const i = Math.floor(Math.log(bytes) / Math.log(k));
648
- return parseFloat((bytes / Math.pow(k, i)).toFixed(2)) + ' ' + sizes[i];
649
- }
650
- `;
651
- }
652
- static getFileTypeChartData(types) {
653
- const typeMapping = {
654
- code: '🧑‍💻 Code',
655
- images: '📷 Images',
656
- documents: '📄 Documents',
657
- videos: '🎬 Videos',
658
- audio: '🎵 Audio',
659
- archives: '🗃️ Archives',
660
- other: '❓ Other'
661
- };
662
- const labels = [];
663
- const data = [];
664
- Object.entries(types).forEach(([key, value]) => {
665
- if (value > 0) {
666
- labels.push(typeMapping[key] || key);
667
- data.push(value);
668
- }
669
- });
670
- return { labels, data };
671
- }
672
- static getLargestFilesChartData(topFiles) {
673
- if (!topFiles || topFiles.length === 0) {
674
- return { labels: [], data: [] };
675
- }
676
- const labels = topFiles.map(file => {
677
- const fileName = file.path.split(/[/\\]/).pop() || file.path;
678
- return fileName.length > 20 ? fileName.substring(0, 17) + '...' : fileName;
679
- });
680
- const data = topFiles.map(file => file.size);
681
- return { labels, data };
682
- }
683
- static countNonZeroTypes(types) {
684
- return Object.values(types).filter(count => count > 0).length;
685
- }
686
- static escapeHtml(text) {
687
- return text
688
- .replace(/&/g, '&amp;')
689
- .replace(/</g, '&lt;').replace(/>/g, '&gt;')
690
- .replace(/"/g, '&quot;')
691
- .replace(/'/g, '&#39;');
692
- }
693
- }
694
- exports.HTMLReportGenerator = HTMLReportGenerator;
695
- //# sourceMappingURL=html-report.js.map