Chore: add react native clean project

This commit is contained in:
Maria Zadnepryanets
2021-08-15 11:56:09 +00:00
parent 87a68ba9c5
commit 4fedb1928c
8 changed files with 153 additions and 27 deletions
+11
View File
@@ -0,0 +1,11 @@
#!/bin/bash
echo "\x1b[35;01m""Start clearing android cache...""\x1b[39;49;00m"
echo "Clean android project..."
cd android && ./gradlew clean && cd ..
echo "Remove Android build..."
rm -rf android/app/build
echo "\x1b[35;01m""Done!""\x1b[39;49;00m"
+17
View File
@@ -0,0 +1,17 @@
#!/bin/bash
echo "\x1b[35;01m""Start clearing general cache...""\x1b[39;49;00m"
echo "Clear Watchman cache..."
watchman watch-del-all
echo "Remove React temp data..."
rm -rf $TMPDIR/react-*
echo "Remove React Native Packager temp data..."
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"
+26
View File
@@ -0,0 +1,26 @@
#!/bin/bash
echo "\x1b[35;01m""Start clearing ios cache...""\x1b[39;49;00m"
echo "Remove all Xcode derived data..."
rm -rf ~/Library/Developer/Xcode/DerivedData
echo "Remove iOS build..."
rm -rf ios/build
echo "Remove iOS Pods data..."
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 "Wipe system iOS Pods cache..."
pod cache clean --all
echo "Wipe user iOS Pods cocoapods cache..."
rm -rf ~/.cocoapods
echo "\x1b[35;01m""Done!""\x1b[39;49;00m"
+64 -24
View File
@@ -1,37 +1,77 @@
#!/bin/bash
echo "rm -rf ios/build..."
rm -rf ios/build
# if user provided argument all, all caches are cleared
echo "rm -rf android/app/build..."
rm -rf android/app/build
if [[ -z "$1" ]];
then
if [[ -z "$TMPDIR" ]];
then
echo "\x1b[35;01m""Your current TMPDIR variable is not set. Please set it before running the script.""\x1b[39;49;00m"
exit
fi
echo "Removed all Xcode derived data..."
rm -rf ~/Library/Developer/Xcode/DerivedData
echo "\x1b[35;01m""Do you want to clear ios project(y/n)?""\x1b[39;49;00m"
read ios
echo "Removed iOS Pods data..."
rm -rf ios/Pods/*
echo "\x1b[35;01m""Do you want to clear android project(y/n)?""\x1b[39;49;00m"
read android
echo "Removed Podfile.lock..."
rm Podfile.lock
echo "\x1b[35;01m""Do you want to clear general cache(y/n)?""\x1b[39;49;00m"
read cache
echo "watchman watch-del-all..."
watchman watch-del-all
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"
echo "rm -rf node_modules..."
rm -rf node_modules
case $key in
ios)
ios="y"
shift
;;
android)
android="y"
shift
;;
cache)
cache="y"
shift
;;
npm)
libraries="y"
shift
;;
*)
shift
;;
esac
done
fi
echo "npm install..."
npm install
echo "ios " $ios
echo "android " $android
echo "cache " $cache
echo "npm " $libraries
echo "Pods install..."
cd ios && pod install && cd ..
if [[ $ios == "y" ]] || [[ $1 == "all" ]];
then
. scripts/clear-ios.sh
fi
echo "rm -rf $TMPDIR/react-*..."
rm -rf $TMPDIR/react-*
if [[ $android == "y" ]] || [[ $1 == "all" ]];
then
. scripts/clear-android.sh
fi
echo "rm -rf $TMPDIR/haste-map-react-native-packager-*..."
rm -rf $TMPDIR/haste-map-react-native-packager-*
if [[ $cache == "y" ]] || [[ $1 == "all" ]];
then
. scripts/clear-cache.sh
fi
echo "rm -rf $TMPDIR/metro-*..."
rm -rf $TMPDIR/metro-*
if [[ $libraries == "y" ]] || [[ $1 == "all" ]];
then
. scripts/reinstall-project.sh
fi
echo "\x1b[35;01m""Clearing is completed. You're ready to go!""\x1b[39;49;00m"
+17
View File
@@ -0,0 +1,17 @@
#!/bin/bash
echo "\x1b[35;01m""Start re-installing dependencies...""\x1b[39;49;00m"
echo "Remove node_modules..."
rm -rf node_modules
echo "Verify npm cache..."
npm cache verify
echo "Npm install..."
npm install
echo "Pods install..."
cd ios && pod install && cd ..
echo "\x1b[35;01m""Done!""\x1b[39;49;00m"