flutter_osouji

Fast parallel Flutter project cleaner that sweeps build artifacts.

Features

  • ๐Ÿ” Smart Detection: Automatically finds Flutter projects by scanning pubspec.yaml files
  • โšก Parallel Execution: Leverages multiple CPU cores for maximum performance
  • ๐Ÿ“Š Size Analysis: Shows how much space you'll free before and after cleaning
  • ๐ŸŽจ Beautiful Output: Colorful, progress-aware CLI interface with real-time scanning progress
  • ๐Ÿš€ High Performance: ~1.9s per GB cleaned on modern SSD systems
  • ๐Ÿ“ˆ Progress Tracking: Real-time scanning progress with current directory and project count

Installation

# Install from pub.dev (when published)
dart pub global activate flutter_osouji

# Or run locally
dart pub get
dart bin/flutter_osouji.dart run

Usage

Basic Commands

# Clean all Flutter projects in current directory (default)
flutter_osouji run

# Clean projects in specific directory with 8 parallel jobs  
flutter_osouji run ./my_projects --concurrency=8

# Dry run - see what would be cleaned without actually cleaning
flutter_osouji dry-run

# Clean with verbose output
flutter_osouji run --verbose

Expected Output

# Run mode with real-time scanning progress
$ flutter_osouji run ./dev --concurrency=8
๐Ÿ” Scanning /dev/projects/app1 (0 found)...
๐Ÿ” Scanning /dev/projects/app2 (1 found)...
๐Ÿ” Scanning /dev/projects/app3 (2 found)...
๐Ÿ” Scanning โ€ฆ 12 Flutter projects detected
โšก Cleaning (8 parallel jobs) โ€ฆ
  โœ” /dev/app1                784 MB  โฑ 3.2 s
  โœ” /dev/app2               1.1 GB   โฑ 2.9 s
  โœ– /dev/app3                  โ€”     ๐Ÿšซ flutter not found
  โ€ฆ
๐Ÿงน  Finished in 12.7 s. Freed 8.6 GB (11 projects OK, 1 failed)

# Dry run mode
$ flutter_osouji dry-run
๐Ÿ” Found 12 Flutter projects
๐Ÿ“Š Cleanable sizes:
  ๐Ÿ“ /dev/app1               784 MB
  ๐Ÿ“ /dev/app2               1.1 GB
  โ€ฆ
๐Ÿ’พ Total cleanable size: 9.4 GB

Options

Option Description Default
--concurrency, -j Number of parallel jobs Number of CPU cores
--exclude Glob pattern to exclude directories None
--verbose, -v Verbose output false

Examples

# Clean with custom concurrency
flutter_osouji run --concurrency=4

# Exclude example directories  
flutter_osouji run --exclude "**/example/**"

# Verbose output
flutter_osouji run --verbose

How it Works

  1. Discovery: Recursively scans directories for pubspec.yaml files
  2. Validation: Checks if projects contain Flutter dependencies (flutter: key)
  3. Analysis: Calculates size of cleanable directories (build/, .dart_tool/, etc.)
  4. Execution: Runs flutter clean in parallel across all found projects
  5. Reporting: Shows cleaned size and execution time

Performance

  • Smart Skipping: Avoids scanning .git, node_modules, and other non-project directories
  • Parallel I/O: Maximizes disk throughput with concurrent operations
  • Memory Efficient: Streams directory contents instead of loading everything into memory

Typical performance: ~1.9s per GB cleaned on modern SSD systems with 8+ cores.

Development

# Clone and setup
git clone <repository>
cd flutter_osouji
dart pub get

# Run tests
dart test

# Run locally
dart bin/flutter_osouji.dart run ./test_projects
dart bin/flutter_osouji.dart dry-run

# Run with global activation (for testing)
dart pub global activate --source path .
flutter_osouji run

Project Structure

flutter_osouji/
โ”œโ”€โ”€ bin/
โ”‚   โ””โ”€โ”€ flutter_osouji.dart          # CLI entry point
โ”œโ”€โ”€ lib/
โ”‚   โ”œโ”€โ”€ flutter_osouji.dart          # Library exports
โ”‚   โ””โ”€โ”€ src/
โ”‚       โ”œโ”€โ”€ commands/
โ”‚       โ”‚   โ”œโ”€โ”€ run_cmd.dart         # Run command implementation
โ”‚       โ”‚   โ””โ”€โ”€ dry_run_cmd.dart     # Dry-run command implementation
โ”‚       โ””โ”€โ”€ utils/
โ”‚           โ”œโ”€โ”€ dir_scan.dart        # Directory scanning utilities
โ”‚           โ”œโ”€โ”€ size.dart            # Size calculation utilities
โ”‚           โ”œโ”€โ”€ clean.dart           # Flutter clean execution
โ”‚           โ””โ”€โ”€ logger.dart          # Logging utilities
โ”œโ”€โ”€ test/
โ”‚   โ””โ”€โ”€ flutter_osouji_test.dart      # Unit tests
โ””โ”€โ”€ pubspec.yaml                     # Dependencies

Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Add tests for new functionality
  5. Run dart test to ensure tests pass
  6. Submit a pull request

License

MIT License - see LICENSE file for details.

Libraries

flutter_osouji
Fast parallel Flutter project cleaner that sweeps build artifacts