mirror of
https://github.com/YunoHost-Apps/flarum_ynh.git
synced 2024-09-03 18:36:24 +02:00
8ba8b17ac9
* retrieving sources instead of create-project * exec_as in composer helpers * reorder install and upgrade steps
55 lines
2.1 KiB
Bash
55 lines
2.1 KiB
Bash
#!/bin/bash
|
|
|
|
# Execute a command with Composer
|
|
#
|
|
# usage: ynh_composer_exec --user=user --phpversion=phpversion [--workdir=$final_path] --commands="commands"
|
|
# | arg: -u, --user - The user to perform the command with.
|
|
# | arg: -v, --phpversion - The php version to perform the command with.
|
|
# | 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=uvwc
|
|
declare -Ar args_array=( [u]=user= [v]=phpversion= [w]=workdir= [c]=commands= )
|
|
local user
|
|
local phpversion
|
|
local workdir
|
|
local commands
|
|
# Manage arguments with getopts
|
|
ynh_handle_getopts_args "$@"
|
|
workdir="${workdir:-$final_path}"
|
|
phpversion="${phpversion:-7.0}"
|
|
|
|
exec_as $user COMPOSER_HOME="$workdir/.composer" \
|
|
php${phpversion} "$workdir/composer.phar" $commands \
|
|
-d "$workdir" --quiet --no-interaction
|
|
}
|
|
|
|
# Install and initialize Composer in the given directory
|
|
#
|
|
# usage: ynh_install_composer --user=user --phpversion=phpversion [--workdir=$final_path]
|
|
# | arg: -u, --user - The user to perform the command with.
|
|
# | arg: -v, --phpversion - The php version to perform the command with.
|
|
# | 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=uvw
|
|
declare -Ar args_array=( [u]=user= [v]=phpversion= [w]=workdir= )
|
|
local user
|
|
local phpversion
|
|
local workdir
|
|
# Manage arguments with getopts
|
|
ynh_handle_getopts_args "$@"
|
|
user="${user:-root}"
|
|
workdir="${workdir:-$final_path}"
|
|
phpversion="${phpversion:-7.0}"
|
|
|
|
curl -sS https://getcomposer.org/installer \
|
|
| exec_as $user COMPOSER_HOME="$workdir/.composer" \
|
|
php${phpversion} -- --quiet --install-dir="$workdir" \
|
|
|| ynh_die "Unable to install Composer."
|
|
|
|
# update dependencies to create composer.lock
|
|
ynh_composer_exec --user=$app --phpversion="${phpversion}" --workdir="$workdir" --commands="install --no-dev" \
|
|
|| ynh_die "Unable to update core dependencies with Composer."
|
|
}
|