Sha256: 8c328425f134b2450ca807812a9771161f3cb72c977d5f8a6ec1122416a3aff4

Contents?: true

Size: 1.24 KB

Versions: 2

Compression:

Stored size: 1.24 KB

Contents

# frozen_string_literal: true

require 'rails/generators'

class TestAppGenerator < Rails::Generators::Base
  source_root File.expand_path('../../../test_app_templates', __dir__)

  def remove_index
    remove_file "public/index.html"
  end

  def run_blacklight_generator
    say_status("warning", "GENERATING BL", :yellow)

    Bundler.with_unbundled_env do
      run "bundle install"
    end
    options = '--devise'
    if ENV['BLACKLIGHT_API_TEST'].present?
      options += ' --skip-assets'
    end

    generate :'blacklight:install', options
  end

  def run_test_support_generator
    say_status("warning", "GENERATING test_support", :yellow)

    generate(:'blacklight:test_support')
  end

  def add_local_assets_for_propshaft
    return unless defined?(Propshaft)

    run "yarn add #{Blacklight::Engine.root}"
  end

  def add_component_template_override
    src_template = File.join(Blacklight::Engine.root, 'app', 'components', 'blacklight', 'top_navbar_component.html.erb')
    target_template = File.join('app', 'components', 'blacklight', 'top_navbar_component.html.erb')
    create_file(target_template) do
      File.read(src_template).gsub('role="navigation"', 'role="navigation" data-template-override="top_navbar_component"')
    end
  end
end

Version data entries

2 entries across 2 versions & 2 rubygems

Version Path
blacklight-spotlight-3.6.0.beta8 vendor/bundle/ruby/3.2.0/gems/blacklight-8.3.0/spec/test_app_templates/lib/generators/test_app_generator.rb
blacklight-8.3.0 spec/test_app_templates/lib/generators/test_app_generator.rb