UNPKG

assetdrain

Version:

๐Ÿงน A blazing-fast CLI to detect and clean unused assets from your codebase with interactive UX.

122 lines (74 loc) โ€ข 3.04 kB
# ๐Ÿงน assetdrain ![npm](https://img.shields.io/npm/v/assetdrain) > ![downloads](https://img.shields.io/npm/dm/assetdrain) > ![license](https://img.shields.io/npm/l/assetdrain) > Find and remove unused images, icons, and media files from your codebase โ€” with a sleek, interactive CLI. Feels like Vite. Cleans like a Roomba.   --- ## ๐Ÿš€ What is this? A blazing-fast CLI tool that scans your repo for assets (like `.svg`, `.png`, `.mp4`, etc.), checks where they're actually used in code, and tells you what you can delete โ€” or deletes it for you ๐Ÿซก. --- ## ๐ŸŽฏ Features - โœ… Scans for unused images, gifs, videos, or any custom extensions - ๐ŸŽฏ Works with **any file structure** (Next.js app router, traditional `src/`, etc.) - ๐Ÿง  Skips false positives by ignoring asset references inside comments โ€” so if // public/file.svg is just sitting there unused, assetdrain will still flag it โœ… - ๐Ÿ”ฅ Interactive prompts (select file types, code extensions, actions) - โœจ Export to **CSV/JSON** - ๐Ÿšจ Safe modes like dry-run and delete confirmation --- ## ๐Ÿ› ๏ธ Installation ```bash npm install -g assetdrain ``` or use directly: ```bash npx assetdrain [asset-folder] ``` --- ## ๐Ÿงช Usage ```bash npx assetdrain [asset-folder] ``` Example: ```bash npx assetdrain public ``` This will scan all supported asset files in `./public/`, match against code in your entire repo, and show unused ones. --- ## โš™๏ธ Modes ``` ? What would you like to do? โœ” Scan and Review (Default) Scan Only Scan and Delete Automatically (At your own risk) ``` - **Scan and Review** โ€“ Shows unused files and _asks if you want to delete_ - **Scan Only** โ€“ Just shows unused files, safe mode - **Scan and Delete Automatically** โ€“ ๐Ÿšจ Deletes immediately, no questions asked --- ## ๐Ÿ“ฆ Export After the scan: ```bash ? Would you like to export the report? โœ” Yes (CSV) Yes (JSON) No ``` - Includes: filename, usage status, deletion status - Saved to: `assetdrain-report.json` / `assetdrain-report.csv` --- ## ๐Ÿง‘โ€๐Ÿ’ป Author Built with โค๏ธ by [Vedant Sonkar](https://github.com/vedantsonkar) Open to contributions, ideas, and collabs. Feel free to reach out! --- ## ๐Ÿž Issues / Bugs / Feature Requests If assetdrain misbehaves or you're dreaming up a feature: ๐Ÿ‘‰ [Open an issue](https://github.com/vedantsonkar/assetdrain/issues) --- ## ๐Ÿงพ License MIT. You can clone it, fork it, break it, and improve it ๐Ÿ˜„ --- ## โš ๏ธ Disclaimer assetdrain is provided \"as-is\" without any warranties. Use it at your own risk. By using this tool, you agree that the author (Vedant Sonkar) is **not responsible** for any accidental deletions, data loss, or damage caused by the use (or misuse) of this software. Always double-check the unused asset list before confirming deletions โ€” especially in **Scan and Delete Automatically** mode. --- ## ๐Ÿค Contributing PRs welcome! If you have an idea, bug report, or want to collaborate on features, open an issue or fork the repo.