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

233 Commits

Author SHA1 Message Date
c5d923cd48 fix(appli-support):using whitelist in application_support clean (#562)
* fix(appli-support):using whitelist in application_support clean

* fix: harden clash verge app support protection

---------

Co-authored-by: Tw93 <hitw93@gmail.com>
2026-03-13 11:38:37 +08:00
Tw93
af84d6f4be docs: strengthen public security signals 2026-03-10 15:31:07 +08:00
tw93
2a36c662aa fix: tighten orphan cleanup retention windows 2026-03-08 15:33:30 +08:00
tw93
26b267c4a2 fix: harden orphan cleanup and lsregister fallback 2026-03-08 15:29:25 +08:00
Tw93
faf29b05f1 Fix perl timeout fallback selection 2026-03-07 20:36:34 +08:00
tw93
09d0de0c8e perf(core): optimize base functions with caching and improve robustness
- Add global caching for `detect_architecture`, `get_darwin_major`, `get_optimal_parallel_jobs`, and `is_ansi_supported` to reduce subshell overhead.
- Improve robustness of `get_lsregister_path` by returning 1 on failure.
- Enhance security of `get_user_home` by replacing `eval echo` with `id -P`.
2026-03-06 19:42:15 +08:00
tw93
0fabc6feec fix(shell): suppress SC2016 in timeout perl fallback 2026-03-06 14:17:42 +08:00
Tw93
92ad46a396 fix(clean): harden project cache scans
Refs #541
2026-03-06 07:49:44 +08:00
tw93
9fea75af25 Merge branch 'main' of https://github.com/tw93/Mole 2026-03-05 13:58:25 +08:00
tw93
8e4b8a5e0d Improve update checks and cleanup UX, add timeout regressions 2026-03-05 12:00:07 +08:00
Noah Qin
a9d7c3912f fix(sudo): add GUI mode support for non-TTY environments (#536)
When Mole is called from GUI applications (e.g., SwiftUI apps), the
request_sudo_access() function would fail with '/dev/tty: Device not
configured' error because /dev/tty is not available in non-TTY contexts.

This commit adds automatic detection of the runtime environment and uses
macOS native password dialog (via osascript) when running in GUI mode,
while preserving all existing TTY behavior including Touch ID support.

Changes:
- Detect TTY availability before attempting terminal-based authentication
- Use osascript to display native password dialog in GUI mode
- Maintain backward compatibility with all terminal-based workflows
- Ensure secure password handling (unset after use)

Fixes commands like 'mole clean', 'mole optimize', 'mole purge' when
invoked from GUI applications.
2026-03-05 09:35:26 +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
d40783cca9 chore: auto format code 2026-02-28 07:27:33 +00:00
tw93
c8190772ac refactor(core): remove unused utility functions
Remove unused functions from base.sh and ui.sh:
- base.sh: is_interactive, spinner stack management, get_terminal_info, validate_terminal_environment
- ui.sh: with_spinner

Net reduction: ~166 lines of dead code
2026-02-28 15:25:53 +08:00
Tw93
194e8ad29a chore: auto format code 2026-02-28 03:11:16 +00:00
tw93
c19a0276b8 refactor: Update shell arithmetic increment syntax from ((var++)) || true to var=$((var + 1)) across various scripts. 2026-02-28 11:10:18 +08:00
tw93
7d70889ad4 chore: auto format code 2026-02-28 11:03:16 +08:00
tw93
1be71edc9d fix: use Base-10 sizes and mdls logical size to match macOS Finder
- Switch bytes_to_human (shell) and humanizeBytes (Go) from Base-2
  (1024) to Base-10 (1000) to match Apple's storage calculation
  standard since Snow Leopard
- Add proper decimal rounding instead of truncation
- Use mdls kMDItemLogicalSize for .app bundles to avoid APFS clone
  file undercounting by du

Fixes #511
2026-02-28 10:02:34 +08:00
tw93
310abb2510 fix: clean aerial wallpaper videos directly without 30d limit and bypass app protection wildcard, close #508 2026-02-28 09:49:16 +08:00
Tw93
c129591cf4 fix: remove redundant pipefail blocks and fix arithmetic bug
This commit addresses the issue #506 where mole would exit prematurely
during application support scanning.

Changes:
1. Remove 4 redundant pipefail disable/restore blocks:
   - safe_find_delete() in lib/core/file_ops.sh
   - safe_sudo_find_delete() in lib/core/file_ops.sh
   - fix_broken_preferences() in lib/optimize/maintenance.sh
   - opt_saved_state_cleanup() in lib/optimize/tasks.sh

   These were unnecessary because process substitution (< <(cmd)) is not
   affected by pipefail - only real pipelines (cmd1 | cmd2) are.

2. Fix real bug in fix_broken_preferences():
   - Add || true to ((broken_count++)) on lines 35 and 55
   - This prevents set -e from exiting when broken_count starts at 0

Fixes #506
2026-02-27 23:44:10 +08:00
Tw93
013549ad25 fix: temporarily disable pipefail to prevent process substitution failures during cleanup operations 2026-02-27 22:52:38 +08:00
tw93
a9433e4acd fix: preserve interrupt semantics and restore purge traps 2026-02-27 11:18:53 +08:00
tw93
2eb0f2b9b3 fix(log): generate summary divider width from terminal width
Replace hardcoded 70-char string with a dynamically generated divider
capped at terminal width (max 70) so the separator fits narrow terminals
instead of overflowing them.
2026-02-26 19:42:58 +08:00
tw93
aa1a436862 fix(clean): improve loading feedback and spinner output 2026-02-26 16:36:06 +08:00
tw93
88b0fe6af3 refactor(base): extract get_lsregister_path as shared utility
Move get_lsregister_path() to base.sh to avoid duplication across
optimize and uninstall modules. Adds macOS 14+ compatibility with
fallback paths.
2026-02-26 11:53:39 +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
3112673ed3 feat(clean): add storage clues after large files 2026-02-23 11:34:04 +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
172afa83af refactor: centralize subcommand help handlers 2026-02-10 15:06:14 +08:00
tw93
7813124f33 refactor: Extract com.clash.app pattern to avoid ShellCheck redundancy warning 2026-02-09 20:25:10 +08:00
tw93
c8b4b085c6 feat: Add com.clash.app to the list of recognized proxy application patterns. 2026-02-09 20:13:59 +08:00
tw93
b2987b0bb9 feat: add VS Code ShipIt cache directories to cleanup list #427 2026-02-09 19:47:50 +08:00
tw93
e6829b9a5d fix: improve cache freshness fallback and proxy detection 2026-02-07 17:48:55 +08:00
tw93
361d0dda05 fix: P1/P2 issues in file ops, menu state, and logging
- Fix safe_sudo_remove early exit on error (P1)
- Fix menu filter state leakage in paginated menu (P2)
- Fix cleanup of MOLE_MENU_FILTER_NAMES in app selector (P2)
- Correct log_operation signature for memory dumps (P2)
- Apply minor formatting fixes to dev cleanup module
2026-02-07 11:21:37 +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
02843dee74 feat(ui): add Ctrl+U support and optimize paginated menu performance 2026-02-07 10:28:41 +08:00
Andrei Murariu
257c639541 bug-fix: add hardcoded directories for raycast removal (#414)
* bug-fix: uninstall raycast leftovers

* bug-fix: add hardcoded directories for raycast removal

---------

Co-authored-by: tw93 <tw93@qq.com>
2026-02-04 19:08:54 +08:00
tw93
41a26204fb perf: skip redundant -name parameter when pattern is wildcard
Optimization:
- Skip -name "*" in safe_sudo_find_delete when pattern matches everything
- Reduces unnecessary parameter passing to find command
- Improves performance for operations that scan all files

Rationale:
- find -name "*" is redundant as it matches everything by default
- Removing it reduces command overhead without changing behavior
2026-02-04 16:18:13 +08:00
tw93
579c963940 uninstall: refine protection flow and menu filtering 2026-02-03 17:36:15 +08:00
tw93
bad1c71231 fix: protect Gradle cache from cleanup by default
Gradle build cache (~/.gradle/caches) is now protected by default whitelist,
similar to Maven repository. This prevents unintentional deletion of large
dependency caches that take time and bandwidth to re-download.

- Add ~/.gradle/caches/* and ~/.gradle/daemon/* to DEFAULT_WHITELIST_PATTERNS
- Remove Gradle cleanup from clean_dev_jvm() function
- Users can disable protection via 'mo clean --whitelist' if needed

Fixes #408
2026-02-03 16:37:33 +08:00
tw93
a5c7abd227 refactor: optimize raycast cleanup code structure
Improve code readability and maintainability:
- Simplify conditional logic with chained operators
- Add clarifying comments for different cleanup scopes
- Rename variables for better semantic clarity
- Maintain consistent style with other app cleanup patterns
2026-02-03 14:53:10 +08:00
Andrei Murariu
4f3eb0eb62 bug-fix: uninstall raycast leftovers (#404) 2026-02-03 14:47:44 +08:00
tw93
5f88d84d3f fix: update authentication failure messages for clarity 2026-02-02 17:18:32 +08:00
tw93
48db04a95b fix: add comment for clarity in safe_sudo_remove function 2026-02-02 17:15:32 +08:00
tw93
05faf2b691 core: improve file removal diagnostics 2026-02-02 17:06:00 +08:00
tw93
aaa3a6ae5a ui: add menu filtering support 2026-02-02 17:05:19 +08:00
tw93
82d46ee286 fix: refine clash pattern matching for data protection and improve spinner handling 2026-02-01 09:28:49 +08:00
tw93
8ac71a3937 fix: add clash patterns to data protection checks 2026-01-31 20:05:38 +08:00