Sha256: 7e7744e4aa991af3bf4a9618b48601e4df988934a86acfa9f041a09858899439

Contents?: true

Size: 962 Bytes

Versions: 2

Compression:

Stored size: 962 Bytes

Contents

# frozen_string_literal: true

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

      def self.exit_on_failure?
        true
      end

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

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

      def run_migrations
        run_migrations = options[:auto_run_migrations] || ['', 'y', 'Y'].include?(ask('Would you like to run the migrations now? [Y/n]')) # rubocop:disable Layout/LineLength
        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

2 entries across 2 versions & 1 rubygems

Version Path
solidus_user_roles-2.0.1 lib/generators/solidus_user_roles/install/install_generator.rb
solidus_user_roles-2.0.0 lib/generators/solidus_user_roles/install/install_generator.rb