-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathclean.sh
executable file
·87 lines (73 loc) · 2.04 KB
/
clean.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
#!/usr/bin/env bash
create_logs_folder() {
echo "Create log folder at $HOME/logs."
{
rm -rf $HOME/logs && mkdir -p $HOME/logs
}
}
clean_workspace() {
echo "Clean $HOME/workspace"
{
sudo rm -rf $HOME/workspace/*
} &>"$HOME/logs/cleanup.log"
}
clean_xcode() {
echo "Clean Xcode and iOS Simulator caches."
{
# Xcode caches
sudo rm -rf /var/folders/* >/dev/null 2>&1 || true
sudo rm -rf /Library/Caches/com.apple.dt.instruments/* || true
sudo rm -rf ~/Library/Developer/Xcode/DerivedData/* || true
sudo rm -rf ~/Library/Caches/CocoaPods/Pods/Release/* || true
# Simulator logs
rm -rf $HOME/Library/Logs/CoreSimulator/*
# Unused SDKs
sudo rm -rf /Library/Developer/CoreSimulator/Profiles/Runtimes/*8.*
sudo rm -rf /Library/Developer/CoreSimulator/Profiles/Runtimes/*9.*
sudo rm -rf /Library/Developer/CoreSimulator/Profiles/Runtimes/*10.*
} &>"$HOME/logs/cleanup.log"
}
clean_gradle() {
echo "Clean Gradle cache."
{
rm -rf ~/.gradle || true
} &>"$HOME/logs/cleanup.log"
}
clean_android() {
echo "Clean Android caches."
{
rm -rf ~/.android/build-cache/*
} &>"$HOME/logs/cleanup.log"
}
clean_brew() {
brew untap adoptopenjdk/openjdk && true
brew untap caskroom/versions && true
echo "y" | /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/uninstall)" || true
}
clean_pods() {
echo "Clean Cocoapods."
{
array=(1.9.3 1.9.2 1.9.1 1.9.0 1.8.4 1.8.3 1.8.2 1.8.1 1.8.0 1.7.5 1.7.4 1.7.3 1.7.2 1.7.1 1.7.0 1.6.2 1.6.1 1.6.0 1.5.3 1.5.2 1.5.1 1.5.0)
for v in "${array[@]}"; do
echo Y | sudo gem uninstall cocoapods -v $v >/dev/null 2>&1 || true
done
rm -rf ~/.cocoapods/
} &>"$HOME/logs/cleanup.log"
}
clean_java() {
echo "Clean Java."
{
sudo rm -rf /Library/Java/JavaVirtualMachines/*
} &>"$HOME/logs/cleanup.log"
}
if [[ "$FORCE_CLEAN" == "true"* ]]; then
echo "Full clean will be performed!"
clean_workspace
clean_brew
clean_pods
clean_java
fi
clean_xcode
clean_gradle
clean_android
echo "Cleanup completed!"