From c212555e7e036294de93ec2843a67c0997237ce6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ivan=20Verg=C3=A9s?= Date: Tue, 14 Nov 2023 12:31:12 +0100 Subject: [PATCH] fixes --- .rubocop_ruby.yml | 5 -- Gemfile | 3 +- Gemfile.lock | 21 ++----- babel.config.json | 7 +-- config/application.rb | 9 +-- config/initializers/carrierwave.rb | 38 ++++++------- config/schedule.yml | 2 +- config/webpack/.modernizrrc | 9 +++ config/webpack/custom.js | 18 +++++- config/webpacker.yml | 2 +- ...fix_reference_for_all_resources.decidim.rb | 2 + lib/decidim/env.rb | 56 ------------------- spec/system/favicon_spec.rb | 4 +- 13 files changed, 56 insertions(+), 120 deletions(-) create mode 100644 config/webpack/.modernizrrc delete mode 100644 lib/decidim/env.rb diff --git a/.rubocop_ruby.yml b/.rubocop_ruby.yml index fe783a56a..69d235843 100644 --- a/.rubocop_ruby.yml +++ b/.rubocop_ruby.yml @@ -71,11 +71,6 @@ AllCops: # Otherwise we fallback to the oldest officially supported Ruby version (2.0). TargetRubyVersion: 3.0 - RSpec: - Patterns: - - "(?:^|/)spec/" - - "(?:^|/)test/" - # Indent private/protected/public as deep as method definitions Layout/AccessModifierIndentation: EnforcedStyle: indent diff --git a/Gemfile b/Gemfile index aca30e8ec..742e68c7a 100644 --- a/Gemfile +++ b/Gemfile @@ -10,7 +10,7 @@ gem "decidim", DECIDIM_VERSION gem "decidim-consultations", DECIDIM_VERSION gem "decidim-action_delegator", github: "coopdevs/decidim-module-action_delegator", branch: "main" -gem "decidim-decidim_awesome", github: "decidim-ice/decidim-module-decidim_awesome", branch: "develop" +gem "decidim-decidim_awesome", github: "decidim-ice/decidim-module-decidim_awesome" gem "decidim-term_customizer", github: "mainio/decidim-module-term_customizer", branch: "master" gem "bootsnap", "~> 1.7" @@ -42,7 +42,6 @@ end group :production do gem "aws-sdk-s3", require: false - gem "fog-aws" gem "sidekiq" gem "sidekiq-cron" end diff --git a/Gemfile.lock b/Gemfile.lock index 089116a5e..139d30b4d 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -13,8 +13,7 @@ GIT GIT remote: https://github.com/decidim-ice/decidim-module-decidim_awesome.git - revision: 4e6db5717752c2031273cd77518730a76b5aa411 - branch: develop + revision: 4f1b2eb8a9db544e3f781a248cc5b3659e808a36 specs: decidim-decidim_awesome (0.10.0) decidim-admin (>= 0.26.0, < 0.28) @@ -24,7 +23,7 @@ GIT GIT remote: https://github.com/decidim/decidim.git - revision: 6271ef2fd11632e4dd340935ea0e4b0a2d70547b + revision: d3df678a92807f7de87cea33d3b0a89251069b9f ref: release/0.27-stable specs: decidim (0.27.4) @@ -282,7 +281,7 @@ GEM nokogiri ast (2.4.2) aws-eventstream (1.2.0) - aws-partitions (1.848.0) + aws-partitions (1.849.0) aws-sdk-core (3.186.0) aws-eventstream (~> 1, >= 1.0.2) aws-partitions (~> 1, >= 1.651.0) @@ -447,23 +446,13 @@ GEM file_validators (3.0.0) activemodel (>= 3.2) mime-types (>= 1.0) - fog-aws (3.21.0) - fog-core (~> 2.1) - fog-json (~> 1.1) - fog-xml (~> 0.1) fog-core (2.3.0) builder excon (~> 0.71) formatador (>= 0.2, < 2.0) mime-types - fog-json (1.2.0) - fog-core - multi_json (~> 1.10) fog-local (0.8.0) fog-core (>= 1.27, < 3.0) - fog-xml (0.1.4) - fog-core - nokogiri (>= 1.5.11, < 2.0.0) formatador (1.1.0) foundation_rails_helper (4.0.1) actionpack (>= 4.1, < 7.1) @@ -583,10 +572,9 @@ GEM mixlib-shellout (3.2.7) chef-utils msgpack (1.7.2) - multi_json (1.15.0) multi_xml (0.6.0) mustache (1.1.1) - net-imap (0.4.4) + net-imap (0.4.5) date net-protocol net-pop (0.1.2) @@ -932,7 +920,6 @@ DEPENDENCIES deface faker (~> 2.18) faraday - fog-aws letter_opener_web listen (~> 3.5) memory_profiler diff --git a/babel.config.json b/babel.config.json index e5811e1ae..86a38f89c 100644 --- a/babel.config.json +++ b/babel.config.json @@ -20,11 +20,6 @@ "corejs": false } ], - [ - "@babel/plugin-transform-regenerator", - { - "async": false - } - ] + ["@babel/plugin-transform-regenerator", { "async": false }] ] } diff --git a/config/application.rb b/config/application.rb index 244e89fd3..1edef75c8 100644 --- a/config/application.rb +++ b/config/application.rb @@ -7,22 +7,15 @@ require "action_cable/engine" # require "action_mailbox/engine" # require "action_text/engine" -require_relative "../lib/decidim/env" # Require the gems listed in Gemfile, including any gems # you've limited to :test, :development, or :production. Bundler.require(*Rails.groups) -module Decidim - def self.module_installed?(mod) - Gem.loaded_specs.has_key?("decidim-#{mod}") - end -end - module DecidimApplication class Application < Rails::Application # Initialize configuration defaults for originally generated Rails version. - config.load_defaults 5.2 + config.load_defaults 6.1 # Settings in config/environments/* take precedence over those specified here. # Application configuration can go into files in config/initializers diff --git a/config/initializers/carrierwave.rb b/config/initializers/carrierwave.rb index a9385af26..b863c3b70 100644 --- a/config/initializers/carrierwave.rb +++ b/config/initializers/carrierwave.rb @@ -11,23 +11,23 @@ # Although we use Backblaze's B2 as object storage for assets, we use its S3's compatible API. We # briefly tried the `fog-backblaze` gem but things didn't seem to work at first. -if Rails.application.secrets.dig(:storage, :s3, :access_key_id) - require "carrierwave/storage/fog" +# if Rails.application.secrets.dig(:storage, :s3, :access_key_id) +# require "carrierwave/storage/fog" - CarrierWave.configure do |config| - config.storage = :fog - config.fog_provider = "fog/aws" - config.fog_credentials = { - provider: "AWS", - aws_access_key_id: Rails.application.secrets.dig(:storage, :s3, :access_key_id), - aws_secret_access_key: Rails.application.secrets.dig(:storage, :s3, :secret_access_key), - endpoint: Rails.application.secrets.dig(:storage, :s3, :endpoint) - } - config.fog_directory = Rails.application.secrets.dig(:storage, :s3, :bucket) - config.fog_public = true - config.fog_attributes = { - "Cache-Control" => "max-age=#{365.days.to_i}", - "X-Content-Type-Options" => "nosniff" - } - end -end +# CarrierWave.configure do |config| +# config.storage = :fog +# config.fog_provider = "fog/aws" +# config.fog_credentials = { +# provider: "AWS", +# aws_access_key_id: Rails.application.secrets.dig(:storage, :s3, :access_key_id), +# aws_secret_access_key: Rails.application.secrets.dig(:storage, :s3, :secret_access_key), +# endpoint: Rails.application.secrets.dig(:storage, :s3, :endpoint) +# } +# config.fog_directory = Rails.application.secrets.dig(:storage, :s3, :bucket) +# config.fog_public = true +# config.fog_attributes = { +# "Cache-Control" => "max-age=#{365.days.to_i}", +# "X-Content-Type-Options" => "nosniff" +# } +# end +# end diff --git a/config/schedule.yml b/config/schedule.yml index 6d529463e..fda5045b5 100644 --- a/config/schedule.yml +++ b/config/schedule.yml @@ -14,7 +14,7 @@ daily_open_data_job: args: task: decidim:open_data:export -daily_clean_delete_download_your_data_files_job: +daily_delete_download_your_data_files_job: cron: "33 3 * * *" class: "InvokeRakeTaskJob" queue: default diff --git a/config/webpack/.modernizrrc b/config/webpack/.modernizrrc new file mode 100644 index 000000000..b76ce76a4 --- /dev/null +++ b/config/webpack/.modernizrrc @@ -0,0 +1,9 @@ +{ + "minify": true, + "options": [ + "setClasses" + ], + "feature-detects": [ + "css/transitions" + ] +} diff --git a/config/webpack/custom.js b/config/webpack/custom.js index 6c37a831b..cac081d39 100644 --- a/config/webpack/custom.js +++ b/config/webpack/custom.js @@ -1,7 +1,6 @@ /* eslint-disable */ - -const path = require("path"); const { config } = require("@rails/webpacker"); +const { InjectManifest } = require("workbox-webpack-plugin"); module.exports = { module: { @@ -93,5 +92,18 @@ module.exports = { optimization: { runtimeChunk: false }, - entry: config.entrypoints + entry: config.entrypoints, + plugins: [ + new InjectManifest({ + swSrc: "src/decidim/sw/sw.js", + + /** + * NOTE: + * @rails/webpacker outputs to '/packs', + * in order to make the SW run properly + * they must be put at the project's root folder '/' + */ + swDest: "../sw.js" + }) + ] } diff --git a/config/webpacker.yml b/config/webpacker.yml index 6a1a41f9f..34b1e9121 100644 --- a/config/webpacker.yml +++ b/config/webpacker.yml @@ -33,7 +33,7 @@ development: hmr: false client: # Should we show a full-screen overlay in the browser when there are compiler errors or warnings? - overlay: true + overlay: false # May also be a string # webSocketURL: # hostname: "0.0.0.0" diff --git a/db/migrate/20200720181588_fix_reference_for_all_resources.decidim.rb b/db/migrate/20200720181588_fix_reference_for_all_resources.decidim.rb index 1bb08f7fd..ad0dd8505 100644 --- a/db/migrate/20200720181588_fix_reference_for_all_resources.decidim.rb +++ b/db/migrate/20200720181588_fix_reference_for_all_resources.decidim.rb @@ -6,6 +6,8 @@ def up models = ActiveRecord::Base.descendants.select { |c| c.included_modules.include?(Decidim::HasReference) } models.each do |model| + next unless model.table_exists? + model.find_each(&:touch) end end diff --git a/lib/decidim/env.rb b/lib/decidim/env.rb deleted file mode 100644 index fab874fba..000000000 --- a/lib/decidim/env.rb +++ /dev/null @@ -1,56 +0,0 @@ -# frozen_string_literal: true - -module Decidim - # This class can be used to parse ENV variables to a set of predefined values - # For instance, "", nil, "false" or 0 will all translate into false using valid? - class Env - FALSE_VALUES = %w(0 false no).freeze - - def initialize(name, default = nil) - @name = name - @value = ENV.fetch(name, nil) - @default = default - end - - def value - @value.presence || @default - end - - delegate :to_s, :to_json, to: :value - - def blank? - value.blank? || FALSE_VALUES.include?(value.to_s.downcase) - end - - # rubocop:disable Rails/Present - def present? - !blank? - end - # rubocop:enable Rails/Present - - def to_boolean_string - present?.to_s - end - - def to_i - str = blank? ? @default : value - str.to_s.to_i - end - - def to_f - str = blank? ? @default : value - str.to_s.to_f - end - - def default_or_present_if_exists - return @default unless ENV.has_key?(@name) - - @value.present? && FALSE_VALUES.exclude?(@value.to_s.downcase) - end - - def to_array(separator: ",") - str = blank? ? @default : value - str.to_s.split(separator).map(&:strip) - end - end -end diff --git a/spec/system/favicon_spec.rb b/spec/system/favicon_spec.rb index b95727585..69d8a1e4c 100644 --- a/spec/system/favicon_spec.rb +++ b/spec/system/favicon_spec.rb @@ -12,7 +12,7 @@ it "uses the default favicon" do visit decidim.root_path - expect(page).to have_xpath("/html/head/link[contains(@href, 'default_favicon')]", visible: :all) + expect(page).to have_xpath("/html/body/link[contains(@href, 'default_favicon')]", visible: :all) end end @@ -25,7 +25,7 @@ it "uses the organization favicon" do visit decidim.root_path - expect(page).to have_xpath("/html/head/link[contains(@href, 'icon.png')]", visible: :all) + expect(page).to have_xpath("/html/body/link[contains(@href, 'icon.png')]", visible: :all) end end end