diff --git a/conf/.sequelizerc.example b/conf/.sequelizerc.example index ddb5cba..9b42bbf 100644 --- a/conf/.sequelizerc.example +++ b/conf/.sequelizerc.example @@ -1,8 +1,10 @@ -var path = require('path'); +const path = require('path') +const config = require('./lib/config') module.exports = { - 'config': path.resolve('config.json'), - 'migrations-path': path.resolve('lib', 'migrations'), - 'models-path': path.resolve('lib', 'models'), - 'url': 'postgres://__DB_NAME__:__DB_PWD__@localhost:5432/__DB_NAME__' + config: path.resolve('config.js'), + 'migrations-path': path.resolve('lib', 'migrations'), + 'models-path': path.resolve('lib', 'models'), + url: 'postgres://__DB_NAME__:__DB_PWD__@localhost:5432/__DB_NAME__' } + diff --git a/scripts/change_url b/scripts/change_url index c0b818f..a5b16b6 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -117,12 +117,12 @@ path_url=${path_url:1} cp ../conf/config.json.example "$final_path/config.json" -ynh_replace_string --match_string="__PORT__" --replace_string="$port" --target_file="$final_path/config.json" -ynh_replace_string --match_string="__DOMAIN__" --replace_string="$domain" --target_file="$final_path/config.json" -ynh_replace_string --match_string="__PATH__" --replace_string="${path_url:1}" --target_file="$final_path/config.json" +ynh_replace_string --match_string="__PORT__" --replace_string="$port" --target_file="$final_path/config.json" +ynh_replace_string --match_string="__DOMAIN__" --replace_string="$domain" --target_file="$final_path/config.json" +ynh_replace_string --match_string="__PATH__" --replace_string="${path_url:1}" --target_file="$final_path/config.json" ynh_replace_string --match_string="__DB_NAME__" --replace_string="$db_name" --target_file="$final_path/config.json" ynh_replace_string --match_string="__DB_PWD__" --replace_string="$db_pwd" --target_file="$final_path/config.json" -ynh_replace_string --match_string="__APP__" --replace_string="$app" --target_file="$final_path/config.json" +ynh_replace_string --match_string="__APP__" --replace_string="$app" --target_file="$final_path/config.json" ynh_store_file_checksum --file="$final_path/config.json" diff --git a/scripts/install b/scripts/install index 7f75254..e27059c 100644 --- a/scripts/install +++ b/scripts/install @@ -69,9 +69,6 @@ ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies # Install Nodejs ynh_exec_warn_less ynh_install_nodejs --nodejs_version=$nodejs_version -# Install Yarn -ynh_install_extra_app_dependencies --repo="deb https://dl.yarnpkg.com/debian/ stable main" --package="yarn" --key="https://dl.yarnpkg.com/debian/pubkey.gpg" - #================================================= # CREATE DEDICATED USER #================================================= @@ -115,12 +112,24 @@ ynh_add_nginx_config #============================================== ynh_script_progression --message="Building CodiMD... (this will take some time and resources!)" --weight=24 +chown -R $app: $final_path + pushd "$final_path" || ynh_die ynh_use_nodejs - ynh_exec_warn_less bin/setup - ynh_exec_warn_less yarn run build + ynh_exec_warn_less bin/setup + ynh_exec_as $app env $ynh_node_load_PATH npm update + ynh_exec_as $app env $ynh_node_load_PATH npm run build popd || ynh_die +#================================================= +# MODIFY A CONFIG FILE +#================================================= +ynh_script_progression --message="Modifying a config file..." + +path=${path_url:1} +ynh_add_config --template="../conf/config.json.example" --destination="$final_path/config.json" +ynh_add_config --template="../conf/.sequelizerc.example" --destination="$final_path/.sequelizerc" + #================================================= # SETUP SYSTEMD #================================================= @@ -128,19 +137,8 @@ ynh_script_progression --message="Configuring a systemd service..." --weight=1 ynh_replace_string --match_string="__ENV_PATH__" --replace_string="$PATH" --target_file="../conf/systemd.service" ynh_replace_string --match_string="__YNH_NPM__" --replace_string="$ynh_npm" --target_file="../conf/systemd.service" - ynh_add_systemd_config -#================================================= -# MODIFY A CONFIG FILE -#================================================= -ynh_script_progression --message="Modifying a config file..." - -path=${path_url:1} - -ynh_add_config --template="../conf/config.json.example" --destination="$final_path/config.json" -ynh_add_config --template="../conf/.sequelizerc.example" --destination="$final_path/.sequelizerc" - #================================================= # GENERIC FINALIZATION #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index c885542..33317e0 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -113,9 +113,6 @@ ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies # Install Nodejs ynh_exec_warn_less ynh_install_nodejs --nodejs_version=$nodejs_version -# Install Yarn -ynh_install_extra_app_dependencies --repo="deb https://dl.yarnpkg.com/debian/ stable main" --package="yarn" --key="https://dl.yarnpkg.com/debian/pubkey.gpg" - #================================================= # CREATE DEDICATED USER #================================================= @@ -136,18 +133,10 @@ then pushd "$final_path" || ynh_die ynh_use_nodejs ynh_exec_warn_less bin/setup - ynh_exec_warn_less yarn run build + ynh_exec_warn_less ynh_npm run build popd || ynh_die fi -#================================================= -# MODIFY A CONFIG FILE -#================================================= -#ynh_script_progression --message="Modifying a config file..." --weight=2 - -#path=${path_url:1} -#ynh_add_config --template="../conf/config.json.example" --destination="$final_path/config.json" - #================================================= # SETUP SYSTEMD #================================================= @@ -155,7 +144,6 @@ ynh_script_progression --message="Configuring a systemd service..." --weight=2 ynh_replace_string --match_string="__ENV_PATH__" --replace_string="$PATH" --target_file="../conf/systemd.service" ynh_replace_string --match_string="__YNH_NPM__" --replace_string="$ynh_npm" --target_file="../conf/systemd.service" - # Create a dedicated systemd config ynh_add_systemd_config