From 6a9c02b56eb41fcba28d55d2672da3a562c4447e Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sat, 25 Apr 2020 19:03:49 +0200 Subject: [PATCH] Composer cleanup --- scripts/_common.sh | 15 ++++++++++----- scripts/install | 4 +--- scripts/upgrade | 4 +--- 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/scripts/_common.sh b/scripts/_common.sh index 2cfd710..d96115d 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -16,7 +16,8 @@ extra_pkg_dependencies="php7.3-mysql php7.3-curl php7.3-simplexml php7.3-gd" # Execute a command with Composer # -# usage: ynh_composer_exec --phpversion=phpversion [--workdir=$final_path] --commands="commands" +# usage: ynh_composer_exec [--phpversion=phpversion] [--workdir=$final_path] --commands="commands" +# | arg: -v, --phpversion - PHP version to use with composer # | arg: -w, --workdir - The directory from where the command will be executed. Default $final_path. # | arg: -c, --commands - Commands to execute. ynh_composer_exec () { @@ -38,18 +39,22 @@ ynh_composer_exec () { # Install and initialize Composer in the given directory # -# usage: ynh_install_composer --phpversion=phpversion [--workdir=$final_path] +# usage: ynh_install_composer [--phpversion=phpversion] [--workdir=$final_path] [--install_args="--optimize-autoloader"] +# | arg: -v, --phpversion - PHP version to use with composer # | arg: -w, --workdir - The directory from where the command will be executed. Default $final_path. +# | arg: -a, --install_args - Additional arguments provided to the composer install. Argument --no-dev already include ynh_install_composer () { # Declare an array to define the options of this helper. - local legacy_args=vw - declare -Ar args_array=( [v]=phpversion= [w]=workdir= ) + local legacy_args=vwa + declare -Ar args_array=( [v]=phpversion= [w]=workdir= [a]=install_args=) local phpversion local workdir + local install_args # Manage arguments with getopts ynh_handle_getopts_args "$@" workdir="${workdir:-$final_path}" phpversion="${phpversion:-7.0}" + install_args="${install_args:-}" curl -sS https://getcomposer.org/installer \ | COMPOSER_HOME="$workdir/.composer" \ @@ -57,7 +62,7 @@ ynh_install_composer () { || ynh_die "Unable to install Composer." # update dependencies to create composer.lock - ynh_composer_exec --phpversion="${phpversion}" --workdir="$workdir" --commands="install --no-dev" \ + ynh_composer_exec --phpversion="${phpversion}" --workdir="$workdir" --commands="install --no-dev $install_args" \ || ynh_die "Unable to update core dependencies with Composer." } diff --git a/scripts/install b/scripts/install index bbc6e88..7a4556b 100644 --- a/scripts/install +++ b/scripts/install @@ -146,9 +146,7 @@ ynh_mysql_connect_as --user=$app --password="$db_pwd" --database=$app < "$final_ ynh_script_progression --message="Installing ampache with composer..." --weight=45 # Install composer -ynh_install_composer --phpversion="7.3" --workdir="$final_path" - -ynh_exec_warn_less ynh_composer_exec --phpversion="7.3" --workdir=$final_path --commands=\"install --prefer-source --no-dev\" +ynh_install_composer --phpversion="7.3" --workdir="$final_path" --install_args="--prefer-source --no-dev" #================================================= # INSTALL MULTIMEDIA DIRECTORIES diff --git a/scripts/upgrade b/scripts/upgrade index 0a99fad..e5640f9 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -182,10 +182,8 @@ then ynh_script_progression --message="Upgrading ampache with composer..." --weight=30 # Install composer - ynh_install_composer --phpversion="7.3" --workdir="$final_path" - + ynh_install_composer --phpversion="7.3" --workdir="$final_path" --install_args="--prefer-source --no-dev" ynh_composer_exec --phpversion="7.3" --workdir=$final_path --commands="config discard-changes true" - ynh_composer_exec --phpversion="7.3" --workdir=$final_path --commands="update --prefer-source --no-dev" fi #=================================================