Sha256: f757d556337116364969f3dd1175b2191f2e2dbaeddfb9182d25900898adf47a

Contents?: true

Size: 1.2 KB

Versions: 2

Compression:

Stored size: 1.2 KB

Contents

# frozen_string_literal: true

module SolidusAdmin
  module Generators
    class InstallGenerator < Rails::Generators::Base
      class_option :lookbook, type: :boolean, default: !!ENV['SOLIDUS_ADMIN_LOOKBOOK'], desc: 'Install Lookbook for component previews'

      source_root "#{__dir__}/templates"

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

      def copy_initializer
        copy_file "config/initializers/solidus_admin.rb"
      end

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

      def build_tailwind
        rake "solidus_admin:tailwindcss:build"
      end

      def install_lookbook
        return unless options[:lookbook]

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

        route "mount Lookbook::Engine, at: '/lookbook' if Rails.env.development?"
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
solidus_admin-0.0.2 lib/generators/solidus_admin/install/install_generator.rb
solidus_admin-0.0.1 lib/generators/solidus_admin/install/install_generator.rb