Sha256: 3cd363c91aed43dbc967bdb025739574d2db378ec76a4d72cc3b459dedd61ccb

Contents?: true

Size: 1.33 KB

Versions: 18

Compression:

Stored size: 1.33 KB

Contents

# frozen_string_literal: true

namespace :app do
  desc "Apply the template supplied by LOCATION=(/path/to/template) or URL"
  task template: :environment do
    template = ENV["LOCATION"]
    raise "No LOCATION value given. Please set LOCATION either as path to a file or a URL" if template.blank?
    require "rails/generators"
    require "rails/generators/rails/app/app_generator"
    Rails::Generators::AppGenerator.apply_rails_template(template, Rails.root)
  end

  namespace :templates do
    # desc "Copy all the templates from rails to the application directory for customization. Already existing local copies will be overwritten"
    task :copy do
      generators_lib = File.expand_path("../generators", __dir__)
      project_templates = "#{Rails.root}/lib/templates"

      default_templates = { "erb"   => %w{controller mailer scaffold},
                            "rails" => %w{controller helper scaffold_controller} }

      default_templates.each do |type, names|
        local_template_type_dir = File.join(project_templates, type)
        mkdir_p local_template_type_dir, verbose: false

        names.each do |name|
          dst_name = File.join(local_template_type_dir, name)
          src_name = File.join(generators_lib, type, name, "templates")
          cp_r src_name, dst_name, verbose: false
        end
      end
    end
  end
end

Version data entries

18 entries across 18 versions & 2 rubygems

Version Path
railties-8.0.0 lib/rails/tasks/framework.rake
railties-7.2.2 lib/rails/tasks/framework.rake
railties-8.0.0.rc2 lib/rails/tasks/framework.rake
railties-7.2.1.2 lib/rails/tasks/framework.rake
railties-8.0.0.rc1 lib/rails/tasks/framework.rake
railties-7.2.1.1 lib/rails/tasks/framework.rake
railties-8.0.0.beta1 lib/rails/tasks/framework.rake
omg-railties-8.0.0.alpha9 lib/rails/tasks/framework.rake
omg-railties-8.0.0.alpha8 lib/rails/tasks/framework.rake
omg-railties-8.0.0.alpha7 lib/rails/tasks/framework.rake
omg-railties-8.0.0.alpha4 lib/rails/tasks/framework.rake
omg-railties-8.0.0.alpha3 lib/rails/tasks/framework.rake
railties-7.2.1 lib/rails/tasks/framework.rake
railties-7.2.0 lib/rails/tasks/framework.rake
railties-7.2.0.rc1 lib/rails/tasks/framework.rake
railties-7.2.0.beta3 lib/rails/tasks/framework.rake
railties-7.2.0.beta2 lib/rails/tasks/framework.rake
railties-7.2.0.beta1 lib/rails/tasks/framework.rake