From 85dc50041c5a2fbcdf3751a29776bbaf9462acd0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A9rard=20Collin?= Date: Mon, 22 Jan 2024 15:50:19 +0100 Subject: [PATCH] Fixed issue upgrading yarn --- scripts/install | 13 ++++++++----- scripts/upgrade | 15 +++++++++------ 2 files changed, 17 insertions(+), 11 deletions(-) diff --git a/scripts/install b/scripts/install index 2086fa5..8f0b482 100755 --- a/scripts/install +++ b/scripts/install @@ -17,11 +17,6 @@ ynh_script_progression --message="Installing NodeJS & Yarn..." --weight=3 ynh_install_nodejs --nodejs_version="$nodejs_version" -pushd "$install_dir" - ynh_use_nodejs - _install_yarn -popd - # Install mongo server only if asked to if [ "$mongo_version" != "None" ]; then ynh_script_progression --message="Installing MongoDB..." --weight=3 @@ -56,6 +51,14 @@ ynh_script_progression --message="Building NodeJS code ..." --weight=6 # Build using Yarn pushd "$install_dir" ynh_use_nodejs + # We must use npm to install yarn but without installing other dependencies as npm fails with them + if [ -f "package.json" ]; then + mv package.json package.json.mov + fi + _install_yarn + if [ -f "package.json.mov" ]; then + mv package.json.mov package.json + fi ynh_exec_as "$app" "$ynh_node_load_PATH" "$ynh_yarn" install ynh_exec_as "$app" "$ynh_node_load_PATH" "$ynh_npm" run build popd diff --git a/scripts/upgrade b/scripts/upgrade index 64b53bf..1feaf5f 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -26,11 +26,6 @@ ynh_script_progression --message="Installing NodeJS & Yarn" --weight=3 ynh_install_nodejs --nodejs_version="$nodejs_version" -pushd "$install_dir" - ynh_use_nodejs - _install_yarn -popd - # Install mongo server only if asked to if [ "$mongo_version" != "None" ]; then ynh_script_progression --message="Installing MongoDB..." --weight=3 @@ -60,11 +55,19 @@ chown "$app:$app" "$install_dir/.env" #================================================= # BUILD NODEJS CODE #================================================= -ynh_script_progression --message="Building NodeJS code and dependencies..." --weight=6 +ynh_script_progression --message="Installing Yarn and Buuilding application..." --weight=6 # Build using Yarn pushd "$install_dir" ynh_use_nodejs + # We must use npm to install yarn but without installing other dependencies as npm fails with them + if [ -f "package.json" ]; then + mv package.json package.json.mov + fi + _install_yarn + if [ -f "package.json.mov" ]; then + mv package.json.mov package.json + fi ynh_exec_as "$app" "$ynh_node_load_PATH" "$ynh_yarn" install ynh_exec_as "$app" "$ynh_node_load_PATH" "$ynh_npm" run build popd