Skip to content
Snippets Groups Projects
Commit 7c70f745 authored by Maria Zadnepryanets's avatar Maria Zadnepryanets
Browse files

Merge branch 'chore/add-react-native-clean-project' into 'master'

Chore: add react native clean project

Closes #431

See merge request bloodyhealth/drip!367
parents 87a68ba9 4fedb192
No related branches found
No related tags found
No related merge requests found
......@@ -97,7 +97,6 @@ $ npm run ios
Make sure that you have Java 1.8 by running `java -version`.
If you don't have Java installed, or your Java version is different, the app may not work. You can try just using Android Studio's Java by prepending it to your `$PATH` in your shell profile:
```
$ export PATH="/Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin:${PATH}"
```
......@@ -116,6 +115,22 @@ If you get error messages about `adb` not being found on your path:
$ ln -s ~/Library/Android/sdk/platform-tools/adb /usr/local/bin/adb
```
### Clearing project cache
If you would like to clear project cache and/or re-install project libraries, you can run clear script as follows:
$ npm run clear
Script accepts the following options:
"none" - 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
"npm" - script will reinstall project libraries.
For example, if you would like to clear android part of the project and re-install project libraries, you can run the following command:
$ npm run clear android npm
## Tests
### Unit tests
......
......@@ -42,7 +42,7 @@ allprojects {
ext {
googlePlayServicesVersion = "+" // default: "+"
firebaseMessagingVersion = "+" // default: "+"
firebaseMessagingVersion = "21.1.0" // default: "+"
buildToolsVersion = "29.0.3"
minSdkVersion = 23
......
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.5-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-6.3-all.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
#!/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"
#!/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"
#!/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"
#!/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"
#!/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"
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment