From 7d2c7d484492578552ed299a042a78d42057c893 Mon Sep 17 00:00:00 2001 From: Maria Zadnepryanets Date: Mon, 15 Aug 2022 19:01:28 +0000 Subject: [PATCH] Chore/update clear script --- README.md | 2 +- scripts/clear-android.sh | 2 +- scripts/clear-cache.sh | 2 +- scripts/clear-ios.sh | 11 +++++--- scripts/clear.sh | 55 +++++++++++++++++++++--------------- scripts/reinstall-project.sh | 2 +- 6 files changed, 43 insertions(+), 31 deletions(-) diff --git a/README.md b/README.md index 5d75835..3e63360 100644 --- a/README.md +++ b/README.md @@ -127,7 +127,7 @@ If you would like to clear project cache and/or re-install project libraries, yo npm run clear Script accepts the following options: -"none" - script will delete all caches and re-install project libraries, +"all" - script will delete all caches and re-install project libraries, "ios" - script will delete ios-related cache "android" - script will delete android-related cache "cache" - script will purge Watchman, Metrobundler, Pachager and React caches diff --git a/scripts/clear-android.sh b/scripts/clear-android.sh index 8c3659e..6e63c68 100644 --- a/scripts/clear-android.sh +++ b/scripts/clear-android.sh @@ -8,4 +8,4 @@ cd android && ./gradlew clean && cd .. echo "Remove Android build..." rm -rf android/app/build -echo "\x1b[35;01m""Done!""\x1b[39;49;00m" +echo "\x1b[35;01m""Done clearing android cache!""\x1b[39;49;00m" diff --git a/scripts/clear-cache.sh b/scripts/clear-cache.sh index 449fdbf..069e3d5 100644 --- a/scripts/clear-cache.sh +++ b/scripts/clear-cache.sh @@ -14,4 +14,4 @@ rm -rf $TMPDIR/haste-map-react-native-packager-* echo "Remove Metro bundler temp data..." rm -rf $TMPDIR/metro-* -echo "\x1b[35;01m""Done!""\x1b[39;49;00m" +echo "\x1b[35;01m""Done clearing general cache!""\x1b[39;49;00m" diff --git a/scripts/clear-ios.sh b/scripts/clear-ios.sh index 62c8f3c..b198d26 100644 --- a/scripts/clear-ios.sh +++ b/scripts/clear-ios.sh @@ -1,6 +1,6 @@ #!/bin/bash -echo "\x1b[35;01m""Start clearing ios cache...""\x1b[39;49;00m" +echo "\x1b[35;01m""Start clearing iOS cache...""\x1b[39;49;00m" echo "Remove all Xcode derived data..." rm -rf ~/Library/Developer/Xcode/DerivedData @@ -14,8 +14,8 @@ rm -rf ios/Pods/* echo "Remove Podfile.lock..." rm Podfile.lock -echo "Wipe iOS build artifacts..." -rm -rf ios/build && (killall Xcode || true) && xcrun -k && cd ios && xcodebuild -alltargets clean && cd .. && rm -rf "$(getconf DARWIN_USER_CACHE_DIR)/org.llvm.clang/ModuleCache" && rm -rf "$(getconf DARWIN_USER_CACHE_DIR)/org.llvm.clang.$(whoami)/ModuleCache" && rm -fr ~/Library/Developer/Xcode/DerivedData/ && rm -fr ~/Library/Caches/com.apple.dt.Xcode/ +echo "Close XCode and wipe iOS build artifacts..." +(killall Xcode || true) && xcrun -k && cd ios && xcodebuild -alltargets clean && cd .. && rm -rf "$(getconf DARWIN_USER_CACHE_DIR)/org.llvm.clang/ModuleCache" && rm -rf "$(getconf DARWIN_USER_CACHE_DIR)/org.llvm.clang.$(whoami)/ModuleCache" && rm -fr ~/Library/Developer/Xcode/DerivedData/ && rm -fr ~/Library/Caches/com.apple.dt.Xcode/ echo "Wipe system iOS Pods cache..." pod cache clean --all @@ -23,4 +23,7 @@ pod cache clean --all echo "Wipe user iOS Pods cocoapods cache..." rm -rf ~/.cocoapods -echo "\x1b[35;01m""Done!""\x1b[39;49;00m" +echo "Pods install..." +cd ios && pod install && cd .. + +echo "\x1b[35;01m""Done clearing iOS cache!""\x1b[39;49;00m" diff --git a/scripts/clear.sh b/scripts/clear.sh index b3b0fc0..e1dd8aa 100644 --- a/scripts/clear.sh +++ b/scripts/clear.sh @@ -10,22 +10,31 @@ then exit fi + echo "\x1b[35;01m""Do you want to clear general cache(y/n)?""\x1b[39;49;00m" + read cache + + echo "\x1b[35;01m""Do you want to re-install project libraries(y/n)?""\x1b[39;49;00m" + read libraries + echo "\x1b[35;01m""Do you want to clear ios project(y/n)?""\x1b[39;49;00m" read ios echo "\x1b[35;01m""Do you want to clear android project(y/n)?""\x1b[39;49;00m" read android - echo "\x1b[35;01m""Do you want to clear general cache(y/n)?""\x1b[39;49;00m" - read cache - - echo "\x1b[35;01m""Do you want to re-install project libraries?""\x1b[39;49;00m" - read libraries else while [[ $# -gt 0 ]]; do key="$1" case $key in + cache) + cache="y" + shift + ;; + npm) + libraries="y" + shift + ;; ios) ios="y" shift @@ -34,11 +43,10 @@ else android="y" shift ;; - cache) + all) + ios="y" + android="y" cache="y" - shift - ;; - npm) libraries="y" shift ;; @@ -49,29 +57,30 @@ else done fi -echo "ios " $ios -echo "android " $android +echo "\x1b[35;01m""Clearing of the following components is starting...""\x1b[39;49;00m" echo "cache " $cache echo "npm " $libraries - -if [[ $ios == "y" ]] || [[ $1 == "all" ]]; -then - . scripts/clear-ios.sh -fi - -if [[ $android == "y" ]] || [[ $1 == "all" ]]; -then - . scripts/clear-android.sh -fi +echo "ios " $ios +echo "android " $android if [[ $cache == "y" ]] || [[ $1 == "all" ]]; then - . scripts/clear-cache.sh + . scripts/clear-cache.sh || true fi if [[ $libraries == "y" ]] || [[ $1 == "all" ]]; then - . scripts/reinstall-project.sh + . scripts/reinstall-project.sh || true +fi + +if [[ $ios == "y" ]] || [[ $1 == "all" ]]; +then + . scripts/clear-ios.sh || true +fi + +if [[ $android == "y" ]] || [[ $1 == "all" ]]; +then + . scripts/clear-android.sh || true fi echo "\x1b[35;01m""Clearing is completed. You're ready to go!""\x1b[39;49;00m" diff --git a/scripts/reinstall-project.sh b/scripts/reinstall-project.sh index d99328c..dcacc3b 100644 --- a/scripts/reinstall-project.sh +++ b/scripts/reinstall-project.sh @@ -14,4 +14,4 @@ npm install echo "Pods install..." cd ios && pod install && cd .. -echo "\x1b[35;01m""Done!""\x1b[39;49;00m" +echo "\x1b[35;01m""Done re-installing dependencies!""\x1b[39;49;00m"