Class: Solrengine::Ui::InstallGenerator
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- Solrengine::Ui::InstallGenerator
- Defined in:
- lib/generators/solrengine/ui/install_generator.rb
Instance Method Summary collapse
- #add_lookbook_preview_path ⇒ Object
- #add_lookbook_route ⇒ Object
- #add_tailwind_source ⇒ Object
- #show_post_install ⇒ Object
Instance Method Details
#add_lookbook_preview_path ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/generators/solrengine/ui/install_generator.rb', line 31 def add_lookbook_preview_path app_file = "config/application.rb" content = File.read(app_file) return if content.include?("lookbook.preview_paths") inject_into_file app_file, before: /^ end/ do <<~RUBY # SolRengine UI Lookbook previews config.lookbook.preview_paths << File.join(Gem.loaded_specs["solrengine-ui"].full_gem_path, "previews") if defined?(Lookbook) RUBY end end |
#add_lookbook_route ⇒ Object
21 22 23 24 25 26 27 28 29 |
# File 'lib/generators/solrengine/ui/install_generator.rb', line 21 def add_lookbook_route route_file = "config/routes.rb" content = File.read(route_file) return if content.include?("Lookbook") inject_into_file route_file, after: "Rails.application.routes.draw do\n" do " mount Lookbook::Engine, at: \"/lookbook\" if Rails.env.development?\n\n" end end |
#add_tailwind_source ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/generators/solrengine/ui/install_generator.rb', line 8 def add_tailwind_source css_file = "app/assets/stylesheets/application.tailwind.css" return unless File.exist?(css_file) content = File.read(css_file) return if content.include?("solrengine-ui") gem_path = Gem.loaded_specs["solrengine-ui"]&.full_gem_path return unless gem_path append_to_file css_file, "\n/* SolRengine UI components */\n@source \"#{gem_path}/app\";\n" end |
#show_post_install ⇒ Object
45 46 47 48 49 50 51 52 53 |
# File 'lib/generators/solrengine/ui/install_generator.rb', line 45 def show_post_install say "\n SolRengine UI installed!", :green say "" say " Next steps:" say " 1. Add gem 'lookbook' to your Gemfile (development group) if not already added" say " 2. yarn add @solrengine/ui (for Stimulus controllers)" say " 3. bin/dev and visit /lookbook to see all components" say "" end |