Skip to content

mitian233/DevCleaner

Repository files navigation

DevCleaner

⚠️ Windows Only: This tool is designed specifically for Windows. It targets Windows-specific paths and tools like Scoop, Winget, Chocolatey, and NuGet.

A powerful CLI tool for cleaning cache files generated by development tools on Windows, featuring a modern TUI interactive interface.

Features

  • Modern TUI Interface - Elegant interactive experience using @clack/prompts
  • Smart Detection - Automatically detect installed development tools and their caches
  • Efficient Cleaning - Prioritizes using tool's built-in cleaning commands for safety
  • Statistics - Before/after comparison showing cleaning results
  • Risk Warnings - Labels high-risk operations to prevent accidental deletion of important files

Supported Cleaning Tools

Package Managers

  • npm - npm cache clean --force
  • Yarn - yarn cache clean
  • pnpm - pnpm store prune

Programming Languages / Build Tools

  • pip - pip cache purge
  • Gradle - Manual cache directory deletion
  • Maven - Manual repository directory deletion (high risk)
  • Cargo - cargo cache -a or manual deletion
  • NuGet - dotnet nuget locals all --clear
  • Go - go clean -cache

System Cache

  • System Temporary Files - %LOCALAPPDATA%\Temp

Requirements

  • Windows (PowerShell or Command Prompt)
  • Node.js >= 18

Installation

# Using npx (no installation required)
npx devcleaner

# Global installation
npm install -g devcleaner
devcleaner

# Using pnpm
pnpm add -g devcleaner
devcleaner

Usage

Run the command:

devcleaner

Or use npx directly:

npx devcleaner

The program will automatically:

  1. Detect installed development tools in the system
  2. Scan cache directory sizes for each tool
  3. Display cache list for selection
  4. Prompt confirmation for high-risk operations
  5. Execute cleaning and display statistics report

Usage Example

┌  DevCleaner - Development Tool Cache Cleaner
│
◇  Detection complete
│
◆  Select caches to clean (Space to select, Enter to confirm)
│  ◻ npm Cache - 1.38 MB (✓ Low Risk)
│  ◻ pip Cache - 641.00 B
│  ◻ Gradle Cache - 749.65 MB
│  ◻ NuGet Packages - 649.11 KB
│  ◻ System Temp - 253.11 MB

Risk Levels

  • 🟢 Low Risk - Automatically regenerated after cleaning, no side effects
  • 🟡 Medium Risk - May need to rebuild project after cleaning
  • 🔴 High Risk - Need to re-download dependencies after cleaning (e.g., Maven repository)

Tech Stack

  • TypeScript - Type-safe development experience
  • @clack/prompts - Modern TUI interaction library
  • execa - Powerful process execution tool
  • picocolors - Terminal color library

Project Structure

DevCleaner/
├── src/
│   ├── index.ts          # CLI entry and TUI interaction
│   ├── types.ts          # TypeScript type definitions
│   ├── tools/            # Cleaner implementations for each tool
│   │   ├── base.ts       # Base cleaner class
│   │   ├── npm.ts        # npm cleaner
│   │   ├── yarn.ts       # yarn cleaner
│   │   └── ...           # Other cleaners
│   └── utils/            # Utility functions
│       ├── size.ts       # Directory size calculation
│       ├── execute.ts    # Command execution
│       └── format.ts     # File system operations
├── dist/                 # Compiled output
├── package.json
└── tsconfig.json

How It Works

  1. Detection Phase

    • Check if cache directories for each development tool exist
    • Calculate cache directory sizes
    • Detect if cleaning commands are available
  2. Cleaning Phase

    • Prioritize using tool's built-in cleaning commands (e.g., npm cache clean)
    • If no cleaning command available, safely delete cache directory
    • Calculate space difference before and after cleaning
  3. Reporting Phase

    • Display cleaning results for each tool
    • Statistics of total space freed

Safety

  • ✅ Only cleans known safe directories
  • ✅ High-risk operations require double confirmation
  • ✅ Prioritizes using tool's built-in cleaning commands
  • ✅ Detailed error handling and logging

Development

# Clone the repository
git clone <repository-url>
cd DevCleaner

# Install dependencies
pnpm install

# Run in development mode
pnpm dev

# Build
pnpm build

FAQ

Q: What to do after cleaning Maven repository?

A: After Maven repository is cleaned, dependencies will be automatically re-downloaded during the next build. It's recommended to do this in a good network environment.

Q: Why are some tools not detected?

A: The tool may not be installed, or the cache directory doesn't exist or is empty.

Q: What if the project build fails after cleaning?

A: Most caches can be rebuilt after cleaning. If you encounter issues, try cleaning the project's node_modules and other directories.

License

MIT

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors