@sjstrykr/dependency-cleaner
v0.1.1
Published
CLI to scan and remove dependency folders (node_modules, __pycache__, etc.) by language
Downloads
10
Maintainers
Readme
dependency-cleaner
A CLI that scans a directory for dependency and cache folders (e.g. node_modules, __pycache__) based on the languages you choose, lets you pick which ones to remove in a list or tree view, then deletes them—either by moving to trash or permanently.
Features
- Multi-language support — Choose one or more languages; the tool scans for that language’s dependency/cache folders only.
- List and tree view — View results as a flat list or a tree, then select folders to remove.
- Select all / Select none — Quickly select or clear all found folders.
- Trash or permanent delete — Move selected folders to the system trash (recoverable) or remove them permanently.
- Safe defaults — No changes until you confirm; optional trash keeps data recoverable.
Installation
Global install (recommended)
npm install -g dependency-cleanerThen run:
dependency-cleaner
dependency-cleaner /path/to/projectRequirements
- Node.js ≥ 18 (used when running the published CLI)
- For development: Bun (used as the bundler)
Usage
dependency-cleaner [directory]directory— Path to the folder to scan. Defaults to the current directory (.) if omitted.
Flow
- Choose languages — Pick which languages to clean (e.g. Node.js, Python, Rust, Java). You can select multiple.
- Scan — The CLI finds all matching dependency/cache folders under the given directory.
- View mode — Choose List (flat list) or Tree (hierarchical view).
- Select folders — Use the checkbox list to select folders to remove. Use Select all / Select none to toggle everything.
- Delete mode — Choose Trash (recoverable) or Permanent (cannot be undone).
- Confirm — Confirm how many folders will be affected, then the tool runs.
Examples
# Scan current directory
dependency-cleaner
# Scan a specific project
dependency-cleaner ~/projects/my-app
# Scan relative path
dependency-cleaner ./packages/backendInitialize a config file
You can scaffold the global config file for custom directory names:
dependency-cleaner --initThis creates ~/.config/dependency-cleaner.config.json with a template:
{
"dirNames": []
}Supported languages and folders
| Language | Folders scanned |
|---------------------|-----------------|
| Node.js / JavaScript | node_modules |
| Python | __pycache__, venv, .venv, .mypy_cache, .pytest_cache, .ruff_cache |
| Rust | target |
| Java / Maven / Gradle | target, build, .gradle, out |
The scanner does not descend into these folders (e.g. it does not walk inside node_modules), so runs stay fast even in large trees.
Configuration
In addition to the built-in language folder lists, you can define custom directory names in a single global config file:
- Path:
~/.config/dependency-cleaner.config.json
Config schema:
{
"dirNames": ["custom_folder", "another_cache"]
}dirNamesis an optional array of strings.- Each entry is treated as an additional directory name to match (for all scans).
- Duplicate or empty names are ignored.
Custom dirNames are merged with the built-in language-specific folder names whenever the config file exists.
Project structure
dependency-cleaner/
├── index.ts # CLI entrypoint (shebang, args, orchestration)
├── language/
│ ├── types.ts # Language type definition
│ ├── index.ts # Registry of all languages
│ ├── node.ts
│ ├── python.ts
│ ├── rust.ts
│ └── java.ts
├── cli/
│ ├── scanner.ts # Recursive scan for dependency folders
│ ├── prompts.ts # Interactive prompts (languages, view, selection, delete mode)
│ ├── delete.ts # Trash or permanent delete
│ ├── tree.ts # Tree visualization for paths
│ └── constants.ts # Shared constants and types
├── dist/ # Build output (generated)
│ └── cli.js
├── package.json
├── tsconfig.json
└── README.mdDevelopment
Setup
bun installBuild
The CLI is written in TypeScript and bundled with Bun for Node:
bun run buildThis produces dist/cli.js, which is what the dependency-cleaner bin points to. The bundle targets Node so end users only need Node.js, not Bun.
Run locally
After building:
node dist/cli.js
node dist/cli.js /path/to/dirOr link the package for a global dependency-cleaner during development:
bun run build
npm link
dependency-cleanerAdding a new language
- Add a file under
language/, e.g.language/ruby.ts:import type { Language } from "./types.js"; export const ruby: Language = { id: "ruby", name: "Ruby", dirNames: ["vendor/bundle", ".bundle"], }; - In
language/index.ts, import the new language and add it toallLanguages.
Publishing
Push to GitHub
- Update the
repositoryURL inpackage.jsonto your repo (e.g.https://github.com/your-username/dependency-cleaner.git). - Initialize git (if not already), add files, and push:
git init
git add .
git commit -m "Initial commit"
git branch -M main
git remote add origin https://github.com/your-username/dependency-cleaner.git
git push -u origin mainPublish to npm
- Create an npm account if you don’t have one.
- Log in from the CLI:
npm login. - Ensure
package.jsonhas the correctname(must be unique on npm) andrepositoryURL. - Build and publish:
bun run build
npm publish- The
prepublishOnlyscript runsbun run buildautomatically beforenpm publish, sodist/is built even if you didn’t runbuildyourself. - The
filesfield inpackage.jsonlimits the published package todist/, so source and dev files are not included.
This project was vibe coded (built with AI assistance).
License
MIT
