@@ -19,7 +19,7 @@ def copy_main_component_file
1919 say "Generating main component"
2020
2121 copy_file File . join ( component_folder_path , "#{ component_folder_name } .rb" ) ,
22- Rails . root . join ( "app/components/ruby_ui/ " , "#{ component_folder_name } .rb" )
22+ Rails . root . join ( "app/components/ruby_ui" , "#{ component_folder_name } .rb" )
2323 end
2424
2525 def copy_subcomponents_files
@@ -29,10 +29,24 @@ def copy_subcomponents_files
2929
3030 subcomponent_file_paths . each do |file_path |
3131 component_file_name = file_path . split ( "/" ) . last
32- copy_file file_path , Rails . root . join ( "app/components/ruby_ui/ " , component_folder_name , component_file_name )
32+ copy_file file_path , Rails . root . join ( "app/components/ruby_ui" , component_folder_name , component_file_name )
3333 end
3434 end
3535
36+ def copy_js_files
37+ return if js_controller_file_paths . empty?
38+
39+ say "Generating Stimulus controllers"
40+
41+ js_controller_file_paths . each do |file_path |
42+ component_file_name = file_path . split ( "/" ) . last
43+ copy_file file_path , Rails . root . join ( "app/javascript/controllers/ruby_ui" , component_file_name )
44+ end
45+
46+ say "Updating Stimulus controllers manifest"
47+ run "rake stimulus:manifest:update"
48+ end
49+
3650 def copy_dependencies
3751 case component_folder_name
3852 when "masked_input"
@@ -52,6 +66,8 @@ def main_component_file_path = File.join(component_folder_path, "#{component_fol
5266
5367 def subcomponent_file_paths = Dir . glob ( File . join ( component_folder_path , "*.rb" ) ) - [ main_component_file_path ]
5468
69+ def js_controller_file_paths = Dir . glob ( File . join ( component_folder_path , "*.js" ) )
70+
5571 def copy_masked_input_dependencies
5672 say "Generating masked input dependencies"
5773
0 commit comments