123456789_123456789_123456789_123456789_123456789_

Class: Rails::Command::App::UpdateCommand

Do not use. This class is for internal use only.
Relationships & Source Files
Super Chains via Extension / Inclusion / Inheritance
Class Chain:
Instance Chain:
Inherits: Rails::Command::Base
Defined in: railties/lib/rails/commands/app/update_command.rb

Class Attribute Summary

::Rails::Command::Base - Inherited

.bin, .bin?,
.engine?

Returns true when the app is a Rails engine.

.exit_on_failure?

Class Method Summary

::Rails::Command::Base - Inherited

.banner,
.base_name

Sets the base_name taking into account the current class namespace.

.command_name

Return command name without namespaces.

.default_command_root

Default file root to place extra files a command might need, placed one folder above the command file.

.desc

Tries to get the description from a USAGE file one folder above the command root.

.executable,
.hide_command!

Convenience method to hide this command from the available ones when running rails command.

.namespace

Convenience method to get the namespace from the class name.

.printing_commands,
.usage_path

Path to lookup a USAGE description in a file.

.create_command

Allow the command method to be called perform.

.namespaced_name, .resolve_path, .class_usage,
.help

Override Thor’s class-level help to also show the USAGE.

.inherited, .perform

Instance Method Summary

::Rails::Command::Actions - Included

#boot_application!, #load_environment_config!,
#load_generators

See additional method definition at line 36.

#load_tasks

See additional method definition at line 31.

#require_application!,
#set_application_directory!

Change to the application’s path if there is no config.ru file in current directory.

Instance Method Details

#active_storage

[ GitHub ]

  
# File 'railties/lib/rails/commands/app/update_command.rb', line 42

def active_storage
  require_application!
  app_generator.update_active_storage
end

#app_generator (private)

[ GitHub ]

  
# File 'railties/lib/rails/commands/app/update_command.rb', line 52

def app_generator
  @app_generator ||= begin
    gen = Rails::Generators::AppGenerator.new(["rails"], generator_options, destination_root: Rails.root)
    gen.send(:valid_const?) unless File.exist?(Rails.root.join("config", "application.rb"))
    gen
  end
end

#asset_pipeline (private)

[ GitHub ]

  
# File 'railties/lib/rails/commands/app/update_command.rb', line 82

def asset_pipeline
  "propshaft" if defined?(Propshaft::Railtie)
end

#bin

[ GitHub ]

  
# File 'railties/lib/rails/commands/app/update_command.rb', line 30

def bin
  require_application!
  app_generator.update_bin_files
end

#configs

[ GitHub ]

  
# File 'railties/lib/rails/commands/app/update_command.rb', line 23

def configs
  require_application!
  app_generator.create_boot_file
  app_generator.update_config_files
end

#display_upgrade_guide_info (private)

[ GitHub ]

  
# File 'railties/lib/rails/commands/app/update_command.rb', line 48

def display_upgrade_guide_info
  say "\nAfter this, check Rails upgrade guide at https://guides.rubyonrails.org/upgrading_ruby_on_rails.html for more details about upgrading your app."
end

#generator_options (private)

[ GitHub ]

  
# File 'railties/lib/rails/commands/app/update_command.rb', line 60

def generator_options
  {
    api:                 !!Rails.application.config.api_only,
    update:              true,
    name:                Rails.application.class.name.chomp("::Application").underscore,
    skip_active_job:     !defined?(ActiveJob::Railtie),
    skip_active_record:  !defined?(ActiveRecord::Railtie),
    skip_active_storage: !defined?(ActiveStorage::Engine),
    skip_action_mailer:  !defined?(ActionMailer::Railtie),
    skip_action_mailbox: !defined?(ActionMailbox::Engine),
    skip_action_text:    !defined?(ActionText::Engine),
    skip_action_cable:   !defined?(ActionCable::Engine),
    skip_brakeman:       skip_gem?("brakeman"),
    skip_rubocop:        skip_gem?("rubocop"),
    skip_thruster:       skip_gem?("thruster"),
    skip_test:           !defined?(Rails::TestUnitRailtie),
    skip_system_test:    Rails.application.config.generators.system_tests.nil?,
    skip_asset_pipeline: asset_pipeline.nil?,
    skip_bootsnap:       !defined?(Bootsnap),
  }.merge(options)
end

#perform

[ GitHub ]

  
# File 'railties/lib/rails/commands/app/update_command.rb', line 14

def perform
  configs
  bin
  public_directory
  active_storage
  display_upgrade_guide_info
end

#public_directory

[ GitHub ]

  
# File 'railties/lib/rails/commands/app/update_command.rb', line 36

def public_directory
  require_application!
  app_generator.create_public_files
end

#skip_gem?(gem_name) ⇒ Boolean (private)

[ GitHub ]

  
# File 'railties/lib/rails/commands/app/update_command.rb', line 86

def skip_gem?(gem_name)
  gem gem_name
  false
rescue LoadError
  true
end