Module: GeneratorMessages

Defined in:
lib/generators/react_on_rails/generator_messages.rb

Class Method Summary collapse

Class Method Details

.add_error(message) ⇒ Object



11
12
13
# File 'lib/generators/react_on_rails/generator_messages.rb', line 11

def add_error(message)
  output << format_error(message)
end

.add_info(message) ⇒ Object



19
20
21
# File 'lib/generators/react_on_rails/generator_messages.rb', line 19

def add_info(message)
  output << format_info(message)
end

.add_warning(message) ⇒ Object



15
16
17
# File 'lib/generators/react_on_rails/generator_messages.rb', line 15

def add_warning(message)
  output << format_warning(message)
end

.clearObject



39
40
41
# File 'lib/generators/react_on_rails/generator_messages.rb', line 39

def clear
  @output = []
end

.format_error(msg) ⇒ Object



27
28
29
# File 'lib/generators/react_on_rails/generator_messages.rb', line 27

def format_error(msg)
  Rainbow("ERROR: #{msg}").red
end

.format_info(msg) ⇒ Object



35
36
37
# File 'lib/generators/react_on_rails/generator_messages.rb', line 35

def format_info(msg)
  Rainbow(msg.to_s).green
end

.format_warning(msg) ⇒ Object



31
32
33
# File 'lib/generators/react_on_rails/generator_messages.rb', line 31

def format_warning(msg)
  Rainbow("WARNING: #{msg}").orange
end

.helpful_message_after_installation(component_name: "HelloWorld", route: "hello_world", rsc: false, shakapacker_just_installed: false) ⇒ Object



43
44
45
46
47
48
49
50
51
52
53
54
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
82
83
84
85
86
87
88
89
90
91
# File 'lib/generators/react_on_rails/generator_messages.rb', line 43

def helpful_message_after_installation(component_name: "HelloWorld", route: "hello_world", rsc: false,
                                       shakapacker_just_installed: false)
  process_manager_section = build_process_manager_section
  testing_section = build_testing_section
  package_manager = detect_package_manager
  shakapacker_status = build_shakapacker_status_section(shakapacker_just_installed: shakapacker_just_installed)
  render_example = build_render_example(component_name: component_name, route: route, rsc: rsc)
  render_label = if rsc
                   "• Streaming server rendering in app/views/#{route}/index.html.erb:"
                 else
                   "• Server-side rendering - Enabled with prerender option in app/views/#{route}/index.html.erb:"
                 end

  <<~MSG

    ╔════════════════════════════════════════════════════════════════════════╗
    ║  🎉 React on Rails Successfully Installed!                             ║
    ╚════════════════════════════════════════════════════════════════════════╝
    #{process_manager_section}#{shakapacker_status}

    📋 QUICK START:
    ─────────────────────────────────────────────────────────────────────────
    1. Install dependencies:
       #{Rainbow("bundle && #{package_manager} install").cyan}

    2. Start the app:
       ./bin/dev              # HMR (Hot Module Replacement) mode
       ./bin/dev static       # Static bundles (no HMR, faster initial load)
       ./bin/dev prod         # Production-like mode for testing
       ./bin/dev help         # See all available options

    3. Visit: #{Rainbow(route ? "http://localhost:3000/#{route}" : 'http://localhost:3000').cyan.underline}
    ✨ KEY FEATURES:
    ─────────────────────────────────────────────────────────────────────────
    • Auto-registration enabled - Your layout only needs:
      <%= javascript_pack_tag %>
      <%= stylesheet_pack_tag %>

    #{render_label}
      #{render_example}

    📚 LEARN MORE:
    ─────────────────────────────────────────────────────────────────────────
    • Documentation: #{Rainbow('https://www.shakacode.com/react-on-rails/docs/').cyan.underline}
    • Webpack customization: #{Rainbow('https://github.com/shakacode/shakapacker#webpack-configuration').cyan.underline}

    💡 TIP: Run 'bin/dev help' for development server options and troubleshooting#{testing_section}
  MSG
end

.messagesObject



23
24
25
# File 'lib/generators/react_on_rails/generator_messages.rb', line 23

def messages
  output
end

.outputObject



7
8
9
# File 'lib/generators/react_on_rails/generator_messages.rb', line 7

def output
  @output ||= []
end