Class: SolidusAdmin::Generators::InstallGenerator

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

Instance Method Summary collapse

Instance Method Details

#build_tailwindObject



28
29
30
# File 'lib/generators/solidus_admin/install/install_generator.rb', line 28

def build_tailwind
  rake "solidus_admin:tailwindcss:install" if options[:tailwind]
end

#copy_initializerObject



20
21
22
# File 'lib/generators/solidus_admin/install/install_generator.rb', line 20

def copy_initializer
  template 'config/initializers/solidus_admin.rb.tt', 'config/initializers/solidus_admin.rb'
end

#ignore_tailwind_build_filesObject



24
25
26
# File 'lib/generators/solidus_admin/install/install_generator.rb', line 24

def ignore_tailwind_build_files
  append_file(".gitignore", "app/assets/builds/solidus_admin/") if File.exist?(Rails.root.join(".gitignore"))
end

#install_lookbookObject



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

def install_lookbook
  return unless options[:lookbook]

  gem_group :development, :test do
    gem "lookbook"
    gem "listen"
    gem "actioncable"
  end

  execute_command :bundle, :install

  route "mount Lookbook::Engine, at: '#{solidus_mount_point}lookbook' if Rails.env.development?"
end

#install_solidus_core_supportObject



11
12
13
14
15
16
17
18
# File 'lib/generators/solidus_admin/install/install_generator.rb', line 11

def install_solidus_core_support
  route <<~RUBY
    mount SolidusAdmin::Engine, at: '#{solidus_mount_point}admin', constraints: ->(req) {
      req.cookies['solidus_admin'] != 'false' &&
      req.params['solidus_admin'] != 'false'
    }
  RUBY
end