1
0
mirror of https://github.com/tw93/Mole.git synced 2026-03-22 17:55:08 +00:00
Commit Graph

523 Commits

Author SHA1 Message Date
Tw93
4f178c1d7a fix(clean/uninstall): harden external cleanup accounting and relative app symlink resolution 2026-03-21 16:06:44 +08:00
Tw93
c5d6cdc2f9 perf(purge/uninstall): eliminate per-item subprocess forks in scan phase
purge:
- is_safe_project_artifact: replace echo|tr|wc depth calc with pure bash
  string arithmetic (2 forks → 0 per item)
- process_scan_results: replace dirname subprocess with ${item%/*}
- is_recently_modified: accept pre-computed epoch to avoid redundant
  get_epoch_seconds call (N date forks → 1 before loop)
- fd pattern construction: replace 45 per-target sed forks with single
  printf|sed pass (45 forks → 2)
- pre-compute _cached_project_paths alongside existing name/basename
  cache so display loop avoids get_project_path subshell per item

uninstall/app-selector:
- default size display: N/A → -- for apps without cached size data
  (cleaner UX on first scan; real sizes populate from background refresh)
- Pass 1 scan: replace basename/dirname subshells with parameter expansion
2026-03-21 15:33:57 +08:00
Tw93
d6b9d9f3f3 Fix cleanup regressions and analyze navigation
Refs #605 #607 #608 #609 #610
2026-03-21 13:05:21 +08:00
Tw93
821a824d81 fix: dedupe cleanup previews by filesystem identity 2026-03-19 00:32:28 +08:00
Tw93
88521a14c2 fix: remove jq dependency from optimize command (#588)
Replace jq with bash-native JSON parsing helpers (json_get_value,
json_validate, parse_optimization_items) so that mo optimize no
longer requires jq to be installed.

Closes #588
2026-03-18 17:36:39 +08:00
Tw93
25892594b0 fix: show full purge paths during confirmation
Fixes #576
2026-03-17 19:20:32 +08:00
Tw93
0cc4862f9c fix(touchid): add Q key support to quit menu
Allow users to press 'q' or 'Q' to quit the Touch ID setup menu,
in addition to ESC key. This fixes the "Invalid key" error when
users press Q as suggested by the prompt.

Fixes #575
2026-03-16 20:19:32 +08:00
Tw93
2e6553ab2b Protect user launch agents during clean 2026-03-14 22:32:53 +08:00
tw93
8e4b8a5e0d Improve update checks and cleanup UX, add timeout regressions 2026-03-05 12:00:07 +08:00
tw93
d12cde5405 refactor: use bytes_to_human_kb for dynamic size formatting
- Replace inline dynamic formatting with shared bytes_to_human_kb()
- Apply to both clean and purge commands
- Simplify movie comparison with integer arithmetic
2026-03-03 16:58:31 +08:00
tw93
66ba1889c6 fix: correct missing $ in color variable reference
Fix typo from PR #523: {NC} → ${NC}
2026-03-03 15:57:18 +08:00
Tw93
c41dcbcdee chore: auto format code 2026-03-03 07:52:51 +00:00
Angelk90
00f29cff20 Clean dynamic size formatting (#523) 2026-03-03 15:52:04 +08:00
tw93
de57a20828 refactor(dry-run): unify flag handling in completion and remove 2026-03-01 21:04:41 +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
75dc9f01dc refactor(clean): use assignment form for arithmetic increments in safe_clean 2026-02-28 11:22:35 +08:00
tw93
7a6da7b419 fix(uninstall): auto-exit return-to-list prompt after configurable timeout
Replace blocking read with a timed read (default 3 s) so the prompt
exits automatically instead of waiting forever. Timeout is configurable
via MOLE_UNINSTALL_RETURN_PROMPT_TIMEOUT_SEC. Use a read_ok flag to
distinguish timeout (exit) from Enter (return to list).
2026-02-26 19:42:47 +08:00
tw93
837df390a5 fix(purge): rewrite spinner for /dev/tty reliability and fix cursor position
- Capture terminal width in parent before forking; avoids unreliable
  tput calls inside the background subshell
- Write spinner output directly to /dev/tty to prevent stdout state
  contention between parent and background processes
- Use \033[2K (erase entire line) instead of \033[K (erase to EOL)
- Add handle_interrupt() so Ctrl-C cleanly stops spinner, restores
  cursor, and exits 130
- cleanup_monitor now writes \r\033[2K\n so subsequent output starts
  on a clean line rather than on the cleared spinner line
2026-02-26 19:42:34 +08:00
tw93
3bd3e400b6 style: improve code consistency and formatting
- Rename _MOLE_HINTS_DIR to mole_hints_dir (naming convention)
- Split local variable declaration and assignment
- Add ICON_INFO constant to base.sh
- Remove redundant has_cached_sudo function (use has_sudo_session)
2026-02-26 11:47:41 +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
ff00e9ba9c refactor(clean): extract shared purge hint helpers 2026-02-23 13:39:22 +08:00
tw93
4c9a71315f refactor(ui): unify action and list hints across commands 2026-02-23 11:34:22 +08:00
tw93
3112673ed3 feat(clean): add storage clues after large files 2026-02-23 11:34:04 +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
a29cadbfd0 fix(purge): resolve trap conflict between purge.sh and project.sh
- Add guard flag in cleanup_monitor to prevent duplicate execution
- Check for existing trap in project.sh before setting new one
- Prevents crash when user presses Ctrl-C or scan process fails
2026-02-16 15:54:16 +08:00
tw93
52d333bc9e feat(uninstall): keep progress visible until app list is ready 2026-02-15 08:45:16 +08:00
tw93
9c8c25116b refactor(uninstall): centralize size and last-used display normalization 2026-02-10 16:33:14 +08:00
tw93
7d8bfbc9d9 improve uninstall scan metadata and list refresh UX 2026-02-10 16:23:15 +08:00
Tw93
9aa5a0a69d chore: auto format code 2026-02-10 07:07:52 +00:00
tw93
172afa83af refactor: centralize subcommand help handlers 2026-02-10 15:06:14 +08:00
Michael Wang 汪東陽
3820bf2be7 feat: add commands help flag (#429) 2026-02-10 15:02:57 +08:00
tw93
e6829b9a5d fix: improve cache freshness fallback and proxy detection 2026-02-07 17:48:55 +08:00
tw93
f3b288a21b feat(uninstall): implement metadata caching for faster app scanning 2026-02-07 10:26:53 +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
c6e58c4ead fix: replace clear with clear_screen for better clarity in main function 2026-02-02 17:38:29 +08:00
tw93
f965ca25c3 uninstall: harden cache and removal flow 2026-02-02 17:05:42 +08:00
tw93
aaa3a6ae5a ui: add menu filtering support 2026-02-02 17:05:19 +08:00
tw93
e12a40f6bf fix: use \033[2K to fully clear spinner lines and prevent text remnants
Fixes text remnants and extra blank lines when spinner messages change.

Issues fixed:
1. Text remnants when switching from longer to shorter messages (e.g., 'Cleaning...ems...')
2. Extra blank lines appearing after section headers

Root causes:
- \033[K only clears from cursor to end of line, leaving remnants when new messages are shorter
- stop_section_spinner was clearing lines even when no spinner was running

Changes:
- lib/core/base.sh:
  - Changed stop_section_spinner(), safe_clear_line(), safe_clear_lines() to use \033[2K
  - Added guard in stop_section_spinner to only clear when spinner is actually running
- lib/core/ui.sh:
  - Clear line once when starting spinner (before loop) to ensure clean start
  - Normal spinner rotation uses \r without clearing (performance optimization)

Performance: Line clearing happens only once per spinner start, not on every loop iteration.

Fixes #390
2026-01-31 10:09:02 +08:00
tw93
0a46bf2077 fix: improve status icons and fix spinner cleanup
- Show ✓ for empty trash and discovered versions (normal states)
- Fix inline spinner not stopping, causing residual display artifacts
2026-01-28 20:15:26 +08:00
tw93
88da841ce9 refactor: remove mo log command, keep log recording only 2026-01-28 19:58:59 +08:00
Tw93
c12f76c9f3 chore: auto format code 2026-01-28 11:46:59 +00:00
tw93
64f79a59d8 feat: optimize log system and add mo log command
- Add get_timestamp() helper and optimize log rotation
- Create mo log viewer with search/filter capabilities
- Improve test coverage to 18.4% with better assertions
- Add security fixes for grep injection prevention
2026-01-28 19:46:01 +08:00
Gokul
9a109b2b39 fix(clean): handle singular 4K movie summary (#376) 2026-01-27 19:42:54 +08:00
Tw93
09f0cf9e53 chore: auto format code 2026-01-26 07:46:58 +00:00
tw93
b67d149cef Merge branch 'main' of https://github.com/tw93/Mole 2026-01-26 15:46:05 +08:00
tw93
0fbf88a6c6 fix: harden cleanup path validation 2026-01-26 15:43:11 +08:00
Tw93
f272d29490 chore: auto format code 2026-01-26 07:32:44 +00:00
tw93
43a92a1847 Merge branch 'main' of https://github.com/tw93/Mole 2026-01-26 15:31:43 +08:00
tw93
981c79cfd1 fix: clear cleaning spinner after cleanup 2026-01-26 15:31:30 +08:00