Skip to content

feat: add generic flutter clean support#450

Merged
tw93 merged 2 commits intotw93:mainfrom
mariovtor:dev
Feb 13, 2026
Merged

feat: add generic flutter clean support#450
tw93 merged 2 commits intotw93:mainfrom
mariovtor:dev

Conversation

@mariovtor
Copy link
Contributor

@mariovtor mariovtor commented Feb 12, 2026

Description

This PR adds support for cleaning Flutter project artifacts (.dart_tool and build directories) to the mo clean command.

Changes

  • Flutter Support: Adds parallel scanning for Flutter projects (similar to existing Next.js and Python scans).
  • Targeted Cleaning: Removes .dart_tool and its sibling build directory when found.
  • Deep Scan: configured with -maxdepth 5 to correctly locate nested projects (e.g., inside projects/client/app).
  • Safety: Explicitly excludes .fvm (Flutter Version Management) directories to prevent accidental deletion of installed SDKs/versions.
  • Compatibility: implementation uses BSD syntax compatible with macOS.

Verification

  • Verified with mo clean --dry-run: correctly identifies Flutter projects.
  • Verified safety: confirmed that .fvm directories are ignored.
  • Ran ./scripts/check.sh: passed syntax checks and optimizations.

Copilot AI review requested due to automatic review settings February 12, 2026 13:50
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds Flutter project artifact cleanup support to the existing mo clean project cache scan/clean flow.

Changes:

  • Adds a parallel find scan for Flutter .dart_tool directories (with deeper max depth) and cleans them.
  • Also cleans the sibling build/ directory when a .dart_tool is found.
  • Extends the scan timeout and adds an exclusion for .fvm paths 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__).
Copy link

Copilot AI Feb 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).

Suggested change
# Parallel scans (Next.js and __pycache__).
# Parallel scans (Next.js .next, Python __pycache__, Flutter .dart_tool).

Copilot uses AI. Check for mistakes.
-not -path "*/.Trash/*" \
-not -path "*/node_modules/*" \
-not -path "*/.*" \
-not -path "*/.git/*" \
Copy link

Copilot AI Feb 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).

Suggested change
-not -path "*/.git/*" \
-not -path "*/.git/*" \
-not -path "$HOME/.cache/*" \
-not -path "$HOME/.npm/*" \
-not -path "$HOME/.cargo/*" \

Copilot uses AI. Check for mistakes.
Comment on lines 182 to 187
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/*" \
Copy link

Copilot AI Feb 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
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" \

Copilot uses AI. Check for mistakes.
Comment on lines +229 to +237
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"
Copy link

Copilot AI Feb 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
@tw93 tw93 changed the base branch from dev to main February 13, 2026 02:23
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.
@tw93 tw93 merged commit a73a739 into tw93:main Feb 13, 2026
3 of 5 checks passed
@tw93
Copy link
Owner

tw93 commented Feb 13, 2026

@mariovtor Merged, thanks! 🎉

The Flutter clean support is now available in mo clean. Good job on the parallel scan implementation and .fvm protection.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

Comments