From bf2aebb9e43632e65b723055f7210f2f0250bbfb Mon Sep 17 00:00:00 2001 From: yalh76 Date: Fri, 29 Mar 2019 00:19:38 +0100 Subject: [PATCH] switch to ynh_install_composer --- scripts/install | 3 ++- scripts/ynh_composer | 44 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+), 1 deletion(-) create mode 100644 scripts/ynh_composer diff --git a/scripts/install b/scripts/install index f53c2fd7..f622f8a2 100644 --- a/scripts/install +++ b/scripts/install @@ -10,6 +10,7 @@ source _common.sh source _pgsql.sh source ynh_install_php source ynh_add_secure_repos__2 +source ynh_composer source /usr/share/yunohost/helpers #================================================= @@ -113,7 +114,7 @@ ynh_add_fpm_config --phpversion=7.2 chown -R "$app": "$final_path" -init_composer "$app" "$final_path" +ynh_install_composer --workdir=$final_path #================================================= # SPECIFIC SETUP diff --git a/scripts/ynh_composer b/scripts/ynh_composer new file mode 100644 index 00000000..3e9cecac --- /dev/null +++ b/scripts/ynh_composer @@ -0,0 +1,44 @@ +#!/bin/bash + +# Execute a command with Composer +# +# usage: ynh_composer_exec [--workdir=$final_path] --commands="commands" +# | arg: -w, --workdir - The directory from where the command will be executed. Default $final_path. +# | arg: -c, --commands - Commands to execute. +ynh_composer_exec () { + # Declare an array to define the options of this helper. + local legacy_args=wc + declare -Ar args_array=( [w]=workdir= [c]=commands= ) + local workdir + local commands + # Manage arguments with getopts + ynh_handle_getopts_args "$@" + workdir="${workdir:-$final_path}" + + COMPOSER_HOME="$workdir/.composer" \ + php "$workdir/composer.phar" $commands \ + -d "$workdir" --quiet --no-interaction +} + +# Install and initialize Composer in the given directory +# +# usage: ynh_install_composer [--workdir=$final_path] +# | arg: -w, --workdir - The directory from where the command will be executed. Default $final_path. +ynh_install_composer () { + # Declare an array to define the options of this helper. + local legacy_args=w + declare -Ar args_array=( [w]=workdir= ) + local workdir + # Manage arguments with getopts + ynh_handle_getopts_args "$@" + workdir="${workdir:-$final_path}" + + curl -sS https://getcomposer.org/installer \ + | COMPOSER_HOME="$workdir/.composer" \ + php -- --quiet --install-dir="$workdir" \ + || ynh_die "Unable to install Composer." + + # update dependencies to create composer.lock + ynh_composer_exec --workdir="$workdir" --commands="install --no-dev" \ + || ynh_die "Unable to update core dependencies with Composer." +}