2018-10-31 11:35:03 +03:00
#!/bin/bash
# Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
2016-01-05 19:59:43 +03:00
RED = "\033[0;31m"
GREEN = "\033[0;32m"
BLUE = "\033[0;35m"
ENDCOLOR = "\033[0m"
error( ) {
2018-09-29 03:00:18 +03:00
echo -e " $RED " " $* " " $ENDCOLOR "
2016-01-05 19:59:43 +03:00
exit 1
}
success( ) {
2018-09-29 03:00:18 +03:00
echo -e " $GREEN " " $* " " $ENDCOLOR "
2016-01-05 19:59:43 +03:00
}
info( ) {
2018-09-29 03:00:18 +03:00
echo -e " $BLUE " " $* " " $ENDCOLOR "
2016-01-05 19:59:43 +03:00
}
2016-03-24 15:30:49 +03:00
repo_root = $( pwd )
2016-01-05 19:59:43 +03:00
2016-06-21 15:18:02 +03:00
rm -rf android
2016-03-15 19:21:50 +03:00
./gradlew :ReactAndroid:installArchives || error "Couldn't generate artifacts"
2016-01-05 19:59:43 +03:00
success "Generated artifacts for Maven"
2021-06-03 02:59:38 +03:00
yarn
2017-03-30 02:12:39 +03:00
success "Killing any running packagers"
lsof -i :8081 | grep LISTEN
lsof -i :8081 | grep LISTEN | /usr/bin/awk '{print $2}' | xargs kill
info "Start the packager in another terminal by running 'npm start' from the root"
info "and then press any key."
info ""
2021-08-27 00:58:39 +03:00
read -r -n 1
2017-03-30 02:12:39 +03:00
2020-08-20 03:54:30 +03:00
./gradlew :packages:rn-tester:android:app:installJscDebug || error "Couldn't build RNTester Android"
2017-03-30 02:12:39 +03:00
2017-05-06 06:50:47 +03:00
info "Press any key to run RNTester in an already running Android emulator/device"
2017-03-30 02:12:39 +03:00
info ""
2021-08-27 00:58:39 +03:00
read -r -n 1
2017-05-06 06:50:47 +03:00
adb shell am start -n com.facebook.react.uiapp/.RNTesterActivity
2017-03-30 02:12:39 +03:00
2021-08-27 00:58:39 +03:00
info "Once done testing, keep emulator running"
info "Press any key to run RNTester on Android with Hermes enabled"
read -r -n 1
./gradlew :packages:rn-tester:android:app:installHermesDebug || error "Couldn't build RNTester Android"
adb shell am start -n com.facebook.react.uiapp/.RNTesterActivity
info "When done testing RNTester on Android,"
info "Press any key to start testing RNTester in iOS"
read -r -n 1
success "About to test iOS JSC... "
success "Installing CocoaPods dependencies..."
2020-08-20 03:54:30 +03:00
rm -rf packages/rn-tester/Pods
2021-10-02 07:21:03 +03:00
( cd packages/rn-tester && bundle exec pod install)
2020-04-17 03:44:49 +03:00
2019-07-11 21:54:38 +03:00
info "Press any key to open the workspace in Xcode, then build and test manually."
2017-03-30 02:12:39 +03:00
info ""
2021-08-27 00:58:39 +03:00
read -r -n 1
open "packages/rn-tester/RNTesterPods.xcworkspace"
info "When done testing iOS JSC, press any key to test iOS Hermes"
read -r -n 1
success "About to test iOS Hermes... "
success "Installing CocoaPods dependencies..."
rm -rf packages/rn-tester/Pods
2021-10-02 07:21:03 +03:00
( cd packages/rn-tester && USE_HERMES = 1 bundle exec pod install)
2021-08-27 00:58:39 +03:00
info "Press any key to open the workspace in Xcode, then build and test manually."
info ""
read -r -n 1
2020-04-17 03:44:49 +03:00
2020-08-20 03:54:30 +03:00
open "packages/rn-tester/RNTesterPods.xcworkspace"
2017-03-30 02:12:39 +03:00
2017-05-06 06:50:47 +03:00
info "When done testing RNTester app on iOS and Android press any key to continue."
2017-03-30 02:12:39 +03:00
info ""
2021-08-27 00:58:39 +03:00
read -r -n 1
2017-03-30 02:12:39 +03:00
success "Killing packager"
lsof -i :8081 | grep LISTEN
lsof -i :8081 | grep LISTEN | /usr/bin/awk '{print $2}' | xargs kill
2021-10-29 01:46:53 +03:00
# Testing the template app
PACKAGE_VERSION = $( cat package.json \
| grep version \
| head -1 \
| awk -F: '{ print $2 }' \
| sed 's/[",]//g' \
| tr -d '[[:space:]]' )
success " Preparing version $PACKAGE_VERSION "
2016-03-24 15:30:49 +03:00
npm pack
2016-01-05 19:59:43 +03:00
2021-09-15 20:55:47 +03:00
TIMESTAMP = $( date +%s)
PACKAGE = $( pwd ) /react-native-$PACKAGE_VERSION -$TIMESTAMP .tgz
2016-03-24 15:30:49 +03:00
success " Package bundled ( $PACKAGE ) "
2016-01-05 19:59:43 +03:00
2021-09-15 20:55:47 +03:00
mv " $( pwd ) /react-native- $PACKAGE_VERSION .tgz " " $PACKAGE "
2019-04-25 11:58:43 +03:00
node scripts/set-rn-template-version.js " file: $PACKAGE "
success "React Native version changed in the template"
2016-01-05 19:59:43 +03:00
project_name = "RNTestProject"
2021-08-27 00:58:39 +03:00
cd /tmp/ || exit
2016-01-05 19:59:43 +03:00
rm -rf " $project_name "
2019-04-25 11:58:43 +03:00
node " $repo_root /cli.js " init " $project_name " --template " $repo_root "
2016-01-05 21:51:50 +03:00
2016-03-24 15:30:49 +03:00
info "Double checking the versions in package.json are correct:"
2021-09-15 20:55:47 +03:00
grep " \"react-native\": \".*react-native- $PACKAGE_VERSION - $TIMESTAMP .tgz\" " " /tmp/ ${ project_name } /package.json " || error " Incorrect version number in /tmp/ ${ project_name } /package.json "
2016-02-09 19:01:36 +03:00
grep -E "com.facebook.react:react-native:\\+" " ${ project_name } /android/app/build.gradle " || error " Dependency in /tmp/ ${ project_name } /android/app/build.gradle must be com.facebook.react:react-native:+ "
2016-01-05 19:59:43 +03:00
success " New sample project generated at /tmp/ ${ project_name } "
2016-04-18 21:30:51 +03:00
info "Test the following on Android:"
2019-06-24 23:49:01 +03:00
info " - Disable Fast Refresh. It might be enabled from last time (the setting is stored on the device)"
2016-01-05 19:59:43 +03:00
info " - Verify 'Reload JS' works"
info ""
info "Press any key to run the sample in Android emulator/device"
2016-03-24 15:30:49 +03:00
info ""
2021-08-27 00:58:39 +03:00
read -r -n 1
2019-12-20 00:42:21 +03:00
cd " /tmp/ ${ project_name } " && npx react-native run-android
2016-01-05 19:59:43 +03:00
2016-04-18 21:30:51 +03:00
info "Test the following on iOS:"
2019-06-24 23:49:01 +03:00
info " - Disable Fast Refresh. It might be enabled from last time (the setting is stored on the device)"
2016-04-18 21:30:51 +03:00
info " - Verify 'Reload JS' works"
info " - Test Chrome debugger by adding breakpoints and reloading JS. We don't have tests for Chrome debugging."
info " - Disable Chrome debugging."
2019-06-24 23:49:01 +03:00
info " - Enable Fast Refresh, change a file (index.js) and save. The UI should refresh."
info " - Disable Fast Refresh."
2016-04-18 21:30:51 +03:00
info ""
2017-02-28 09:46:00 +03:00
info "Press any key to open the project in Xcode"
2016-03-24 15:30:49 +03:00
info ""
2021-08-27 00:58:39 +03:00
read -r -n 1
2020-04-17 03:44:49 +03:00
open " /tmp/ ${ project_name } /ios/ ${ project_name } .xcworkspace "
2016-01-05 19:59:43 +03:00
2021-08-27 00:58:39 +03:00
cd " $repo_root " || exit
2016-01-05 19:59:43 +03:00
info "Next steps:"
2021-10-25 20:47:11 +03:00
info "https://github.com/facebook/react-native/wiki/Release-Process"