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+ # The goal of this script is to automate the testing of react-native, react-native-code-push and
11+ # their internal compatibility. Run **./run.sh** to create an app and test it.
12+
13+ # You can configure below variables in the bash.
14+
15+ # 1. `code_push_version`
16+ # 2. `react_native_code_push_version`
17+ # 3. `react_native_version`
18+ # 4. `mobile_env`
19+
20+ # If you use other libs or packages, and fail to run this test, welcome to modify this script
21+ # so that we can reproduce any issues that you have.
22+
23+
24+ echo ' Automate synchronization testing between React Native and React Native Code Push' ;
25+ echo
26+
27+ rm -rf testapp_rn
28+
29+ # Please make sure you installed react native in your mac machine
30+
31+ echo ' ************************ Configuration ***********************************' ;
32+
33+ # ################### Code Push Config #########################W#########################
34+
35+ code_push_cli_version=` code-push --version` ;
36+ echo ' Code Push CLI version: ' + ${code_push_cli_version} ;
37+
38+ # ################### React Native Config #################################################
39+
40+ echo " list all react native versions: npm show react-native versions --json"
41+ read -p " Enter react native version, [default] is the latest version:" react_native_version
42+
43+ if [ ! $react_native_version ]; then
44+ react_native_version=` npm view react-native version`
45+ fi
46+ echo ' React Native version: ' + $react_native_version
47+
48+ npm list -g rninit
49+
50+ # ################### React Native Code Push Config ######################################
51+
52+ echo " list all react native versions: npm show react-native-code-push versions --json"
53+ read -p " Enter react native code push version, [default] is the latest version: " react_native_code_push_version
54+
55+ if [ ! $react_native_code_push_version ]; then
56+ react_native_code_push_version=` npm view react-native-code-push version`
57+ fi
58+ echo ' React Native Code Push version: ' + $react_native_code_push_version
59+ echo
60+
61+
62+ # ################### Start Testing #########################################################
63+
64+ echo ' ********************* Yo, start to test ***************************************' ;
65+
66+ current_dir=` pwd` ;
67+ echo ' Current directory: ' + $current_dir ;
68+
69+ echo ' Create testapp_rn app' ;
70+ rninit init testapp_rn --source react-native@$react_native_version
71+
72+ cd testapp_rn
73+
74+ echo ' Install React Native Code Push Version $react_native_code_push_version'
75+ npm install --save react-native-code-push@$react_native_code_push_version
76+
77+ echo ' react native link to react native code push'
78+ react-native link react-native-code-push
79+
80+ rm index.android.js
81+ rm index.ios.js
82+ cp ../CodePushDemoApp/* js .
83+ mkdir images
84+ cp ../CodePushDemoApp/images/* images
85+
86+ echo ' ********************* Running IOS ***************************************' ;
87+
88+ react-native run-ios
89+
90+ echo ' ********************* Running Android ***************************************' ;
91+
92+ read -p " you need to open the android simulator manually before continue running this script. Enter [Enter] to continue"
93+
94+ react-native run-android
95+
96+ # cd ..
97+ # rm -rf testapp
98+ # exit;
0 commit comments