mirror of
https://github.com/tw93/Mole.git
synced 2026-02-16 19:20:16 +00:00
feat: Improve clean command's regex handling and pnpm cache cleaning, enhance test output, update completion descriptions, and clarify installation instructions.
This commit is contained in:
@@ -32,10 +32,10 @@
|
|||||||
brew install mole
|
brew install mole
|
||||||
```
|
```
|
||||||
|
|
||||||
**or by Script:**
|
**or by Script, for older macOS or latest code:**
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# Append '-s latest' for latest code or '-s 1.17.0' for specific version
|
# Use for older macOS or latest code; add '-s latest' for newest, or '-s 1.17.0' for a fixed version.
|
||||||
curl -fsSL https://raw.githubusercontent.com/tw93/mole/main/install.sh | bash
|
curl -fsSL https://raw.githubusercontent.com/tw93/mole/main/install.sh | bash
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
@@ -22,16 +22,18 @@ clean_dev_npm() {
|
|||||||
fi
|
fi
|
||||||
# Clean pnpm store cache
|
# Clean pnpm store cache
|
||||||
local pnpm_default_store=~/Library/pnpm/store
|
local pnpm_default_store=~/Library/pnpm/store
|
||||||
if command -v pnpm > /dev/null 2>&1; then
|
# Check if pnpm is actually usable (not just Corepack shim)
|
||||||
clean_tool_cache "pnpm cache" pnpm store prune
|
if command -v pnpm > /dev/null 2>&1 && env COREPACK_ENABLE_DOWNLOAD_PROMPT=0 pnpm --version > /dev/null 2>&1; then
|
||||||
|
clean_tool_cache "pnpm cache" env COREPACK_ENABLE_DOWNLOAD_PROMPT=0 pnpm store prune
|
||||||
local pnpm_store_path
|
local pnpm_store_path
|
||||||
start_section_spinner "Checking store path..."
|
start_section_spinner "Checking store path..."
|
||||||
pnpm_store_path=$(run_with_timeout 2 pnpm store path 2> /dev/null) || pnpm_store_path=""
|
pnpm_store_path=$(run_with_timeout 2 env COREPACK_ENABLE_DOWNLOAD_PROMPT=0 pnpm store path 2> /dev/null) || pnpm_store_path=""
|
||||||
stop_section_spinner
|
stop_section_spinner
|
||||||
if [[ -n "$pnpm_store_path" && "$pnpm_store_path" != "$pnpm_default_store" ]]; then
|
if [[ -n "$pnpm_store_path" && "$pnpm_store_path" != "$pnpm_default_store" ]]; then
|
||||||
safe_clean "$pnpm_default_store"/* "Orphaned pnpm store"
|
safe_clean "$pnpm_default_store"/* "Orphaned pnpm store"
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
|
# pnpm not installed or not usable, just clean the default store directory
|
||||||
safe_clean "$pnpm_default_store"/* "pnpm store"
|
safe_clean "$pnpm_default_store"/* "pnpm store"
|
||||||
fi
|
fi
|
||||||
note_activity
|
note_activity
|
||||||
|
|||||||
@@ -307,9 +307,14 @@ scan_purge_targets() {
|
|||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
if command -v fd > /dev/null 2>&1; then
|
if command -v fd > /dev/null 2>&1; then
|
||||||
|
# Escape regex special characters in target names for fd patterns
|
||||||
|
local escaped_targets=()
|
||||||
|
for target in "${PURGE_TARGETS[@]}"; do
|
||||||
|
escaped_targets+=("$(printf '%s' "$target" | sed -e 's/[][(){}.^$*+?|\\]/\\&/g')")
|
||||||
|
done
|
||||||
local pattern="($(
|
local pattern="($(
|
||||||
IFS='|'
|
IFS='|'
|
||||||
echo "${PURGE_TARGETS[*]}"
|
echo "${escaped_targets[*]}"
|
||||||
))"
|
))"
|
||||||
local fd_args=(
|
local fd_args=(
|
||||||
"--absolute-path"
|
"--absolute-path"
|
||||||
|
|||||||
@@ -50,14 +50,14 @@ if command -v bats > /dev/null 2>&1 && [ -d "tests" ]; then
|
|||||||
set -- tests
|
set -- tests
|
||||||
fi
|
fi
|
||||||
if [[ -t 1 ]]; then
|
if [[ -t 1 ]]; then
|
||||||
if bats -p "$@"; then
|
if bats -p "$@" | sed -e 's/^ok /OK /' -e 's/^not ok /FAIL /'; then
|
||||||
printf "${GREEN}${ICON_SUCCESS} Unit tests passed${NC}\n"
|
printf "${GREEN}${ICON_SUCCESS} Unit tests passed${NC}\n"
|
||||||
else
|
else
|
||||||
printf "${RED}${ICON_ERROR} Unit tests failed${NC}\n"
|
printf "${RED}${ICON_ERROR} Unit tests failed${NC}\n"
|
||||||
((FAILED++))
|
((FAILED++))
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
if TERM="${TERM:-xterm-256color}" bats --tap "$@"; then
|
if TERM="${TERM:-xterm-256color}" bats --tap "$@" | sed -e 's/^ok /OK /' -e 's/^not ok /FAIL /'; then
|
||||||
printf "${GREEN}${ICON_SUCCESS} Unit tests passed${NC}\n"
|
printf "${GREEN}${ICON_SUCCESS} Unit tests passed${NC}\n"
|
||||||
else
|
else
|
||||||
printf "${RED}${ICON_ERROR} Unit tests failed${NC}\n"
|
printf "${RED}${ICON_ERROR} Unit tests failed${NC}\n"
|
||||||
|
|||||||
@@ -94,8 +94,8 @@ setup() {
|
|||||||
@test "completion zsh includes command descriptions" {
|
@test "completion zsh includes command descriptions" {
|
||||||
run "$PROJECT_ROOT/bin/completion.sh" zsh
|
run "$PROJECT_ROOT/bin/completion.sh" zsh
|
||||||
[ "$status" -eq 0 ]
|
[ "$status" -eq 0 ]
|
||||||
[[ "$output" == *"optimize:Free up disk space"* ]]
|
[[ "$output" == *"optimize:Check and maintain system"* ]]
|
||||||
[[ "$output" == *"clean:Remove apps completely"* ]]
|
[[ "$output" == *"clean:Free up disk space"* ]]
|
||||||
}
|
}
|
||||||
|
|
||||||
@test "completion fish generates valid fish script" {
|
@test "completion fish generates valid fish script" {
|
||||||
@@ -115,6 +115,7 @@ setup() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@test "completion auto-install detects zsh" {
|
@test "completion auto-install detects zsh" {
|
||||||
|
# shellcheck disable=SC2030,SC2031
|
||||||
export SHELL=/bin/zsh
|
export SHELL=/bin/zsh
|
||||||
|
|
||||||
# Simulate auto-install (no interaction)
|
# Simulate auto-install (no interaction)
|
||||||
@@ -131,8 +132,10 @@ setup() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@test "completion auto-install detects already installed" {
|
@test "completion auto-install detects already installed" {
|
||||||
|
# shellcheck disable=SC2031
|
||||||
export SHELL=/bin/zsh
|
export SHELL=/bin/zsh
|
||||||
mkdir -p "$HOME"
|
mkdir -p "$HOME"
|
||||||
|
# shellcheck disable=SC2016
|
||||||
echo 'eval "$(mole completion zsh)"' > "$HOME/.zshrc"
|
echo 'eval "$(mole completion zsh)"' > "$HOME/.zshrc"
|
||||||
|
|
||||||
run "$PROJECT_ROOT/bin/completion.sh"
|
run "$PROJECT_ROOT/bin/completion.sh"
|
||||||
|
|||||||
Reference in New Issue
Block a user