mirror of
https://github.com/YunoHost-Apps/snipeit_ynh.git
synced 2024-09-03 20:26:16 +02:00
Merge pull request #5 from YunoHost-Apps/improve-composer
fix composer issue
This commit is contained in:
commit
b6e44548cd
4 changed files with 60 additions and 38 deletions
|
@ -5,7 +5,7 @@
|
||||||
"description": {
|
"description": {
|
||||||
"en": "Open source asset management"
|
"en": "Open source asset management"
|
||||||
},
|
},
|
||||||
"version": "4.6.15~ynh1",
|
"version": "4.6.15~ynh2",
|
||||||
"url": "https://snipeitapp.com/",
|
"url": "https://snipeitapp.com/",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"maintainer": {
|
"maintainer": {
|
||||||
|
|
|
@ -29,37 +29,53 @@ exec_as() {
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
# Execute a composer command from a given directory
|
|
||||||
# usage: composer_exec AS_USER WORKDIR COMMAND [ARG ...]
|
|
||||||
exec_composer() {
|
|
||||||
local AS_USER=$1
|
|
||||||
local WORKDIR=$2
|
|
||||||
shift 2
|
|
||||||
|
|
||||||
exec_as "$AS_USER" COMPOSER_HOME="${WORKDIR}/.composer" \
|
|
||||||
php "${WORKDIR}/composer.phar" $@ \
|
|
||||||
-d "${WORKDIR}" --quiet --no-interaction
|
|
||||||
}
|
|
||||||
|
|
||||||
# Install and initialize Composer in the given directory
|
|
||||||
# usage: init_composer destdir
|
|
||||||
init_composer() {
|
|
||||||
local AS_USER=$1
|
|
||||||
local WORKDIR=$2
|
|
||||||
|
|
||||||
# install composer
|
|
||||||
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
|
|
||||||
exec_composer "$AS_USER" "$WORKDIR" install --no-dev --prefer-source \
|
|
||||||
|| ynh_die "Unable to update core dependencies with Composer"
|
|
||||||
}
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# FUTURE OFFICIAL HELPERS
|
# FUTURE OFFICIAL HELPERS
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
|
# Execute a command with Composer
|
||||||
|
#
|
||||||
|
# usage: ynh_composer_exec --phpversion=phpversion [--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=vwc
|
||||||
|
declare -Ar args_array=( [v]=phpversion= [w]=workdir= [c]=commands= )
|
||||||
|
local phpversion
|
||||||
|
local workdir
|
||||||
|
local commands
|
||||||
|
# Manage arguments with getopts
|
||||||
|
ynh_handle_getopts_args "$@"
|
||||||
|
workdir="${workdir:-$final_path}"
|
||||||
|
phpversion="${phpversion:-7.0}"
|
||||||
|
|
||||||
|
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 --phpversion=phpversion [--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=vw
|
||||||
|
declare -Ar args_array=( [v]=phpversion= [w]=workdir= )
|
||||||
|
local phpversion
|
||||||
|
local workdir
|
||||||
|
# Manage arguments with getopts
|
||||||
|
ynh_handle_getopts_args "$@"
|
||||||
|
workdir="${workdir:-$final_path}"
|
||||||
|
phpversion="${phpversion:-7.0}"
|
||||||
|
|
||||||
|
curl -sS https://getcomposer.org/installer \
|
||||||
|
| 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 --phpversion="${phpversion}" --workdir="$workdir" --commands="install --no-dev" \
|
||||||
|
|| ynh_die "Unable to update core dependencies with Composer."
|
||||||
|
}
|
|
@ -161,15 +161,15 @@ ynh_script_progression --message="Configuring php-fpm..." --time --weight=1
|
||||||
# Create a dedicated php-fpm config
|
# Create a dedicated php-fpm config
|
||||||
ynh_add_fpm_config
|
ynh_add_fpm_config
|
||||||
|
|
||||||
( cd $final_path && curl -sS https://getcomposer.org/installer | php )
|
|
||||||
( cd $final_path && /usr/bin/php composer.phar install --no-dev --prefer-source )
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# SPECIFIC SETUP
|
# SPECIFIC SETUP
|
||||||
#=================================================
|
#=================================================
|
||||||
# ...
|
# INSTALL AND INITIALIZE COMPOSER
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_script_progression --message="Installing composer..." --time --weight=1
|
||||||
|
|
||||||
|
# Install composer
|
||||||
|
ynh_install_composer
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# MODIFY A CONFIG FILE
|
# MODIFY A CONFIG FILE
|
||||||
|
|
|
@ -136,9 +136,15 @@ ynh_add_fpm_config
|
||||||
#=================================================
|
#=================================================
|
||||||
# SPECIFIC UPGRADE
|
# SPECIFIC UPGRADE
|
||||||
#=================================================
|
#=================================================
|
||||||
|
# INSTALL AND INITIALIZE COMPOSER
|
||||||
|
#=================================================
|
||||||
|
ynh_script_progression --message="Installing composer..." --time --weight=1
|
||||||
|
|
||||||
|
# Install composer
|
||||||
|
ynh_install_composer
|
||||||
|
|
||||||
|
ynh_exec_warn_less ynh_composer_exec --commands=\"dump-autoload\"
|
||||||
|
|
||||||
( cd $final_path && sudo /usr/bin/php composer.phar install --no-dev --prefer-source )
|
|
||||||
( cd $final_path && sudo /usr/bin/php composer.phar dump-autoload )
|
|
||||||
( cd $final_path && sudo /usr/bin/php artisan migrate -n )
|
( cd $final_path && sudo /usr/bin/php artisan migrate -n )
|
||||||
( cd $final_path && sudo /usr/bin/php artisan config:clear -n )
|
( cd $final_path && sudo /usr/bin/php artisan config:clear -n )
|
||||||
( cd $final_path && sudo /usr/bin/php artisan config:cache -n )
|
( cd $final_path && sudo /usr/bin/php artisan config:cache -n )
|
||||||
|
|
Loading…
Add table
Reference in a new issue