UNPKG

clean-disk-space

Version:

๐Ÿงน The first comprehensive macOS cleanup tool for npm! No Homebrew or Python needed. Clean disk space with npx - from trash to node_modules, caches to Docker. Safe, interactive, and tracks space freed. System-wide cleanup made simple.

371 lines (260 loc) โ€ข 9.44 kB
# ๐Ÿงน clean-disk-space [![npm version](https://img.shields.io/npm/v/clean-disk-space.svg)](https://www.npmjs.com/package/clean-disk-space) [![npm downloads](https://img.shields.io/npm/dm/clean-disk-space.svg)](https://www.npmjs.com/package/clean-disk-space) [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT) [![Node.js Version](https://img.shields.io/node/v/clean-disk-space.svg)](https://nodejs.org) > **The first comprehensive macOS cleanup tool available as an npm package!** ๐Ÿš€ > > No Homebrew required. No Python dependencies. Just `npx clean-disk-space` and go. Clean up **gigabytes** of unnecessary files with confidence. Features **space tracking**, **dry-run mode**, and **two cleanup levels** (safe & aggressive). ```bash # Install globally npm install -g clean-disk-space # Or use instantly with npx (no installation needed!) npx clean-disk-space ``` --- ## ๐ŸŽฏ Why clean-disk-space? Unlike other macOS cleanup tools, **clean-disk-space** is: ### โœ… npm-Native - **No Homebrew needed** (unlike `mac-cleanup`) - **No Python required** (unlike `mac-cleanup-py`) - Works instantly with `npx` - zero setup! ### โœ… Comprehensive - **System-wide cleanup** (not just node_modules like `npkill`) - Cleans Homebrew, Docker, Xcode, caches, logs, and more - All in one command ### โœ… Developer-Friendly - Built for the Node.js ecosystem - Zero external dependencies - Interactive confirmations for safety - Tracks exactly how much space you freed ### โœ… Safe by Default - Preview mode with `--dry-run` - Shows what will be deleted before deletion - No sudo required - Never touches system files --- ## ๐Ÿ“Š Comparison with Alternatives | Feature | clean-disk-space | mac-cleanup | mac-cleanup-py | npkill | |---------|------------------|-------------|----------------|--------| | **Installation** | npm/npx | Homebrew | pip | npm | | **External Dependencies** | โœ… None | โŒ Homebrew | โŒ Python | โœ… None | | **System-wide Cleanup** | โœ… Yes | โœ… Yes | โœ… Yes | โŒ No | | **node_modules Cleanup** | โœ… Yes | โŒ No | โŒ No | โœ… Yes | | **Docker Cleanup** | โœ… Yes | โœ… Yes | โœ… Yes | โŒ No | | **Xcode Cleanup** | โœ… Yes | โœ… Yes | โœ… Yes | โŒ No | | **Space Tracking** | โœ… Yes | โŒ No | โŒ No | โŒ No | | **Dry-run Preview** | โœ… Yes | โŒ No | โœ… Yes | โŒ No | | **Built-in Docs** | โœ… Yes | โŒ No | โŒ No | โŒ No | | **Works with npx** | โœ… Yes | โŒ No | โŒ No | โœ… Yes | **clean-disk-space is the only npm-native, comprehensive macOS cleanup tool!** --- ## โœจ Features <table> <tr> <td width="33%"> ### ๐Ÿ›ก๏ธ Safety First - **Dry-run mode** to preview - **Interactive confirmations** - **Color-coded warnings** - **No system files touched** </td> <td width="33%"> ### ๐Ÿ“Š Smart Tracking - **Before/after sizes** - **Total space freed** - **Detailed breakdowns** - **Progress indicators** </td> <td width="33%"> ### ๐Ÿ’ช Powerful - **Standard + Deep modes** - **Built-in documentation** - **Zero dependencies** - **Lightning fast** </td> </tr> </table> --- ## ๐Ÿš€ Quick Start ### Installation ```bash # Install globally npm install -g clean-disk-space # Or use without installing npx clean-disk-space ``` ### Basic Usage ```bash # Preview what will be cleaned (recommended first run) clean-disk-space --dry-run # Run interactive cleanup clean-disk-space # Auto-confirm all safe operations clean-disk-space --yes ``` ### Advanced Usage ```bash # Deep cleanup (node_modules, Docker, etc.) - with confirmations clean-disk-space deep # Preview deep cleanup clean-disk-space deep --dry-run # View full documentation clean-disk-space docs ``` --- ## ๐Ÿ“บ Demo ```bash $ clean-disk-space --dry-run โ•”โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•— โ•‘ ๐Ÿงน macOS Disk Space Cleaner โ•‘ โ•šโ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ• โš ๏ธ DRY RUN MODE - No changes will be made ๐Ÿ’พ Disk Space: Total: 500GB Used: 450GB (90%) Available: 50GB ๐Ÿ“ฆ Emptying Trash... Current size: 2.3GB ๐Ÿ’พ Would free: 2.3GB ๐Ÿบ Cleaning Homebrew cache... Can free: ~1.2GB ๐Ÿ—„๏ธ Cleaning user caches... Current size: 3.5GB ๐Ÿ’พ Would free: 3.5GB โœจ Cleanup complete! Run with --deep for aggressive cleanup ``` --- ## ๐Ÿงน What Gets Cleaned ### ๐Ÿ“ฆ Standard Cleanup (Safe - Default) | Item | What It Does | Typical Space Freed | Safe? | |------|--------------|---------------------|-------| | ๐Ÿ—‘๏ธ **Trash** | Empties `~/.Trash` | 0-5GB | โœ… Yes | | ๐Ÿบ **Homebrew Cache** | Removes old downloads | 0.5-2GB | โœ… Yes | | ๐ŸŒ **Browser Caches** | Safari, Chrome caches | 1-5GB | โœ… Yes | | ๐Ÿ“ฆ **npm Cache** | Cached packages | 0.5-2GB | โœ… Yes | | ๐Ÿงถ **Yarn Cache** | Cached dependencies | 0.5-2GB | โœ… Yes | | ๐Ÿ“ **Old Logs** | Logs older than 30 days | 0.1-1GB | โœ… Yes | | ๐Ÿ“ฑ **Xcode DerivedData** | Build artifacts (rebuilds automatically) | 5-20GB | โœ… Yes* | *Requires confirmation **Total Typical Savings: 2-10GB** ๐Ÿ’พ ### ๐Ÿ”ฅ Deep Cleanup (Aggressive) | Item | What It Does | Typical Space Freed | Requires Confirmation | |------|--------------|---------------------|----------------------| | ๐Ÿ“‚ **node_modules** | Removes all node_modules folders | 5-50GB | โš ๏ธ Yes | | ๐Ÿณ **Docker** | Unused images/containers | 1-10GB | โš ๏ธ Yes | | ๐Ÿ’Ž **CocoaPods** | iOS dependency cache | 0.5-5GB | โš ๏ธ Yes | | ๐Ÿค– **Gradle** | Android build cache | 1-10GB | โš ๏ธ Yes | | ๐Ÿ“ฆ **Xcode Archives** | App distribution builds | 5-50GB | โš ๏ธ Yes | **Total Typical Savings: 10-50GB+** ๐Ÿ’พ --- ## ๐ŸŽฏ Commands & Options ### Commands ```bash clean-disk-space # Standard cleanup (default) clean-disk-space deep # Aggressive cleanup clean-disk-space help # Show help clean-disk-space docs # Show full documentation ``` ### Options | Option | Alias | Description | |--------|-------|-------------| | `--dry-run` | `-d` | Preview without making changes | | `--yes` | `-y` | Auto-confirm all prompts | | `--verbose` | `-v` | Detailed output | | `--help` | `-h` | Show help | --- ## ๐Ÿ“– Common Workflows ### ๐Ÿ—“๏ธ Monthly Maintenance ```bash # Quick monthly cleanup (safe) clean-disk-space --yes ``` ### ๐Ÿ’พ Low Disk Space Emergency ```bash # Step 1: Preview standard cleanup clean-disk-space --dry-run # Step 2: Run standard cleanup clean-disk-space # Step 3: Preview deep cleanup clean-disk-space deep --dry-run # Step 4: Run deep cleanup (will ask for confirmation) clean-disk-space deep ``` ### ๐Ÿ” Exploration Mode ```bash # Learn what it does clean-disk-space docs # See what would be cleaned clean-disk-space --dry-run clean-disk-space deep --dry-run ``` ### ๐Ÿš€ Before Major Updates ```bash # Free maximum space before macOS update clean-disk-space deep --dry-run clean-disk-space deep ``` --- ## ๐Ÿ›ก๏ธ Safety Features ### โœ… What's Safe to Delete - โœ… Application caches (rebuilds automatically) - โœ… Package manager caches (re-downloads on demand) - โœ… Old log files (>30 days) - โœ… Trash contents - โœ… Build artifacts (can rebuild) ### โš ๏ธ What Requires Confirmation - โš ๏ธ **node_modules**: Shows full list before deletion - โš ๏ธ **Docker images**: May remove images you need - โš ๏ธ **Xcode Archives**: App distribution builds (backup first!) - โš ๏ธ **Build caches**: Gradle, CocoaPods ### โŒ What's NEVER Deleted - โŒ System files - โŒ Applications - โŒ User documents - โŒ Active project files - โŒ Recent logs (<30 days) --- ## ๐Ÿ’ก Pro Tips 1. **Always dry-run first**: `clean-disk-space --dry-run` 2. **Start with standard cleanup**: Only use deep mode when necessary 3. **Monthly maintenance**: Run `clean-disk-space --yes` monthly 4. **Before major updates**: Use deep cleanup before macOS upgrades 5. **node_modules cleanup**: Great for freeing 20GB+ for developers 6. **Keep backups**: Especially before cleaning Xcode Archives --- ## ๐Ÿ”ง Requirements - **OS**: macOS 10.15 (Catalina) or later - **Node.js**: v12.0.0 or later - **Permissions**: Terminal access (no sudo required for most operations) --- ## ๐Ÿค Contributing Contributions are welcome! Please feel free to submit a Pull Request. 1. Fork the repository 2. Create your feature branch (`git checkout -b feature/amazing-feature`) 3. Commit your changes (`git commit -m 'Add amazing feature'`) 4. Push to the branch (`git push origin feature/amazing-feature`) 5. Open a Pull Request --- ## ๐Ÿ“ License MIT ยฉ [CVSRohit](https://github.com/CVSRohit) --- ## ๐Ÿ”— Links - **npm Package**: https://www.npmjs.com/package/clean-disk-space - **GitHub Repository**: https://github.com/CVSRohit/clean-disk-space - **Report Issues**: https://github.com/CVSRohit/clean-disk-space/issues --- ## โญ Show Your Support If this tool helped you free up disk space, please consider: - โญ Starring the repository - ๐Ÿ“ Writing a review - ๐Ÿค Contributing improvements - ๐Ÿ’ฌ Sharing with others --- <div align="center"> **Made with โค๏ธ for the macOS community** [![GitHub Stars](https://img.shields.io/github/stars/CVSRohit/clean-disk-space?style=social)](https://github.com/CVSRohit/clean-disk-space) **Note**: Always have backups of important data before running cleanup tools! </div>