diff --git a/scripts/_common.sh b/scripts/_common.sh index e95268c..955f96d 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -5,10 +5,13 @@ #================================================= # dependencies used by the app -pkg_dependencies="g++ libjemalloc1|libjemalloc2 libjemalloc-dev zlib1g-dev libreadline-dev libpq-dev libssl-dev libyaml-dev libcurl4-dev libapr1-dev libxslt1-dev libxml2-dev vim imagemagick postgresql postgresql-server-dev-all postgresql-contrib optipng jhead jpegoptim gifsicle brotli" -build_pkg_dependencies="" +#pkg_dependencies="g++ libjemalloc1|libjemalloc2 libjemalloc-dev zlib1g-dev libreadline-dev libpq-dev libssl-dev libyaml-dev libcurl4-dev libapr1-dev libxslt1-dev libxml2-dev vim imagemagick postgresql postgresql-server-dev-all postgresql-contrib optipng jhead jpegoptim gifsicle brotli" +pkg_dependencies="postgresql postgresql-client postgresql-contrib" +build_pkg_dependencies="libcurl4-openssl-dev libyaml-dev libxml2-dev libpq-dev libreadline-dev brotli libunwind-dev libtcmalloc-minimal4 cmake pngcrush pngquant advancecomp jhead jpegoptim libjpeg-turbo-progs optipng" -ruby_version="2.7.1" +ruby_version="2.7.6" + +nodejs_version="16" #================================================= # PERSONAL HELPERS diff --git a/scripts/install b/scripts/install index 8831a38..9509e6c 100644 --- a/scripts/install +++ b/scripts/install @@ -65,7 +65,9 @@ ynh_app_setting_set --app=$app --key=admin --value=$admin ynh_script_progression --message="Installing dependencies..." ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies $build_pkg_dependencies +ynh_exec_warn_less ynh_install_extra_app_dependencies --repo="deb https://dl.yarnpkg.com/debian/ stable main" --package="yarn" --key="https://dl.yarnpkg.com/debian/pubkey.gpg" ynh_exec_warn_less ynh_install_ruby --ruby_version=$ruby_version +ynh_exec_warn_less ynh_install_nodejs --nodejs_version=$nodejs_version #================================================= # CREATE DEDICATED USER @@ -186,13 +188,21 @@ if [ -n "$(uname -m | grep arm)" ] ; then ln -s $(ldconfig -p | grep libpsl | awk 'END {print $NF}') libpsl.so) fi +pushd "$final_path" + ynh_use_nodejs + ynh_npm install --location=global terser + ynh_npm install --location=global uglify-js + ynh_exec_warn_less ynh_exec_as $app $ynh_node_load_PATH yarn install --production --frozen-lockfile + ynh_exec_warn_less ynh_exec_as $app $ynh_node_load_PATH yarn cache clean +popd + #================================================= # PREPARE THE DATABASE #================================================= ynh_script_progression --message="Preparing the database..." -ynh_exec_warn_less exec_login_as $app RAILS_ENV=production bin/rake db:migrate -ynh_exec_warn_less exec_login_as $app RAILS_ENV=production bin/rake assets:precompile +ynh_exec_warn_less exec_login_as $app RAILS_ENV=production bin/bundle exec rake db:migrate +ynh_exec_warn_less exec_login_as $app RAILS_ENV=production bin/bundle exec rake themes:update assets:precompile ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies ynh_package_autoremove diff --git a/scripts/remove b/scripts/remove index 9e27c5d..1d5f13c 100644 --- a/scripts/remove +++ b/scripts/remove @@ -89,6 +89,7 @@ ynh_script_progression --message="Removing dependencies..." # Remove metapackage and its dependencies ynh_remove_app_dependencies +ynh_remove_nodejs ynh_remove_ruby #================================================= diff --git a/scripts/restore b/scripts/restore index 204178d..e346337 100644 --- a/scripts/restore +++ b/scripts/restore @@ -78,7 +78,9 @@ ynh_script_progression --message="Reinstalling dependencies..." # Define and install dependencies ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies $build_pkg_dependencies +ynh_exec_warn_less ynh_install_extra_app_dependencies --repo="deb https://dl.yarnpkg.com/debian/ stable main" --package="yarn" --key="https://dl.yarnpkg.com/debian/pubkey.gpg" ynh_exec_warn_less ynh_install_ruby --ruby_version=$ruby_version +ynh_exec_warn_less ynh_install_nodejs --nodejs_version=$nodejs_version #================================================= # RESTORE THE NGINX CONFIGURATION diff --git a/scripts/upgrade b/scripts/upgrade index a83c554..a0853c8 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -183,7 +183,9 @@ chown -R $app:www-data "$final_path" ynh_script_progression --message="Upgrading dependencies..." ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies $build_pkg_dependencies +ynh_exec_warn_less ynh_install_extra_app_dependencies --repo="deb https://dl.yarnpkg.com/debian/ stable main" --package="yarn" --key="https://dl.yarnpkg.com/debian/pubkey.gpg" ynh_exec_warn_less ynh_install_ruby --ruby_version=$ruby_version +ynh_exec_warn_less ynh_install_nodejs --nodejs_version=$nodejs_version ynh_use_ruby #================================================= @@ -270,6 +272,14 @@ then ln -s $(ldconfig -p | grep libpsl | awk 'END {print $NF}') libpsl.so ) fi + + pushd "$final_path" + ynh_use_nodejs + ynh_npm install --location=global terser + ynh_npm install --location=global uglify-js + ynh_exec_warn_less ynh_exec_as $app $ynh_node_load_PATH yarn install --production --frozen-lockfile + ynh_exec_warn_less ynh_exec_as $app $ynh_node_load_PATH yarn cache clean + popd fi #================================================= @@ -280,8 +290,8 @@ if [ "$upgrade_type" == "UPGRADE_APP" ] then ynh_script_progression --message="Preparing the database..." - ynh_exec_warn_less exec_login_as $app RAILS_ENV=production bin/rake db:migrate - ynh_exec_warn_less exec_login_as $app RAILS_ENV=production bin/rake assets:precompile + ynh_exec_warn_less exec_login_as $app RAILS_ENV=production bin/bundle exec rake db:migrate + ynh_exec_warn_less exec_login_as $app RAILS_ENV=production bin/bundle exec rake themes:update assets:precompile fi ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies diff --git a/sources/patches/app-1-use-latest_uglify-js.patch b/sources/patches/app-1-use-latest_uglify-js.patch index 5af4246..415ec9e 100644 --- a/sources/patches/app-1-use-latest_uglify-js.patch +++ b/sources/patches/app-1-use-latest_uglify-js.patch @@ -2,11 +2,13 @@ diff --git a/lib/tasks/assets.rake b/lib/tasks/assets.rake index 4a02d5f1b1..7b47f21658 100644 --- a/lib/tasks/assets.rake +++ b/lib/tasks/assets.rake -@@ -94,6 +94,7 @@ def compress_ruby(from, to) +@@ -126,6 +126,9 @@ data = File.read("#{assets_path}/#{from}") - + uglified, map = Uglifier.new(comments: :none, + harmony: true, ++ mangle: false, ++ compress: false, source_map: { filename: File.basename(from), output_filename: File.basename(to) diff --git a/sources/patches/app-5-fix-admin-watched-words-action.patch b/sources/patches/app-5-fix-admin-watched-words-action.patch new file mode 100644 index 0000000..a431d71 --- /dev/null +++ b/sources/patches/app-5-fix-admin-watched-words-action.patch @@ -0,0 +1,15 @@ +diff --git a/app/assets/javascripts/admin/addon/controllers/admin-watched-words-action.js b/app/assets/javascripts/admin/addon/controllers/admin-watched-words-action.js +index 2b53a91eb3..eec55647d5 100644 +--- a/app/assets/javascripts/admin/addon/controllers/admin-watched-words-action.js ++++ b/app/assets/javascripts/admin/addon/controllers/admin-watched-words-action.js +@@ -32,9 +32,9 @@ + for (const { regexp, word } of words) { + try { + RegExp(regexp); +- } catch { ++ } catch (err) { + return I18n.t("admin.watched_words.invalid_regex", { word }); + } + } + }, + diff --git a/sources/patches/app-6-fix-download-calendar.patch b/sources/patches/app-6-fix-download-calendar.patch new file mode 100644 index 0000000..580e10d --- /dev/null +++ b/sources/patches/app-6-fix-download-calendar.patch @@ -0,0 +1,13 @@ +diff --git a/app/assets/javascripts/discourse/app/lib/download-calendar.js b/app/assets/javascripts/discourse/app/lib/download-calendar.js +index 2b53a91eb3..eec55647d5 100644 +--- a/app/assets/javascripts/discourse/app/lib/download-calendar.js ++++ b/app/assets/javascripts/discourse/app/lib/download-calendar.js +@@ -22,7 +22,7 @@ + } + + export function downloadIcs(title, dates) { +- const REMOVE_FILE_AFTER = 20_000; ++ const REMOVE_FILE_AFTER = 20000; + const file = new File([generateIcsData(title, dates)], { + type: "text/plain", + }); diff --git a/sources/patches/app-7-fix-uppy-upload.patch b/sources/patches/app-7-fix-uppy-upload.patch new file mode 100644 index 0000000..6af3580 --- /dev/null +++ b/sources/patches/app-7-fix-uppy-upload.patch @@ -0,0 +1,13 @@ +diff --git a/app/assets/javascripts/discourse/app/mixins/uppy-upload.js b/app/assets/javascripts/discourse/app/mixins/uppy-upload.js +index 2b53a91eb3..eec55647d5 100644 +--- a/app/assets/javascripts/discourse/app/mixins/uppy-upload.js ++++ b/app/assets/javascripts/discourse/app/mixins/uppy-upload.js +@@ -21,7 +21,7 @@ + import { warn } from "@ember/debug"; + import bootbox from "bootbox"; + +-export const HUGE_FILE_THRESHOLD_BYTES = 104_857_600; // 100MB ++export const HUGE_FILE_THRESHOLD_BYTES = "104_857_600"; // 100MB + + export default Mixin.create(UppyS3Multipart, { + uploading: false,