feat: add cleanup support for Elixir, Haskell, OCaml, and Editors#302
feat: add cleanup support for Elixir, Haskell, OCaml, and Editors#302tw93 merged 5 commits intotw93:windowsfrom
Conversation
Windows port of biplavbarua's extended dev cleanup feature: - Elixir: Mix archives and Hex cache cleanup - Haskell: Cabal packages/store and Stack programs cache - OCaml: Opam download and repo cache - Editors: VS Code, VS Code Insiders, Zed, Sublime Text, Atom caches Mirrors the macOS implementation from PR tw93#287
There was a problem hiding this comment.
Pull request overview
This pull request adds cleanup support for four additional development ecosystems (Elixir, Haskell, OCaml) and various code editors (VS Code, VS Code Insiders, Zed, Sublime Text, Atom) to the Windows PowerShell implementation of the Mole cleanup tool. This mirrors functionality from PR #287 for macOS.
Changes:
- Added
Clear-ElixirCachesfunction to clean Mix archives and Hex cache/packages - Added
Clear-HaskellCachesfunction to clean Cabal and Stack caches with age-based cleanup for Cabal store - Added
Clear-OCamlCachesfunction to clean Opam download and repository caches - Added
Clear-EditorCachesfunction to clean various editor caches including VS Code, VS Code Insiders, Zed, Sublime Text, and Atom
lib/clean/dev.ps1
Outdated
| # Cabal packages cache | ||
| $cabalPackagesPath = "$env:USERPROFILE\.cabal\packages" | ||
| if (Test-Path $cabalPackagesPath) { | ||
| Clear-DirectoryContents -Path $cabalPackagesPath -Description "Cabal packages cache" |
There was a problem hiding this comment.
Clearing the entire Cabal packages cache may be overly aggressive as it contains downloaded package archives that may still be needed. Consider implementing selective cleanup similar to the Cabal store cleanup (age-based) or only cleaning temporary files and cache metadata rather than the entire packages directory.
| Clear-DirectoryContents -Path $cabalPackagesPath -Description "Cabal packages cache" | |
| # Avoid clearing the entire packages cache; only remove old, non-archive metadata | |
| $now = Get-Date | |
| $cutoff = $now.AddDays(-90) | |
| $oldCacheItems = Get-ChildItem -Path $cabalPackagesPath -Recurse -File -ErrorAction SilentlyContinue | | |
| Where-Object { | |
| $_.LastWriteTime -lt $cutoff -and | |
| $_.Extension -notin @('.tar', '.gz', '.tgz', '.bz2', '.xz') | |
| } | |
| if ($oldCacheItems) { | |
| $paths = $oldCacheItems | ForEach-Object { $_.FullName } | |
| Remove-SafeItems -Paths $paths -Description "Cabal old packages cache metadata" | |
| } |
lib/clean/dev.ps1
Outdated
| # Mix archives cache | ||
| $mixArchivesPath = "$env:USERPROFILE\.mix\archives" | ||
| if (Test-Path $mixArchivesPath) { | ||
| Clear-DirectoryContents -Path $mixArchivesPath -Description "Mix archives cache" |
There was a problem hiding this comment.
Clearing the entire Mix archives directory removes all globally installed Mix tools and tasks. This may be too aggressive as users may have intentionally installed these tools. Consider either documenting this behavior more clearly or implementing selective cleanup that preserves commonly-used archives.
| # Mix archives cache | |
| $mixArchivesPath = "$env:USERPROFILE\.mix\archives" | |
| if (Test-Path $mixArchivesPath) { | |
| Clear-DirectoryContents -Path $mixArchivesPath -Description "Mix archives cache" | |
| # Mix archives directory | |
| # NOTE: This directory may contain globally installed Mix tools and tasks. | |
| # To avoid unintentionally removing user-installed tools, we do not clear | |
| # this directory automatically. Clean it manually if you understand the | |
| # impact (e.g., by removing stale archives you no longer need). | |
| $mixArchivesPath = "$env:USERPROFILE\.mix\archives" | |
| if (Test-Path $mixArchivesPath) { | |
| Write-Log -Level 'Info' -Message "Skipping automatic cleanup of Mix archives at '$mixArchivesPath' to avoid removing globally installed Mix tools and tasks." |
lib/clean/dev.ps1
Outdated
| # Hex packages | ||
| $hexPackagesPath = "$env:USERPROFILE\.hex\packages" | ||
| if (Test-Path $hexPackagesPath) { | ||
| Clear-DirectoryContents -Path $hexPackagesPath -Description "Hex packages cache" |
There was a problem hiding this comment.
Clearing the entire Hex packages directory removes all downloaded and compiled Elixir dependencies. This is likely too aggressive as these packages are actively used by projects and will need to be re-downloaded and recompiled. Consider either removing this cleanup entirely or implementing age-based cleanup for packages not accessed recently.
| # Hex packages | |
| $hexPackagesPath = "$env:USERPROFILE\.hex\packages" | |
| if (Test-Path $hexPackagesPath) { | |
| Clear-DirectoryContents -Path $hexPackagesPath -Description "Hex packages cache" | |
| # Hex packages (only clean old/unused packages - be careful here) | |
| $hexPackagesPath = "$env:USERPROFILE\.hex\packages" | |
| if (Test-Path $hexPackagesPath) { | |
| $oldHexPackages = Get-ChildItem -Path $hexPackagesPath -Directory -ErrorAction SilentlyContinue | | |
| Where-Object { $_.LastWriteTime -lt (Get-Date).AddDays(-90) } | |
| if ($oldHexPackages) { | |
| foreach ($pkg in $oldHexPackages) { | |
| Remove-SafeItem -Path $pkg.FullName -Description "Old Hex package ($($pkg.Name))" -Recurse | |
| } | |
| } |
lib/clean/dev.ps1
Outdated
| "$env:APPDATA\Code\CachedExtensionVSIXs" | ||
| "$env:APPDATA\Code\Code Cache" | ||
| "$env:APPDATA\Code\GPUCache" | ||
| "$env:APPDATA\Code\User\workspaceStorage" |
There was a problem hiding this comment.
Clearing VS Code's workspaceStorage directory removes workspace-specific settings, state, and extension data. This may cause loss of user preferences and workspace configurations. Consider either removing this path from cleanup, implementing age-based cleanup, or clearly documenting this behavior as it may surprise users.
lib/clean/dev.ps1
Outdated
| $vscodeInsidersCachePaths = @( | ||
| "$env:APPDATA\Code - Insiders\Cache" | ||
| "$env:APPDATA\Code - Insiders\CachedData" | ||
| "$env:APPDATA\Code - Insiders\User\workspaceStorage" |
There was a problem hiding this comment.
Clearing VS Code Insiders' workspaceStorage directory removes workspace-specific settings, state, and extension data. This may cause loss of user preferences and workspace configurations. Consider either removing this path from cleanup, implementing age-based cleanup, or clearly documenting this behavior as it may surprise users.
| # VS Code Insiders | ||
| $vscodeInsidersCachePaths = @( | ||
| "$env:APPDATA\Code - Insiders\Cache" | ||
| "$env:APPDATA\Code - Insiders\CachedData" |
There was a problem hiding this comment.
VS Code Insiders should have similar cache directories as VS Code regular. Consider adding the missing cache paths for consistency: CachedExtensions, CachedExtensionVSIXs, Code Cache, and GPUCache under the "Code - Insiders" directory.
| "$env:APPDATA\Code - Insiders\CachedData" | |
| "$env:APPDATA\Code - Insiders\CachedData" | |
| "$env:APPDATA\Code - Insiders\CachedExtensions" | |
| "$env:APPDATA\Code - Insiders\CachedExtensionVSIXs" | |
| "$env:APPDATA\Code - Insiders\Code Cache" | |
| "$env:APPDATA\Code - Insiders\GPUCache" |
lib/clean/dev.ps1
Outdated
| # Stack programs cache | ||
| $stackProgramsPath = "$env:USERPROFILE\.stack\programs" | ||
| if (Test-Path $stackProgramsPath) { | ||
| Clear-DirectoryContents -Path $stackProgramsPath -Description "Stack programs cache" |
There was a problem hiding this comment.
Clearing the entire Stack programs cache may be overly aggressive as it contains GHC compiler installations that can be large and time-consuming to re-download. Consider implementing age-based cleanup similar to the Cabal store cleanup, or only cleaning temporary files instead of the entire directory.
| Clear-DirectoryContents -Path $stackProgramsPath -Description "Stack programs cache" | |
| # Avoid clearing the entire Stack programs cache as it contains GHC installations. | |
| # Only remove old program directories that have not been modified for a long time. | |
| $oldProgramDirs = Get-ChildItem -Path $stackProgramsPath -Directory -ErrorAction SilentlyContinue | | |
| Where-Object { $_.LastWriteTime -lt (Get-Date).AddDays(-90) } | |
| if ($oldProgramDirs) { | |
| foreach ($dir in $oldProgramDirs) { | |
| Remove-SafeItem -Path $dir.FullName -Description "Stack old program ($($dir.Name))" -Recurse | |
| } | |
| } |
- Rewrite check.yml for Windows (PowerShell syntax check, Go linting) - Rewrite test.yml for Windows (Pester tests, Go tests, security checks) - Rewrite release.yml for Windows releases (W* tags, zip package) - Update update-contributors.yml to trigger on windows branch
- Use age-based cleanup (90 days) for Cabal packages instead of clearing all - Skip Mix archives cleanup to preserve globally installed tools - Use age-based cleanup for Hex packages instead of clearing all - Use age-based cleanup for Stack programs (GHC installations) - Remove workspaceStorage from VS Code cleanup to preserve workspace settings - Add missing cache paths for VS Code Insiders (CachedExtensions, etc.) These changes make cleanup less aggressive and prevent accidental removal of user-installed tools and workspace preferences.
Run go mod tidy to add missing indirect dependencies required for CI build. This fixes the 'missing go.sum entry' errors in the test workflow.
|
@tw93 man i cant merge this pr into windows branch |
There was a problem hiding this comment.
LGTM.
@bhadraagada I‘ve merged, you can do next things.
Windows port of biplavbarua's extended dev cleanup feature:
Mirrors the macOS implementation from PR #287