1
0
mirror of https://github.com/tw93/Mole.git synced 2026-03-22 23:40:09 +00:00
Commit Graph

177 Commits

Author SHA1 Message Date
tw93
8e4b8a5e0d Improve update checks and cleanup UX, add timeout regressions 2026-03-05 12:00:07 +08:00
tw93
27a2cc5927 feat: show nightly channel in version output
Refs #517
2026-03-02 10:55:36 +08:00
tw93
241e6a7a34 fix(purge): avoid counting failed dry-run removals 2026-03-01 20:35:49 +08:00
陳德生
05446e0847 Add dry-run support across destructive commands (#516)
* chore: update contributors [skip ci]

* Add dry-run support across destructive commands

Implement dry-run for uninstall, purge, installer, touchid, completion, and remove flows.\nGuard side effects in uninstall path (launchctl, defaults writes, kill/brew actions), update help/README, and add coverage in CLI/Bats tests.\n\nValidation: ./scripts/check.sh and ./scripts/test.sh (452 tests, 0 failures, 8 skipped).

* test(purge): keep dev-compatible purge coverage

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Tw93 <hitw93@gmail.com>
2026-03-01 20:03:22 +08:00
tw93
022b42687e test: mock defaults in tmutil tests to bypass early check added in #510 2026-02-28 11:45:26 +08:00
tw93
7568bfc579 test: update bytes_to_human performance test inputs to use Base-10 values 2026-02-28 11:38:49 +08:00
tw93
9fed092283 test: update bytes_to_human test inputs to use Base-10 values 2026-02-28 11:30:17 +08:00
tw93
a9433e4acd fix: preserve interrupt semantics and restore purge traps 2026-02-27 11:18:53 +08:00
tw93
d13c0927a6 feat(purge): add confirm dialog, two-pass column alignment, adaptive footer
- Add confirm_purge_cleanup() to show item count + size and require
  explicit Enter/y confirmation before any deletion
- Two-pass layout in clean_project_artifacts: pass 1 collects data,
  pre-scan finds max path and artifact widths, pass 2 formats with
  consistent column alignment across all rows
- Adaptive footer hints in select_purge_categories degrade gracefully
  on narrow terminals (full → reduced → minimal)
- Use printf '\033[J' to clear stale content when list height shrinks
- Guard empty-array expansions with ${arr[*]-} for set -u safety
- Add BATS tests for confirm_purge_cleanup (Enter confirm, ESC cancel)
2026-02-26 19:42:42 +08:00
tw93
0b5ac830e5 test(clean): add test for Application Support size counting
- Add test for nested directory contents in dry-run size summary
2026-02-26 11:47:51 +08:00
tw93
5241b59ea9 refactor: reuse sudo cache checks in clean dry-run tests 2026-02-25 10:32:12 +08:00
Luke Bullimore
ee1f2bd372 Fix --dry-run hiding system cleanup preview (#493)
The dry-run mode hardcoded SYSTEM_CLEAN=false, which meant
the entire system section was silently skipped during preview.
Users had no way to see what /Library/Caches, /private/var/log,
diagnostics, or other sudo-required paths would be cleaned.

Now dry-run checks for a cached sudo session (sudo -n) and
includes the system preview when available. When sudo isn't
cached, a hint tells the user how to get the full preview
without running the whole script as root.
2026-02-25 10:22:56 +08:00
tw93
7dac5dc4e2 refactor quick launcher metadata and docs 2026-02-24 14:24:46 +08:00
Sky Slinger
98089eeba8 Fix(raycast) : Made mole script commands discoverable (#489) 2026-02-24 14:17:51 +08:00
tw93
b864b61891 test(update): cover nightly update flows 2026-02-23 13:39:31 +08:00
tw93
3e3594dc58 fix(clean): avoid false success for third-party log cleanup 2026-02-23 13:39:27 +08:00
tw93
ff00e9ba9c refactor(clean): extract shared purge hint helpers 2026-02-23 13:39:22 +08:00
tw93
8f5b70457e fix(purge): normalize search roots for scan filtering (#478) 2026-02-22 22:06:19 +08:00
tw93
fd5ceea743 feat(clean): expand conservative cache cleanup coverage
- add conservative support/app/system cache targets\n- fix dry-run + success logging behavior for memory exception cleanup\n- add regression tests for new cleanup paths and safeguards\n\nRefs #477
2026-02-22 11:06:48 +08:00
tw93
894c81bb9a fix(purge): detect artifacts when search path is project root 2026-02-22 10:08:20 +08:00
tw93
82366d8c5a test(perf): reduce get_file_size loop count in benchmark
- lower iterations from 100 to 50 to reduce flaky timing noise
2026-02-21 23:36:15 +08:00
tw93
16a8bcafde chore(dev-clean): streamline runtime volume reporting
- reduce noisy scan output outside debug mode

- consolidate final result messaging

- run xcode/code editor stages explicitly in developer flow

- update dev cache tests for new stage calls
2026-02-21 23:36:05 +08:00
tw93
c95a4ec5a8 fix(system): enforce safe sudo cleanup paths
- replace direct delete patterns with safe_sudo_find_delete/safe_sudo_remove

- keep log/temp/diagnostic cleanup behavior with guarded scans

- align system maintenance tests with safe deletion flow
2026-02-21 23:35:58 +08:00
tw93
dc8d1bd948 refactor(clean): merge app cache/user essentials flow
- reorganize perform_cleanup sections and naming

- merge macOS + sandbox caches into clean_app_caches

- move recent items and mail downloads into user essentials

- update core/user tests for renamed internal helpers
2026-02-21 23:35:53 +08:00
tw93
9440d9e52a fix(dev): normalize npm cache paths and add maven function guard
- Normalize npm cache paths with pwd -P to handle symlinks and
  trailing slashes, preventing duplicate scans of same directory
- Add declare -f check before calling clean_maven_repository for
  robustness when dynamic source fails
- Add test for trailing slash handling

Addresses: dev.sh (line 27, 48, 602)
2026-02-21 20:22:01 +08:00
tw93
0597021fd4 fix(purge): save and restore caller traps to prevent state leak
- Save caller's INT/TERM traps before installing local cleanup trap
- Restore original traps after clean_project_artifacts completes
- Add test to verify trap restoration behavior

Fixes P3 issue: project.sh (line 825, 870)
2026-02-21 20:21:54 +08:00
tw93
68b0b601a4 feat(clean): add Group Containers logs/caches cleanup
Add clean_group_container_caches() to safely clean Group Containers:
- Skip Apple-owned containers (com.apple.*, group.com.apple.*, systemgroup.com.apple.*)
- For protected apps: only clean Logs directories
- For non-protected apps: clean Logs, tmp, and Caches
- Add symlink checks to prevent path traversal
- Respect whitelist and should_protect_path checks
- Integrate with clean_sandboxed_app_caches flow

Also add symlink checks in process_container_cache() for consistency.

Includes 4 BATS tests covering protected apps, whitelist,
system containers, and empty results handling.
2026-02-20 10:44:09 +08:00
tw93
7c974bf351 fix(purge): prevent hangs during size calculation 2026-02-19 22:52:27 +08:00
Michael Aristarco
ab83bd1ed9 fix: deep clean npm residual caches (#457)
Fixes #454
2026-02-16 15:40:13 +08:00
tw93
950af1a5ed Improve clean progress visibility for dev runtime scans 2026-02-15 08:45:47 +08:00
tw93
91d0e5353a fix: handle cd failure in diagnostic report standalone test 2026-02-15 08:18:02 +08:00
tw93
c896163d4b fix(clean): ensure flutter .dart_tool caches are discovered 2026-02-15 08:03:38 +08:00
tw93
744ecec4ba fix(clean): use sudo-safe cleanup for Xcode documentation cache 2026-02-15 07:52:43 +08:00
NeedmeFordev
85cd0253d5 feat(uninstall): remove app diagnostic reports from /Library/Logs/DiagnosticReports (fixes #441) (#443)
* Implement deleting files from DiagnosticReports

* fix(uninstall): avoid diagnostic size double-count and set -e exit

---------

Co-authored-by: tw93 <tw93@qq.com>
2026-02-11 14:35:45 +08:00
tw93
4c60fcca73 fix(uninstall): show full preview paths and add regression tests 2026-02-11 14:22:22 +08:00
NeedmeFordev
42893381e3 fix silent exit on permission denied during App State Cleanup (#440) 2026-02-11 10:40:34 +08:00
tw93
8b025dd640 feat: clean duplicate Xcode documentation indexes safely 2026-02-10 15:51:28 +08:00
tw93
9b25260efe test(uninstall): fix regex assertions for shellcheck SC2076 2026-02-07 12:32:02 +08:00
tw93
5cdfcf2479 fix(uninstall): detect Maestro Studio .mobiledev and add regression test (#421) 2026-02-07 10:44:10 +08:00
tw93
500ab2f568 fix(uninstall): detect Zed HTTPStorages channel variants (#422) 2026-02-07 10:38:17 +08:00
tw93
0fbf2661c8 perf: optimize system cleanup by merging find operations
Performance improvements:
- Merge 3 separate find operations into 1 for /Library/Caches
  - Combine *.cache, *.tmp, *.log patterns in single scan
  - Reduces filesystem traversal overhead
- Merge 2 find operations into 1 for /private/var/log
  - Combine *.log and *.gz patterns
- Optimize diagnostics cleanup with single combined scan
  - Merge Special, Persist, and tracev3 patterns
  - Reduces redundant directory traversal
- Use find -delete for batch removal of memory exception reports
  - More efficient than iterative removal for large file counts
  - Add summary logging to operations.log

UI improvements:
- Add granular spinner messages for each cleanup stage
- Separate diagnostic logs and power logs output for clarity
- Add progress feedback during Time Machine status check

Tests:
- Update sudo mock functions to support new combined find patterns
- Verify find -delete usage for memory exception cleanup
- Update assertions to match optimized implementation
2026-02-04 16:18:06 +08:00
tw93
a4e084a4ed feat: improve app cleanup with orphaned LaunchAgent detection
New features:
- Add orphaned LaunchAgent/LaunchDaemon detection with 5-layer verification
  - Layer 1: Check if program path exists
  - Layer 2: Verify AssociatedBundleIdentifiers via mdfind
  - Layer 3: Check Application Support directory activity (7 days)
  - Layer 4: Fuzzy match app name in /Applications
  - Layer 5: Special handling for PrivilegedHelperTools
- Only process user-level ~/Library/LaunchAgents (safer than system-level)
- Unload agent before removal using launchctl

Bug fixes:
- Handle paths with spaces correctly in orphaned_app_data cleanup
  - Add nullglob state management to prevent word splitting
  - Use IFS=$'\n' for proper array iteration
- Only count successful deletions (check safe_clean return value)

Tests:
- Add 4 new tests for is_launch_item_orphaned edge cases
- Add tests for space handling and deletion count accuracy
2026-02-04 16:17:36 +08:00
tw93
0fb4d32bb6 fix: improve whitelist pattern validation in cleanup tests 2026-02-03 20:53:21 +08:00
Andrei Murariu
e8f46a7a1c feat: Homebrew uninstall with --zap flag (#397)
Uninstalling mole with Zap will automatically remove also the directories that brew creates for it. -> More complete uninstallation

Also updated the test about uninstalling
2026-02-02 11:26:58 +08:00
tw93
82df7abc35 Merge branch 'main' into dev 2026-01-31 17:37:46 +08:00
dekran
dcac6a3391 fix: handle dotfiles in Trash cleanup (#395)
Replace glob pattern with find command to properly clean dotfiles
in Trash when osascript fallback is used. The old pattern
~/.Trash/* does not match files starting with "." in bash.

This fix ensures that hidden files like .DS_Store, .hidden_file,
etc. are properly removed when cleaning the Trash.
2026-01-31 17:37:22 +08:00
tw93
2865a788e8 test: add checks for uninstallable Apple apps in should_protect_from_uninstall function 2026-01-30 13:57:43 +08:00
tw93
47ce6b0c50 Fix the issue with automated testing 2026-01-30 11:06:54 +08:00
tw93
6f0255c56e fix(uninstall): enhance app leftover detection with naming variants (#377) 2026-01-28 19:06:52 +08:00
tw93
e0aba780c8 feat: remove automatic Rosetta 2 installation prompt
- Change Rosetta 2 status from warning to info
- Remove auto-fix suggestion for missing Rosetta 2
- Update tests to reflect new behavior (3 -> 2 expected fixes)
2026-01-26 14:36:12 +08:00