diff --git a/README.md b/README.md index 2495b7d..f571191 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,7 @@ If you don't have YunoHost, please consult [the guide](https://yunohost.org/#/in This is an open-source online implementation of the great board game Terraforming mars. It is not affiliated with FryxGames, Asmodee Digital or Steam in any way. -**Shipped version:** 20231115~ynh1 +**Shipped version:** 20231205~ynh1 **Demo:** https://terraforming-mars.herokuapp.com/ diff --git a/README_fr.md b/README_fr.md index 765d2be..dd459f4 100644 --- a/README_fr.md +++ b/README_fr.md @@ -18,7 +18,7 @@ Si vous n’avez pas YunoHost, regardez [ici](https://yunohost.org/#/install) po Cette application est une implémentation en ligne et open source de l’excellent jeu de plateau Terraforming mars. Elle n’est affiliée à FryxGames, Asmodee Digital ou Steam en aucun cas. -**Version incluse :** 20231115~ynh1 +**Version incluse :** 20231205~ynh1 **Démo :** https://terraforming-mars.herokuapp.com/ diff --git a/conf/systemd.service b/conf/systemd.service index 674e703..7a2780d 100644 --- a/conf/systemd.service +++ b/conf/systemd.service @@ -7,7 +7,7 @@ After=network-online.target Type=simple User=__APP__ Group=__APP__ -WorkingDirectory=__INSTALL_DIR__/terraforming-mars +WorkingDirectory=__INSTALL_DIR__ EnvironmentFile=__INSTALL_DIR__/.env Environment="__YNH_NODE_LOAD_PATH__" Environment=NODE_ENV=production diff --git a/manifest.toml b/manifest.toml index 4531941..75f7363 100644 --- a/manifest.toml +++ b/manifest.toml @@ -7,7 +7,7 @@ name = "Terraforming Mars " description.en = "Open-source online implementation of the great board game Terraforming mars." description.fr = "Implementation en ligne à code source ouvert de l’excellent jeu de plateau Terraforming Mars" -version = "20231115~ynh1" +version = "20231205~ynh1" maintainers = ["Thovi98"] @@ -41,6 +41,14 @@ ram.runtime = "50M" default = "visitors" [resources] + + [resources.sources] + + [resources.sources.main] + url = "https://codeload.github.com/terraforming-mars/terraforming-mars/tar.gz/78e5e5d0433e4d1632639ea7da1a1993672bd82a" + sha256 = "ad4e3107b42d61aac93546887f01714f6ef2d0ed84fb6f7c6f8178bf60264e1f" + in_subdir = true + autoupdate.strategy = "latest_github_commit" [resources.system_user] diff --git a/scripts/_common.sh b/scripts/_common.sh index e6f43c4..5fc0a5a 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -5,10 +5,7 @@ #================================================= # nodejs version -nodejs_version=16 - -# Terraforming-mars commit -TM_version="38c69c7" +nodejs_version=16.13.2 #================================================= # PERSONAL HELPERS diff --git a/scripts/install b/scripts/install index e168d09..9bf5f96 100755 --- a/scripts/install +++ b/scripts/install @@ -17,7 +17,19 @@ ynh_script_progression --message="Installing dependencies..." --weight=5 ynh_exec_warn_less ynh_install_nodejs --nodejs_version=$nodejs_version # Upgrade NPM -ynh_npm install --global npm@6.14.18 +ynh_npm install --global npm@8.1.2 + +#================================================= +# DOWNLOAD, CHECK AND UNPACK SOURCE +#================================================= +ynh_script_progression --message="Setting up source files..." --weight=1 + +# Download, check integrity, uncompress and patch the source from app.src +ynh_setup_source --dest_dir="$install_dir" + +chmod 750 "$install_dir" +chmod -R o-rwx "$install_dir" +chown -R $app:www-data "$install_dir" #================================================= # NGINX CONFIGURATION @@ -30,30 +42,6 @@ ynh_add_nginx_config #================================================= # SPECIFIC SETUP #================================================= -#================================================= -# BUILD APP -#================================================= - -cd $install_dir -ynh_exec_warn_less git clone https://github.com/terraforming-mars/terraforming-mars.git - -cd $install_dir/terraforming-mars -ynh_exec_warn_less git checkout $TM_version - -pushd $install_dir/terraforming-mars - ynh_use_nodejs - - ynh_script_progression --message="npm install... This can be very long, be patient !" --weight=18 - ynh_exec_warn_less env $ynh_node_load_PATH $ynh_npm install --network-timeout=100000 - - ynh_script_progression --message="npm run build... This can be very long, be patient !" --weight=25 - ynh_exec_warn_less env $ynh_node_load_PATH $ynh_npm run build -popd - -chmod 750 "$install_dir" -chmod -R o-rwx "$install_dir" -chown -R $app:$app "$install_dir" - #================================================= # ADD A CONFIGURATION #================================================= @@ -68,6 +56,26 @@ ynh_add_config --template="../conf/.env" --destination="$install_dir/.env" chmod 600 "$install_dir/.env" chown $app:$app "$install_dir/.env" +#================================================= +# BUILD APP +#================================================= + +pushd $install_dir + ynh_use_nodejs + + ynh_script_progression --message="npm install... This can be very long, be patient !" --weight=18 + ynh_exec_warn_less ynh_exec_as $app env $ynh_node_load_PATH $ynh_npm ci --quiet --production --prefer-offline --network-timeout=100000 + ynh_exec_warn_less ynh_exec_as $app env $ynh_node_load_PATH $ynh_npm install --save-dev @types/html-escaper + + ynh_script_progression --message="npm run build... This can be very long, be patient !" --weight=25 + SOURCE_VERSION="$(cat $YNH_APP_BASEDIR/manifest.toml | toml_to_json | jq -r ".resources.sources.main.url" | awk -F/ '{ print $NF }')" + ynh_exec_warn_less ynh_exec_as $app env $ynh_node_load_PATH SOURCE_VERSION="$SOURCE_VERSION" $ynh_npm run build +popd + +chmod 750 "$install_dir" +chmod -R o-rwx "$install_dir" +chown -R $app:$app "$install_dir" + #================================================= # SETUP SYSTEMD #================================================= diff --git a/scripts/restore b/scripts/restore index baa934a..9c5f77c 100755 --- a/scripts/restore +++ b/scripts/restore @@ -10,6 +10,15 @@ source ../settings/scripts/_common.sh source /usr/share/yunohost/helpers +#================================================= +# REINSTALL DEPENDENCIES +#================================================= +ynh_script_progression --message="Reinstalling dependencies..." --weight=10 + +ynh_exec_warn_less ynh_install_nodejs --nodejs_version=$nodejs_version + +ynh_npm install --global npm@8.1.2 + #================================================= # RESTORE THE APP MAIN DIR #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index a6b04cd..ccb8e94 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -19,7 +19,19 @@ ynh_script_progression --message="Installing dependencies..." --weight=5 ynh_exec_warn_less ynh_install_nodejs --nodejs_version=$nodejs_version # Upgrade NPM -ynh_npm install --global npm@6.14.18 +ynh_npm install --global npm@8.1.2 + +#================================================= +# DOWNLOAD, CHECK AND UNPACK SOURCE +#================================================= +ynh_script_progression --message="Setting up source files..." --weight=1 + +# Download, check integrity, uncompress and patch the source from app.src +ynh_setup_source --dest_dir="$install_dir" --full_replace=1 + +chmod 750 "$install_dir" +chmod -R o-rwx "$install_dir" +chown -R $app:www-data "$install_dir" #================================================= # STANDARD UPGRADE STEPS @@ -31,26 +43,31 @@ ynh_script_progression --message="Stopping a systemd service..." --weight=1 ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app/$app.log" #================================================= -# "REBUILD" THE APP (DEPLOY NEW SOURCES, RERUN NPM BUILD...) +# RECONFIGURE THE APP (UPDATE CONF, APPLY MIGRATIONS...) #================================================= -# DOWNLOAD, CHECK AND UNPACK SOURCE +# UPDATE A CONFIG FILE +#================================================= +ynh_script_progression --message="Updating a configuration file..." --weight=1 + +ynh_add_config --template="../conf/.env" --destination="$install_dir/.env" + +chmod 400 "$install_dir/.env" +chown $app:$app "$install_dir/.env" + +#================================================= +# BUILD APP #================================================= -cd $install_dir -ynh_secure_remove terraforming-mars -ynh_exec_warn_less git clone https://github.com/terraforming-mars/terraforming-mars.git - -cd $install_dir/terraforming-mars -ynh_exec_warn_less git checkout $TM_version - -pushd $install_dir/terraforming-mars +pushd $install_dir ynh_use_nodejs ynh_script_progression --message="npm install... This can be very long, be patient !" --weight=18 - ynh_exec_warn_less env $ynh_node_load_PATH $ynh_npm install --network-timeout=100000 + ynh_exec_warn_less ynh_exec_as $app env $ynh_node_load_PATH $ynh_npm ci --quiet --production --prefer-offline --network-timeout=100000 + ynh_exec_warn_less ynh_exec_as $app env $ynh_node_load_PATH $ynh_npm install --save-dev @types/html-escaper ynh_script_progression --message="npm run build... This can be very long, be patient !" --weight=25 - ynh_exec_warn_less env $ynh_node_load_PATH $ynh_npm run build + SOURCE_VERSION="$(cat $YNH_APP_BASEDIR/manifest.toml | toml_to_json | jq -r ".resources.sources.main.url" | awk -F/ '{ print $NF }')" + ynh_exec_warn_less ynh_exec_as $app env $ynh_node_load_PATH SOURCE_VERSION="$SOURCE_VERSION" $ynh_npm run build popd chmod 750 "$install_dir"