Class: ReactOnRails::Generators::ReactNoReduxGenerator

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

Instance Method Summary collapse

Methods included from GeneratorHelper

#add_documentation_reference, #add_npm_dependencies, #component_extension, #copy_file_and_missing_parent_directories, #dest_dir_exists?, #dest_file_exists?, #destination_config_path, #detect_react_version, #empty_directory_with_keep_file, #gem_in_lockfile?, #keep_file, #mark_pro_gem_installed!, #package_json, #print_generator_messages, #pro_gem_installed?, #resolve_server_client_or_both_path, #setup_file_error, #shakapacker_version_9_or_higher?, #symlink_dest_file_to_dest_file, #use_pro?, #use_rsc?, #using_rspack?, #using_swc?

Instance Method Details

#copy_base_filesObject



19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/generators/react_on_rails/react_no_redux_generator.rb', line 19

def copy_base_files
  base_js_path = "base/base"

  # Determine which component files to copy based on TypeScript option
  component_files = [
    "app/javascript/src/HelloWorld/ror_components/HelloWorld.client.#{component_extension(options)}",
    "app/javascript/src/HelloWorld/ror_components/HelloWorld.server.#{component_extension(options)}",
    "app/javascript/src/HelloWorld/ror_components/HelloWorld.module.css"
  ]

  component_files.each do |file|
    copy_file("#{base_js_path}/#{file}", file)
  end
end

#create_appropriate_templatesObject



34
35
36
37
38
39
40
41
42
43
# File 'lib/generators/react_on_rails/react_no_redux_generator.rb', line 34

def create_appropriate_templates
  base_path = "base/base"
  config = {
    component_name: "HelloWorld"
  }

  # 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", config)
end