@halilertekin/macos-system-cleaner 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +318 -0
- package/README.tr.md +318 -0
- package/install.sh +155 -0
- package/macos-system-cleaner.rb +45 -0
- package/main_cleaner.sh +173 -0
- package/package.json +40 -0
- package/scripts/brew_update_with_cache.sh +12 -0
- package/scripts/cache_cleaner.sh +200 -0
- package/scripts/ide_cleaner.sh +273 -0
- package/scripts/ram_cleaner.sh +146 -0
- package/update_formula_sha.sh +265 -0
package/install.sh
ADDED
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
|
|
3
|
+
# macOS System Cleaner Kurulum Scripti
|
|
4
|
+
|
|
5
|
+
set -e # Hatalarda çık
|
|
6
|
+
|
|
7
|
+
# Renkler
|
|
8
|
+
RED='\033[0;31m'
|
|
9
|
+
GREEN='\033[0;32m'
|
|
10
|
+
YELLOW='\033[1;33m'
|
|
11
|
+
BLUE='\033[0;34m'
|
|
12
|
+
NC='\033[0m' # Renksiz
|
|
13
|
+
|
|
14
|
+
# Renkli çıktı fonksiyonları
|
|
15
|
+
print_status() {
|
|
16
|
+
echo -e "${BLUE}[BİLGİ]${NC} $1"
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
print_success() {
|
|
20
|
+
echo -e "${GREEN}[BAŞARILI]${NC} $1"
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
print_warning() {
|
|
24
|
+
echo -e "${YELLOW}[UYARI]${NC} $1"
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
print_error() {
|
|
28
|
+
echo -e "${RED}[HATA]${NC} $1"
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
# Yardım menüsü
|
|
32
|
+
show_help() {
|
|
33
|
+
echo "macOS System Cleaner Kurulum Scripti"
|
|
34
|
+
echo "Script'leri kurar ve gerekli ayarlamaları yapar"
|
|
35
|
+
echo
|
|
36
|
+
echo "Kullanım: $0 [seçenek]"
|
|
37
|
+
echo
|
|
38
|
+
echo "Seçenekler:"
|
|
39
|
+
echo " --bash-alias Bash alias kurulumu yapar"
|
|
40
|
+
echo " --zsh-alias Zsh alias kurulumu yapar"
|
|
41
|
+
echo " --npm-install npm ile global kurulum yapar (npm gerekli)"
|
|
42
|
+
echo " --help Bu yardım menüsünü gösterir"
|
|
43
|
+
echo
|
|
44
|
+
echo "Not: Script'ler zaten çalıştırma iznine sahip olarak gelmektedir."
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
# Bash alias kurulumu
|
|
48
|
+
install_bash_alias() {
|
|
49
|
+
print_status "Bash alias kurulumu yapılıyor..."
|
|
50
|
+
|
|
51
|
+
# Bashrc dosyasını kontrol et
|
|
52
|
+
BASHRC_FILE="$HOME/.bashrc"
|
|
53
|
+
if [ ! -f "$BASHRC_FILE" ]; then
|
|
54
|
+
BASHRC_FILE="$HOME/.bash_profile"
|
|
55
|
+
if [ ! -f "$BASHRC_FILE" ]; then
|
|
56
|
+
print_error "Ne .bashrc ne de .bash_profile dosyası bulunamadı."
|
|
57
|
+
return 1
|
|
58
|
+
fi
|
|
59
|
+
fi
|
|
60
|
+
|
|
61
|
+
# Alias zaten var mı kontrol et
|
|
62
|
+
if grep -q "alias msc=" "$BASHRC_FILE"; then
|
|
63
|
+
print_warning "msc alias zaten mevcut, güncelleniyor..."
|
|
64
|
+
sed -i.bak '/alias msc=/d' "$BASHRC_FILE"
|
|
65
|
+
fi
|
|
66
|
+
|
|
67
|
+
# Script dizinini bul
|
|
68
|
+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
69
|
+
|
|
70
|
+
# Yeni alias ekle
|
|
71
|
+
echo "alias msc='$SCRIPT_DIR/main_cleaner.sh'" >> "$BASHRC_FILE"
|
|
72
|
+
|
|
73
|
+
# Ek kısayollar
|
|
74
|
+
echo "alias msc-analyze='$SCRIPT_DIR/main_cleaner.sh analyze'" >> "$BASHRC_FILE"
|
|
75
|
+
echo "alias msc-cache='$SCRIPT_DIR/scripts/cache_cleaner.sh clean'" >> "$BASHRC_FILE"
|
|
76
|
+
echo "alias msc-ram='$SCRIPT_DIR/scripts/ram_cleaner.sh clear'" >> "$BASHRC_FILE"
|
|
77
|
+
echo "alias msc-ide='$SCRIPT_DIR/scripts/ide_cleaner.sh all'" >> "$BASHRC_FILE"
|
|
78
|
+
|
|
79
|
+
print_success "Bash alias'ları kuruldu. Yeni terminal oturumunda aktif olacak."
|
|
80
|
+
print_status "Eğer hemen kullanmak istiyorsanız: source $BASHRC_FILE"
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
# Zsh alias kurulumu
|
|
84
|
+
install_zsh_alias() {
|
|
85
|
+
print_status "Zsh alias kurulumu yapılıyor..."
|
|
86
|
+
|
|
87
|
+
# Zshrc dosyasını kontrol et
|
|
88
|
+
ZSHRC_FILE="$HOME/.zshrc"
|
|
89
|
+
if [ ! -f "$ZSHRC_FILE" ]; then
|
|
90
|
+
print_error ".zshrc dosyası bulunamadı."
|
|
91
|
+
return 1
|
|
92
|
+
fi
|
|
93
|
+
|
|
94
|
+
# Alias zaten var mı kontrol et
|
|
95
|
+
if grep -q "alias msc=" "$ZSHRC_FILE"; then
|
|
96
|
+
print_warning "msc alias zaten mevcut, güncelleniyor..."
|
|
97
|
+
sed -i.bak '/alias msc=/d' "$ZSHRC_FILE"
|
|
98
|
+
fi
|
|
99
|
+
|
|
100
|
+
# Script dizinini bul
|
|
101
|
+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
102
|
+
|
|
103
|
+
# Yeni alias ekle
|
|
104
|
+
echo "alias msc='$SCRIPT_DIR/main_cleaner.sh'" >> "$ZSHRC_FILE"
|
|
105
|
+
|
|
106
|
+
# Ek kısayollar
|
|
107
|
+
echo "alias msc-analyze='$SCRIPT_DIR/main_cleaner.sh analyze'" >> "$ZSHRC_FILE"
|
|
108
|
+
echo "alias msc-cache='$SCRIPT_DIR/scripts/cache_cleaner.sh clean'" >> "$ZSHRC_FILE"
|
|
109
|
+
echo "alias msc-ram='$SCRIPT_DIR/scripts/ram_cleaner.sh clear'" >> "$ZSHRC_FILE"
|
|
110
|
+
echo "alias msc-ide='$SCRIPT_DIR/scripts/ide_cleaner.sh all'" >> "$ZSHRC_FILE"
|
|
111
|
+
|
|
112
|
+
print_success "Zsh alias'ları kuruldu. Yeni terminal oturumunda aktif olacak."
|
|
113
|
+
print_status "Eğer hemen kullanmak istiyorsanız: source $ZSHRC_FILE"
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
# Npm kurulumu
|
|
117
|
+
install_npm() {
|
|
118
|
+
print_status "npm ile global kurulum yapılıyor..."
|
|
119
|
+
|
|
120
|
+
# npm yüklü mü kontrol et
|
|
121
|
+
if ! command -v npm &> /dev/null; then
|
|
122
|
+
print_error "npm bulunamadı. npm yüklü olduğundan emin olun."
|
|
123
|
+
return 1
|
|
124
|
+
fi
|
|
125
|
+
|
|
126
|
+
# Proje dizinine git
|
|
127
|
+
PROJECT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
128
|
+
cd "$PROJECT_DIR"
|
|
129
|
+
|
|
130
|
+
# npm paketini global olarak yükle
|
|
131
|
+
npm install -g .
|
|
132
|
+
|
|
133
|
+
print_success "npm ile global kurulum tamamlandı. Artık 'msc' komutunu doğrudan kullanabilirsiniz."
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
# Ana fonksiyon
|
|
137
|
+
main() {
|
|
138
|
+
case "${1:-help}" in
|
|
139
|
+
"--bash-alias")
|
|
140
|
+
install_bash_alias
|
|
141
|
+
;;
|
|
142
|
+
"--zsh-alias")
|
|
143
|
+
install_zsh_alias
|
|
144
|
+
;;
|
|
145
|
+
"--npm-install")
|
|
146
|
+
install_npm
|
|
147
|
+
;;
|
|
148
|
+
"--help"|"-h"|*)
|
|
149
|
+
show_help
|
|
150
|
+
;;
|
|
151
|
+
esac
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
# Ana fonksiyonu çalıştır
|
|
155
|
+
main "$@"
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
class MacosSystemCleaner < Formula
|
|
2
|
+
desc "A collection of scripts to clean RAM, cache and IDEs for improved macOS system performance"
|
|
3
|
+
homepage "https://github.com/halilertekin/macOS-System-Cleaner"
|
|
4
|
+
url "https://github.com/halilertekin/macOS-System-Cleaner/archive/refs/tags/v1.0.0.tar.gz"
|
|
5
|
+
sha256 "REPLACE_WITH_ACTUAL_SHA256" # This will be updated with each new release
|
|
6
|
+
license "MIT"
|
|
7
|
+
|
|
8
|
+
def install
|
|
9
|
+
# Install all scripts
|
|
10
|
+
bin.install "main_cleaner.sh" => "msc"
|
|
11
|
+
prefix.install Dir["scripts/*"]
|
|
12
|
+
prefix.install %w[LICENSE README.md README.tr.md install.sh package.json .npmignore]
|
|
13
|
+
|
|
14
|
+
# Make scripts executable
|
|
15
|
+
chmod 0755, bin/"msc"
|
|
16
|
+
chmod 0755, Dir[prefix/"scripts/*"]
|
|
17
|
+
chmod 0755, prefix/"main_cleaner.sh"
|
|
18
|
+
chmod 0755, prefix/"install.sh"
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def caveats
|
|
22
|
+
<<~EOS
|
|
23
|
+
macOS System Cleaner has been installed!
|
|
24
|
+
|
|
25
|
+
To use the command directly:
|
|
26
|
+
msc [command]
|
|
27
|
+
|
|
28
|
+
For more information:
|
|
29
|
+
msc --help
|
|
30
|
+
|
|
31
|
+
To install bash/zsh aliases:
|
|
32
|
+
source #{prefix}/install.sh --bash-alias # for bash
|
|
33
|
+
source #{prefix}/install.sh --zsh-alias # for zsh
|
|
34
|
+
|
|
35
|
+
Note: When updating to a new version, the SHA256 hash in the formula
|
|
36
|
+
needs to be updated with the new tarball's hash.
|
|
37
|
+
You can calculate it with: shasum -a 256 <tarball_name>.tar.gz
|
|
38
|
+
EOS
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
test do
|
|
42
|
+
# Test that the main command exists
|
|
43
|
+
system "#{bin}/msc", "--help"
|
|
44
|
+
end
|
|
45
|
+
end
|
package/main_cleaner.sh
ADDED
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
|
|
3
|
+
# macOS Sistem Temizleyici Ana Script
|
|
4
|
+
# Tüm temizlik script'lerini tek bir yerden yönetir
|
|
5
|
+
|
|
6
|
+
set -e # Hatalarda çık
|
|
7
|
+
|
|
8
|
+
# Renkler
|
|
9
|
+
RED='\033[0;31m'
|
|
10
|
+
GREEN='\033[0;32m'
|
|
11
|
+
YELLOW='\033[1;33m'
|
|
12
|
+
BLUE='\033[0;34m'
|
|
13
|
+
NC='\033[0m' # Renksiz
|
|
14
|
+
|
|
15
|
+
# Renkli çıktı fonksiyonları
|
|
16
|
+
print_status() {
|
|
17
|
+
echo -e "${BLUE}[BİLGİ]${NC} $1"
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
print_success() {
|
|
21
|
+
echo -e "${GREEN}[BAŞARILI]${NC} $1"
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
print_warning() {
|
|
25
|
+
echo -e "${YELLOW}[UYARI]${NC} $1"
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
print_error() {
|
|
29
|
+
echo -e "${RED}[HATA]${NC} $1"
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
# Script dizinini belirle
|
|
33
|
+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
34
|
+
PROJECT_ROOT="$(dirname "$SCRIPT_DIR")"
|
|
35
|
+
|
|
36
|
+
# Yardım menüsü
|
|
37
|
+
show_help() {
|
|
38
|
+
echo "macOS Sistem Temizleyici"
|
|
39
|
+
echo "Tüm sistem temizlik işlemlerini tek bir komutla yapar"
|
|
40
|
+
echo
|
|
41
|
+
echo "Kullanım: $0 [komut]"
|
|
42
|
+
echo
|
|
43
|
+
echo "Komutlar:"
|
|
44
|
+
echo " full - Tüm sistem temizliği (RAM + önbellekler + IDE)"
|
|
45
|
+
echo " cache - Sadece önbellek temizliği"
|
|
46
|
+
echo " ram - Sadece RAM temizliği"
|
|
47
|
+
echo " ide - Sadece IDE temizliği"
|
|
48
|
+
echo " analyze - Sadece analiz (temizleme yapmaz)"
|
|
49
|
+
echo " help - Bu yardım menüsünü göster"
|
|
50
|
+
echo
|
|
51
|
+
echo "Not: Her komut için ayrı ayrı onay istenecektir."
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
# Önbellek analizi
|
|
55
|
+
analyze_caches() {
|
|
56
|
+
print_status "Önbellek analizi yapılıyor..."
|
|
57
|
+
"$PROJECT_ROOT/scripts/cache_cleaner.sh" analyze
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
# RAM analizi
|
|
61
|
+
analyze_ram() {
|
|
62
|
+
print_status "RAM analizi yapılıyor..."
|
|
63
|
+
"$PROJECT_ROOT/scripts/ram_cleaner.sh" status
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
# IDE analizi
|
|
67
|
+
analyze_ide() {
|
|
68
|
+
print_status "IDE analizi yapılıyor..."
|
|
69
|
+
"$PROJECT_ROOT/scripts/ide_cleaner.sh" find
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
# Tam temizlik
|
|
73
|
+
full_clean() {
|
|
74
|
+
print_warning "Tam sistem temizliği başlatılıyor..."
|
|
75
|
+
print_warning "Bu işlem tüm önbellekleri, RAM'i ve IDE önbelleklerini temizleyecektir."
|
|
76
|
+
|
|
77
|
+
read -p "Devam etmek istiyor musunuz? (e/H): " -n 1 -r
|
|
78
|
+
echo
|
|
79
|
+
if [[ ! $REPLY =~ ^[Ee]$ ]]; then
|
|
80
|
+
print_warning "İşlem iptal edildi."
|
|
81
|
+
return 0
|
|
82
|
+
fi
|
|
83
|
+
|
|
84
|
+
print_status "RAM temizliği yapılıyor..."
|
|
85
|
+
"$PROJECT_ROOT/scripts/ram_cleaner.sh" clear
|
|
86
|
+
|
|
87
|
+
echo
|
|
88
|
+
print_status "Önbellek temizliği yapılıyor..."
|
|
89
|
+
"$PROJECT_ROOT/scripts/cache_cleaner.sh" clean
|
|
90
|
+
|
|
91
|
+
echo
|
|
92
|
+
print_status "IDE temizliği yapılıyor..."
|
|
93
|
+
"$PROJECT_ROOT/scripts/ide_cleaner.sh" all
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
# Temizleme sonrası özet ekranı
|
|
97
|
+
show_summary() {
|
|
98
|
+
local lang="en"
|
|
99
|
+
if [ -n "$LANG" ] && [[ "$LANG" =~ ^tr ]]; then
|
|
100
|
+
lang="tr"
|
|
101
|
+
fi
|
|
102
|
+
|
|
103
|
+
if [ "$lang" = "tr" ]; then
|
|
104
|
+
print_success "TEMİZLEME İŞLEMİ TAMAMLANDI! 🎉"
|
|
105
|
+
echo
|
|
106
|
+
echo " ┌─────────────────────────────────────────┐"
|
|
107
|
+
echo " │ TEMİZLEME ÖZETİ │"
|
|
108
|
+
echo " ├─────────────────────────────────────────┤"
|
|
109
|
+
echo " │ • RAM temizliği: ✓ │"
|
|
110
|
+
echo " │ • Önbellek temizliği: ✓ │"
|
|
111
|
+
echo " │ • IDE temizliği: ✓ │"
|
|
112
|
+
echo " │ • Sistem kararlılığı: ✓ │"
|
|
113
|
+
echo " └─────────────────────────────────────────┘"
|
|
114
|
+
echo
|
|
115
|
+
print_success "Sistem performansınız artırıldı!"
|
|
116
|
+
print_status "Dilerseniz sistem durumunu tekrar analiz etmek için:"
|
|
117
|
+
echo " $0 analyze"
|
|
118
|
+
else
|
|
119
|
+
print_success "CLEANING COMPLETED! 🎉"
|
|
120
|
+
echo
|
|
121
|
+
echo " ┌─────────────────────────────────────────┐"
|
|
122
|
+
echo " │ CLEANING SUMMARY │"
|
|
123
|
+
echo " ├─────────────────────────────────────────┤"
|
|
124
|
+
echo " │ • RAM cleaning: ✓ │"
|
|
125
|
+
echo " │ • Cache cleaning: ✓ │"
|
|
126
|
+
echo " │ • IDE cleaning: ✓ │"
|
|
127
|
+
echo " │ • System stability: ✓ │"
|
|
128
|
+
echo " └─────────────────────────────────────────┘"
|
|
129
|
+
echo
|
|
130
|
+
print_success "System performance increased!"
|
|
131
|
+
print_status "To analyze system status again:"
|
|
132
|
+
echo " $0 analyze"
|
|
133
|
+
fi
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
# Ana fonksiyon
|
|
137
|
+
main() {
|
|
138
|
+
case "${1:-help}" in
|
|
139
|
+
"full")
|
|
140
|
+
full_clean
|
|
141
|
+
show_summary
|
|
142
|
+
;;
|
|
143
|
+
"cache")
|
|
144
|
+
print_status "Önbellek temizliği başlatılıyor..."
|
|
145
|
+
"$PROJECT_ROOT/scripts/cache_cleaner.sh" clean
|
|
146
|
+
print_success "Önbellek temizliği tamamlandı!"
|
|
147
|
+
;;
|
|
148
|
+
"ram")
|
|
149
|
+
print_status "RAM temizliği başlatılıyor..."
|
|
150
|
+
"$PROJECT_ROOT/scripts/ram_cleaner.sh" deep
|
|
151
|
+
print_success "RAM temizliği tamamlandı!"
|
|
152
|
+
;;
|
|
153
|
+
"ide")
|
|
154
|
+
print_status "IDE temizliği başlatılıyor..."
|
|
155
|
+
"$PROJECT_ROOT/scripts/ide_cleaner.sh" all
|
|
156
|
+
print_success "IDE temizliği tamamlandı!"
|
|
157
|
+
;;
|
|
158
|
+
"analyze")
|
|
159
|
+
print_status "Sistem analizi başlatılıyor..."
|
|
160
|
+
analyze_ram
|
|
161
|
+
echo
|
|
162
|
+
analyze_caches
|
|
163
|
+
echo
|
|
164
|
+
analyze_ide
|
|
165
|
+
;;
|
|
166
|
+
"help"|*)
|
|
167
|
+
show_help
|
|
168
|
+
;;
|
|
169
|
+
esac
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
# Ana fonksiyonu çalıştır
|
|
173
|
+
main "$@"
|
package/package.json
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@halilertekin/macos-system-cleaner",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "A collection of scripts to clean RAM, cache and IDEs for improved macOS system performance",
|
|
5
|
+
"main": "main_cleaner.sh",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"start": "bash main_cleaner.sh",
|
|
8
|
+
"analyze": "bash main_cleaner.sh analyze",
|
|
9
|
+
"full-clean": "bash main_cleaner.sh full",
|
|
10
|
+
"cache-clean": "bash scripts/cache_cleaner.sh clean",
|
|
11
|
+
"ram-clean": "bash scripts/ram_cleaner.sh clear",
|
|
12
|
+
"ide-clean": "bash scripts/ide_cleaner.sh all",
|
|
13
|
+
"test": "echo 'No tests specified'"
|
|
14
|
+
},
|
|
15
|
+
"bin": {
|
|
16
|
+
"msc": "./main_cleaner.sh"
|
|
17
|
+
},
|
|
18
|
+
"repository": {
|
|
19
|
+
"type": "git",
|
|
20
|
+
"url": "https://github.com/halilertekin/macOS-System-Cleaner.git"
|
|
21
|
+
},
|
|
22
|
+
"keywords": [
|
|
23
|
+
"macos",
|
|
24
|
+
"system",
|
|
25
|
+
"cleaner",
|
|
26
|
+
"cache",
|
|
27
|
+
"ram",
|
|
28
|
+
"performance",
|
|
29
|
+
"xcode",
|
|
30
|
+
"ide",
|
|
31
|
+
"utilities"
|
|
32
|
+
],
|
|
33
|
+
"author": "Halil Ertekin",
|
|
34
|
+
"license": "MIT",
|
|
35
|
+
"bugs": {
|
|
36
|
+
"url": "https://github.com/halilertekin/macOS-System-Cleaner/issues"
|
|
37
|
+
},
|
|
38
|
+
"homepage": "https://github.com/halilertekin/macOS-System-Cleaner#readme",
|
|
39
|
+
"preferGlobal": true
|
|
40
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
# Wrapper script that runs brew update followed by cache analysis
|
|
3
|
+
|
|
4
|
+
echo "Running brew update..."
|
|
5
|
+
brew update
|
|
6
|
+
|
|
7
|
+
echo ""
|
|
8
|
+
echo "Running cache analysis after brew update..."
|
|
9
|
+
/Users/halil/cache_cleaner.sh analyze
|
|
10
|
+
|
|
11
|
+
echo ""
|
|
12
|
+
echo "To clean caches after review, run: /Users/halil/cache_cleaner.sh clean"
|
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
|
|
3
|
+
# macOS Cache Cleaner Script
|
|
4
|
+
# This script analyzes and optionally cleans various cache directories on macOS
|
|
5
|
+
# Designed to be run as part of a brew update process or standalone
|
|
6
|
+
|
|
7
|
+
set -e # Exit on any error
|
|
8
|
+
|
|
9
|
+
# Colors for output
|
|
10
|
+
RED='\033[0;31m'
|
|
11
|
+
GREEN='\033[0;32m'
|
|
12
|
+
YELLOW='\033[1;33m'
|
|
13
|
+
BLUE='\033[0;34m'
|
|
14
|
+
NC='\033[0m' # No Color
|
|
15
|
+
|
|
16
|
+
# Function to print colored output
|
|
17
|
+
print_status() {
|
|
18
|
+
echo -e "${BLUE}[INFO]${NC} $1"
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
print_success() {
|
|
22
|
+
echo -e "${GREEN}[SUCCESS]${NC} $1"
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
print_warning() {
|
|
26
|
+
echo -e "${YELLOW}[WARNING]${NC} $1"
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
print_error() {
|
|
30
|
+
echo -e "${RED}[ERROR]${NC} $1"
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
# Function to get directory size
|
|
34
|
+
get_dir_size() {
|
|
35
|
+
du -sh "$1" 2>/dev/null | cut -f1
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
# Function to analyze caches
|
|
39
|
+
analyze_caches() {
|
|
40
|
+
print_status "Analyzing cache sizes..."
|
|
41
|
+
echo
|
|
42
|
+
|
|
43
|
+
# User caches
|
|
44
|
+
echo "=== USER CACHES ==="
|
|
45
|
+
if [ -d "$HOME/Library/Caches" ]; then
|
|
46
|
+
total_user_cache=$(get_dir_size "$HOME/Library/Caches")
|
|
47
|
+
echo "Total User Cache Size: $total_user_cache"
|
|
48
|
+
|
|
49
|
+
echo "Top 10 Largest User Caches:"
|
|
50
|
+
du -sh "$HOME/Library/Caches"/* 2>/dev/null | grep -v "Operation not permitted" | sort -hr | head -10
|
|
51
|
+
echo
|
|
52
|
+
fi
|
|
53
|
+
|
|
54
|
+
# npm cache
|
|
55
|
+
echo "=== NPM/YARN CACHES ==="
|
|
56
|
+
if command -v npm &> /dev/null; then
|
|
57
|
+
npm_cache_info=$(npm cache verify 2>/dev/null | grep -E "(Content verified|Content garbage-collected)" || echo "npm not available")
|
|
58
|
+
echo "npm cache: $npm_cache_info"
|
|
59
|
+
else
|
|
60
|
+
echo "npm not installed"
|
|
61
|
+
fi
|
|
62
|
+
|
|
63
|
+
if command -v yarn &> /dev/null; then
|
|
64
|
+
yarn_cache_size=$(get_dir_size "$HOME/Library/Caches/Yarn")
|
|
65
|
+
echo "Yarn cache size: $yarn_cache_size"
|
|
66
|
+
else
|
|
67
|
+
echo "Yarn not installed"
|
|
68
|
+
fi
|
|
69
|
+
|
|
70
|
+
# Homebrew cache
|
|
71
|
+
echo -e "\n=== HOMEBREW CACHES ==="
|
|
72
|
+
if command -v brew &> /dev/null; then
|
|
73
|
+
print_status "Checking Homebrew cache..."
|
|
74
|
+
brew cleanup --dry-run
|
|
75
|
+
else
|
|
76
|
+
echo "Homebrew not installed"
|
|
77
|
+
fi
|
|
78
|
+
|
|
79
|
+
# Temporary directories
|
|
80
|
+
echo -e "\n=== TEMPORARY DIRECTORIES ==="
|
|
81
|
+
tmp_size=$(get_dir_size "/tmp")
|
|
82
|
+
echo "Size of /tmp: $tmp_size"
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
# Function to clean caches
|
|
86
|
+
clean_caches() {
|
|
87
|
+
print_status "Starting cache cleaning process..."
|
|
88
|
+
|
|
89
|
+
# Ask for confirmation before cleaning
|
|
90
|
+
read -p "Do you want to proceed with cleaning caches? (y/N): " -n 1 -r
|
|
91
|
+
echo
|
|
92
|
+
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
|
|
93
|
+
print_warning "Cache cleaning cancelled by user."
|
|
94
|
+
return 0
|
|
95
|
+
fi
|
|
96
|
+
|
|
97
|
+
cleaned_size=0
|
|
98
|
+
|
|
99
|
+
# Clean Google caches
|
|
100
|
+
if [ -d "$HOME/Library/Caches/Google" ]; then
|
|
101
|
+
size=$(get_dir_size "$HOME/Library/Caches/Google")
|
|
102
|
+
print_status "Cleaning Google caches ($size)..."
|
|
103
|
+
rm -rf "$HOME/Library/Caches/Google"/*
|
|
104
|
+
print_success "Google caches cleaned"
|
|
105
|
+
fi
|
|
106
|
+
|
|
107
|
+
# Clean Adobe caches
|
|
108
|
+
if [ -d "$HOME/Library/Caches/Adobe" ]; then
|
|
109
|
+
size=$(get_dir_size "$HOME/Library/Caches/Adobe")
|
|
110
|
+
print_status "Cleaning Adobe caches ($size)..."
|
|
111
|
+
rm -rf "$HOME/Library/Caches/Adobe"/*
|
|
112
|
+
print_success "Adobe caches cleaned"
|
|
113
|
+
fi
|
|
114
|
+
|
|
115
|
+
# Clean Playwright caches
|
|
116
|
+
if [ -d "$HOME/Library/Caches/ms-playwright" ]; then
|
|
117
|
+
size=$(get_dir_size "$HOME/Library/Caches/ms-playwright")
|
|
118
|
+
print_status "Cleaning Playwright caches ($size)..."
|
|
119
|
+
rm -rf "$HOME/Library/Caches/ms-playwright"/*
|
|
120
|
+
print_success "Playwright caches cleaned"
|
|
121
|
+
fi
|
|
122
|
+
|
|
123
|
+
if [ -d "$HOME/Library/Caches/ms-playwright-go" ]; then
|
|
124
|
+
size=$(get_dir_size "$HOME/Library/Caches/ms-playwright-go")
|
|
125
|
+
print_status "Cleaning Playwright Go caches ($size)..."
|
|
126
|
+
rm -rf "$HOME/Library/Caches/ms-playwright-go"/*
|
|
127
|
+
print_success "Playwright Go caches cleaned"
|
|
128
|
+
fi
|
|
129
|
+
|
|
130
|
+
# Clean DeepL Translator cache
|
|
131
|
+
if [ -d "$HOME/Library/Caches/com.linguee.DeepLCopyTranslator" ]; then
|
|
132
|
+
size=$(get_dir_size "$HOME/Library/Caches/com.linguee.DeepLCopyTranslator")
|
|
133
|
+
print_status "Cleaning DeepL Translator cache ($size)..."
|
|
134
|
+
rm -rf "$HOME/Library/Caches/com.linguee.DeepLCopyTranslator"/*
|
|
135
|
+
print_success "DeepL Translator cache cleaned"
|
|
136
|
+
fi
|
|
137
|
+
|
|
138
|
+
# Clean Spotify cache
|
|
139
|
+
if [ -d "$HOME/Library/Caches/com.spotify.client" ]; then
|
|
140
|
+
size=$(get_dir_size "$HOME/Library/Caches/com.spotify.client")
|
|
141
|
+
print_status "Cleaning Spotify cache ($size)..."
|
|
142
|
+
rm -rf "$HOME/Library/Caches/com.spotify.client"/*
|
|
143
|
+
print_success "Spotify cache cleaned"
|
|
144
|
+
fi
|
|
145
|
+
|
|
146
|
+
# Clean Yarn cache
|
|
147
|
+
if command -v yarn &> /dev/null; then
|
|
148
|
+
print_status "Cleaning Yarn cache..."
|
|
149
|
+
yarn cache clean
|
|
150
|
+
print_success "Yarn cache cleaned"
|
|
151
|
+
fi
|
|
152
|
+
|
|
153
|
+
# Clean npm cache
|
|
154
|
+
if command -v npm &> /dev/null; then
|
|
155
|
+
print_status "Cleaning npm cache..."
|
|
156
|
+
npm cache clean --force
|
|
157
|
+
print_success "npm cache cleaned"
|
|
158
|
+
fi
|
|
159
|
+
|
|
160
|
+
# Clean Homebrew cache
|
|
161
|
+
if command -v brew &> /dev/null; then
|
|
162
|
+
print_status "Cleaning Homebrew cache..."
|
|
163
|
+
brew cleanup
|
|
164
|
+
print_success "Homebrew cache cleaned"
|
|
165
|
+
fi
|
|
166
|
+
|
|
167
|
+
print_success "Cache cleaning completed!"
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
# Function to run analysis only
|
|
171
|
+
analyze_only() {
|
|
172
|
+
print_status "Running cache analysis only (no cleaning)..."
|
|
173
|
+
analyze_caches
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
# Main function
|
|
177
|
+
main() {
|
|
178
|
+
case "${1:-help}" in
|
|
179
|
+
"clean")
|
|
180
|
+
analyze_caches
|
|
181
|
+
clean_caches
|
|
182
|
+
;;
|
|
183
|
+
"analyze")
|
|
184
|
+
analyze_only
|
|
185
|
+
;;
|
|
186
|
+
"help"|*)
|
|
187
|
+
echo "Usage: $0 [command]"
|
|
188
|
+
echo
|
|
189
|
+
echo "Commands:"
|
|
190
|
+
echo " clean - Analyze and optionally clean caches"
|
|
191
|
+
echo " analyze - Analyze caches only (no cleaning)"
|
|
192
|
+
echo " help - Show this help message"
|
|
193
|
+
echo
|
|
194
|
+
echo "Run as part of brew update to automatically analyze and clean caches."
|
|
195
|
+
;;
|
|
196
|
+
esac
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
# Run main function with all arguments
|
|
200
|
+
main "$@"
|