Class: SolidusStaticContent::Generators::InstallGenerator
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- SolidusStaticContent::Generators::InstallGenerator
- Defined in:
- lib/generators/solidus_static_content/install/install_generator.rb
Instance Method Summary collapse
- #add_javascripts ⇒ Object
- #add_migrations ⇒ Object
- #add_stylesheets ⇒ Object
- #copy_starter_frontend_files ⇒ Object
- #run_migrations ⇒ Object
Instance Method Details
#add_javascripts ⇒ Object
19 20 21 |
# File 'lib/generators/solidus_static_content/install/install_generator.rb', line 19 def add_javascripts empty_directory "app/assets/javascripts" end |
#add_migrations ⇒ Object
15 16 17 |
# File 'lib/generators/solidus_static_content/install/install_generator.rb', line 15 def add_migrations run "bin/rails railties:install:migrations FROM=solidus_static_content" end |
#add_stylesheets ⇒ Object
11 12 13 |
# File 'lib/generators/solidus_static_content/install/install_generator.rb', line 11 def add_stylesheets inject_into_file "vendor/assets/stylesheets/spree/frontend/all.css", " *= require spree/frontend/solidus_static_content\n", before: %r{\*/}, verbose: true end |
#copy_starter_frontend_files ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/generators/solidus_static_content/install/install_generator.rb', line 23 def copy_starter_frontend_files return if [:frontend] != "starter" copy_file "app/controllers/static_content_controller.rb" copy_file "app/views/static_content/show.html.erb" insert_into_file "config/initializers/spree.rb", after: "Spree.config do |config|\n" do <<~RUBY.indent(2) config.layout = 'layouts/storefront' RUBY end route <<~ROUTES if Spree::Config.layout == 'layouts/storefront' constraints(SolidusStaticContent::RouteMatcher) do get '/(*path)', to: 'static_content#show', as: 'static' end end ROUTES end |
#run_migrations ⇒ Object
44 45 46 47 48 49 50 51 |
# File 'lib/generators/solidus_static_content/install/install_generator.rb', line 44 def run_migrations run_migrations = [:auto_run_migrations] || ["", "y", "Y"].include?(ask("Would you like to run the migrations now? [Y/n]")) if run_migrations run "bin/rails db:migrate" else puts "Skipping bin/rails db:migrate, don't forget to run it!" end end |