class Underlay::AppGenerator

Public Class Methods

banner() click to toggle source
new(*args) click to toggle source
Calls superclass method
# File lib/underlay/generators/app_generator.rb, line 54
def initialize(*args)
  super

  if api_mode?
    self.options = options.merge(
      api: true,
      skip_sprockets: true,
      skip_javascript: true
    ).freeze
  end
end

Public Instance Methods

clean_up() click to toggle source
# File lib/underlay/generators/app_generator.rb, line 227
def clean_up
  say 'Code cleaning'
  build :rubocop_autocorrect
  build :manual_code_correct
  build_for_api :non_api_files_removal
end
configure_app() click to toggle source
# File lib/underlay/generators/app_generator.rb, line 171
def configure_app
  say 'Configuring app'
  build :configure_action_mailer
  build :configure_active_job
  build :configure_time_formats
  build :setup_default_rake_task
  build :replace_default_puma_configuration
  build :set_up_forego
  build :setup_rack_mini_profiler
end
copy_miscellaneous_files() click to toggle source
# File lib/underlay/generators/app_generator.rb, line 239
def copy_miscellaneous_files
  say 'Copying miscellaneous support files'
  build :copy_miscellaneous_files
end
create_github_repo() click to toggle source
# File lib/underlay/generators/app_generator.rb, line 202
def create_github_repo
  if !options[:skip_git] && options[:github]
    say 'Creating Github repo'
    build :create_github_repo, options[:github]
  end
end
create_heroku_apps() click to toggle source
# File lib/underlay/generators/app_generator.rb, line 189
def create_heroku_apps
  if options[:heroku]
    say 'Creating Heroku apps'
    build :create_heroku_apps, options[:heroku_flags]
    build :set_heroku_remotes
    build :set_heroku_rails_secrets
    build :set_heroku_application_host
    build :set_heroku_backup_schedule
    build :create_heroku_pipeline
    build :configure_automatic_deployment
  end
end
create_local_heroku_setup() click to toggle source
# File lib/underlay/generators/app_generator.rb, line 182
def create_local_heroku_setup
  say 'Creating local Heroku setup'
  build :create_review_apps_setup_script
  build :create_deploy_script
  build :create_heroku_application_manifest_file
end
create_underlay_views() click to toggle source
# File lib/underlay/generators/app_generator.rb, line 162
def create_underlay_views
  say 'Creating underlay views'
  build :create_partials_directory
  build_for_non_api :create_shared_flashes
  build_for_non_api :create_shared_javascripts
  build_for_non_api :create_shared_css_overrides
  build_for_non_api :create_application_layout
end
customize_error_pages() click to toggle source
# File lib/underlay/generators/app_generator.rb, line 244
def customize_error_pages
  say 'Customizing the 500/404/422 pages' unless options[:api]
  build_for_non_api :customize_error_pages
end
customize_gemfile() click to toggle source
# File lib/underlay/generators/app_generator.rb, line 98
def customize_gemfile
  build :replace_gemfile, options[:path]
  build :set_ruby_to_version_being_used
  bundle_command 'install'
  build_for_non_api :configure_simple_form
end
finish_template() click to toggle source
Calls superclass method
# File lib/underlay/generators/app_generator.rb, line 66
def finish_template
  invoke :underlay_customization
  super
end
generate_default() click to toggle source
# File lib/underlay/generators/app_generator.rb, line 261
def generate_default
  run('spring stop')
  generate('underlay:initialize_active_job')
  generate('underlay:enforce_ssl')
  generate('underlay:static')
  generate('underlay:stylesheet_base')
end
outro() click to toggle source
# File lib/underlay/generators/app_generator.rb, line 269
def outro
  say 'You just laid the underlay. Time to add some value!'
end
remove_app_comment_lines() click to toggle source
# File lib/underlay/generators/app_generator.rb, line 249
def remove_app_comment_lines
  build :remove_app_comment_lines
end
remove_config_comment_lines() click to toggle source
# File lib/underlay/generators/app_generator.rb, line 253
def remove_config_comment_lines
  build :remove_config_comment_lines
end
remove_routes_comment_lines() click to toggle source
# File lib/underlay/generators/app_generator.rb, line 257
def remove_routes_comment_lines
  build :remove_routes_comment_lines
end
setup_bundler_audit() click to toggle source
# File lib/underlay/generators/app_generator.rb, line 222
def setup_bundler_audit
  say 'Setting up bundler-audit'
  build :setup_bundler_audit
end
setup_database() click to toggle source
# File lib/underlay/generators/app_generator.rb, line 105
def setup_database
  say 'Setting up database'

  if options[:database] == 'postgresql'
    build :use_postgres_config_template
  end

  build :create_database
end
setup_default_directories() click to toggle source
# File lib/underlay/generators/app_generator.rb, line 218
def setup_default_directories
  build :setup_default_directories
end
setup_development_environment() click to toggle source
# File lib/underlay/generators/app_generator.rb, line 115
def setup_development_environment
  say 'Setting up the development environment'
  build_for_non_api :raise_on_missing_assets_in_test
  build :raise_on_delivery_errors
  build :set_test_delivery_method
  build :add_bullet_gem_configuration
  build :raise_on_unpermitted_parameters
  build :provide_setup_script
  build :provide_rake_script
  build :provide_update_script
  build :provide_dev_prime_task
  build :configure_generators
  build :configure_i18n_for_missing_translations
  build_for_non_api :configure_quiet_assets
end
setup_figaro() click to toggle source
# File lib/underlay/generators/app_generator.rb, line 214
def setup_figaro
  build :copy_figaro_files
end
setup_google_tag_manager() click to toggle source
# File lib/underlay/generators/app_generator.rb, line 209
def setup_google_tag_manager
  say 'Setting up Google Tage Manager' unless options[:api]
  build_for_non_api :setup_google_tag_manager
end
setup_production_environment() click to toggle source
# File lib/underlay/generators/app_generator.rb, line 148
def setup_production_environment
  say 'Setting up the production environment'
  build :configure_smtp
  build :configure_rack_timeout
  build :enable_rack_canonical_host
  build :enable_rack_deflater
  build_for_non_api :setup_asset_host
end
setup_secret_token() click to toggle source
# File lib/underlay/generators/app_generator.rb, line 157
def setup_secret_token
  say 'Moving secret token out of version control'
  build :setup_secret_token
end
setup_spring() click to toggle source
# File lib/underlay/generators/app_generator.rb, line 234
def setup_spring
  say 'Springifying binstubs'
  build :setup_spring
end
setup_test_environment() click to toggle source
# File lib/underlay/generators/app_generator.rb, line 131
def setup_test_environment
  say 'Setting up the test environment'
  build :set_up_factory_bot_for_rspec
  build :generate_factories_file
  build :generate_rspec
  build :configure_rspec
  build :enable_database_cleaner
  build :provide_shoulda_matchers_config
  build :configure_spec_support_features
  build :configure_ci
  build :configure_rubocop
  build_for_non_api :configure_linters
  build :configure_i18n_for_test_environment
  build :configure_action_mailer_in_specs
  build_for_non_api :configure_capybara
end
underlay_customization() click to toggle source
# File lib/underlay/generators/app_generator.rb, line 71
def underlay_customization
  invoke :customize_gemfile
  invoke :setup_development_environment
  invoke :setup_test_environment
  invoke :setup_production_environment
  invoke :setup_secret_token
  invoke :create_underlay_views
  invoke :configure_app
  invoke :copy_miscellaneous_files
  invoke :customize_error_pages
  invoke :remove_app_comment_lines
  invoke :remove_config_comment_lines
  invoke :remove_routes_comment_lines
  invoke :setup_figaro
  invoke :setup_database
  invoke :create_local_heroku_setup
  invoke :create_heroku_apps
  invoke :create_github_repo
  invoke :setup_google_tag_manager
  invoke :setup_bundler_audit
  invoke :setup_spring
  invoke :generate_default
  invoke :setup_default_directories
  invoke :clean_up
  invoke :outro
end

Protected Instance Methods

api_mode?() click to toggle source
# File lib/underlay/generators/app_generator.rb, line 301
def api_mode?
  options[:application_mode].blank?
end
build_for_api(args) click to toggle source
# File lib/underlay/generators/app_generator.rb, line 295
def build_for_api(args)
  return unless api_mode?

  build args
end
build_for_non_api(args) click to toggle source
# File lib/underlay/generators/app_generator.rb, line 289
def build_for_non_api(args)
  return if api_mode?

  build args
end
get_builder_class() click to toggle source

rubocop:disable AccessorMethodName

# File lib/underlay/generators/app_generator.rb, line 280
def get_builder_class
  Underlay::AppBuilder
end
using_active_record?() click to toggle source

rubocop:enable AccessorMethodName

# File lib/underlay/generators/app_generator.rb, line 285
def using_active_record?
  !options[:skip_active_record]
end