Sha256: 9da69365252c800f8e42a89a2df479fa92d2d699edd5db82be8c0b785fd1a7ff

Contents?: true

Size: 1.08 KB

Versions: 17

Compression:

Stored size: 1.08 KB

Contents

# frozen_string_literal: true

module SolidusBrazilianAdaptations
  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_brazilian_adaptations.rb"
      end

      def copy_translate_yml
        template "config/locales/pt-BR.yml", "config/locales/pt-BR.yml"
      end

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

17 entries across 17 versions & 1 rubygems

Version Path
solidus_brazilian_adaptations-1.4.0 lib/generators/solidus_brazilian_adaptations/install/install_generator.rb
solidus_brazilian_adaptations-1.3.3 lib/generators/solidus_brazilian_adaptations/install/install_generator.rb
solidus_brazilian_adaptations-1.3.2 lib/generators/solidus_brazilian_adaptations/install/install_generator.rb
solidus_brazilian_adaptations-1.3.1 lib/generators/solidus_brazilian_adaptations/install/install_generator.rb
solidus_brazilian_adaptations-1.3.0 lib/generators/solidus_brazilian_adaptations/install/install_generator.rb
solidus_brazilian_adaptations-1.2.0 lib/generators/solidus_brazilian_adaptations/install/install_generator.rb
solidus_brazilian_adaptations-1.1.10 lib/generators/solidus_brazilian_adaptations/install/install_generator.rb
solidus_brazilian_adaptations-1.1.9 lib/generators/solidus_brazilian_adaptations/install/install_generator.rb
solidus_brazilian_adaptations-1.1.8 lib/generators/solidus_brazilian_adaptations/install/install_generator.rb
solidus_brazilian_adaptations-1.1.7 lib/generators/solidus_brazilian_adaptations/install/install_generator.rb
solidus_brazilian_adaptations-1.1.6 lib/generators/solidus_brazilian_adaptations/install/install_generator.rb
solidus_brazilian_adaptations-1.1.5 lib/generators/solidus_brazilian_adaptations/install/install_generator.rb
solidus_brazilian_adaptations-1.1.4 lib/generators/solidus_brazilian_adaptations/install/install_generator.rb
solidus_brazilian_adaptations-1.1.3 lib/generators/solidus_brazilian_adaptations/install/install_generator.rb
solidus_brazilian_adaptations-1.1.2 lib/generators/solidus_brazilian_adaptations/install/install_generator.rb
solidus_brazilian_adaptations-1.1.1 lib/generators/solidus_brazilian_adaptations/install/install_generator.rb
solidus_brazilian_adaptations-1.1.0 lib/generators/solidus_brazilian_adaptations/install/install_generator.rb