Sha256: b7ae754ecf2d39c08ad3f2a4a7bdc981aee2b38ede8fa29a2c232279cf60b3a1

Contents?: true

Size: 1.34 KB

Versions: 7

Compression:

Stored size: 1.34 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[auth backend frontend].each do |section|
          append_file "vendor/assets/javascripts/archangel/#{section}.js",
                      "//= require archangel/#{section}/<%= extension_name %>\n"
        end
      end

      def add_stylesheets
        %w[auth backend frontend].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

7 entries across 7 versions & 1 rubygems

Version Path
archangel-0.3.0 lib/archangel/commands/templates/extension/lib/generators/%extension_name%/install/install_generator.rb.tt
archangel-0.0.8 lib/archangel/command/templates/extension/lib/generators/%extension_name%/install/install_generator.rb.tt
archangel-0.0.7 lib/archangel/command/templates/extension/lib/generators/%extension_name%/install/install_generator.rb.tt
archangel-0.0.6 lib/archangel/command/templates/extension/lib/generators/%extension_name%/install/install_generator.rb.tt
archangel-0.0.5 lib/archangel/command/templates/extension/lib/generators/%extension_name%/install/install_generator.rb.tt
archangel-0.0.4 lib/archangel/command/templates/extension/lib/generators/%extension_name%/install/install_generator.rb.tt
archangel-0.0.3 lib/archangel/command/templates/extension/lib/generators/%extension_name%/install/install_generator.rb.tt