Class: NitroKit::MigrationInventory

Inherits:
Object
  • Object
show all
Defined in:
lib/nitro_kit/migration_inventory.rb

Defined Under Namespace

Classes: Finding

Constant Summary collapse

LEGACY_COMPONENTS =
%w[
  accordion alert avatar avatar_stack badge button button_group card checkbox
  checkbox_group combobox component datepicker dialog dropdown field field_group
  fieldset form_builder icon input label pagination radio_button radio_button_group
  select switch table tabs textarea toast tooltip
].freeze
LEGACY_CONTROLLERS =
%w[
  accordion combobox datepicker dialog dropdown switch tabs toast tooltip
].freeze
HELPER_REPLACEMENTS =
{
  "nk_button_link_to" => "replace with Button(..., href:)",
  "nk_button_to" => "replace with ButtonTo(..., href:, method:)",
  "nk_form_with" => "replace with Rails form_with(..., builder: NitroKit::FormBuilder)",
  "nk_form_for" => "replace with Rails form_with(..., builder: NitroKit::FormBuilder)",
  "nk_pagy_nav" => "replace with Pagination(pagy:)",
  "nk_toast_flash_messages" => "replace with NitroKit::Toast::FlashMessages",
  "nk_toast_turbo_stream_refresh" => "append NitroKit::Toast::Item to the toast list",
  "nk_toast_action" => "replace the client toast action with Rails flash or a rendered Toast::Item",
  "nk_checkbox_tag" => "replace with Checkbox(...) and preserve the submitted name and values",
  "nk_check_box_tag" => "replace with Checkbox(...) and preserve the submitted name and values"
}.freeze
DIRECT_HELPERS =
(LEGACY_COMPONENTS - %w[component datepicker form_builder]).freeze
FIELD_TAG_REPLACEMENTS =
{
  "color" => :color,
  "date" => :date,
  "datetime" => :"datetime-local",
  "datetime_local" => :"datetime-local",
  "email" => :email,
  "file" => :file,
  "hidden" => :hidden,
  "month" => :month,
  "number" => :number,
  "password" => :password,
  "phone" => :tel,
  "range" => :range,
  "search" => :search,
  "telephone" => :tel,
  "text" => :text,
  "time" => :time,
  "url" => :url,
  "week" => :week
}.transform_keys { "nk_#{_1}_field_tag" }.freeze
VENDORED_MODULES =
{
  "@floating-ui/core" => "remove the 1.x Floating UI pin or package after copied controllers are removed",
  "@floating-ui/dom" => "remove the 1.x Floating UI pin or package after copied controllers are removed",
  "@floating-ui/utils" => "remove the 1.x Floating UI pin or package after copied controllers are removed",
  "@github/combobox-nav" => "remove the 1.x combobox package; Nitro Kit 2 owns combobox behavior"
}.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(application_root) ⇒ MigrationInventory

Returns a new instance of MigrationInventory.



59
60
61
# File 'lib/nitro_kit/migration_inventory.rb', line 59

def initialize(application_root)
  @application_root = Pathname.new(application_root)
end

Instance Attribute Details

#application_rootObject (readonly)

Returns the value of attribute application_root.



57
58
59
# File 'lib/nitro_kit/migration_inventory.rb', line 57

def application_root
  @application_root
end

Instance Method Details

#categoriesObject



63
64
65
66
67
68
69
70
71
72
# File 'lib/nitro_kit/migration_inventory.rb', line 63

def categories
  {
    "Legacy helpers" => legacy_helpers,
    "Copied or shadow components" => copied_components,
    "Custom or legacy controllers" => controllers,
    "Vendored dependencies" => vendored_dependencies,
    "Known replacements" => replacement_summary,
    "Unresolved or application-owned items" => disposition_summary
  }
end