From bbcce980553bd5f501b9e3950febe0021afeaa80 Mon Sep 17 00:00:00 2001 From: Alexandre Aubin Date: Sun, 12 May 2024 20:36:20 +0200 Subject: [PATCH] Build the app locally from git sources, using npm etc --- scripts/_common.sh | 18 +----------------- scripts/backup | 20 -------------------- scripts/install | 23 +++++++++++++++++++---- scripts/remove | 6 ------ scripts/restore | 8 +------- scripts/upgrade | 29 ++++++++++++++++++++--------- 6 files changed, 41 insertions(+), 63 deletions(-) diff --git a/scripts/_common.sh b/scripts/_common.sh index 1e47ce7..9157d07 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -1,19 +1,3 @@ #!/bin/bash -#================================================= -# COMMON VARIABLES -#================================================= -# PHP APP SPECIFIC -#================================================= - -#================================================= -# PERSONAL HELPERS -#================================================= - -#================================================= -# EXPERIMENTAL HELPERS -#================================================= - -#================================================= -# FUTURE OFFICIAL HELPERS -#================================================= +nodejs_version="10.15" diff --git a/scripts/backup b/scripts/backup index c9a5a41..1d1ef84 100644 --- a/scripts/backup +++ b/scripts/backup @@ -1,11 +1,5 @@ #!/bin/bash -#================================================= -# GENERIC START -#================================================= -# IMPORT GENERIC HELPERS -#================================================= - # Keep this path for calling _common.sh inside the execution's context of backup and restore scripts source ../settings/scripts/_common.sh source /usr/share/yunohost/helpers @@ -15,22 +9,8 @@ source /usr/share/yunohost/helpers #================================================= ynh_print_info --message="Declaring files to be backed up..." -#================================================= -# BACKUP THE APP MAIN DIR -#================================================= - ynh_backup --src_path="$install_dir" --is_big - -#================================================= -# BACKUP THE NGINX CONFIGURATION -#================================================= - ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf" - -#================================================= -# BACKUP THE PHP-FPM CONFIGURATION -#================================================= - ynh_backup --src_path="/etc/php/$phpversion/fpm/pool.d/$app.conf" #================================================= diff --git a/scripts/install b/scripts/install index 98dec66..2b515a6 100644 --- a/scripts/install +++ b/scripts/install @@ -9,13 +9,28 @@ source _common.sh source /usr/share/yunohost/helpers +#================================================= +# INSTALL NODEJS +#================================================= +ynh_script_progression --message="Install nodejs..." + +ynh_install_nodejs --nodejs_version=$nodejs_version +ynh_use_nodejs + #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= -ynh_script_progression --message="Setting up source files..." --weight=4 +ynh_script_progression --message="Setting up source files..." -# Download, check integrity, uncompress and patch the source from app.src -ynh_setup_source --dest_dir="$install_dir" + +tmpdir=$(mktemp -d) +ynh_setup_source --dest_dir="$tmpdir" +pushd $tmpdir + npm ci + npm run build + mv build/_h5ai $install_dir/_h5ai +popd +ynh_secure_remove $tmpdir chmod -R o-rwx "$install_dir" chown -R $app:www-data "$install_dir" @@ -24,7 +39,7 @@ chmod 700 "$install_dir/_h5ai/private/conf" #================================================= # SYSTEM CONFIGURATION #================================================= -ynh_script_progression --message="Adding system configurations related to $app..." --weight=3 +ynh_script_progression --message="Adding system configurations related to $app..." # Create a dedicated PHP-FPM config ynh_add_fpm_config diff --git a/scripts/remove b/scripts/remove index 5b17c2d..6aa19c6 100644 --- a/scripts/remove +++ b/scripts/remove @@ -1,11 +1,5 @@ #!/bin/bash -#================================================= -# GENERIC START -#================================================= -# IMPORT GENERIC HELPERS -#================================================= - source _common.sh source /usr/share/yunohost/helpers diff --git a/scripts/restore b/scripts/restore index 84e8208..0ba14eb 100644 --- a/scripts/restore +++ b/scripts/restore @@ -1,11 +1,5 @@ #!/bin/bash -#================================================= -# GENERIC START -#================================================= -# IMPORT GENERIC HELPERS -#================================================= - # Keep this path for calling _common.sh inside the execution's context of backup and restore scripts source ../settings/scripts/_common.sh source /usr/share/yunohost/helpers @@ -15,7 +9,7 @@ source /usr/share/yunohost/helpers #================================================= ynh_script_progression --message="Restoring the app main directory..." --weight=4 -ynh_restore_file --origin_path="$install_dir" --not_mandatory +ynh_restore_file --origin_path="$install_dir" chmod -R o-rwx "$install_dir" chown -R $app:www-data "$install_dir" diff --git a/scripts/upgrade b/scripts/upgrade index a4c1df1..cab6e26 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -3,19 +3,30 @@ source _common.sh source /usr/share/yunohost/helpers -upgrade_type=$(ynh_check_app_version_changed) +#================================================= +# INSTALL NODEJS +#================================================= +ynh_script_progression --message="Install nodejs..." + +ynh_install_nodejs --nodejs_version=$nodejs_version +ynh_use_nodejs #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= - -if [ "$upgrade_type" == "UPGRADE_APP" ] -then - ynh_script_progression --message="Upgrading source files..." - - # Download, check integrity, uncompress and patch the source from app.src - ynh_setup_source --dest_dir="$install_dir" --keep="_h5ai/private/conf/options.json" -fi +ynh_script_progression --message="Setting up source files..." + +tmpdir=$(mktemp -d) +ynh_setup_source --dest_dir="$tmpdir" +pushd $tmpdir + cp $install_dir/_h5ai/private/conf/options.json ./options.json.bkp + npm ci + npm run build + ynh_secure_remove $install_dir/_h5ai + mv build/_h5ai $install_dir/_h5ai + cp ./options.json.bkp $install_dir/_h5ai/private/conf/options.json +popd +ynh_secure_remove $tmpdir chmod o-rwx "$install_dir" chown $app:www-data "$install_dir"