Sha256: b6db555ad232d9abd11e64bfaeb3fa73dfbc8282bab2799a3891813da42236c3

Contents?: true

Size: 1.33 KB

Versions: 1

Compression:

Stored size: 1.33 KB

Contents

# frozen_string_literal: true

module <%= class_name %>
  module Generators
    class InstallGenerator < ::Rails::Generators::Base
      class_option :auto_run_migrations, type: :boolean, default: false

      def add_javascripts
        # %w[backend].each do |section|
        #   append_file "vendor/assets/javascripts/archangel/#{section}.js",
        #               "//= require archangel/#{section}/<%= extension_name %>\n"
        # end
      end

      def add_stylesheets
        # %w[backend].each do |section|
        #   inject_into_file "vendor/assets/stylesheets/archangel/#{section}.css",
        #                    "*= require archangel/#{section}/<%= extension_name %>\n ",
        #                    before: %r{\*/},
        #                    verbose: true
        # end
      end

      def add_migrations
        run "bundle exec rails railties:install:migrations FROM=<%= extension_name %>"
      end

      def run_migrations
        migration_message = "Would you like to run the migrations now? [Y/n]"

        run_migrations = options[:auto_run_migrations] || ["", "y", "Y"]
                         .include?(ask(migration_message))

        if run_migrations
          run "bundle exec rails db:migrate"
        else
          puts "Skipping `rails db:migrate`, don't forget to run it!"
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
archangel-0.4.0 lib/archangel/commands/templates/extension/lib/generators/%extension_name%/install/install_generator.rb.tt