Class: ReactOnRails::Generators::ReactNoReduxGenerator

Inherits:
Rails::Generators::Base
  • Object
show all
Includes:
GeneratorHelper, DemoPageConfig
Defined in:
lib/generators/react_on_rails/react_no_redux_generator.rb

Instance Method Summary collapse

Methods included from DemoPageConfig

#build_hello_server_view_config, #build_hello_world_view_config

Methods included from GeneratorHelper

#add_documentation_reference, #add_npm_dependencies, #bundler_flag_given?, #component_extension, #destination_config_path, #detect_react_version, #explicit_bundler_choice, #gem_in_lockfile?, #package_json, #print_generator_messages, #pro_gem_installed?, #resolve_server_client_or_both_path, #root_route_present?, #rsc_plugin_class_name, #rsc_plugin_import_path, #rspack_bundler_default, #shakapacker_version_9_or_higher?, #use_pro?, #use_rsc?, #use_tailwind?, #using_rspack?, #using_swc?

Instance Method Details

#copy_base_filesObject



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/generators/react_on_rails/react_no_redux_generator.rb', line 31

def copy_base_files
  base_js_path = "base/base"
  tailwind_js_path = "base/tailwind"
  ext = component_extension(options)

  # Determine which component files to copy based on TypeScript option
  client_component =
    "app/javascript/src/HelloWorld/ror_components/HelloWorld.client.#{ext}"
  server_component =
    "app/javascript/src/HelloWorld/ror_components/HelloWorld.server.#{ext}"

  if use_tailwind?
    copy_file("#{tailwind_js_path}/#{client_component}", client_component)
  else
    copy_file("#{base_js_path}/#{client_component}", client_component)
    copy_file("#{base_js_path}/app/javascript/src/HelloWorld/ror_components/HelloWorld.module.css",
              "app/javascript/src/HelloWorld/ror_components/HelloWorld.module.css")
  end

  copy_file("#{base_js_path}/#{server_component}", server_component)
end

#create_appropriate_templatesObject



53
54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/generators/react_on_rails/react_no_redux_generator.rb', line 53

def create_appropriate_templates
  base_path = "base/base"

  # Only create the view template - no manual bundle needed for auto-bundling
  template("#{base_path}/app/views/hello_world/index.html.erb.tt",
           "app/views/hello_world/index.html.erb",
           build_hello_world_view_config(
             component_name: "HelloWorld",
             source_path: "app/javascript/src/HelloWorld/",
             landing_page: new_app_landing_page_available?,
             redux: false,
             rsc_demo: false
           ))
end