class Rails::Command::DevcontainerCommand

:nodoc:

def database

def database
  adapter = ActiveRecord::Base.connection_db_config.adapter
  adapter == "mysql2" ? "mysql" : adapter
end

def devcontainer_options

def devcontainer_options
  @devcontainer_options ||= {
    app_name: Rails.application.railtie_name.chomp("_application"),
    database: !!defined?(ActiveRecord) && database,
    active_storage: !!defined?(ActiveStorage),
    redis: !!((defined?(ActionCable) && !defined?(SolidCable)) || (defined?(ActiveJob) && !defined?(SolidQueue))),
    system_test: File.exist?("test/application_system_test_case.rb"),
    node: File.exist?(".node-version"),
    kamal: File.exist?("config/deploy.yml"),
  }
end

def perform(*)

def perform(*)
  boot_application!
  say "Generating Dev Container with the following options:"
  devcontainer_options.each do |option, value|
    say "#{option}: #{value}"
  end
  Rails::Generators::DevcontainerGenerator.new([], devcontainer_options).invoke_all
end