From 45fc94f63727cba00517e8445ad234913c4ef46a Mon Sep 17 00:00:00 2001 From: Gareth Jones Date: Fri, 6 Oct 2023 09:53:27 +1300 Subject: [PATCH 01/11] feat: require Rails v7.1 --- README.md | 2 +- template.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index e48384bf..77737a21 100644 --- a/README.md +++ b/README.md @@ -155,7 +155,7 @@ Before running this template, you must have the following installed on your machine: - Yarn v1.21.0 or later -- Rails 7.0.x +- Rails 7.1.x The following are not strictly required to run the template but you will need it to start the Rails app that this template creates: diff --git a/template.rb b/template.rb index b0e031ad..549949e0 100644 --- a/template.rb +++ b/template.rb @@ -2,7 +2,7 @@ require "shellwords" require "pp" -RAILS_REQUIREMENT = "~> 7.0.3".freeze +RAILS_REQUIREMENT = "~> 7.1.0".freeze ## # This single template file will be downloaded and run by the `rails new` From 60bd7f945cf8a782c723cf328673ccd0e10713bb Mon Sep 17 00:00:00 2001 From: Gareth Jones Date: Fri, 6 Oct 2023 09:53:40 +1300 Subject: [PATCH 02/11] fix: force copying our `Dockerfile` and `.dockerignore` --- template.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/template.rb b/template.rb index 549949e0..f4bf70cb 100644 --- a/template.rb +++ b/template.rb @@ -92,10 +92,10 @@ def apply_template! # rubocop:disable Metrics/MethodLength, Metrics/AbcSize, Met copy_file "variants/backend-base/.node-version", ".node-version" - copy_file "variants/backend-base/Dockerfile", "Dockerfile" + copy_file "variants/backend-base/Dockerfile", "Dockerfile", force: true copy_file "variants/backend-base/docker-compose.yml", "docker-compose.yml" copy_file "variants/backend-base/.osv-detector.yml", ".osv-detector.yml" - copy_file "variants/backend-base/.dockerignore", ".dockerignore" + copy_file "variants/backend-base/.dockerignore", ".dockerignore", force: true apply "variants/backend-base/Rakefile.rb" apply "variants/backend-base/config.ru.rb" From e0af1d0ca4ebf7d1a4a63dff8d5dc89f1f6c6756 Mon Sep 17 00:00:00 2001 From: Gareth Jones Date: Fri, 6 Oct 2023 10:17:09 +1300 Subject: [PATCH 03/11] fix: don't do stuff that shakapacker now does for us --- variants/frontend-base/template.rb | 2 -- 1 file changed, 2 deletions(-) diff --git a/variants/frontend-base/template.rb b/variants/frontend-base/template.rb index 011447dc..e16da4d9 100644 --- a/variants/frontend-base/template.rb +++ b/variants/frontend-base/template.rb @@ -25,8 +25,6 @@ # Configure app/frontend run "mv app/javascript app/frontend" -run "mkdir app/frontend/packs" -run "mv app/frontend/application.js app/frontend/packs/application.js" copy_file "config/webpack/webpack.config.js", force: true From 5c23c8d8b54257095b36c8a240f8775800af388f Mon Sep 17 00:00:00 2001 From: Gareth Jones Date: Fri, 6 Oct 2023 10:26:42 +1300 Subject: [PATCH 04/11] fix: require skipping docker entirely --- .github/workflows/ci.yml | 2 +- README.md | 7 ++++--- ci/bin/build-and-test | 2 +- template.rb | 1 + 4 files changed, 7 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 87bb65b4..085402b3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -150,7 +150,7 @@ jobs: # "react", "sidekiq" etc. APP_NAME: ${{ matrix.variant.name }}-demo CONFIG_PATH: ${{ matrix.variant.config_path }} - SKIPS: "--skip-javascript ${{ matrix.variant.skips }}" + SKIPS: "--skip-javascript --skip-docker ${{ matrix.variant.skips }}" PGUSER: postgres PGPASSWORD: postgres PGHOST: localhost diff --git a/README.md b/README.md index 77737a21..e46370d8 100644 --- a/README.md +++ b/README.md @@ -192,7 +192,7 @@ $ wget https://raw.githubusercontent.com/ackama/rails-template/main/ackama_rails # Create a new app using the template. Template options will be taken from # ./ackama_rails_template.config.yml -$ rails new my_app --no-rc --database=postgresql --skip-javascript --template=https://raw.githubusercontent.com/ackama/rails-template/main/template.rb +$ rails new my_app --no-rc --database=postgresql --skip-javascript --skip-docker --template=https://raw.githubusercontent.com/ackama/rails-template/main/template.rb # Example 2 # ######### @@ -200,7 +200,7 @@ $ rails new my_app --no-rc --database=postgresql --skip-javascript --template=ht # Create a custom config YAML file, saving as ./my_custom_config.yml # Template options will be taken from ../my_custom_config.yml (relative to the new app directory) -$ CONFIG_PATH=../my_custom_config.yml rails new my_app --no-rc --database=postgresql --skip-javascript --template=https://raw.githubusercontent.com/ackama/rails-template/main/template.rb +$ CONFIG_PATH=../my_custom_config.yml rails new my_app --no-rc --database=postgresql --skip-javascript --skip-docker --template=https://raw.githubusercontent.com/ackama/rails-template/main/template.rb ``` Here are some additional options you can add to this command. We don't @@ -228,6 +228,7 @@ To make this the default Rails application template on your system, create a # ~/.railsrc -d postgresql --skip-javascript +--skip-docker -m https://raw.githubusercontent.com/ackama/rails-template/main/template.rb ``` @@ -275,7 +276,7 @@ $ CONFIG_PATH="ci/configs/react.yml" APP_NAME="enterprise" ./ci/bin/build-and-te # because the template is run by `rails new` which uses the rails app dir as # it's working dir, hence the `../` at the start. # -$ rm -rf mydemoapp && CONFIG_PATH="../ci/configs/react.yml" rails new mydemoapp -d postgresql --skip-javascript -m ./template.rb +$ rm -rf mydemoapp && CONFIG_PATH="../ci/configs/react.yml" rails new mydemoapp -d postgresql --skip-javascript --skip-docker -m ./template.rb ``` Rubocop is configured for this repo and is run as part of CI. Run rubocop diff --git a/ci/bin/build-and-test b/ci/bin/build-and-test index 94e9b966..247d46c8 100755 --- a/ci/bin/build-and-test +++ b/ci/bin/build-and-test @@ -15,7 +15,7 @@ config_path = if ENV.fetch("CONFIG_PATH", "") == "" end config_env_var = %Q(CONFIG_PATH="#{config_path}") if config_path -skip_flags = ENV.fetch("SKIPS", "--skip-javascript") +skip_flags = ENV.fetch("SKIPS", "--skip-javascript --skip-docker") puts "=" * 80 puts <<~EO_CONFIG_SUMMARY diff --git a/template.rb b/template.rb index f4bf70cb..92e21f0f 100644 --- a/template.rb +++ b/template.rb @@ -304,6 +304,7 @@ def assert_valid_options skip_test_unit: true, skip_active_storage: false, skip_javascript: true, + skip_docker: true, edge: false } valid_options.each do |key, expected| From 5b12b687fbbdace70c3214f1818e11f808938f59 Mon Sep 17 00:00:00 2001 From: Gareth Jones Date: Fri, 6 Oct 2023 10:27:52 +1300 Subject: [PATCH 05/11] fix: skip `bullet` for now --- template.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/template.rb b/template.rb index 92e21f0f..7fe45577 100644 --- a/template.rb +++ b/template.rb @@ -142,7 +142,7 @@ def apply_template! # rubocop:disable Metrics/MethodLength, Metrics/AbcSize, Met # The accessibility template brings in the lighthouse and # lighthouse matcher parts we need to run performance specs apply "variants/performance/template.rb" - apply "variants/bullet/template.rb" + # apply "variants/bullet/template.rb" # TODO: does not support Rails 7.1 yet apply "variants/pundit/template.rb" apply "variants/audit-logging/template.rb" apply "variants/sidekiq/template.rb" if TEMPLATE_CONFIG.apply_variant_sidekiq? From 259b9f678013cb990711da8622c2477b06e82fdc Mon Sep 17 00:00:00 2001 From: Gareth Jones Date: Fri, 6 Oct 2023 10:32:36 +1300 Subject: [PATCH 06/11] fix: update file name to match class --- .../{auditor_log_formatter.rb => audit_log_log_formatter.rb} | 0 variants/audit-logging/template.rb | 4 ++-- 2 files changed, 2 insertions(+), 2 deletions(-) rename variants/audit-logging/lib/{auditor_log_formatter.rb => audit_log_log_formatter.rb} (100%) diff --git a/variants/audit-logging/lib/auditor_log_formatter.rb b/variants/audit-logging/lib/audit_log_log_formatter.rb similarity index 100% rename from variants/audit-logging/lib/auditor_log_formatter.rb rename to variants/audit-logging/lib/audit_log_log_formatter.rb diff --git a/variants/audit-logging/template.rb b/variants/audit-logging/template.rb index 21f24667..49659eae 100644 --- a/variants/audit-logging/template.rb +++ b/variants/audit-logging/template.rb @@ -1,6 +1,6 @@ source_paths.unshift(File.dirname(__FILE__)) -copy_file("variants/audit-logging/lib/auditor_log_formatter.rb", "lib/auditor_log_formatter.rb") +copy_file("variants/audit-logging/lib/audit_log_log_formatter.rb", "lib/audit_log_log_formatter.rb") copy_file("variants/audit-logging/services/audit_log.rb", "app/services/audit_log.rb") copy_file("variants/audit-logging/spec/services/audit_log_spec.rb", "spec/services/audit_log_spec.rb") @@ -19,7 +19,7 @@ prepend_to_file "config/application.rb" do <<~RUBY - require_relative "../lib/auditor_log_formatter" + require_relative "../lib/audit_log_log_formatter" RUBY end From c6ef1c641bdcfd799b23db388f5ce8a01e640e41 Mon Sep 17 00:00:00 2001 From: Gareth Jones Date: Fri, 6 Oct 2023 14:27:03 +1300 Subject: [PATCH 07/11] ci: remove duplicate env variables --- .github/workflows/ci.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 085402b3..2f21227e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -154,8 +154,4 @@ jobs: PGUSER: postgres PGPASSWORD: postgres PGHOST: localhost - RAILS_SECRET_KEY_BASE: "placeholder" - ACTIVE_RECORD_ENCRYPTION_PRIMARY_KEY: "placeholder" - ACTIVE_RECORD_ENCRYPTION_DETERMINISTIC_KEY: "placeholder" - ACTIVE_RECORD_ENCRYPTION_KEY_DERIVATION_SALT: "placeholder" run: ./ci/bin/build-and-test From 348a9503637b6c7203fc158b2a39047c326757a9 Mon Sep 17 00:00:00 2001 From: Eoin Kelly Date: Fri, 6 Oct 2023 13:26:28 +1300 Subject: [PATCH 08/11] fix: include nonce --- .../backend-base/app/views/layouts/application.html.erb.tt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/variants/backend-base/app/views/layouts/application.html.erb.tt b/variants/backend-base/app/views/layouts/application.html.erb.tt index c3c68b5e..e20f9ef9 100644 --- a/variants/backend-base/app/views/layouts/application.html.erb.tt +++ b/variants/backend-base/app/views/layouts/application.html.erb.tt @@ -2,7 +2,7 @@ - <%%= strip_tags(yield(:title)) + " – " if content_for?(:title) %> + <%%= strip_tags(yield(:title)) + " - " if content_for?(:title) %> <%= app_const_base.titleize %> @@ -15,7 +15,7 @@ <%%= stylesheet_link_tag("application", media: "all", "data-turbolinks-track": "reload") %> <%%# JavaScript must be in head for Turbolinks to work. %> - <%%= javascript_pack_tag "application", "data-turbolinks-track": "reload", defer: true %> + <%%= javascript_pack_tag "application", "data-turbolinks-track": "reload", defer: true, nonce: true %> <%%= yield(:head) %> From 3e617ece3d0d7db14e288b2f8da04ef4d72d0ec3 Mon Sep 17 00:00:00 2001 From: Eoin Kelly Date: Sat, 21 Oct 2023 14:34:17 +1300 Subject: [PATCH 09/11] Bump to latest 7.1 --- template.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/template.rb b/template.rb index 7fe45577..c8eae737 100644 --- a/template.rb +++ b/template.rb @@ -2,7 +2,7 @@ require "shellwords" require "pp" -RAILS_REQUIREMENT = "~> 7.1.0".freeze +RAILS_REQUIREMENT = "~> 7.1.1".freeze ## # This single template file will be downloaded and run by the `rails new` From 27013a2ae191a50cad6b39d8ad00e44560aa84b7 Mon Sep 17 00:00:00 2001 From: Eoin Kelly Date: Sat, 21 Oct 2023 14:34:35 +1300 Subject: [PATCH 10/11] Bullet gem is now 7.1 compatible --- template.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/template.rb b/template.rb index c8eae737..853c9d7b 100644 --- a/template.rb +++ b/template.rb @@ -142,7 +142,7 @@ def apply_template! # rubocop:disable Metrics/MethodLength, Metrics/AbcSize, Met # The accessibility template brings in the lighthouse and # lighthouse matcher parts we need to run performance specs apply "variants/performance/template.rb" - # apply "variants/bullet/template.rb" # TODO: does not support Rails 7.1 yet + apply "variants/bullet/template.rb" apply "variants/pundit/template.rb" apply "variants/audit-logging/template.rb" apply "variants/sidekiq/template.rb" if TEMPLATE_CONFIG.apply_variant_sidekiq? From 4b4cdb9d641ec3f0fac3ba97a3b56977543b06e6 Mon Sep 17 00:00:00 2001 From: Eoin Kelly Date: Sat, 21 Oct 2023 16:00:41 +1300 Subject: [PATCH 11/11] Disable config.action_controller.raise_on_missing_callback_actions checks --- variants/backend-base/config/environments/development.rb | 4 ++++ variants/backend-base/config/environments/test.rb | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/variants/backend-base/config/environments/development.rb b/variants/backend-base/config/environments/development.rb index ae27edd3..d4a52b50 100644 --- a/variants/backend-base/config/environments/development.rb +++ b/variants/backend-base/config/environments/development.rb @@ -18,3 +18,7 @@ gsub_file "config/environments/development.rb", "join('tmp', 'caching-dev.txt')", 'join("tmp/caching-dev.txt")' + +gsub_file "config/environments/development.rb", + "config.action_controller.raise_on_missing_callback_actions = true", + "# config.action_controller.raise_on_missing_callback_actions = true" diff --git a/variants/backend-base/config/environments/test.rb b/variants/backend-base/config/environments/test.rb index 928e2512..9742ec1c 100644 --- a/variants/backend-base/config/environments/test.rb +++ b/variants/backend-base/config/environments/test.rb @@ -16,3 +16,7 @@ config.i18n.raise_on_missing_translations = true RUBY end + +gsub_file "config/environments/test.rb", + "config.action_controller.raise_on_missing_callback_actions = true", + "# config.action_controller.raise_on_missing_callback_actions = true"