module SvelteOnRails::Installer::HelloWorld

def self.remove_hello_world(templates = ['rails_vite_hello_world'], app_root: nil, ask: true)

def self.remove_hello_world(templates = ['rails_vite_hello_world'], app_root: nil, ask: true)
  utils = SvelteOnRails::Installer::Utils
  files = utils.template_paths(templates, app_root: app_root)
  existing_files = files.dup.select { |f| File.exist?(f[2]) }
  if ask && existing_files.any?
    question = "Remove Hello World component?\nThe following files will be removed:\n#{existing_files.map { |f| f[1] }.join("\n")}"
    return unless utils.ask_yn(question)
  end
  existing_files.each do |f|
    File.delete(f[2])
  end
  puts "Removed Hello World component files."
  utils.remove_line_from_file(
    utils.app_root_path(app_root).join('config/routes.rb'),
    "svelte_on_rails_hello_world",
    force: !ask,
  )
end