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
Markdown
# ๐งน 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.