Skip to content

Commit 638f0ee

Browse files
committed
Update doctor.rb to check Pro config for immediate_hydration
Moves immediate_hydration configuration check from ReactOnRails config analysis to ReactOnRailsPro config analysis. The doctor now reads the react_on_rails_pro.rb initializer file to display immediate_hydration settings when the Pro package is configured.
1 parent 31edd4f commit 638f0ee

File tree

1 file changed

+24
-6
lines changed

1 file changed

+24
-6
lines changed

lib/react_on_rails/doctor.rb

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -633,6 +633,7 @@ def check_shakapacker_configuration_details
633633

634634
def check_react_on_rails_configuration_details
635635
check_react_on_rails_initializer
636+
check_react_on_rails_pro_initializer
636637
check_deprecated_configuration_settings
637638
check_breaking_changes_warnings
638639
end
@@ -664,6 +665,29 @@ def check_react_on_rails_initializer
664665
end
665666
end
666667

668+
def check_react_on_rails_pro_initializer
669+
config_path = "config/initializers/react_on_rails_pro.rb"
670+
671+
return unless File.exist?(config_path)
672+
673+
begin
674+
content = File.read(config_path)
675+
676+
checker.add_info("\n📋 React on Rails Pro Configuration:")
677+
checker.add_info("📍 Documentation: https://www.shakacode.com/react-on-rails-pro/")
678+
679+
# Immediate hydration (Pro feature)
680+
immediate_hydration_match = content.match(/config\.immediate_hydration\s*=\s*([^\s\n,]+)/)
681+
if immediate_hydration_match
682+
checker.add_info(" immediate_hydration: #{immediate_hydration_match[1]}")
683+
else
684+
checker.add_info(" immediate_hydration: false (default)")
685+
end
686+
rescue StandardError => e
687+
checker.add_warning("⚠️ Unable to read react_on_rails_pro.rb: #{e.message}")
688+
end
689+
end
690+
667691
def analyze_server_rendering_config(content)
668692
checker.add_info("\n🖥️ Server Rendering:")
669693

@@ -732,12 +756,6 @@ def analyze_performance_config(content)
732756
auto_load_match = content.match(/config\.auto_load_bundle\s*=\s*([^\s\n,]+)/)
733757
checker.add_info(" auto_load_bundle: #{auto_load_match[1]}") if auto_load_match
734758

735-
# Immediate hydration (Pro feature)
736-
immediate_hydration_match = content.match(/config\.immediate_hydration\s*=\s*([^\s\n,]+)/)
737-
if immediate_hydration_match
738-
checker.add_info(" immediate_hydration: #{immediate_hydration_match[1]} (React on Rails Pro)")
739-
end
740-
741759
# Component registry timeout
742760
timeout_match = content.match(/config\.component_registry_timeout\s*=\s*([^\s\n,]+)/)
743761
return unless timeout_match

0 commit comments

Comments
 (0)