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_motion, #pin_tippy_js, #pin_with_importmap, #using_importmap?, #using_npm?, #using_yarn?
Instance Method Details
#copy_js_files ⇒ Object
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
# File 'lib/generators/ruby_ui/component_generator.rb', line 30
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
|
21
22
23
24
25
26
27
28
|
# File 'lib/generators/ruby_ui/component_generator.rb', line 21
def copy_related_component_files
say "Generating components"
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_name} files..."
end
|
#install_dependencies ⇒ Object
47
48
49
50
51
52
53
54
55
|
# File 'lib/generators/ruby_ui/component_generator.rb', line 47
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
|