Module: ReactOnRails::Generators::ProSetup
- Included in:
- InstallGenerator, ProGenerator
- Defined in:
- lib/generators/react_on_rails/pro_setup.rb
Overview
Provides Pro setup functionality for React on Rails generators.
This module extracts Pro-specific setup methods that can be shared between:
-
InstallGenerator (when –pro or –rsc flags are used)
-
ProGenerator (standalone generator for upgrading existing apps)
Required Dependencies
Including classes must provide (typically via Rails::Generators::Base):
-
destination_root: Path to the target Rails application
-
template, copy_file, append_to_file: Thor file manipulation methods
-
options: Generator options hash
Including classes must also include GeneratorHelper which provides:
-
use_pro?, use_rsc?: Feature flag helpers
-
pro_gem_installed?: Pro gem detection
Instance Method Summary collapse
-
#missing_pro_gem?(force: false) ⇒ Boolean
Check if Pro gem is missing.
-
#setup_pro ⇒ Object
Main entry point for Pro setup.
Instance Method Details
#missing_pro_gem?(force: false) ⇒ Boolean
Check if Pro gem is missing.
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/generators/react_on_rails/pro_setup.rb', line 55 def missing_pro_gem?(force: false) return false unless force || use_pro? return false if pro_gem_installed? # Detect context: install_generator defines :pro/:rsc options, standalone generators don't context_line = if .key?(:pro) || .key?(:rsc) flag = [:rsc] ? "--rsc" : "--pro" "You specified #{flag}, which requires the react_on_rails_pro gem." else "This generator requires the react_on_rails_pro gem." end GeneratorMessages.add_error(<<~MSG.strip) 🚫 React on Rails Pro gem is not installed. #{context_line} Add to your Gemfile: gem 'react_on_rails_pro', '>= 16.3.0' Then run: bundle install Try Pro free! Email justin@shakacode.com for an evaluation license. More info: https://www.shakacode.com/react-on-rails-pro/ MSG true end |
#setup_pro ⇒ Object
NPM dependencies are handled separately by JsDependencyManager
Main entry point for Pro setup. Orchestrates creation of all Pro-related files and configuration.
Creates:
-
config/initializers/react_on_rails_pro.rb
-
client/node-renderer.js
-
Procfile.dev entry for node-renderer
34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/generators/react_on_rails/pro_setup.rb', line 34 def setup_pro puts Rainbow("\n#{'=' * 80}").cyan puts Rainbow("🚀 REACT ON RAILS PRO SETUP").cyan.bold puts Rainbow("=" * 80).cyan create_pro_initializer create_node_renderer add_pro_to_procfile update_webpack_config_for_pro puts Rainbow("=" * 80).cyan puts Rainbow("✅ React on Rails Pro setup complete!").green puts Rainbow("=" * 80).cyan end |