Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- platform=$(uname)
- SCRIPT_NAME=$(basename $0)
- SCRIPT_DIR=$(cd $(dirname $0);pwd)
- cd ${SCRIPT_DIR}
- error_exit()
- {
- echo "$SCRIPT_NAME:Fatal Failure in ${FUNCNAME[1]}:${BASH_LINENO[0]}: $*"
- exit -1
- }
- error_trap_exit()
- {
- errorno=$?
- echo "$SCRIPT_NAME:ERR trapped at line #${BASH_LINENO[0]}: \$?=$errorno"
- exit $errorno
- }
- trap error_trap_exit ERR
- if ! which cordova >/dev/null;then
- echo "cordova not found, make sure you've installed cordova."
- exit 1
- fi
- npm install
- if [ "$1" == "clean" ];then
- rm -rf plugins merges platforms
- fi
- mkdir -p plugins merges platforms
- if [ "$platform" == "Darwin" ];then # mac
- PLATFORMS=(android ios)
- else # all others only support android
- PLATFORMS=(android)
- fi
- #################################################################################
- # install or update cordova platforms as needed
- #################################################################################
- rm -f platform_list.tmp
- cordova platform list | grep Installed | awk -F: '{ print $2 }' | tr , '\n' >platform_list.tmp
- for i in ${PLATFORMS[@]};do
- line=$(grep $i platform_list.tmp || echo -n) # the echo after the || is to surpess error returned by grep if string not found
- if [ -z "$line" ];then
- echo "adding cordova platform ${i}"
- cordova platform add ${i}
- else
- platform_version=$(echo $line | awk '{ print $2 }')
- cordova_version=$(cordova -v | awk -F- '{ print $1}')
- if [ "$platform_version" != "$cordova_version" ];then
- echo "updating cordova platform ${i}"
- cordova platform up ${i}
- fi
- fi
- done
- #################################################################################
- rm -f platform_list.tmp
- #################################################################################
- # install any plugins that are needed
- #################################################################################
- if [ ! -d plugins/de.appplant.cordova.plugin.email-composer ];then
- cordova plugin add https://github.com/katzer/cordova-plugin-email-composer.git
- fi
- #################################################################################
- echo "Adding Splash screens"
- if [ "$platform" == "Darwin" ];then # mac
- cp www/img/screens/ios/* platforms/ios/TestApp/Resources/splash/
- fi
- cp www/img/screens/android/screen-xhdpi-landscape.png platforms/android/res/drawable-land-xhdpi/screen.png
- cp www/img/screens/android/screen-hdpi-landscape.png platforms/android/res/drawable-land-hdpi/screen.png
- cp www/img/screens/android/screen-mdpi-landscape.png platforms/android/res/drawable-land-mdpi/screen.png
- cp www/img/screens/android/screen-ldpi-landscape.png platforms/android/res/drawable-land-ldpi/screen.png
- cp www/img/screens/android/screen-xhdpi-portrait.png platforms/android/res/drawable-port-xhdpi/screen.png
- cp www/img/screens/android/screen-hdpi-portrait.png platforms/android/res/drawable-port-hdpi/screen.png
- cp www/img/screens/android/screen-mdpi-portrait.png platforms/android/res/drawable-port-mdpi/screen.png
- cp www/img/screens/android/screen-ldpi-portrait.png platforms/android/res/drawable-port-ldpi/screen.png
- echo "Cordova project setup successful."
Advertisement
Add Comment
Please, Sign In to add comment