Sha256: 31dfa8454a158205dfead1877a8d4e4eb17963b20768911e70e36b39a269fb4d

Contents?: true

Size: 981 Bytes

Versions: 1

Compression:

Stored size: 981 Bytes

Contents

# frozen_string_literal: true

module SolidusTaxCloud
  module Generators
    class InstallGenerator < Rails::Generators::Base
      class_option :auto_run_migrations, type: :boolean, default: false

      argument :file_name, type: :string, desc: 'rails app_path', default: '.'
      source_root File.expand_path('../templates', __dir__)

      def copy_initializer_file
        template 'ca-bundle.crt', "#{file_name}/lib/ca-bundle.crt"
      end

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

1 entries across 1 versions & 1 rubygems

Version Path
solidus_tax_cloud-1.0.0 lib/generators/solidus_tax_cloud/install/install_generator.rb