-
Notifications
You must be signed in to change notification settings - Fork 57
/
refresh-example.sh
executable file
·63 lines (49 loc) · 2.18 KB
/
refresh-example.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#!/bin/bash
set -e
echo "You should run this from directory where you have cloned the react-native-update-apk repo"
echo "You should only do this when your git working set is completely clean (e.g., git reset --hard)"
echo "You must have already run \`yarn\` in the repository so \`npx react-native\` will work"
echo "This scaffolding refresh has been tested on macOS, if you use it on linux, it might not work"
# Copy the important files out temporarily
if [ -d TEMP ]; then
echo "TEMP directory already exists - we use that to store files while refreshing."
exit 1
else
echo "Saving files to TEMP while refreshing scaffolding..."
mkdir -p TEMP/android/app/src/main/res/xml
mkdir -p TEMP/android/keystores
# This fixes possible build problems with ANDROID_SDK_HOME not specified
cp example/android/local.properties TEMP/android/ || true
# We have to provide File Provider information
cp example/android/app/src/main/AndroidManifest.xml TEMP/android/app/src/main/ || true
cp example/android/app/src/main/res/xml/filepaths.xml TEMP/android/app/src/main/res/xml/ || true
# Our example app is different than the default example app naturally
cp example/App.js TEMP/
cp example/test-version.json TEMP/
# Build is custom - Play services, and if you don't sign with the same key, updates will fail
cp example/android/keystores/debug.keystore* TEMP/android/keystores/ || true
fi
# Purge the old sample
\rm -fr example
# Make the new example
npx react-native init example --skip-install
pushd example
\rm -fr .ruby-version .bundle Gemfile
yarn
yarn add https://github.com/mikehardy/react-native-update-apk.git
yarn add react-native-fs
# sed -i -e $'s/ext {$/ext {\\\n appCompatVersion = "1.3.0"/' android/build.gradle
# rm -f android/build.gradle??
sed -i -e $'s/storeFile file(\'debug.keystore\')/storeFile rootProject.file("keystores\/debug.keystore")/' android/app/build.gradle
rm -f android/app/build.gradle??
# Why is this needed for react-native 0.70.3 ?
echo '*.xcworkspace' >> .gitignore
pushd ios
pod install
popd
# Copy the important files back in
popd
echo "Copying update-apk example files into refreshed example..."
cp -frv TEMP/* example/
# Clean up after ourselves
\rm -fr TEMP