Skip to content

Implement Homebrew cleanup module #35

@Sstark97

Description

@Sstark97

Phase 4: Cleanup Modules

Implement Homebrew cleanup module for macOS and Linux (Linuxbrew).

Implementation

In Infrastructure/Modules/Homebrew/HomebrewModule.cs

  • Implements ICleanupModule
  • Uses brew CLI via ICommandRunner

Features to Port from Bash

From src/modules/homebrew.sh:

  1. Remove outdated package versions - remove_outdated_package_versions
  2. Remove unused dependencies (orphans) - remove_unused_dependencies
  3. Clear Homebrew download cache - clear_homebrew_download_cache
  4. Update and diagnose - update_and_diagnose_homebrew

AnalyzeAsync

  • Check if brew command is available
  • Get cache path: brew --cache
  • Estimate sizes for outdated packages and cache
  • Return List<CleanupTarget>

CleanAsync

  • Execute cleanup operations
  • Run brew cleanup
  • Run brew autoremove
  • Optional: brew update and brew doctor
  • Return List<CleanupResult>

Properties

  • Name: ModuleName.Homebrew
  • Description: "Clean Homebrew (old packages, cache, diagnostics)"
  • IsDestructive: false
  • IsAvailableOnPlatform: true for macOS/Linux, false for Windows

Tests to Port

All in tests/Infrastructure/Modules/Homebrew/HomebrewModuleTests.cs

Port tests from bash tests/unit/homebrew_test.sh:

  • Brew availability check
  • Cache path detection
  • Outdated package removal
  • Dependency cleanup
  • Platform availability (skip on Windows)

Definition of Done

  • HomebrewModule fully implemented
  • All bash tests ported
  • Works on macOS and Linux (Linuxbrew)
  • Skipped gracefully on Windows
  • ~500MB-2GB typical recovery

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions