diff --git a/.gitignore b/.gitignore index 9f7d0a26c..c0d6d3831 100755 --- a/.gitignore +++ b/.gitignore @@ -186,3 +186,6 @@ ipch/ [Dd]ebug*/ [Rr]elease*/ Ankh.NoLoad + +# RN New Version App Generation +Examples/testapp_rn \ No newline at end of file diff --git a/Examples/CodePushDemoApp/demo.js b/Examples/CodePushDemoApp/demo.js index 22ca5ee8a..1a66d1f71 100644 --- a/Examples/CodePushDemoApp/demo.js +++ b/Examples/CodePushDemoApp/demo.js @@ -11,12 +11,6 @@ import { import CodePush from "react-native-code-push"; -/** - * Configured with a MANUAL check frequency for easy testing. For production apps, it is recommended to configure a - * different check frequency, such as ON_APP_START, for a 'hands-off' approach where CodePush.sync() does not - * need to be explicitly called. All options of CodePush.sync() are also available in this decorator. - */ -@CodePush({ checkFrequency: CodePush.CheckFrequency.MANUAL }) class CodePushDemoApp extends Component { constructor() { super(); @@ -156,4 +150,13 @@ const styles = StyleSheet.create({ }, }); -AppRegistry.registerComponent("CodePushDemoApp", () => CodePushDemoApp); +/** + * Configured with a MANUAL check frequency for easy testing. For production apps, it is recommended to configure a + * different check frequency, such as ON_APP_START, for a 'hands-off' approach where CodePush.sync() does not + * need to be explicitly called. All options of CodePush.sync() are also available in this decorator. + */ +let codePushOptions = { checkFrequency: CodePush.CheckFrequency.MANUAL }; + +CodePushDemoApp = CodePush(codePushOptions)(CodePushDemoApp); + +AppRegistry.registerComponent("CodePushDemoApp", () => CodePushDemoApp); \ No newline at end of file diff --git a/Examples/generate-app.sh b/Examples/generate-app.sh new file mode 100755 index 000000000..cbc4ca86c --- /dev/null +++ b/Examples/generate-app.sh @@ -0,0 +1,63 @@ +#!/bin/bash + +# Copyright (c) 2015-present, Microsoft Inc. +# All rights reserved. +# +# This source code is licensed under the BSD-style license found in the +# LICENSE file in the root directory of this source tree. An additional grant +# of patent rights can be found in the PATENTS file in the same directory. + +echo 'CodePush + RN sample app generation script'; +echo + +rm -rf testapp_rn + +echo '************************ Configuration ***********************************'; + +#################### Configure versions ################################################# + +read -p "Enter React Native version (default: latest):" react_native_version +read -p "Enter CodePush version (default: latest): " react_native_code_push_version + +echo + +if [ ! $react_native_version]; then + react_native_version=`npm view react-native version` +fi +echo 'React Native version: ' + $react_native_version + +if [ ! $react_native_code_push_version ]; then + react_native_code_push_version=`npm view react-native-code-push version` +fi +echo 'React Native Code Push version: ' + $react_native_code_push_version +echo + +#################### Create app ######################################################### + +echo '********************* Creating app ***************************************'; + +current_dir=`pwd`; +echo 'Current directory: ' + $current_dir; + +echo 'Create testapp_rn app'; +rninit init testapp_rn --source react-native@$react_native_version + +cd testapp_rn + +echo 'Install React Native Code Push Version $react_native_code_push_version' +npm install --save react-native-code-push@$react_native_code_push_version + +echo 'react native link to react native code push' +react-native link react-native-code-push + +rm index.android.js +rm index.ios.js +cp ../CodePushDemoApp/*js . +mkdir images +cp ../CodePushDemoApp/images/* images + +# Make changes required to test CodePush in debug mode (see OneNote) +sed -ie '162s/AppRegistry.registerComponent("CodePushDemoApp", () => CodePushDemoApp);/AppRegistry.registerComponent("testapp_rn", () => CodePushDemoApp);/' demo.js +perl -i -p0e 's/#ifdef DEBUG.*?#endif/jsCodeLocation = [CodePush bundleURL];/s' ios/testapp_rn/AppDelegate.m +sed -ie '17,20d' node_modules/react-native/packager/react-native-xcode.sh +sed -ie '90s/targetName.toLowerCase().contains("release")/true/' node_modules/react-native/react.gradle