added check_composer.sh

feature/246
Cédric Bonhomme 2020-02-24 14:03:45 +01:00
parent 8bebf629c2
commit 304555d580
No known key found for this signature in database
GPG Key ID: A1CB94DE57B7A70D
2 changed files with 57 additions and 1 deletions

51
scripts/check_composer.sh Normal file
View File

@ -0,0 +1,51 @@
#! /usr/bin/env bash
RED='\033[0;31m'
GREEN='\033[0;32m'
NC='\033[0m' # No Color
vercomp () {
if [[ $1 == $2 ]]
then
return 1
fi
local IFS=.
local i ver1=($1) ver2=($2)
# fill empty fields in ver1 with zeros
for ((i=${#ver1[@]}; i<${#ver2[@]}; i++))
do
ver1[i]=0
done
for ((i=0; i<${#ver1[@]}; i++))
do
if [[ -z ${ver2[i]} ]]
then
# fill empty fields in ver2 with zeros
ver2[i]=0
fi
if ((10#${ver1[i]} > 10#${ver2[i]}))
then
return 1
fi
done
return 0
}
composer_version_string=`composer --version`
composer_version=`echo $composer_version_string | awk 'BEGIN { FS="[ ]" } ; { print $3 }'`
if [[ $(vercomp $composer_version 1.9.0 ; echo $?) -eq 0 ]]; then
echo -e "${RED}Please update your version of composer.${NC} The minimum requirements is 1.9.0."
echo -e "The minimum requirement is 1.9.0. You can use the following to update your composer installation:"
cat << EOF
$ php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
$ php -r "if (hash_file('sha384', 'composer-setup.php') === 'e0012edf3e80b6978849f5eff0d4b4e4c79ff1609dd1e613307e16318854d24ae64f26d17af3ef0bf7cfb710ca74755a') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
$ php composer-setup.php --install-dir=/tmp --filename=composer
$ mv /tmp/composer /usr/local/bin/composer
EOF
exit 1
fi

View File

@ -52,7 +52,12 @@ if [ $? != 0 ]; then
exit 1
fi
composer install -o
./scripts/check_composer.sh
if [[ $? -eq 1 ]]; then
exit 1
fi
composer install -o --no-dev
pathCore="module/Monarc/Core"
pathBO="module/Monarc/BackOffice"