diff --git a/lib/clean/dev.sh b/lib/clean/dev.sh index f7a237d..cd16042 100644 --- a/lib/clean/dev.sh +++ b/lib/clean/dev.sh @@ -256,24 +256,24 @@ clean_sqlite_temp_files() { return 0 } # Elixir/Erlang ecosystem. +# Note: ~/.mix/archives contains installed Mix tools - excluded from cleanup clean_dev_elixir() { - # safe_clean ~/.mix/archives/* "Mix cache" safe_clean ~/.hex/cache/* "Hex cache" } # Haskell ecosystem. +# Note: ~/.stack/programs contains Stack-installed GHC compilers - excluded from cleanup clean_dev_haskell() { safe_clean ~/.cabal/packages/* "Cabal install cache" - # safe_clean ~/.stack/programs/* "Stack cache" } # OCaml ecosystem. clean_dev_ocaml() { safe_clean ~/.opam/download-cache/* "Opam cache" } # Editor caches. +# Note: ~/Library/Application Support/Code/User/workspaceStorage contains workspace settings - excluded from cleanup clean_dev_editors() { safe_clean ~/Library/Caches/com.microsoft.VSCode/Cache/* "VS Code cached data" safe_clean ~/Library/Application\ Support/Code/CachedData/* "VS Code cached data" - # safe_clean ~/Library/Application\ Support/Code/User/workspaceStorage/* "VS Code workspace storage" safe_clean ~/Library/Caches/Zed/* "Zed cache" } # Main developer tools cleanup sequence. diff --git a/lib/manage/whitelist.sh b/lib/manage/whitelist.sh index 41f3ade..e648e9e 100755 --- a/lib/manage/whitelist.sh +++ b/lib/manage/whitelist.sh @@ -248,15 +248,13 @@ is_whitelisted() { return 1 fi - if [[ ${#CURRENT_WHITELIST_PATTERNS[@]} -gt 0 ]]; then - for existing in "${CURRENT_WHITELIST_PATTERNS[@]}"; do - local existing_expanded="${existing/#\~/$HOME}" - # Only use exact string match to prevent glob expansion security issues - if [[ "$check_pattern" == "$existing_expanded" ]]; then - return 0 - fi - done - fi + for existing in "${CURRENT_WHITELIST_PATTERNS[@]}"; do + local existing_expanded="${existing/#\~/$HOME}" + # Only use exact string match to prevent glob expansion security issues + if [[ "$check_pattern" == "$existing_expanded" ]]; then + return 0 + fi + done return 1 } diff --git a/tests/dev_extended.bats b/tests/dev_extended.bats index abf87c0..313db2d 100644 --- a/tests/dev_extended.bats +++ b/tests/dev_extended.bats @@ -20,7 +20,7 @@ teardown_file() { fi } -@test "clean_dev_elixir cleans mix and hex caches" { +@test "clean_dev_elixir cleans hex cache" { mkdir -p "$HOME/.mix" "$HOME/.hex" run env HOME="$HOME" PROJECT_ROOT="$PROJECT_ROOT" bash --noprofile --norc <<'EOF' set -euo pipefail @@ -31,11 +31,23 @@ clean_dev_elixir EOF [ "$status" -eq 0 ] - [[ "$output" == *"Hex cache"* ]] } -@test "clean_dev_haskell cleans cabal install and stack caches" { +@test "clean_dev_elixir does not clean mix archives" { + mkdir -p "$HOME/.mix/archives" + touch "$HOME/.mix/archives/test_tool.ez" + + # Source and run the function + source "$PROJECT_ROOT/lib/core/common.sh" + source "$PROJECT_ROOT/bin/clean.sh" + clean_dev_elixir > /dev/null 2>&1 || true + + # Verify the file still exists + [ -f "$HOME/.mix/archives/test_tool.ez" ] +} + +@test "clean_dev_haskell cleans cabal install cache" { mkdir -p "$HOME/.cabal" "$HOME/.stack" run env HOME="$HOME" PROJECT_ROOT="$PROJECT_ROOT" bash --noprofile --norc <<'EOF' set -euo pipefail @@ -47,7 +59,19 @@ EOF [ "$status" -eq 0 ] [[ "$output" == *"Cabal install cache"* ]] +} +@test "clean_dev_haskell does not clean stack programs" { + mkdir -p "$HOME/.stack/programs/x86_64-osx" + touch "$HOME/.stack/programs/x86_64-osx/ghc-9.2.8.tar.xz" + + # Source and run the function + source "$PROJECT_ROOT/lib/core/common.sh" + source "$PROJECT_ROOT/bin/clean.sh" + clean_dev_haskell > /dev/null 2>&1 || true + + # Verify the file still exists + [ -f "$HOME/.stack/programs/x86_64-osx/ghc-9.2.8.tar.xz" ] } @test "clean_dev_ocaml cleans opam cache" { @@ -76,6 +100,18 @@ EOF [ "$status" -eq 0 ] [[ "$output" == *"VS Code cached data"* ]] - [[ "$output" == *"Zed cache"* ]] } + +@test "clean_dev_editors does not clean VS Code workspace storage" { + mkdir -p "$HOME/Library/Application Support/Code/User/workspaceStorage/abc123" + touch "$HOME/Library/Application Support/Code/User/workspaceStorage/abc123/workspace.json" + + # Source and run the function + source "$PROJECT_ROOT/lib/core/common.sh" + source "$PROJECT_ROOT/bin/clean.sh" + clean_dev_editors > /dev/null 2>&1 || true + + # Verify the file still exists + [ -f "$HOME/Library/Application Support/Code/User/workspaceStorage/abc123/workspace.json" ] +}