Sha256: cf140bda0261fbd6de240bf268d77eff8714e063b89105b65f25e10ee94efeec

Contents?: true

Size: 1018 Bytes

Versions: 5

Compression:

Stored size: 1018 Bytes

Contents

# frozen_string_literal: true

module SolidusSocial
  module Generators
    class InstallGenerator < Rails::Generators::Base
      source_root "#{__dir__}/templates"

      class_option :auto_run_migrations, type: :boolean, default: false

      def add_stylesheets
        inject_into_file 'vendor/assets/stylesheets/spree/frontend/all.css', " *= require spree/frontend/solidus_social\n", before: %r{\*/}, verbose: true
      end

      def add_migrations
        run 'bin/rails railties:install:migrations FROM=solidus_social'
      end

      def copy_initializer
        template "config/initializers/solidus_social.rb"
      end

      def run_migrations
        run_migrations = options[: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!' # rubocop:disable Rails/Output
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
solidus_social-1.6.0 lib/generators/solidus_social/install/install_generator.rb
solidus_social-1.5.0 lib/generators/solidus_social/install/install_generator.rb
solidus_social-1.4.0 lib/generators/solidus_social/install/install_generator.rb
solidus_social-1.3.1 lib/generators/solidus_social/install/install_generator.rb
solidus_social-1.3.0 lib/generators/solidus_social/install/install_generator.rb