dir-analysis-tool 1.0.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.
@@ -0,0 +1,11 @@
1
+ {
2
+ "excludePatterns": [
3
+ "*.log",
4
+ "*.map"
5
+ ],
6
+ "largeSizeThreshold": 5000,
7
+ "enableDuplicateDetection": false,
8
+ "enableProgressBar": false,
9
+ "outputFormat": "table",
10
+ "maxDepth": 3
11
+ }
package/README.md ADDED
@@ -0,0 +1,502 @@
1
+ # Directory- ๐Ÿ“ **Depth Control**: Limit scanning depth for performanceAnalyzer
2
+
3
+ A powerful cross-platform command-line tool written in TypeScript that analyzes directories and provides comprehensive insights about their contents, including file classification, large file detection, duplicate analysis, and advanced reporting features.
4
+
5
+ ## ๐Ÿš€ Features
6
+
7
+ ### Core Analysis
8
+
9
+ - ๐Ÿ“Š **Directory Analysis**: Get total size, file count, and folder count
10
+ - ๐Ÿ“‚ **File Classification**: Automatically categorize files by type (images, videos, documents, etc.)
11
+ - ๐Ÿ”„ **Recursive Scanning**: Analyze nested directories with optional recursion
12
+ - ๐Ÿšซ **Smart Exclusions**: Skip common directories like `node_modules`, `.git`, etc.
13
+ - ๏ฟฝ **Depth Control**: Limit scanning depth for performance
14
+
15
+ ### Advanced Features (Phase 1)
16
+
17
+ - ๐Ÿ” **Large File Detection**: Identify files exceeding customizable size thresholds
18
+ - ๐Ÿ”„ **Duplicate File Detection**: Find identical files and calculate wasted space
19
+ - ๐Ÿ“Š **Progress Indicators**: Real-time progress bars during analysis
20
+ - ๐Ÿ“‹ **CSV Export**: Export results, large files, and duplicates to CSV format
21
+ - โš™๏ธ **Configuration Files**: Save and load analysis settings from config files
22
+ - ๐Ÿ“ **File Size Filters**: Filter analysis by minimum/maximum file sizes
23
+ - ๐Ÿ“… **Date Range Filters**: Filter files by modification date ranges
24
+ - ๐ŸŒณ **Tree View Output**: Beautiful directory tree visualization
25
+ - ๐Ÿ“ˆ **Top N Largest Files**: Show ranking of largest files
26
+ - ๐Ÿ“ญ **Empty File Detection**: Identify and report empty files
27
+
28
+ ### Interactive Features (Phase 2)
29
+
30
+ - ๐ŸŽฏ **Interactive Mode**: Dynamic CLI interface for exploration and analysis
31
+ - ๐Ÿ‘€ **Watch Mode**: Real-time monitoring of directory changes
32
+ - ๐Ÿ“Š **HTML Reports**: Beautiful HTML reports with interactive charts
33
+ - ๐Ÿ”„ **Directory Comparison**: Compare two directories side-by-side
34
+ - ๐ŸŽจ **Rich Visualizations**: Charts and graphs for better data understanding
35
+
36
+ ### Output & Reporting
37
+
38
+ - ๐ŸŽจ **Beautiful Terminal Output**: Colorful display with emoji icons
39
+ - ๐Ÿ“‹ **Multiple Formats**: Human-readable terminal output, JSON, CSV, or HTML
40
+ - ๐Ÿ“ˆ **Detailed Statistics**: Comprehensive metrics and insights
41
+ - ๐Ÿ—‚๏ธ **Categorized Reports**: Separate exports for different data types
42
+
43
+ ## Installation
44
+
45
+ ### Using npm/pnpm globally
46
+
47
+ ```bash
48
+ npm install -g dir-analyzer
49
+ # or
50
+ pnpm install -g dir-analyzer
51
+ ```
52
+
53
+ ### Using npx (no installation)
54
+
55
+ ```bash
56
+ npx dir-analyzer [options]
57
+ ```
58
+
59
+ ### Local development
60
+
61
+ ```bash
62
+ git clone <repository>
63
+ cd dir-analyzer
64
+ pnpm install
65
+ pnpm build
66
+ ```
67
+
68
+ ## Usage
69
+
70
+ ### Basic usage
71
+
72
+ ```bash
73
+ dir-analyzer
74
+ ```
75
+
76
+ ### Analyze a specific directory
77
+
78
+ ```bash
79
+ dir-analyzer --path /path/to/directory
80
+ ```
81
+
82
+ ### Enable large file detection (100MB threshold)
83
+
84
+ ```bash
85
+ dir-analyzer --large-files
86
+ ```
87
+
88
+ ### Custom large file threshold (50MB)
89
+
90
+ ```bash
91
+ dir-analyzer --large-files 52428800
92
+ ```
93
+
94
+ ### Enable duplicate detection
95
+
96
+ ```bash
97
+ dir-analyzer --duplicates
98
+ ```
99
+
100
+ ### Export to CSV
101
+
102
+ ```bash
103
+ # Export general analysis
104
+ dir-analyzer --csv
105
+
106
+ # Export with custom filename
107
+ dir-analyzer --csv my-analysis.csv
108
+
109
+ # Export large files to CSV
110
+ dir-analyzer --large-files --csv-large large-files.csv
111
+
112
+ # Export duplicates to CSV
113
+ dir-analyzer --duplicates --csv-duplicates duplicates.csv
114
+ ```
115
+
116
+ ### Use configuration file
117
+
118
+ ```bash
119
+ dir-analyzer --config ./my-config.json
120
+ ```
121
+
122
+ ### Combine multiple features
123
+
124
+ ```bash
125
+ dir-analyzer --path /my/project --large-files --duplicates --csv --progress --max-depth 5
126
+ ```
127
+
128
+ ### Get JSON output
129
+
130
+ ```bash
131
+ dir-analyzer --json
132
+ ```
133
+
134
+ ### Disable recursive scanning
135
+
136
+ ```bash
137
+ dir-analyzer --no-recursive
138
+ ```
139
+
140
+ ### Exclude specific patterns
141
+
142
+ ```bash
143
+ dir-analyzer --exclude "*.log" "temp*" "cache"
144
+ ```
145
+
146
+ ## Options
147
+
148
+ | Option | Description | Default |
149
+ |--------|-------------|---------|
150
+ | `-p, --path <path>` | Target directory to analyze | `.` (current directory) |
151
+ | `-r, --recursive` | Recursively analyze nested directories | `true` |
152
+ | `--no-recursive` | Disable recursive analysis | - |
153
+ | `-j, --json` | Output results in JSON format | `false` |
154
+ | `-t, --types` | Show file type classification summary | `true` |
155
+ | `--no-types` | Hide file type classification | - |
156
+ | `-e, --exclude <patterns...>` | Exclude file patterns or directories | `[]` |
157
+ | `-l, --large-files [threshold]` | Detect large files (default: 100MB) | `undefined` |
158
+ | `-d, --duplicates` | Enable duplicate file detection | `false` |
159
+ | `--csv [filename]` | Export results to CSV file | `undefined` |
160
+ | `--csv-large [filename]` | Export large files to CSV | `undefined` |
161
+ | `--csv-duplicates [filename]` | Export duplicates to CSV | `undefined` |
162
+ | `--progress` | Show progress bar during analysis | `true` |
163
+ | `--no-progress` | Disable progress bar | - |
164
+ | `--max-depth <depth>` | Maximum directory depth to scan | `-1` (no limit) |
165
+ | `-c, --config [path]` | Load configuration from file | `undefined` |
166
+ | `-h, --help` | Display help information | - |
167
+ | `-V, --version` | Display version number | - |
168
+
169
+ ## Configuration Files
170
+
171
+ You can save analysis settings in a configuration file to avoid repeating command-line options. The tool looks for configuration files in the following order:
172
+
173
+ 1. `.dir-analyzer.json` in the current directory
174
+ 2. `dir-analyzer.config.json` in the current directory
175
+ 3. Searches parent directories up to the root
176
+
177
+ ### Configuration File Example
178
+
179
+ ```json
180
+ {
181
+ "excludePatterns": ["*.log", "temp*", ".cache"],
182
+ "largeSizeThreshold": 52428800,
183
+ "enableDuplicateDetection": true,
184
+ "enableProgressBar": true,
185
+ "outputFormat": "table",
186
+ "maxDepth": 10
187
+ }
188
+ ```
189
+
190
+ ### Configuration Options
191
+
192
+ | Option | Type | Description | Default |
193
+ |--------|------|-------------|---------|
194
+ | `excludePatterns` | `string[]` | File patterns to exclude | `[]` |
195
+ | `largeSizeThreshold` | `number` | Large file threshold in bytes | `104857600` (100MB) |
196
+ | `enableDuplicateDetection` | `boolean` | Enable duplicate detection | `false` |
197
+ | `enableProgressBar` | `boolean` | Show progress indicators | `true` |
198
+ | `outputFormat` | `string` | Output format (`table`, `json`, `csv`) | `table` |
199
+ | `maxDepth` | `number` | Maximum scan depth (-1 = no limit) | `-1` |
200
+
201
+ ## File Type Classification
202
+
203
+ The tool automatically classifies files into the following categories:
204
+
205
+ | Type | Extensions |
206
+ |------|------------|
207
+ | **Images** | `.png`, `.jpg`, `.jpeg`, `.gif`, `.svg`, `.webp`, `.bmp`, `.tiff`, `.ico` |
208
+ | **Videos** | `.mp4`, `.mkv`, `.avi`, `.mov`, `.webm`, `.flv`, `.wmv`, `.m4v` |
209
+ | **Documents** | `.pdf`, `.docx`, `.xlsx`, `.pptx`, `.txt`, `.doc`, `.xls`, `.ppt`, `.rtf`, `.odt`, `.ods`, `.odp` |
210
+ | **Audio** | `.mp3`, `.wav`, `.flac`, `.aac`, `.ogg`, `.wma`, `.m4a` |
211
+ | **Code** | `.js`, `.ts`, `.jsx`, `.tsx`, `.py`, `.java`, `.cpp`, `.c`, `.h`, `.hpp`, `.cs`, `.php`, `.rb`, `.go`, `.rs`, `.swift`, `.kt`, `.scala`, `.clj`, `.sh`, `.bat`, `.ps1`, `.sql`, `.html`, `.css`, `.scss`, `.sass`, `.less`, `.json`, `.xml`, `.yaml`, `.yml`, `.toml`, `.ini`, `.cfg`, `.conf` |
212
+ | **Archives** | `.zip`, `.rar`, `.7z`, `.tar`, `.gz`, `.bz2`, `.xz`, `.tar.gz`, `.tar.bz2` |
213
+ | **Other** | All other file types |
214
+
215
+ ## Output Examples
216
+
217
+ ### Terminal Output
218
+
219
+ ```bash
220
+ ๐Ÿ” Starting directory analysis...
221
+ [โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ] 100% (1,247/1,247) /path/to/file.js
222
+ โœ… Analysis complete!
223
+
224
+ ๐Ÿ“‚ Directory: ./my-project
225
+ ๐Ÿ“ฆ Total Size: 124.7 MB
226
+ ๐Ÿ“ Folders: 17
227
+ ๐Ÿ“„ Files: 328
228
+
229
+ ๐Ÿ—‚ File Types:
230
+ ๐Ÿ“ท Images: 87
231
+ ๐ŸŽฌ Videos: 4
232
+ ๐Ÿ“„ Documents: 12
233
+ ๐ŸŽต Audio: 8
234
+ ๐Ÿง‘โ€๐Ÿ’ป Code: 165
235
+ ๐Ÿ—ƒ๏ธ Archives: 3
236
+ โ“ Other: 49
237
+
238
+ ๐Ÿšจ Large Files (Top 5):
239
+ ๐Ÿ“ assets/video/demo.mp4 - 45.2 MB
240
+ ๐Ÿ“ dist/bundle.min.js - 12.8 MB
241
+ ๐Ÿ“ docs/manual.pdf - 8.4 MB
242
+ ๐Ÿ“ src/data/dataset.json - 5.9 MB
243
+ ๐Ÿ“ assets/images/banner.png - 3.2 MB
244
+
245
+ ๐Ÿ”„ Duplicate Files:
246
+ ๐Ÿ“Š Groups: 8
247
+ ๐Ÿ’พ Wasted Space: 156.8 MB
248
+
249
+ Top duplicate groups:
250
+ 1. 23.4 MB each ร— 4 files
251
+ ๐Ÿ“„ backup/project-v1.zip
252
+ ๐Ÿ“„ archives/project-backup.zip
253
+ ... and 2 more
254
+ 2. 12.8 MB each ร— 3 files
255
+ ๐Ÿ“„ dist/bundle.min.js
256
+ ๐Ÿ“„ build/main.js
257
+ ... and 1 more
258
+ ```
259
+
260
+ ### JSON Output
261
+
262
+ ```json
263
+ {
264
+ "path": "./my-project",
265
+ "totalSizeBytes": 130861056,
266
+ "totalSizeMB": 124.7,
267
+ "folders": 17,
268
+ "files": 328,
269
+ "types": {
270
+ "images": 87,
271
+ "videos": 4,
272
+ "documents": 12,
273
+ "audio": 8,
274
+ "code": 165,
275
+ "archives": 3,
276
+ "other": 49
277
+ },
278
+ "largeFiles": [
279
+ {
280
+ "path": "/project/assets/video/demo.mp4",
281
+ "size": 47430656,
282
+ "sizeFormatted": "45.2 MB"
283
+ }
284
+ ],
285
+ "duplicateGroups": [
286
+ {
287
+ "hash": "a1b2c3d4...",
288
+ "size": 24543232,
289
+ "sizeFormatted": "23.4 MB",
290
+ "files": [
291
+ "/project/backup/project-v1.zip",
292
+ "/project/archives/project-backup.zip"
293
+ ],
294
+ "totalWastedSpace": 24543232,
295
+ "totalWastedSpaceFormatted": "23.4 MB"
296
+ }
297
+ ],
298
+ "duplicateStats": {
299
+ "totalGroups": 8,
300
+ "totalWastedSpace": 164470938,
301
+ "totalWastedSpaceFormatted": "156.8 MB"
302
+ }
303
+ }
304
+ ```
305
+
306
+ ### CSV Export
307
+
308
+ The tool can export data to CSV format for further analysis:
309
+
310
+ #### General Analysis CSV (`--csv`)
311
+
312
+ ```csv
313
+ Type,Path,Size (Bytes),Size (Formatted),Count,Details
314
+ Summary,./my-project,130861056,124.7MB,328,Folders: 17
315
+ FileType,images,-,-,87,-
316
+ FileType,code,-,-,165,-
317
+ LargeFile,"/project/assets/video/demo.mp4",47430656,"45.2 MB",1,-
318
+ Duplicate,"/project/backup/project-v1.zip",24543232,"23.4 MB",1,"Group 1, Total files: 2, Wasted space: 23.4 MB"
319
+ ```
320
+
321
+ #### Large Files CSV (`--csv-large`)
322
+
323
+ ```csv
324
+ Path,Size (Bytes),Size (Formatted)
325
+ "/project/assets/video/demo.mp4",47430656,"45.2 MB"
326
+ "/project/dist/bundle.min.js",13421772,"12.8 MB"
327
+ ```
328
+
329
+ #### Duplicates CSV (`--csv-duplicates`)
330
+
331
+ ```csv
332
+ Group,Path,Size (Bytes),Size (Formatted),Files in Group,Wasted Space
333
+ 1,"/project/backup/project-v1.zip",24543232,"23.4 MB",2,"23.4 MB"
334
+ 1,"/project/archives/project-backup.zip",24543232,"23.4 MB",2,"23.4 MB"
335
+ ```
336
+
337
+ ## Performance & Large Directories
338
+
339
+ For optimal performance when analyzing large directories:
340
+
341
+ - Use `--max-depth` to limit scan depth
342
+ - Use `--exclude` to skip unnecessary directories
343
+ - Disable features you don't need (e.g., `--no-progress`, `--no-types`)
344
+ - Use `--no-recursive` for single-level analysis
345
+
346
+ ## Default Exclusions
347
+
348
+ The following directories are excluded by default:
349
+
350
+ - `node_modules`
351
+ - `.git`
352
+ - `.svn`
353
+ - `.hg`
354
+ - `dist`
355
+ - `build`
356
+ - `.cache`
357
+
358
+ You can add custom exclusions using the `--exclude` option or configuration file.
359
+
360
+ ## Phase 1 Features
361
+
362
+ ### File size filtering
363
+
364
+ ```bash
365
+ # Show only files between 1MB and 10MB
366
+ dir-analyzer --min-size 1048576 --max-size 10485760
367
+
368
+ # Show only files larger than 50MB
369
+ dir-analyzer --min-size 52428800
370
+ ```
371
+
372
+ ### Date range filtering
373
+
374
+ ```bash
375
+ # Show files modified after January 1, 2024
376
+ dir-analyzer --date-from 2024-01-01
377
+
378
+ # Show files modified between two dates
379
+ dir-analyzer --date-from 2024-01-01 --date-to 2024-12-31
380
+ ```
381
+
382
+ ### Tree view and top files
383
+
384
+ ```bash
385
+ # Display directory structure as a tree
386
+ dir-analyzer --tree
387
+
388
+ # Show top 20 largest files
389
+ dir-analyzer --top-n 20
390
+
391
+ # Detect empty files
392
+ dir-analyzer --empty-files
393
+ ```
394
+
395
+ ## Phase 2 Features
396
+
397
+ ### Interactive mode
398
+
399
+ ```bash
400
+ # Start interactive exploration mode
401
+ dir-analyzer --interactive
402
+ ```
403
+
404
+ ### Watch mode
405
+
406
+ ```bash
407
+ # Monitor directory for changes
408
+ dir-analyzer --watch
409
+
410
+ # Watch with limited depth
411
+ dir-analyzer --watch --max-depth 3
412
+ ```
413
+
414
+ ### HTML reports
415
+
416
+ ```bash
417
+ # Generate HTML report with charts
418
+ dir-analyzer --html
419
+
420
+ # Generate HTML report with custom filename
421
+ dir-analyzer --html my-report.html
422
+
423
+ # Full analysis with HTML report
424
+ dir-analyzer --large-files --duplicates --top-n 15 --html complete-report.html
425
+ ```
426
+
427
+ ## Advanced Usage Examples
428
+
429
+ ### Cleanup Large Projects
430
+
431
+ ```bash
432
+ # Find large files and duplicates in a project
433
+ dir-analyzer --large-files 10485760 --duplicates --csv cleanup-report.csv
434
+
435
+ # Analyze with specific exclusions
436
+ dir-analyzer --exclude "node_modules" "*.log" "tmp*" --large-files --duplicates
437
+ ```
438
+
439
+ ### CI/CD Integration
440
+
441
+ ```bash
442
+ # Generate JSON report for automated processing
443
+ dir-analyzer --json --large-files --max-depth 3 > analysis-report.json
444
+
445
+ # Check for space usage with threshold
446
+ dir-analyzer --large-files 52428800 --csv-large large-files.csv
447
+ ```
448
+
449
+ ### Documentation & Reporting
450
+
451
+ ```bash
452
+ # Generate comprehensive CSV reports
453
+ dir-analyzer --csv analysis.csv --csv-large large.csv --csv-duplicates dupes.csv --large-files --duplicates
454
+
455
+ # Create project documentation
456
+ dir-analyzer --path ./src --types --json > project-structure.json
457
+ ```
458
+
459
+ ## Requirements
460
+
461
+ - Node.js >= 18.0.0
462
+
463
+ ## Development
464
+
465
+ ```bash
466
+ # Install dependencies
467
+ pnpm install
468
+
469
+ # Build the project
470
+ pnpm build
471
+
472
+ # Run in development mode
473
+ pnpm dev --path ./test-directory
474
+
475
+ # Run the built version
476
+ pnpm start --path ./test-directory
477
+ ```
478
+
479
+ ## License
480
+
481
+ MIT
482
+
483
+ ## Contributing
484
+
485
+ Contributions are welcome! Please feel free to submit a Pull Request.
486
+
487
+ ## Roadmap
488
+
489
+ ### Phase 2 (Planned)
490
+
491
+ - ๐Ÿ“ˆ **Advanced Analytics**: File age analysis, access patterns
492
+ - ๐Ÿ” **Search & Filter**: Find files by criteria
493
+ - ๐Ÿงน **Cleanup Tools**: Interactive duplicate removal
494
+ - ๐Ÿ“Š **Visualization**: Charts and graphs for data representation
495
+ - โšก **Performance**: Multi-threading and caching improvements
496
+
497
+ ### Phase 3 (Future)
498
+
499
+ - ๐ŸŒ **Web Interface**: Browser-based analysis dashboard
500
+ - ๐Ÿ”— **Integration**: Git integration, cloud storage analysis
501
+ - ๐Ÿค– **AI Features**: Smart categorization and recommendations
502
+ - ๐Ÿ“ฑ **Mobile**: React Native app for mobile analysis
package/bin/index.js ADDED
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ require("./cli");
5
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,13 @@
1
+ {
2
+ "excludePatterns": [
3
+ "*.log",
4
+ "temp*",
5
+ ".cache",
6
+ "*.tmp"
7
+ ],
8
+ "largeSizeThreshold": 104857600,
9
+ "enableDuplicateDetection": false,
10
+ "enableProgressBar": true,
11
+ "outputFormat": "table",
12
+ "maxDepth": -1
13
+ }
package/package.json ADDED
@@ -0,0 +1,48 @@
1
+ {
2
+ "name": "dir-analysis-tool",
3
+ "version": "1.0.0",
4
+ "description": "A cross-platform command-line tool that analyzes directories and outputs size, file counts, and file type classifications",
5
+ "main": "bin/index.js",
6
+ "bin": {
7
+ "dir-analysis-tool": "bin/index.js"
8
+ },
9
+ "scripts": {
10
+ "build": "tsc",
11
+ "dev": "tsx src/cli.ts",
12
+ "start": "node bin/index.js",
13
+ "prepublishOnly": "pnpm build"
14
+ },
15
+ "keywords": [
16
+ "cli",
17
+ "directory",
18
+ "analyzer",
19
+ "file-system",
20
+ "typescript"
21
+ ],
22
+ "author": "Khaled Saeed",
23
+ "license": "MIT",
24
+ "repository": {
25
+ "type": "git",
26
+ "url": "git+https://github.com/khaled-saeed/dir-analysis-tool.git"
27
+ },
28
+ "bugs": {
29
+ "url": "https://github.com/khaled-saeed/dir-analysis-tool/issues"
30
+ },
31
+ "homepage": "https://github.com/khaled-saeed/dir-analysis-tool#readme",
32
+ "dependencies": {
33
+ "chalk": "^4.1.2",
34
+ "chokidar": "^4.0.3",
35
+ "commander": "^11.1.0",
36
+ "inquirer": "^12.6.3",
37
+ "pretty-bytes": "^5.6.0"
38
+ },
39
+ "devDependencies": {
40
+ "@types/inquirer": "^9.0.8",
41
+ "@types/node": "^20.10.0",
42
+ "tsx": "^4.6.0",
43
+ "typescript": "^5.3.0"
44
+ },
45
+ "engines": {
46
+ "node": ">=18.0.0"
47
+ }
48
+ }