mikes-macos-developer-disk-cleanup 1.0.9 → 1.0.11

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/.env CHANGED
@@ -5,4 +5,4 @@
5
5
  DOTENV_PUBLIC_KEY="036dc3b1c538f3b753f28504685c42364d6aa3fd3cdc0d544ffab9dbe9c8d2afef"
6
6
 
7
7
  # .env
8
- GITHUB_TOKEN="encrypted:BNnSFezPjmz67d7bbIftawwuKLB65j8o5QStETBFPmMqZMlWMk0V1qF1NkhYKFvMcnjsv/qIV+1gT/Dkt4IzGZu8bXGhJ6cBfpZJ/QP79YvYGvrn/4qCLj/QsBtsNZc2iCpDJvU7dAzey7gi+2qCCDkZpjv042tsZtTcviAK+JbF31UBqsYTjxSM2FcaXwlbGlQjx6ygDk5AXJbTtQpCa1iAjfeW7ma9MypeKGGfSUBkCDMW42MZmXJZ+TN/Dw=="
8
+ GITHUB_TOKEN="encrypted:BDXSoNLrWFQCQpL2MYnEhmCdGz0TR7znqFIMghNtujL0ADFC5shdKOG/kq7dS1i62whj0gBxZLZYXpg8babGmf9fPM2fBCTxKEgOuSYlRItCYPK4neGRDmonuaj7OOQADGLSw16uHZIb+PnUxQYWk+fkvEA/e53PySLy6H/haK2ld5rFKZLbRjmLk2Rh/JrvWko3DFA5mVQSHqt/gB0m4Rwm/LxTjUAXkeWTBMZP4ZkzGK3v0s87CbqOQN5GOg=="
@@ -9,14 +9,15 @@
9
9
  "gradle-shared",
10
10
  "hints",
11
11
  "homebrew-caches",
12
+ "infra",
12
13
  "library-caches",
13
14
  "meteor-builds-and-packages",
14
15
  "node-modules",
15
16
  "npm-cache",
16
17
  "ruby-gems",
18
+ "*",
17
19
  "trash",
18
20
  "xcode-artifacts",
19
21
  "yarn-cache",
20
- "infra"
21
22
  ]
22
23
  }
package/CHANGELOG.md CHANGED
@@ -2,9 +2,65 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file.
4
4
 
5
+ ## 1.0.11 - 2025-05-14
6
+
7
+ [v1.0.10...1.0.11](../../compare/v1.0.10...1.0.11)
8
+
9
+ ### :rocket: New features
10
+
11
+ - :sparkles: add more folders to clear [<sup>(f97bab9)</sup>][f97bab9]
12
+
13
+ ### :bug: Bug fixes
14
+
15
+ - *(*)* :arrow_up: npm audit fix [<sup>(fe33211)</sup>][fe33211]
16
+
17
+ ### :gear: Miscellaneous Tasks
18
+
19
+ - :technologist: vscode config: conventional commit scopes [<sup>(58af793)</sup>][58af793]
20
+
21
+ <!-- LINKS -->
22
+ [f97bab9]:../../commit/f97bab9f8bd42adcdabba32a6c34139874b38b64
23
+ [fe33211]:../../commit/fe33211298811f123e7a5a7189786f668ee9572b
24
+ [58af793]:../../commit/58af793e6a88cf7c756db682548d800eff3ffbae
25
+
26
+ ## 1.0.10 - 2025-03-04
27
+
28
+ [v1.0.9...1.0.10](../../compare/v1.0.9...1.0.10)
29
+
30
+ ### :rocket: New features
31
+
32
+ - *(xcode-artifacts)* :sparkles: remove iOS runtimes [<sup>(586155a)</sup>][586155a]
33
+
34
+ ### :bug: Bug fixes
35
+
36
+ - *(ruby-gems)* :bug: remove dry-run flag [<sup>(5525759)</sup>][5525759]
37
+ - *(android-sdk)* :bug: fix obsolete package delete [<sup>(60c184a)</sup>][60c184a]
38
+
39
+ ### :memo: Documentation
40
+
41
+ - *(infra)* :memo: fix changelog links [<sup>(a81eb4e)</sup>][a81eb4e]
42
+
43
+ ### :recycle: Refactor
44
+
45
+ - :recycle: main : separate module loading and execution [<sup>(496b562)</sup>][496b562]
46
+
47
+ ### :gear: Miscellaneous Tasks
48
+
49
+ - *(infra)* :memo: workaround git-cliff bug [<sup>(21e404c)</sup>][21e404c]
50
+ - *(infra)* :wrench: .env (encrypted): rotate GITHUB_TOKEN [<sup>(2582880)</sup>][2582880]
51
+
52
+ <!-- LINKS -->
53
+ [21e404c]:../../commit/21e404c3062b38ab03beec99b5a1cd35c54c9a49
54
+ [a81eb4e]:../../commit/a81eb4e5c3830d6b9ae01e07ce8f0a9d90e7b575
55
+ [2582880]:../../commit/2582880f7274c54c021d639f87c748a11996e204
56
+ [5525759]:../../commit/5525759d5fabda664b505f1721ddbf661a3b4ebd
57
+ [60c184a]:../../commit/60c184a8ccde88d9ee3a2e51ca9d8fd01877e03a
58
+ [586155a]:../../commit/586155aa21c63b79bf2f026d41f8ee24038852bd
59
+ [496b562]:../../commit/496b562e97e697ff41f68207b319996d8558c143
60
+
5
61
  ## 1.0.9 - 2025-02-12
6
62
 
7
- [v1.0.8...1.0.9](../../compare/v1.0.8...1.0.9)
63
+ [v1.0.8...v1.0.9](../../compare/v1.0.8...v1.0.9)
8
64
 
9
65
  ### :memo: Documentation
10
66
 
@@ -39,7 +95,6 @@ All notable changes to this project will be documented in this file.
39
95
  ### :gear: Miscellaneous Tasks
40
96
 
41
97
  - :construction_worker: release-it - auto-publish NPM module [<sup>(e452923)</sup>][e452923]
42
- - Release 1.0.8 [<sup>(6424ffc)</sup>][6424ffc]
43
98
 
44
99
  <!-- LINKS -->
45
100
  [4bfc4a4]:../../commit/4bfc4a4f01631e5a1b6c49e71aefc918251845fc
@@ -50,7 +105,6 @@ All notable changes to this project will be documented in this file.
50
105
  [e6620de]:../../commit/e6620deacacfbce8ae0292d208f4a1c2f3117aee
51
106
  [7c56838]:../../commit/7c56838eee1fa245bf81b040ac4ee4b17dbca9bb
52
107
  [e452923]:../../commit/e452923ade48217127cc9c786a6e12af2eab3829
53
- [6424ffc]:../../commit/6424ffcda40491db4ff9ef84a8adf38acdb67df1
54
108
 
55
109
  ## 1.0.7 - 2025-02-05
56
110
 
@@ -68,14 +122,12 @@ All notable changes to this project will be documented in this file.
68
122
  ### :gear: Miscellaneous Tasks
69
123
 
70
124
  - :construction_worker: fix changelog generation [<sup>(30f323d)</sup>][30f323d]
71
- - Release 1.0.7 [<sup>(64546f9)</sup>][64546f9]
72
125
 
73
126
  <!-- LINKS -->
74
127
  [8792d75]:../../commit/8792d759de54c46be3cf3471a7ef3c18f937a41c
75
128
  [2aace79]:../../commit/2aace79ab5570049af7bfd87908cbfd4a5f9334f
76
129
  [9b28ba2]:../../commit/9b28ba2f4163454a5d36e48af93c3e51509a8b9c
77
130
  [30f323d]:../../commit/30f323da067b92b69f912cea5ce85b90997cef44
78
- [64546f9]:../../commit/64546f9fb87b06d86703311de819256761e2f7ad
79
131
 
80
132
  ## 1.0.6 - 2024-12-09
81
133
 
@@ -85,12 +137,10 @@ All notable changes to this project will be documented in this file.
85
137
 
86
138
  - :hammer: add GITHUB_TOKEN [<sup>(4d14cbf)</sup>][4d14cbf]
87
139
  - :arrow_up: update dependency to node >= 18 [<sup>(ca92511)</sup>][ca92511]
88
- - Release 1.0.6 [<sup>(88faf33)</sup>][88faf33]
89
140
 
90
141
  <!-- LINKS -->
91
142
  [4d14cbf]:../../commit/4d14cbfae18980d645d60f10a7feef9ce7650b06
92
143
  [ca92511]:../../commit/ca925115cb3137e795d55769dfa7332cf38b89cf
93
- [88faf33]:../../commit/88faf333e35787b53a8988f8a42647e5fde4bfdc
94
144
 
95
145
  ## 1.0.5 - 2024-12-09
96
146
 
@@ -109,7 +159,6 @@ All notable changes to this project will be documented in this file.
109
159
  - *(infra)* :hammer: add vscode conventional commit scopes [<sup>(84e7ca5)</sup>][84e7ca5]
110
160
  - *(infra)* :hammer: add vscode conventional commit scopes [<sup>(5979eed)</sup>][5979eed]
111
161
  - *(infra)* :hammer: add release-it config [<sup>(639b8bb)</sup>][639b8bb]
112
- - Release 1.0.5 [<sup>(462ee69)</sup>][462ee69]
113
162
 
114
163
  <!-- LINKS -->
115
164
  [6bb0ba6]:../../commit/6bb0ba6fcca63f56f44808eff220eda86579ce85
@@ -117,24 +166,11 @@ All notable changes to this project will be documented in this file.
117
166
  [5979eed]:../../commit/5979eed216a65ef6faa733bf71d2a5f47ffb708b
118
167
  [639b8bb]:../../commit/639b8bb2122be6c4d7a83267c516636458d1743c
119
168
  [12729bd]:../../commit/12729bd019abd9219e6cb3eeda040fc90e836228
120
- [462ee69]:../../commit/462ee6964edfa65a224b1cc56f1f7cc15fdc600a
121
169
 
122
170
  ## 1.0.4 - 2024-10-03
123
171
 
124
172
  [v1.0.3...v1.0.4](../../compare/v1.0.3...v1.0.4)
125
173
 
126
- <!-- LINKS -->
127
- [bc39b3e]:../../commit/bc39b3e006b19b68acd7deb3b30a8be93b50a52b
128
-
129
174
  ## 1.0.3 - 2024-10-03
130
175
 
131
-
132
- <!-- LINKS -->
133
- [9ae79ca]:../../commit/9ae79caa43c647f21aee76bab842286e1b9b10ff
134
- [1d768b4]:../../commit/1d768b473316daacb557b0cbe8a25ab69f6c7f94
135
- [c33840f]:../../commit/c33840f3acdee816ec75861bc7d96c9b9497579d
136
- [dd9c730]:../../commit/dd9c73025a7e2fc9f07766dd76e67a85eafe4c1c
137
- [5b23c45]:../../commit/5b23c45d8ee2ce2a051a99295c8701e1c747ec8f
138
- [d44b8c0]:../../commit/d44b8c0a12b30f9b4d8f15f89a1ee80150d147cd
139
-
140
176
  <!-- generated by git-cliff -->
package/cliff.toml CHANGED
@@ -10,6 +10,7 @@ All notable changes to this project will be documented in this file.\n
10
10
  # template for the changelog body
11
11
  # https://keats.github.io/tera/docs/#introduction
12
12
  body = """\
13
+ {% set orig_version = version %}\
13
14
  {% if version %}\
14
15
  ## {{ version | trim_start_matches(pat="v") }} - {{ timestamp | date(format="%Y-%m-%d") }}
15
16
  {% else %}\
@@ -17,7 +18,7 @@ body = """\
17
18
  {% endif %}{% raw %}\n{% endraw %}\
18
19
  {% if previous %}\
19
20
  {% if previous.version and version %}\
20
- [{{ previous.version }}...{{ version }}](../../compare/{{ previous.version }}...{{ version }})
21
+ [{{ previous.version }}...{{ orig_version }}](../../compare/{{ previous.version }}...{{ orig_version }})
21
22
  {% endif %}\
22
23
  {% endif %}\
23
24
  {% for group, commits in commits | group_by(attribute="group") %}
@@ -1,4 +1,4 @@
1
- #!/usr/bin/env bash -l
1
+ #!/bin/bash
2
2
  # ####### Mikes Ultimate Mac OS Developer Disk Cleanup ######
3
3
  # @author Mike Cunneen (https://github.com/cunneen)
4
4
  # @license MIT
@@ -8,7 +8,7 @@
8
8
  # This script will clean up your Mac's disk space. Aggressively.
9
9
  # Currently it searches for (and cleans) the following items:
10
10
  # - MacOS Trash
11
- # - MacOS (User) Library Caches
11
+ # - MacOS (User) Library Caches - ALL OF THEM!
12
12
  # - meteor package cache (shared between projects)
13
13
  # - meteor projects in your development base directory
14
14
  # - node_modules folders in your development base directory
@@ -27,6 +27,16 @@
27
27
  # - Android AVDs
28
28
  # - Homebrew caches
29
29
  # - CocoaPods
30
+ # - GoLang cache
31
+ # - Cargo Caches
32
+ # - MediaAnalysisD cache
33
+ # - MobileSMS temp files
34
+ # - MS Teams temp files
35
+ # - Messages Previews cache
36
+ # - Log files
37
+ # - VSCode Extensions
38
+ # - Expo caches
39
+ # - ~/.cache
30
40
 
31
41
  # ==== CONFIGURATION DEFAULTS - change as needed ====
32
42
  CONFIGFILE="${HOME}/.config/mikes-macos-disk-cleanup.env" # you'll be prompted to create this if it doesn't exist
@@ -133,58 +143,107 @@ source "${DIR}/modules/hints.sh"
133
143
 
134
144
  # CocoaPods
135
145
  source "${DIR}/modules/cocoapods.sh"
136
- cocoapods
137
146
 
138
147
  # remove everything in ~/Library/Caches
139
148
  source "${DIR}/modules/library-caches.sh"
140
- libraryCaches
141
149
 
142
150
  # remove everything from Trash - this sometimes prompts for confirmation
143
151
  source "${DIR}/modules/trash.sh"
144
- trash
145
152
 
146
153
  # meteor
147
154
  source "${DIR}/modules/meteor-builds-and-packages.sh"
148
- meteorBuildsAndPackages
149
155
 
150
156
  # npm cache
151
157
  source "${DIR}/modules/npm-cache.sh"
152
- npmCache
153
158
 
154
159
  # yarn cache
155
160
  source "${DIR}/modules/yarn-cache.sh"
156
- yarnCache
157
161
 
158
162
  # bun cache
159
163
  source "${DIR}/modules/bun-cache.sh"
160
- bunCache
161
164
 
162
165
  # ### XCode ###
163
166
  source "${DIR}/modules/xcode-artifacts.sh"
164
- xcodeArtifacts
165
167
 
166
168
  # Clear shared gradle caches
167
169
  source "${DIR}/modules/gradle-shared.sh"
168
- gradleShared
169
170
 
170
171
  # node_modules folders
171
172
  source "${DIR}/modules/node-modules.sh"
172
- nodeModules
173
173
 
174
174
  # ruby gems
175
175
  source "${DIR}/modules/ruby-gems.sh"
176
- rubyGems
177
176
 
178
177
  # Docker
179
178
  source "${DIR}/modules/docker-files.sh"
180
- dockerFiles
181
179
 
182
180
  # Android projects - remove build folders
183
181
  source "${DIR}/modules/android-build-folders.sh"
184
- androidBuildFolders
185
182
 
186
183
  # Android SDKs
187
184
  source "${DIR}/modules/android-sdk.sh"
185
+
186
+ # Android AVDs
187
+ source "${DIR}/modules/android-avd.sh"
188
+
189
+ # Homebrew Caches
190
+ source "${DIR}/modules/homebrew-caches.sh"
191
+
192
+ # Golang Caches
193
+ source "${DIR}/modules/golang-cache.sh"
194
+
195
+ # Cargo Caches
196
+ source "${DIR}/modules/cargo-cache.sh"
197
+
198
+ # MediaAnalysisD cache
199
+ source "${DIR}/modules/mediaanalysisd.sh"
200
+
201
+ # MobileSMS temp files
202
+ source "${DIR}/modules/mobilesmstmp.sh"
203
+
204
+ # MS Teams temp files
205
+ source "${DIR}/modules/msteams.sh"
206
+
207
+ # Messages Previews cache
208
+ source "${DIR}/modules/messagespreviews.sh"
209
+
210
+ # Log files
211
+ source "${DIR}/modules/logs.sh"
212
+
213
+ # VSCode Extensions
214
+ source "${DIR}/modules/vscodeextensions.sh"
215
+
216
+ # Expo caches
217
+ source "${DIR}/modules/expo.sh"
218
+
219
+ # ~/.cache
220
+ source "${DIR}/modules/dotcache.sh"
221
+
222
+ # ======
223
+ # Now run all our modules
224
+ cocoapods
225
+ libraryCaches
226
+ trash
227
+ meteorBuildsAndPackages
228
+ npmCache
229
+ yarnCache
230
+ bunCache
231
+ xcodeArtifacts
232
+ gradleShared
233
+ nodeModules
234
+ rubyGems
235
+ dockerFiles
236
+ goCaches
237
+ cargoCaches
238
+ mediaanalysisd
239
+ mobilesmstmp
240
+ msteams
241
+ messagespreviews
242
+ logs
243
+ vscodeextensions
244
+ expo
245
+ dotcache
246
+ androidBuildFolders
188
247
  set +e ; # don't exit on error
189
248
  androidSDK
190
249
  RETCODE=$?
@@ -199,13 +258,7 @@ if [ ${RETCODE} -ne 0 ]; then
199
258
  exit ${RETCODE}
200
259
  fi
201
260
  fi
202
-
203
- # Android AVDs
204
- source "${DIR}/modules/android-avd.sh"
205
261
  androidAVD
206
-
207
- # Homebrew Caches
208
- source "${DIR}/modules/homebrew-caches.sh"
209
262
  homebrewCaches
210
263
 
211
264
  # get the disk usage now that we've run the cleanup
@@ -61,39 +61,51 @@ BEGIN{
61
61
  }
62
62
  lastPath="";
63
63
  lastCat="";
64
+ processedHeading=0;
64
65
  delete itemsToRemove[0]; # initializes a new array
65
66
  itemsToRemoveLength=0; # length of array
66
67
  }
67
68
  /Installed packages:/{
68
69
  inInstalled=1;
69
70
  inObsolete=0;
71
+ processedHeading=0;
70
72
  }
71
73
  /Installed Obsolete Packages:/{
72
74
  inInstalled=0;
73
75
  inObsolete=1;
76
+ processedHeading=0;
74
77
  }
75
- /\;/{
76
- path=$1;
77
- version=$3;
78
- loc=$NF; # last field is location; description has spaces to hard to grab
79
- cat=path;
80
- gsub(/;.+$/,"",cat); # the category is just the first portion of the path before the semicolon e.g. "platforms"
81
- if (inInstalled) {
82
- # If this category is the same as the last one, add the
83
- # previous record to our list of ones to remove (and keep only the most recent).
84
- if (cat == lastCat) {
85
- # add the last category as a new item on the end of our array
78
+ $7 ~ /^-------/ { # this is the end of a heading; move to the next line
79
+ processedHeading=1;
80
+ next;
81
+ }
82
+ $0 ~ /^.+$/ { # non-empty line
83
+ if (processedHeading == 1) {
84
+ path=$1;
85
+ version=$3;
86
+ loc=$NF; # last field is location; description has spaces to hard to grab
87
+ cat=path;
88
+ gsub(/;.+$/,"",cat); # the category is just the first portion of the path before the semicolon e.g. "platforms"
89
+
90
+ if (inInstalled) {
91
+ # If this category is the same as the last one, add the
92
+ # previous record to our list of ones to remove (and keep only the most recent).
93
+ if (cat == lastCat) {
94
+ # add the last category as a new item on the end of our array
95
+ printf("Adding least-recent\"%s\" to itemsToRemove (superceded by \"%s\")\n", lastPath, path);
96
+ itemsToRemoveLength++;
97
+ itemsToRemove[itemsToRemoveLength] = lastPath;
98
+ } else {
99
+ # we're in a category we haven't yet seen (or the output is not sorted and everything will fall apart)
100
+ }
101
+ lastCat = cat;
102
+ lastPath = path;
103
+ } else if (inObsolete) {
104
+ printf("Obsolete: Adding \"%s\" to itemsToRemove\n", path);
105
+ # we'll just add all obsolete packages to the list of items to remove
86
106
  itemsToRemoveLength++;
87
- itemsToRemove[itemsToRemoveLength] = lastPath;
88
- } else {
89
- # we're in a new category
107
+ itemsToRemove[itemsToRemoveLength] = path;
90
108
  }
91
- lastCat = cat;
92
- lastPath = path;
93
- } else if (inObsolete) {
94
- # we'll just add all obsolete packages to the list of items to remove
95
- itemsToRemoveLength++;
96
- itemsToRemove[itemsToRemoveLength] = path;
97
109
  }
98
110
  }
99
111
  END{
@@ -0,0 +1,40 @@
1
+ cargoCaches() {
2
+ # cargo cache
3
+ command -v cargo >/dev/null 2>&1 && {
4
+ if [ -d ${HOME}/.cargo/registry ]; then
5
+ local CARGO_CACHE_SIZE=$(du -hs ${HOME}/.cargo/registry)
6
+ echo "=== removing Cargo registry (${CARGO_CACHE_SIZE}) ==="
7
+ rm -rf ${HOME}/.cargo/registry
8
+ fi
9
+
10
+ # search the development folder for "Cargo.lock" files, and run "cargo clean"
11
+ # where we find them
12
+
13
+ local CARGO_LOCKFILES=$(
14
+ find -E "${DEVELOPMENT_BASE_DIR}" -type f -name Cargo.lock \
15
+ -not -regex "^.*node_modules.+"
16
+ )
17
+ echo " - found cargo lock files; cleaning related 'target' folders..."
18
+ IFS=$'\n' # make newlines the only separator
19
+ local MODULESWERE_REMOVED=0
20
+
21
+ for CARGO_LOCKFILE in ${CARGO_LOCKFILES}; do
22
+ MODULESWERE_REMOVED=1
23
+ local CARGO_FOLDER=$(dirname ${CARGO_LOCKFILE})
24
+ local TARGET="${CARGO_FOLDER}/target"
25
+ if [ -d ${TARGET} ]; then
26
+ local TARGET_SIZE=$(du -hs "${TARGET}" | cut -f1)
27
+ printf " - removing '${TARGET}' (${TARGET_SIZE}) ... "
28
+ rm -rf "${TARGET}"
29
+ echo "done"
30
+ fi
31
+ done
32
+ unset IFS
33
+ if [ ${MODULESWERE_REMOVED} -eq 1 ]; then
34
+ addHint "- You will need to re-run cargo in each of your projects"
35
+ fi
36
+ } || {
37
+ echo "=== 'cargo' command not found; continuing... ==="
38
+
39
+ }
40
+ }
@@ -5,13 +5,21 @@ dockerFiles() {
5
5
  local DOCKER_RUNNING=0;
6
6
  docker version && DOCKER_RUNNING=1 || DOCKER_RUNNING=0;
7
7
  if [ ! $DOCKER_RUNNING == 1 ]; then
8
- echo "======= ERROR: docker daemon not running; skipping docker cleanup ======="
9
- else
8
+
9
+ echo " INFO: docker daemon not running; attempting to start docker desktop ..."
10
+ command docker desktop start >/dev/null 2>&1 && {
11
+ DOCKER_RUNNING=1
12
+ } || {
13
+ echo "======= ERROR: docker daemon not running and couldn't start; skipping docker cleanup ======="
14
+ }
15
+ fi
16
+
17
+ if [ $DOCKER_RUNNING == 1 ]; then
10
18
  echo " BEFORE DOCKER CLEANUP:"
11
19
  docker system df
12
20
  # remove all docker artifacts
13
21
  echo " = removing all docker containers"
14
- docker ps -a -q | xargs -r docker rm force
22
+ docker ps -a -q | xargs -r docker rm -—force
15
23
 
16
24
  echo " = removing all docker images"
17
25
  docker image prune --all --force
@@ -31,6 +39,8 @@ dockerFiles() {
31
39
  docker system df
32
40
 
33
41
  fi
42
+ } || {
43
+ echo "=== 'docker' command not found; continuing... ==="
34
44
  }
35
45
 
36
46
  }
@@ -0,0 +1,8 @@
1
+ dotcache(){
2
+ local CACHEFOLDER="${HOME}/.cache"
3
+ if [ -d "${CACHEFOLDER}" ]; then
4
+ local SIZEBEFORE=$(du -hs "${CACHEFOLDER}" | cut -f1)
5
+ echo "=== removing ${SIZEBEFORE} of ${CACHEFOLDER} ==="
6
+ rm -rf "${CACHEFOLDER}"
7
+ fi
8
+ }
@@ -0,0 +1,14 @@
1
+ expo(){
2
+ local CACHEFOLDER="${HOME}/.expo/ios-simulator-app-cache"
3
+ if [ -d "${CACHEFOLDER}" ]; then
4
+ local SIZEBEFORE=$(du -hs "${CACHEFOLDER}" | cut -f1)
5
+ echo "=== removing ${SIZEBEFORE} of Expo iOS Simulator App caches ==="
6
+ rm -rf "${CACHEFOLDER}"
7
+ fi
8
+ CACHEFOLDER="${HOME}/.expo/android-apk-cache"
9
+ if [ -d "${CACHEFOLDER}" ]; then
10
+ local SIZEBEFORE=$(du -hs "${CACHEFOLDER}" | cut -f1)
11
+ echo "=== removing ${SIZEBEFORE} of Expo Android APK caches ==="
12
+ rm -rf "${CACHEFOLDER}"
13
+ fi
14
+ }
@@ -0,0 +1,23 @@
1
+ goCaches() {
2
+ # go cache
3
+ command -v go >/dev/null 2>&1 && {
4
+ # Go Build Cache
5
+ local GOBUILD_CACHE=$(go env GOCACHE);
6
+ # Go module download cache
7
+ local GOMOD_CACHE=$(go env GOMODCACHE);
8
+
9
+ if [ -d "${GOBUILD_CACHE}" ]; then
10
+ local GOBUILD_CACHE_SIZE=$(du -hs ${GOBUILD_CACHE});
11
+ echo "=== removing Go Build Cache (${GOBUILD_CACHE_SIZE}) ==="
12
+ go clean -cache
13
+ fi
14
+
15
+ if [ -d "${GOMOD_CACHE}" ]; then
16
+ local GOMOD_CACHE_SIZE=$(du -hs ${GOMOD_CACHE});
17
+ echo "=== removing Go Module Cache (${GOMOD_CACHE_SIZE}) ==="
18
+ go clean -modcache
19
+ fi
20
+ } || {
21
+ echo "=== 'go' command not found; continuing... ==="
22
+ }
23
+ }
@@ -25,7 +25,6 @@ homebrewCaches(){
25
25
  local SIZEAFTER=$(du -hs ${HOME}/Library/Caches/Homebrew | cut -f1)
26
26
  echo " cache size before: ${SIZEBEFORE}; after: ${SIZEAFTER}"
27
27
  } || {
28
- echo "brew command not found"
29
- return 1;
28
+ echo "=== 'brew' command not found; continuing... ==="
30
29
  }
31
30
  }
@@ -0,0 +1,138 @@
1
+ # Usage:
2
+ # export CACHEPATH=$(realpath $HOME/Library/Caches );
3
+ # lsof -w -b +c 32 -n | awk -v CACHEPATH=$CACHEPATH -f library-caches-lsof-output.awk
4
+
5
+ function getProcessNames(retString) {
6
+ for(proc in processes) {
7
+ if (proc != ""){
8
+ retString=retString""sprintf("%s:", proc);
9
+ # retString=retString""processes[proc];
10
+ split(processes[proc], theseFolders, ";");
11
+ for(folder in theseFolders) {
12
+ if (theseFolders[folder] != "" && (theseFolders[folder] in folderSizes)) {
13
+ retString=retString""sprintf("%s (%'dKB),", theseFolders[folder], folderSizes[theseFolders[folder]]);
14
+ }
15
+ }
16
+ retString=retString"\n";
17
+ }
18
+ }
19
+ return retString;
20
+ }
21
+
22
+ function getCacheFoldersByName(retString) {
23
+ for(cacheFolder in folders) {
24
+ if (cacheFolder != "" && (cacheFolder in folderSizes)) {
25
+ retString=retString""sprintf("%s (%'dKB):", cacheFolder, folderSizes[cacheFolder]);
26
+ retString=retString""folders[cacheFolder];
27
+ # split(folders[cacheFolder], theseProcesses, ";");
28
+ # for(proc in theseProcesses) {
29
+ # if (theseProcesses[proc] != "") {
30
+ # retString=retString""sprintf("%s,", theseProcesses[proc]);
31
+ # }
32
+ # }
33
+ retString=retString"\n";
34
+ }
35
+ }
36
+ return retString;
37
+ }
38
+
39
+ function getCacheFoldersBySize(retString) {
40
+ for(cacheFolder in folders) {
41
+ if (cacheFolder != "" && (cacheFolder in folderSizes)) {
42
+ retString=retString""sprintf("%s (%'dKB)%s:", folderSizes[cacheFolder], folderSizes[cacheFolder], cacheFolder);
43
+ retString=retString""folders[cacheFolder];
44
+ # split(folders[cacheFolder], theseProcesses, ";");
45
+ # for(proc in theseProcesses) {
46
+ # if (theseProcesses[proc] != "") {
47
+ # retString=retString""sprintf("%s,", theseProcesses[proc]);
48
+ # }
49
+ # }
50
+ retString=retString"\n";
51
+ }
52
+ }
53
+ return retString;
54
+ }
55
+
56
+
57
+ BEGIN {
58
+ if (CACHEPATH == "") {
59
+ CACHEPATH=$HOME"/Library/Caches";
60
+ }
61
+ delete processes[0]; # initializes a new array
62
+ delete folders[0]; # initializes a new array
63
+ delete folderSizes[0]; # initializes a new array
64
+ totalSizesOfFoldersInUse = 0;
65
+ }
66
+
67
+ ($9 ~ CACHEPATH) &&
68
+ !($9 ~ "com.apple.") &&
69
+ !($9 ~ "CloudKit") &&
70
+ !($9 ~ "familycircled") &&
71
+ !($9 ~ "GeoServices") {
72
+ pathcopy = $9;
73
+ gsub(CACHEPATH"/", "", pathcopy);
74
+ gsub(/\/.*$/, "", pathcopy);
75
+ processName = $1;
76
+ libraryCacheFolder = pathcopy;
77
+ # printf("%s\t%s\n", processName, libraryCacheFolder);
78
+ if (processName in processes) {
79
+ existingFolderValsString = processes[processName];
80
+ split(existingFolderValsString, existingFolderValsArray, ";");
81
+ recorded = 0;
82
+ for(thisFolderIdx in existingFolderValsArray) {
83
+ if (existingFolderValsArray[thisFolderIdx] == libraryCacheFolder) {
84
+ recorded = 1;
85
+ break;
86
+ }
87
+ }
88
+ if (recorded == 0) {
89
+ processes[processName] = processes[processName]";"libraryCacheFolder;
90
+ }
91
+ } else {
92
+ if (processName != "" && libraryCacheFolder != "") {
93
+ processes[processName]=libraryCacheFolder;
94
+ }
95
+ }
96
+ if (libraryCacheFolder in folders) {
97
+ existingProcessValsString = folders[libraryCacheFolder];
98
+ split(existingProcessValsString, existingProcessValsArray, ";");
99
+ recorded = 0;
100
+ for(thisProcIdx in existingProcessValsArray) {
101
+ if (existingProcessValsArray[thisProcIdx] == processName) {
102
+ recorded = 1;
103
+ break;
104
+ }
105
+ }
106
+ if (recorded == 0) {
107
+ folders[libraryCacheFolder] = folders[libraryCacheFolder]";"processName
108
+ }
109
+ } else {
110
+ if (processName != "" && libraryCacheFolder != "") {
111
+ folders[libraryCacheFolder]=processName;
112
+ # get disk size
113
+ # -ks : summary in kilobytes; -t 5M : threshold of 5MB
114
+ # duCmd = "du -n -x -ks -t 5M "CACHEPATH"/"libraryCacheFolder" 2>/dev/null | cut -f1" ;
115
+ duCmd = "du -n -x -ks "CACHEPATH"/"libraryCacheFolder" 2>/dev/null | cut -f1" ;
116
+ duCmd | getline duOutput;
117
+ close(duCmd);
118
+ folderSizes[libraryCacheFolder] = duOutput;
119
+ totalSizesOfFoldersInUse += duOutput;
120
+ # printf("DUCMD: %s\n", duCmd)
121
+ }
122
+ }
123
+ }
124
+ END {
125
+ printf(" --- PROCESSES USING CACHE FILES: ---\n");
126
+ # printf(getProcessNames()) | "sort";
127
+ # fflush();
128
+ # printf("\n");
129
+ # printf(" --- CACHE FOLDERS IN USE (By NAME): ---\n");
130
+ # printf(getCacheFoldersByName()) | "sort";
131
+ # fflush();
132
+ # printf("\n");
133
+ printf(" --- CACHE FOLDERS IN USE (By SIZE): ---\n");
134
+ printf(getCacheFoldersBySize()) | "sort -rn";
135
+ fflush();
136
+ printf("\n");
137
+ printf (" --- TOTAL SIZE OF FOLDERS IN USE: %s KB\n", totalSizesOfFoldersInUse);
138
+ }
@@ -1,6 +1,31 @@
1
1
  # remove everything in ~/Library/Caches
2
2
  libraryCaches() {
3
- local LIBRARYCACHESIZE=$((du -hs "${HOME}/Library/Caches" | cut -f1 ) || echo "ERROR: COULD NOT RUN 'du'")
4
- echo "=== emptying ~/Library/Caches...(${LIBRARYCACHESIZE}) ==="
5
- rm -rf "${HOME}/Library/Caches" || echo "=== ERROR! COULD NOT empty ~/Library/Caches. Continuing. ==="
3
+ local THISMODULEDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
4
+ local CACHEPATH=$(realpath $HOME/Library/Caches );
5
+ echo "=== emptying ~/Library/Caches... ==="
6
+ # # find files in use
7
+ # lsof -w -b +c 32 -n | \
8
+ # awk -v CACHEPATH=$CACHEPATH \
9
+ # -f ${THISMODULEDIR}/library-caches-lsof-output.awk
10
+
11
+
12
+ local LIBRARYCACHESIZE=$((du -hs "${HOME}/Library/Caches" 2>/dev/null | cut -f1 ) || echo "ERROR: COULD NOT RUN 'du'")
13
+ echo " Library Caches size: ${LIBRARYCACHESIZE}"
14
+
15
+ # now for ~/.cache
16
+ if [ -d ${HOME}/.cache ]; then
17
+ CACHEPATH=$(realpath $HOME/.cache )
18
+ echo "=== emptying ${CACHEPATH}... ==="
19
+ # find files in use
20
+ # lsof -w -b +c 32 -n | \
21
+ # awk -v CACHEPATH=$CACHEPATH \
22
+ # -f ${THISMODULEDIR}/library-caches-lsof-output.awk
23
+
24
+
25
+ LIBRARYCACHESIZE=$((du -hs "${CACHEPATH}" 2>/dev/null | cut -f1 ) || echo "ERROR: COULD NOT RUN 'du'")
26
+ echo " ${CACHEPATH} size: ${LIBRARYCACHESIZE}"
27
+ fi
28
+
29
+ rm -rf "${HOME}/Library/Caches" || echo "=== ERROR! COULD NOT empty ~/Library/Caches. Continuing. ==="
30
+ rm -rf "${HOME}/.cache" || echo "=== ERROR! COULD NOT empty ~/.cache. Continuing. ==="
6
31
  }
@@ -0,0 +1,8 @@
1
+ logs(){
2
+ local CACHEFOLDER="${HOME}/Library/Logs"
3
+ if [ -d "${CACHEFOLDER}" ]; then
4
+ local SIZEBEFORE=$(du -hs "${CACHEFOLDER}" | cut -f1)
5
+ echo "=== removing ${SIZEBEFORE} of Logs ==="
6
+ rm -rf "${CACHEFOLDER}"
7
+ fi
8
+ }
@@ -0,0 +1,8 @@
1
+ mediaanalysisd(){
2
+ local CACHEFOLDER="${HOME}/Library/Containers/com.apple.mediaanalysisd/Data/Library/Caches"
3
+ if [ -d "${CACHEFOLDER}" ]; then
4
+ local SIZEBEFORE=$(du -hs ${HOME}/Library/Containers/com.apple.mediaanalysisd/Data/Library/Caches | cut -f1)
5
+ echo "=== removing ${SIZEBEFORE} from mediaanalysisd Cache ==="
6
+ rm -rf "${CACHEFOLDER}"
7
+ fi
8
+ }
@@ -0,0 +1,9 @@
1
+ messagespreviews(){
2
+ local CACHEFOLDER="${HOME}/Library/Messages/Caches"
3
+ if [ -d "${CACHEFOLDER}" ]; then
4
+
5
+ local SIZEBEFORE=$(du -hs "${CACHEFOLDER}" | cut -f1)
6
+ echo "=== removing ${SIZEBEFORE} from Messages Preview cache ==="
7
+ rm -rf "${CACHEFOLDER}"
8
+ fi
9
+ }
@@ -0,0 +1,8 @@
1
+ mobilesmstmp(){
2
+ local CACHEFOLDER="${HOME}/Library/Containers/com.apple.MobileSMS/Data/tmp"
3
+ if [ -d "${CACHEFOLDER}" ]; then
4
+ local SIZEBEFORE=$(du -hs "${CACHEFOLDER}" | cut -f1)
5
+ echo "=== removing ${SIZEBEFORE} of MobileSMS temp files ==="
6
+ rm -rf "${CACHEFOLDER}"
7
+ fi
8
+ }
@@ -0,0 +1,13 @@
1
+ msteams(){
2
+ local CACHEFOLDER="${HOME}/Library/Containers/com.microsoft.teams2/Data/Library/Application Support/Microsoft/MSTeams/EBWebView"
3
+ if [ -d "${CACHEFOLDER}" ]; then
4
+
5
+ echo "=== removing MS Teams Caches ==="
6
+ local SIZEBEFORE=$(du -hs "${CACHEFOLDER}" | cut -f1)
7
+ echo " SIZE BEFORE: ${SIZEBEFORE}..."
8
+ rm -rf "${CACHEFOLDER}/WV2Profile_tfw/Service Worker/CacheStorage"
9
+ rm -rf "${CACHEFOLDER}/WV2Profile_tfl/Service Worker/CacheStorage"
10
+ local SIZEAFTER=$(du -hs "${CACHEFOLDER}" | cut -f1)
11
+ echo " SIZE AFTER: ${SIZEAFTER}..."
12
+ fi
13
+ }
@@ -19,7 +19,7 @@ rubyGems() {
19
19
  done
20
20
  unset IFS
21
21
  # remove gems
22
- gem cleanup -d
22
+ gem cleanup
23
23
  }
24
24
  }
25
25
 
@@ -41,8 +41,10 @@ rubyGems() {
41
41
 
42
42
  unset IFS
43
43
  rvm use
44
+ addHint "- You might need to reinstall your ruby gems"
45
+ addHint " - e.g. gem install cocoapods"
46
+ } || {
47
+ echo "=== 'rvm' command not found; continuing... ==="
44
48
  }
45
49
 
46
- addHint "- You might need to reinstall your ruby gems"
47
- addHint " - e.g. gem install cocoapods"
48
50
  }
@@ -0,0 +1,9 @@
1
+ vscodeextensions(){
2
+ local CACHEFOLDER="${HOME}/.vscode/extensions"
3
+ if [ -d "${CACHEFOLDER}" ]; then
4
+
5
+ local SIZEBEFORE=$(du -hs "${CACHEFOLDER}" | cut -f1)
6
+ echo "=== removing $SIZEBEFORE of VSCode extensions ==="
7
+ rm -rf "${CACHEFOLDER}"
8
+ fi
9
+ }
@@ -1,45 +1,57 @@
1
1
  xcodeArtifacts() {
2
+ local DEVELOPERDIR="${HOME}/Library/Developer"
2
3
  # ### XCode ###
3
- if [ -d ${HOME}/Library/Developer/Xcode ]; then
4
+ if [ -d ${DEVELOPERDIR}/Xcode ]; then
4
5
  echo "=== clearing Xcode folders ==="
5
6
 
6
7
  # Xcode DerivedData
7
- if [ -d ${HOME}/Library/Developer/Xcode/DerivedData ]; then
8
- local XCDDSIZE=$(du -hs ${HOME}/Library/Developer/Xcode/DerivedData | cut -f1)
8
+ local DERIVEDDATADIR="${DEVELOPERDIR}/Xcode/DerivedData"
9
+ if [ -d "${DERIVEDDATADIR}" ]; then
10
+ local XCDDSIZE=$(du -hs "${DERIVEDDATADIR}" | cut -f1)
9
11
  echo " removing Xcode DerivedData(${XCDDSIZE})..."
10
- rm -rf ${HOME}/Library/Developer/Xcode/DerivedData
12
+ rm -rf "${DERIVEDDATADIR}"
11
13
  fi
12
14
 
13
15
  # Xcode DeviceLogs
14
- if [ -d ${HOME}/Library/Developer/Xcode/DeviceLogs ]; then
15
- local XCDLSIZE=$(du -hs ${HOME}/Library/Developer/Xcode/DeviceLogs | cut -f1)
16
+ local DEVICELOGDIR="${DEVELOPERDIR}/Xcode/DeviceLogs"
17
+ if [ -d "${DEVICELOGDIR}" ]; then
18
+ local XCDLSIZE=$(du -hs "${DEVICELOGDIR}" | cut -f1)
16
19
  echo " removing Xcode DeviceLogs (${XCDLSIZE})..."
17
- rm -rf ${HOME}/Library/Developer/Xcode/DeviceLogs
20
+ rm -rf "${DEVICELOGDIR}"
18
21
  fi
19
22
 
20
23
  # Xcode DeviceLogs
21
- if [ -d ${HOME}/Library/Developer/CoreSimulator/Caches ]; then
22
- local XCCACHESIZE=$(du -hs ${HOME}/Library/Developer/CoreSimulator/Caches | cut -f1)
24
+ local SIMULATORCACHEDIR="${DEVELOPERDIR}/CoreSimulator/Caches"
25
+ if [ -d "${SIMULATORCACHEDIR}" ]; then
26
+ local XCCACHESIZE=$(du -hs "${SIMULATORCACHEDIR}" | cut -f1)
23
27
  echo " removing Xcode CoreSimulator Caches (${XCCACHESIZE})..."
24
- rm -rf ${HOME}/Library/Developer/CoreSimulator/Caches
28
+ rm -rf "${SIMULATORCACHEDIR}"
25
29
  fi
26
30
 
27
31
  # iOS device support files
28
- if [ -d "${HOME}/Library/Developer/Xcode/iOS DeviceSupport" ]; then
32
+ local DEVICESUPPORTDIR="${DEVELOPERDIR}/Xcode/iOS DeviceSupport"
33
+ if [ -d "${DEVICESUPPORTDIR}" ]; then
29
34
  # display commands to remove iOS device support files (but don't actually remove);
30
35
  # e.g. this would display something like:
31
36
  # - This command would recover 3812 megabytes:
32
37
  # rm -rf "/Users/me/Library/Developer/Xcode/iOS DeviceSupport/iPhone12,8 17.6.1 (21G93)"
33
38
  local DEVICESUPPORTCOMMAND=$(
34
- du -hs "${HOME}/Library/Developer/Xcode/iOS DeviceSupport/"* |
39
+ du -hs "${DEVICESUPPORTDIR}"/* |
35
40
  awk '{\
36
- r=$0;\
37
- gsub(/^[^[:space:]]+[[:space:]]+/,"",r);\
38
- printf("- This command would recover an additional %s:\n rm -rf \"%s\"\n",$1, r);\
39
- }'
41
+ r=$0;\
42
+ gsub(/^[^[:space:]]+[[:space:]]+/,"",r);\
43
+ printf("- This command would recover an additional %s:\n rm -rf \"%s\"\n",$1, r);\
44
+ }'
40
45
  )
41
46
  echo "${DEVICESUPPORTCOMMAND}"
42
47
  addHint "${DEVICESUPPORTCOMMAND}"
43
48
  fi
49
+
50
+ echo " removing unavailable simulator devices..."
51
+ xcrun simctl delete unavailable
52
+
53
+ echo " removing all but the most recent iOS simulator runtime..."
54
+ xcrun simctl runtime list | grep -E '^iOS' | sort -r -n -k 2 | awk 'NR>1{print $5}' | xargs -I{} xcrun simctl runtime delete {}
55
+
44
56
  fi # xcode
45
57
  }
@@ -1,9 +1,17 @@
1
1
  yarnCache() {
2
2
  # yarn cache
3
3
  command -v yarn >/dev/null 2>&1 && {
4
+ yarn set version classic
4
5
  local YARNCACHEDIR=$(yarn cache dir)
5
6
  local YARNSIZE=$(du -hs ${YARNCACHEDIR} | cut -f1)
6
- echo "=== removing yarn cache ${YARNCACHEDIR} (${YARNSIZE}) ==="
7
+ echo "=== removing yarn 'classic' cache ${YARNCACHEDIR} (${YARNSIZE}) ==="
7
8
  yarn cache clean
9
+ yarn set version berry
10
+ YARNCACHEDIR=$(yarn config get cacheFolder)
11
+ YARNSIZE=$(du -hs ${YARNCACHEDIR} | cut -f1)
12
+ echo "=== removing yarn 'berry' cache ${YARNCACHEDIR} (${YARNSIZE}) ==="
13
+ yarn cache clean
14
+ } || {
15
+ echo "=== 'yarn' command not found; continuing... ==="
8
16
  }
9
17
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mikes-macos-developer-disk-cleanup",
3
- "version": "1.0.9",
3
+ "version": "1.0.11",
4
4
  "description": "Cleans up a developer's mac disk space. Aggressively.",
5
5
  "bin": {
6
6
  "mikes-macos-disk-cleanup": "mikes-macos-disk-cleanup.sh"