|
| 1 | +#!/bin/bash |
| 2 | + |
| 3 | +# Copyright (c) 2015-present, Microsoft Inc. |
| 4 | +# All rights reserved. |
| 5 | +# |
| 6 | +# This source code is licensed under the BSD-style license found in the |
| 7 | +# LICENSE file in the root directory of this source tree. An additional grant |
| 8 | +# of patent rights can be found in the PATENTS file in the same directory. |
| 9 | + |
| 10 | +echo 'CodePush + RN sample app generation script'; |
| 11 | +echo |
| 12 | + |
| 13 | +rm -rf testapp_rn |
| 14 | + |
| 15 | +echo '************************ Configuration ***********************************'; |
| 16 | + |
| 17 | +#################### Configure versions ################################################# |
| 18 | + |
| 19 | +read -p "Enter React Native version (default: latest):" react_native_version |
| 20 | +read -p "Enter CodePush version (default: latest): " react_native_code_push_version |
| 21 | + |
| 22 | +echo |
| 23 | + |
| 24 | +if [ ! $react_native_version]; then |
| 25 | + react_native_version=`npm view react-native version` |
| 26 | +fi |
| 27 | +echo 'React Native version: ' + $react_native_version |
| 28 | + |
| 29 | +if [ ! $react_native_code_push_version ]; then |
| 30 | + react_native_code_push_version=`npm view react-native-code-push version` |
| 31 | +fi |
| 32 | +echo 'React Native Code Push version: ' + $react_native_code_push_version |
| 33 | +echo |
| 34 | + |
| 35 | +#################### Create app ######################################################### |
| 36 | + |
| 37 | +echo '********************* Creating app ***************************************'; |
| 38 | + |
| 39 | +current_dir=`pwd`; |
| 40 | +echo 'Current directory: ' + $current_dir; |
| 41 | + |
| 42 | +echo 'Create testapp_rn app'; |
| 43 | +rninit init testapp_rn --source react-native@$react_native_version |
| 44 | + |
| 45 | +cd testapp_rn |
| 46 | + |
| 47 | +echo 'Install React Native Code Push Version $react_native_code_push_version' |
| 48 | +npm install --save react-native-code-push@$react_native_code_push_version |
| 49 | + |
| 50 | +echo 'react native link to react native code push' |
| 51 | +react-native link react-native-code-push |
| 52 | + |
| 53 | +rm index.android.js |
| 54 | +rm index.ios.js |
| 55 | +cp ../CodePushDemoApp/*js . |
| 56 | +mkdir images |
| 57 | +cp ../CodePushDemoApp/images/* images |
| 58 | + |
| 59 | +# Make changes required to test CodePush in debug mode (see OneNote) |
| 60 | +sed -ie '162s/AppRegistry.registerComponent("CodePushDemoApp", () => CodePushDemoApp);/AppRegistry.registerComponent("testapp_rn", () => CodePushDemoApp);/' demo.js |
| 61 | +perl -i -p0e 's/#ifdef DEBUG.*?#endif/jsCodeLocation = [CodePush bundleURL];/s' ios/testapp_rn/AppDelegate.m |
| 62 | +sed -ie '17,20d' node_modules/react-native/packager/react-native-xcode.sh |
| 63 | +sed -ie '90s/targetName.toLowerCase().contains("release")/true/' node_modules/react-native/react.gradle |
0 commit comments