diff --git a/README.md b/README.md index 68a6ed8..53173c8 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/android/build.gradle b/android/build.gradle index 3b60165..367c5c4 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -42,7 +42,7 @@ allprojects { ext { googlePlayServicesVersion = "+" // default: "+" - firebaseMessagingVersion = "+" // default: "+" + firebaseMessagingVersion = "21.1.0" // default: "+" buildToolsVersion = "29.0.3" minSdkVersion = 23 diff --git a/android/gradle/wrapper/gradle-wrapper.properties b/android/gradle/wrapper/gradle-wrapper.properties index e0c4de3..6623300 100644 --- a/android/gradle/wrapper/gradle-wrapper.properties +++ b/android/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ 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 diff --git a/scripts/clear-android.sh b/scripts/clear-android.sh new file mode 100644 index 0000000..8c3659e --- /dev/null +++ b/scripts/clear-android.sh @@ -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" diff --git a/scripts/clear-cache.sh b/scripts/clear-cache.sh new file mode 100644 index 0000000..449fdbf --- /dev/null +++ b/scripts/clear-cache.sh @@ -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" diff --git a/scripts/clear-ios.sh b/scripts/clear-ios.sh new file mode 100644 index 0000000..62c8f3c --- /dev/null +++ b/scripts/clear-ios.sh @@ -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" diff --git a/scripts/clear.sh b/scripts/clear.sh index 14d9732..b3b0fc0 100644 --- a/scripts/clear.sh +++ b/scripts/clear.sh @@ -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" diff --git a/scripts/reinstall-project.sh b/scripts/reinstall-project.sh new file mode 100644 index 0000000..d99328c --- /dev/null +++ b/scripts/reinstall-project.sh @@ -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"