Class: RubyUI::Generators::ComponentGenerator
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- RubyUI::Generators::ComponentGenerator
show all
- Includes:
- JavascriptUtils
- Defined in:
- lib/generators/ruby_ui/component_generator.rb
Instance Method Summary
collapse
#install_js_package, #pin_with_importmap, #using_importmap?, #using_npm?, #using_yarn?
Instance Method Details
#copy_js_files ⇒ Object
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
# File 'lib/generators/ruby_ui/component_generator.rb', line 43
def copy_js_files
return if js_controller_file_paths.empty?
say "Generating Stimulus controllers"
js_controller_file_paths.each do |file_path|
controller_file_name = file_path.split("/").last
copy_file file_path, Rails.root.join("app/javascript/controllers/ruby_ui", controller_file_name)
end
if !using_importmap?
say "Updating Stimulus controllers manifest"
run "rake stimulus:manifest:update"
end
end
|
#copy_main_component_file ⇒ Object
21
22
23
24
25
26
27
28
29
30
|
# File 'lib/generators/ruby_ui/component_generator.rb', line 21
def copy_main_component_file
main_component_file_path = File.join(component_folder_path, "#{component_folder_name}.rb")
return unless File.exist? main_component_file_path
say "Generating main component"
copy_file main_component_file_path, Rails.root.join("app/components/ruby_ui", "#{component_folder_name}.rb")
end
|
32
33
34
35
36
37
38
39
40
41
|
# File 'lib/generators/ruby_ui/component_generator.rb', line 32
def copy_related_component_files
return if related_components_file_paths.empty?
say "Generating related components"
related_components_file_paths.each do |file_path|
component_file_name = file_path.split("/").last
copy_file file_path, Rails.root.join("app/components/ruby_ui", component_folder_name, component_file_name)
end
end
|
#generate_component ⇒ Object
12
13
14
15
16
17
18
19
|
# File 'lib/generators/ruby_ui/component_generator.rb', line 12
def generate_component
if component_not_found?
say "Component not found: #{component_name}", :red
exit
end
say "Generating component files"
end
|
#install_dependencies ⇒ Object
60
61
62
63
64
65
66
67
68
|
# File 'lib/generators/ruby_ui/component_generator.rb', line 60
def install_dependencies
return if dependencies.blank?
say "Installing dependencies"
install_components_dependencies(dependencies["components"])
install_gems_dependencies(dependencies["gems"])
install_js_packages(dependencies["js_packages"])
end
|