From e50ed0440eb61a3c7b256fdc8448e5b75110922c Mon Sep 17 00:00:00 2001 From: Trinity Takei Date: Mon, 24 Jun 2024 18:29:23 +0200 Subject: [PATCH 1/6] Look for tailwind.config.js in Rails.root, app/**, config/** --- .../phlex/install/install_generator.rb | 20 ++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/lib/generators/phlex/install/install_generator.rb b/lib/generators/phlex/install/install_generator.rb index ecbd734..b154746 100644 --- a/lib/generators/phlex/install/install_generator.rb +++ b/lib/generators/phlex/install/install_generator.rb @@ -5,7 +5,6 @@ class InstallGenerator < ::Rails::Generators::Base source_root File.expand_path("templates", __dir__) APPLICATION_CONFIGURATION_PATH = Rails.root.join("config/application.rb") - TAILWIND_CONFIGURATION_PATH = Rails.root.join("tailwind.config.js") def autoload_components return unless APPLICATION_CONFIGURATION_PATH.exist? @@ -38,9 +37,9 @@ def autoload_views end def configure_tailwind - return unless TAILWIND_CONFIGURATION_PATH.exist? + return unless tailwind_configuration_path.exist? - insert_into_file TAILWIND_CONFIGURATION_PATH, after: "content: [" do + insert_into_file tailwind_configuration_path, after: "content: [" do "\n './app/views/**/*.rb'," \ end end @@ -55,6 +54,21 @@ def create_application_layout def create_application_view template "application_view.rb", Rails.root.join("app/views/application_view.rb") + end + + private + + def tailwind_configuration_path + @_tailwind_configuration_path ||= + Pathname.new(tailwind_configuration_files.first) + end + + def tailwind_configuration_files + Dir.glob([ + "#{Rails.root}/tailwind.config.js", + "#{Rails.root}/app/**/tailwind.config.js", + "#{Rails.root}/config/**/tailwind.config.js", + ]) end end end From ae342e793ca14081ef1c50662c274931bd8de886 Mon Sep 17 00:00:00 2001 From: Trinity Takei Date: Wed, 28 Aug 2024 18:54:04 +0200 Subject: [PATCH 2/6] Update lib/generators/phlex/install/install_generator.rb Yes! Co-authored-by: Joel Drapper Signed-off-by: Trinity Takei --- lib/generators/phlex/install/install_generator.rb | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/lib/generators/phlex/install/install_generator.rb b/lib/generators/phlex/install/install_generator.rb index b154746..83b24cf 100644 --- a/lib/generators/phlex/install/install_generator.rb +++ b/lib/generators/phlex/install/install_generator.rb @@ -64,11 +64,13 @@ def tailwind_configuration_path end def tailwind_configuration_files - Dir.glob([ - "#{Rails.root}/tailwind.config.js", - "#{Rails.root}/app/**/tailwind.config.js", - "#{Rails.root}/config/**/tailwind.config.js", - ]) + Dir.glob( + [ + "#{Rails.root}/tailwind.config.js", + "#{Rails.root}/app/**/tailwind.config.js", + "#{Rails.root}/config/**/tailwind.config.js", + ] + ) end end end From 7572901f6f446c86646cc7e7f169a72f834b65a1 Mon Sep 17 00:00:00 2001 From: Matt Jankowski Date: Sat, 17 Aug 2024 15:11:59 -0400 Subject: [PATCH 3/6] Fix `data` attribute in layout generator template --- lib/generators/phlex/install/templates/application_layout.rb | 2 +- test/dummy/app/views/layouts/application_layout.rb | 2 +- test/phlex/layout_test.rb | 2 ++ 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/generators/phlex/install/templates/application_layout.rb b/lib/generators/phlex/install/templates/application_layout.rb index 14d451c..457547e 100644 --- a/lib/generators/phlex/install/templates/application_layout.rb +++ b/lib/generators/phlex/install/templates/application_layout.rb @@ -12,7 +12,7 @@ def view_template(&block) meta name: "viewport", content: "width=device-width,initial-scale=1" csp_meta_tag csrf_meta_tags - stylesheet_link_tag "application", data_turbo_track: "reload" + stylesheet_link_tag "application", data: { turbo_track: "reload" } javascript_importmap_tags end diff --git a/test/dummy/app/views/layouts/application_layout.rb b/test/dummy/app/views/layouts/application_layout.rb index 52fac84..49f3974 100644 --- a/test/dummy/app/views/layouts/application_layout.rb +++ b/test/dummy/app/views/layouts/application_layout.rb @@ -16,7 +16,7 @@ def view_template(&block) meta name: "viewport", content: "width=device-width,initial-scale=1" csp_meta_tag csrf_meta_tags - stylesheet_link_tag "application", data_turbo_track: "reload" + stylesheet_link_tag "application", data: { turbo_track: "reload" } end body(class: tokens(-> { @color == :blue } => { then: "bg-blue", else: "bg-black" })) do diff --git a/test/phlex/layout_test.rb b/test/phlex/layout_test.rb index 1c701c7..3eedfe2 100644 --- a/test/phlex/layout_test.rb +++ b/test/phlex/layout_test.rb @@ -7,6 +7,7 @@ class LayoutTest < ActionDispatch::IntegrationTest get "/layout/with_erb_view" assert_response :success assert_select "body.bg-blue" + assert_select "link[rel=stylesheet][data-turbo-track=reload]" assert_select "title", "ERB View" assert_select "h1", "Hello from ERB" end @@ -14,6 +15,7 @@ class LayoutTest < ActionDispatch::IntegrationTest test "with phlex view" do get "/layout/with_phlex_view" assert_response :success + assert_select "link[rel=stylesheet][data-turbo-track=reload]" assert_select "title", "Phlex View" assert_select "h1", "Hello from Phlex" end From 87b3b5b10efebee5b58fbce31144f0a5563290f0 Mon Sep 17 00:00:00 2001 From: Matt Jankowski Date: Sat, 17 Aug 2024 15:17:48 -0400 Subject: [PATCH 4/6] Use release version of `appraisal` gem The issues fixed in the branch have been resolved, merged, released. --- Gemfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile b/Gemfile index d322aca..5738ea3 100644 --- a/Gemfile +++ b/Gemfile @@ -9,7 +9,7 @@ gem "phlex", github: "phlex-ruby/phlex", branch: "1.11" gem "rubocop" gem "solargraph" gem "view_component" -gem "appraisal", github: "excid3/appraisal", branch: "fix-bundle-env" +gem "appraisal" gem "yard" gem "rails" From ce710dca6ebb139740f9ba74335436ac14cc911f Mon Sep 17 00:00:00 2001 From: Matt Jankowski Date: Mon, 26 Aug 2024 10:42:14 -0400 Subject: [PATCH 5/6] Use rails-version-specific sqlite3 gem versions --- Appraisals | 2 ++ Gemfile | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/Appraisals b/Appraisals index 3bc5650..e01d6f3 100644 --- a/Appraisals +++ b/Appraisals @@ -2,10 +2,12 @@ appraise "rails-7" do gem "rails", "~> 7" + gem "sqlite3", "~> 1.7" end if RUBY_VERSION >= "3.1.0" appraise "rails-edge" do gem "rails", github: "rails/rails" + gem "sqlite3", ">= 2.0" end end diff --git a/Gemfile b/Gemfile index 5738ea3..af86fd7 100644 --- a/Gemfile +++ b/Gemfile @@ -14,4 +14,4 @@ gem "yard" gem "rails" gem "puma" -gem "sqlite3", "~> 1.7" +gem "sqlite3" From 8c5746f6bbb28a5397c581cb0a3be4522651633c Mon Sep 17 00:00:00 2001 From: Matt Jankowski Date: Mon, 26 Aug 2024 10:58:50 -0400 Subject: [PATCH 6/6] Remove deprecated hash style of route declaration in dummy app --- lib/generators/phlex/install/install_generator.rb | 2 +- test/dummy/config/routes.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/generators/phlex/install/install_generator.rb b/lib/generators/phlex/install/install_generator.rb index 83b24cf..23a30f8 100644 --- a/lib/generators/phlex/install/install_generator.rb +++ b/lib/generators/phlex/install/install_generator.rb @@ -69,7 +69,7 @@ def tailwind_configuration_files "#{Rails.root}/tailwind.config.js", "#{Rails.root}/app/**/tailwind.config.js", "#{Rails.root}/config/**/tailwind.config.js", - ] + ], ) end end diff --git a/test/dummy/config/routes.rb b/test/dummy/config/routes.rb index 03e975a..aaca9a4 100644 --- a/test/dummy/config/routes.rb +++ b/test/dummy/config/routes.rb @@ -5,7 +5,7 @@ # Reveal health status on /up that returns 200 if the app boots with no exceptions, otherwise 500. # Can be used by load balancers and uptime monitors to verify that the app is live. - get "up" => "rails/health#show", :as => :rails_health_check + get "up", to: "rails/health#show", as: :rails_health_check # Defines the root path route ("/") root "posts#index"