diff --git a/lib/clean/dev.sh b/lib/clean/dev.sh index 869d1cc..bb519e7 100644 --- a/lib/clean/dev.sh +++ b/lib/clean/dev.sh @@ -131,7 +131,23 @@ clean_dev_frontend() { safe_clean ~/.cache/prettier/* "Prettier cache" } # Mobile dev caches (can be large). +# Check for multiple Android NDK versions. +check_android_ndk() { + local ndk_dir="$HOME/Library/Android/sdk/ndk" + if [[ -d "$ndk_dir" ]]; then + local count + count=$(find "$ndk_dir" -mindepth 1 -maxdepth 1 -type d 2> /dev/null | wc -l | tr -d ' ') + if [[ "$count" -gt 1 ]]; then + note_activity + echo -e " Found ${GREEN}${count}${NC} Android NDK versions" + echo -e " You can delete unused versions manually: ${ndk_dir}" + fi + fi +} + clean_dev_mobile() { + check_android_ndk + if command -v xcrun > /dev/null 2>&1; then debug_log "Checking for unavailable Xcode simulators" if [[ "$DRY_RUN" == "true" ]]; then diff --git a/lib/clean/user.sh b/lib/clean/user.sh index 950571e..f5dac2e 100644 --- a/lib/clean/user.sh +++ b/lib/clean/user.sh @@ -5,6 +5,9 @@ clean_user_essentials() { start_section_spinner "Scanning caches..." safe_clean ~/Library/Caches/* "User app cache" stop_section_spinner + start_section_spinner "Scanning empty items..." + clean_empty_library_items + stop_section_spinner safe_clean ~/Library/Logs/* "User app logs" if is_path_whitelisted "$HOME/.Trash"; then note_activity @@ -14,6 +17,19 @@ clean_user_essentials() { fi } +clean_empty_library_items() { + local -a empty_dirs=() + while IFS= read -r -d '' dir; do + [[ -d "$dir" ]] && empty_dirs+=("$dir") + done < <(find "$HOME/Library" -mindepth 1 -maxdepth 1 -type d -empty -print0 2> /dev/null) + + if [[ ${#empty_dirs[@]} -gt 0 ]]; then + safe_clean "${empty_dirs[@]}" "Empty Library folders" + fi + + # Empty file cleanup is skipped to avoid removing app sentinel files. +} + # Remove old Google Chrome versions while keeping Current. clean_chrome_old_versions() { local -a app_paths=( diff --git a/tests/scripts.bats b/tests/scripts.bats index 3629b72..6cab9ea 100644 --- a/tests/scripts.bats +++ b/tests/scripts.bats @@ -71,3 +71,10 @@ setup() { run bash -c "grep -q 'write_raycast_script' '$PROJECT_ROOT/scripts/setup-quick-launchers.sh'" [ "$status" -eq 0 ] } + +@test "install.sh supports dev branch installs" { + run bash -c "grep -q 'refs/heads/dev.tar.gz' '$PROJECT_ROOT/install.sh'" + [ "$status" -eq 0 ] + run bash -c "grep -q 'MOLE_VERSION=\"dev\"' '$PROJECT_ROOT/install.sh'" + [ "$status" -eq 0 ] +} diff --git a/tests/tmp-clean-home.AKSUWT/.m2/repository/org/example/lib.jar b/tests/tmp-clean-home.AKSUWT/.m2/repository/org/example/lib.jar deleted file mode 100644 index 14cc903..0000000 --- a/tests/tmp-clean-home.AKSUWT/.m2/repository/org/example/lib.jar +++ /dev/null @@ -1 +0,0 @@ -dependency diff --git a/tests/tmp-clean-home.AKSUWT/bin/tmutil b/tests/tmp-clean-home.AKSUWT/bin/tmutil deleted file mode 100755 index dfbf767..0000000 --- a/tests/tmp-clean-home.AKSUWT/bin/tmutil +++ /dev/null @@ -1,19 +0,0 @@ -#!/bin/bash -if [[ "$1" == "status" ]]; then - cat << 'TMUTIL_OUTPUT' -Backup session status: -{ - ClientID = "com.apple.backupd"; - Running = 1; -} -TMUTIL_OUTPUT -elif [[ "$1" == "destinationinfo" ]]; then - cat << 'DEST_OUTPUT' -==================================================== -Name : TestBackup -Kind : Local -Mount Point : /Volumes/TestBackup -ID : 12345678-1234-1234-1234-123456789012 -==================================================== -DEST_OUTPUT -fi diff --git a/tests/user_clean_core.bats b/tests/user_clean_core.bats index 148e51a..6aaa5bd 100644 --- a/tests/user_clean_core.bats +++ b/tests/user_clean_core.bats @@ -102,3 +102,19 @@ EOF [ "$status" -eq 0 ] } + +@test "clean_empty_library_items only cleans empty dirs" { + run env HOME="$HOME" PROJECT_ROOT="$PROJECT_ROOT" /bin/bash --noprofile --norc <<'EOF' +set -euo pipefail +source "$PROJECT_ROOT/lib/core/common.sh" +source "$PROJECT_ROOT/lib/clean/user.sh" +safe_clean() { echo "$2"; } +mkdir -p "$HOME/Library/EmptyDir" +touch "$HOME/Library/empty.txt" +clean_empty_library_items +EOF + + [ "$status" -eq 0 ] + [[ "$output" == *"Empty Library folders"* ]] + [[ "$output" != *"Empty Library files"* ]] +}