Class: ViteReact::Generators::MigrationGenerator

Inherits:
Rails::Generators::NamedBase
  • Object
show all
Defined in:
lib/generators/vite_react/migration/migration.rb

Instance Method Summary collapse

Instance Method Details

#update_typesObject



16
17
18
19
20
21
22
23
24
25
26
# File 'lib/generators/vite_react/migration/migration.rb', line 16

def update_types
  puts "Updating TypeScript definitions based on #{migration_name}..."

  types_file_path = Rails.root.join("app/javascript/types.d.ts")
  # read the file, parse it, inject new columns if they don’t exist, etc.
  # For references, do the same logic we did in the scaffold generator

  interface_code = build_migration_interface_snippet

  append_to_file types_file_path, interface_code
end