Class: SolidusFrontend::Generators::InstallGenerator

Inherits:
Rails::Generators::Base
  • Object
show all
Defined in:
lib/generators/solidus_frontend/install/install_generator.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.exit_on_failure?Boolean

Returns:

  • (Boolean)


10
11
12
# File 'lib/generators/solidus_frontend/install/install_generator.rb', line 10

def self.exit_on_failure?
  true
end

Instance Method Details

#copy_initializerObject



14
15
16
# File 'lib/generators/solidus_frontend/install/install_generator.rb', line 14

def copy_initializer
  template 'initializer.rb', 'config/initializers/solidus_frontend.rb'
end

#install_solidus_boltObject



43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/generators/solidus_frontend/install/install_generator.rb', line 43

def install_solidus_bolt
  return if ENV['SKIP_SOLIDUS_BOLT'] || !File.exist?('Gemfile') || !(options[:auto_accept] || yes?(<<~MSG))
    Would you like to add bolt (https://www.bolt.com) as a default payment method?

    If you answer yes, solidus_bolt (https://github.com/solidusio/solidus_bolt)
    will be added to the installation (y/n):
  MSG

  gem 'solidus_bolt'
  bundle_cleanly { `bundle` }
  generate 'solidus_bolt:install --auto-run-migrations'
end

#robots_directivesObject



18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/generators/solidus_frontend/install/install_generator.rb', line 18

def robots_directives
  FileUtils.touch "public/robots.txt"
  append_file "public/robots.txt", <<-ROBOTS.strip_heredoc
    User-agent: *
    Disallow: /checkout
    Disallow: /cart
    Disallow: /orders
    Disallow: /user
    Disallow: /account
    Disallow: /api
    Disallow: /password
  ROBOTS
end

#setup_assetsObject



32
33
34
35
36
37
38
39
40
41
# File 'lib/generators/solidus_frontend/install/install_generator.rb', line 32

def setup_assets
  empty_directory 'app/assets/images'

  %w{javascripts stylesheets images}.each do |path|
    empty_directory "vendor/assets/#{path}/spree/frontend"
  end

  template "vendor/assets/javascripts/spree/frontend/all.js"
  template "vendor/assets/stylesheets/spree/frontend/all.css"
end