class Generators::Avo::Js::InstallGenerator

def install_for_esbuild

def install_for_esbuild
  unless Rails.root.join("app", "javascript", "avo.custom.js").exist?
    say "Add default app/javascript/avo.custom.js"
    copy_file template_path("avo.custom.js"), "app/javascript/avo.custom.js"
  end
  say "Ejecting the _head.html.erb partial"
  Rails::Generators.invoke("avo:eject", [":head", "--skip-avo-version"], {destination_root: Rails.root})
  say "Adding the JS asset to the partial"
  append_to_file Rails.root.join("app", "views", "avo", "partials", "_head.html.erb"), "<%= javascript_include_tag \"avo.custom\", \"data-turbo-track\": \"reload\", defer: true %>"
end