Sha256: 211b2c80e0dafda15138521150c642f09f6e80b7f1c7ca657bdcebd97f1fb46c

Contents?: true

Size: 868 Bytes

Versions: 8

Compression:

Stored size: 868 Bytes

Contents

# frozen_string_literal: true

module SolidusBacktracs
  module Generators
    class InstallGenerator < Rails::Generators::Base
      class_option :auto_run_migrations, type: :boolean, default: false
      source_root File.expand_path('templates', __dir__)

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

      def add_migrations
        run 'bin/rails railties:install:migrations FROM=solidus_backtracs'
      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

8 entries across 8 versions & 2 rubygems

Version Path
solidus_bactracs-3.0.0 lib/generators/solidus_backtracs/install/install_generator.rb
solidus_backtracs-2.2.6 lib/generators/solidus_backtracs/install/install_generator.rb
solidus_backtracs-2.2.5 lib/generators/solidus_backtracs/install/install_generator.rb
solidus_backtracs-2.2.4 lib/generators/solidus_backtracs/install/install_generator.rb
solidus_backtracs-2.2.3 lib/generators/solidus_backtracs/install/install_generator.rb
solidus_backtracs-2.2.2 lib/generators/solidus_backtracs/install/install_generator.rb
solidus_backtracs-2.2.1 lib/generators/solidus_backtracs/install/install_generator.rb
solidus_backtracs-2.2.0 lib/generators/solidus_backtracs/install/install_generator.rb