Conversation
There was a problem hiding this comment.
Pull request overview
Adds Flutter project artifact cleanup support to the existing mo clean project cache scan/clean flow.
Changes:
- Adds a parallel
findscan for Flutter.dart_tooldirectories (with deeper max depth) and cleans them. - Also cleans the sibling
build/directory when a.dart_toolis found. - Extends the scan timeout and adds an exclusion for
.fvmpaths to reduce risk of deleting managed SDKs.
| local flutter_tmp_file | ||
| flutter_tmp_file=$(create_temp_file) | ||
| local find_timeout=30 | ||
| # Parallel scans (Next.js and __pycache__). |
There was a problem hiding this comment.
The comment says this block runs parallel scans for “Next.js and pycache”, but it now also launches a Flutter scan. Update the comment to reflect all parallel scans so future changes don’t miss the extra process (and its timeout implications).
| # Parallel scans (Next.js and __pycache__). | |
| # Parallel scans (Next.js .next, Python __pycache__, Flutter .dart_tool). |
lib/clean/caches.sh
Outdated
| -not -path "*/.Trash/*" \ | ||
| -not -path "*/node_modules/*" \ | ||
| -not -path "*/.*" \ | ||
| -not -path "*/.git/*" \ |
There was a problem hiding this comment.
The find filter for the Next.js scan no longer excludes most dot-directories (previously it did), so it will descend into large hidden folders under $HOME (e.g., ~/.cache, ~/.npm, ~/.cargo) up to maxdepth 3. This can significantly slow the scan and increase the chance the overall scan hits the timeout and misses real projects; consider pruning a targeted list of heavy hidden directories (while still allowing the target “.next” directories to be found).
| -not -path "*/.git/*" \ | |
| -not -path "*/.git/*" \ | |
| -not -path "$HOME/.cache/*" \ | |
| -not -path "$HOME/.npm/*" \ | |
| -not -path "$HOME/.cargo/*" \ |
| command find -P "$HOME" -mount -type d -name ".dart_tool" -maxdepth 5 \ | ||
| -not -path "*/Library/*" \ | ||
| -not -path "*/.Trash/*" \ | ||
| -not -path "*/node_modules/*" \ | ||
| -not -path "*/.git/*" \ | ||
| -not -path "*/.fvm/*" \ |
There was a problem hiding this comment.
The Flutter scan searches for a dot-directory name (.dart_tool), which means you can’t use a blanket “/.” exclude, but as written it may still traverse large hidden directories under $HOME (e.g., ~/.cache) up to maxdepth 5. Consider switching to a prune-based find expression (or adding specific hidden-dir excludes) so the scan avoids heavy paths while still allowing .dart_tool matches.
| command find -P "$HOME" -mount -type d -name ".dart_tool" -maxdepth 5 \ | |
| -not -path "*/Library/*" \ | |
| -not -path "*/.Trash/*" \ | |
| -not -path "*/node_modules/*" \ | |
| -not -path "*/.git/*" \ | |
| -not -path "*/.fvm/*" \ | |
| command find -P "$HOME" -mount -maxdepth 5 \ | |
| \( -path "$HOME/Library" -o \ | |
| -path "$HOME/.Trash" -o \ | |
| -path "$HOME/.cache" -o \ | |
| -path "*/node_modules" -o \ | |
| -path "*/.git" -o \ | |
| -path "*/.fvm" \) -prune -o \ | |
| -type d -name ".dart_tool" \ |
| while IFS= read -r flutter_tool; do | ||
| if [[ -d "$flutter_tool" ]]; then | ||
| safe_clean "$flutter_tool" "Flutter build cache (.dart_tool)" || true | ||
| local build_dir="$(dirname "$flutter_tool")/build" | ||
| if [[ -d "$build_dir" ]]; then | ||
| safe_clean "$build_dir" "Flutter build cache (build/)" || true | ||
| fi | ||
| fi | ||
| done < "$flutter_tmp_file" |
There was a problem hiding this comment.
Flutter cache cleaning (.dart_tool and sibling build/) is new behavior but there’s no test coverage asserting it’s detected/cleaned and that .fvm paths are ignored. Add a Bats test similar to the existing clean_project_caches tests that creates a sample Flutter project with .dart_tool + build, plus a .fvm/.dart_tool sentinel, and asserts only the project artifacts are targeted.
Restore */.* pattern to exclude all hidden directories consistently across Next.js, Python, and Flutter scans. This prevents scanning into .venv, .idea, .DS_Store and other hidden directories.
|
@mariovtor Merged, thanks! 🎉 The Flutter clean support is now available in |
Description
This PR adds support for cleaning Flutter project artifacts (
.dart_toolandbuilddirectories) to themo cleancommand.Changes
.dart_tooland its siblingbuilddirectory when found.-maxdepth 5to correctly locate nested projects (e.g., insideprojects/client/app)..fvm(Flutter Version Management) directories to prevent accidental deletion of installed SDKs/versions.Verification
mo clean --dry-run: correctly identifies Flutter projects..fvmdirectories are ignored../scripts/check.sh: passed syntax checks and optimizations.