class SvelteOnRails::Generators::InstallGenerator

def svelte_on_rails

def svelte_on_rails
  puts '-' * 80
  puts ' ▶︎▶︎▶︎ INSTALLING SVELTE-ON-RAILS GEM'
  utils = SvelteOnRails::Installer::Utils
  npm_i = SvelteOnRails::Installer::Npm
  utils.write_templates(['config_base'], ask_for_overwrite: !options[:force])
  # add script to package json
  pkg_js = JSON.parse(File.read('package.json'))
  pkg_js['scripts'] ||= { 'build:ssr': "vite build --config vite-ssr.config.ts" }
  File.write('package.json', JSON.pretty_generate(pkg_js))
  if @local_npm_package_url
  #   puts '☝️ <<<'
  #   puts 'LINK LOCAL PACKAGE'
  #   puts 'BUGFIX: npm does not install peer dependencies of local linked packages!'
  #   puts '    For packages from the registry, this does since newer versins of npm.'
  #   puts '    So we need to install the peer dependencies manually.'
  #   npm_i.install_or_update_package('rollup-plugin-svelte', dev_dependency: true)
  #   npm_i.install_or_update_package('rollup', dev_dependency: true)
  #   npm_i.install_or_update_package('@rollup/plugin-node-resolve', dev_dependency: true)
  #   npm_i.install_or_update_package('@rollup/plugin-commonjs', dev_dependency: true)
  #   npm_i.install_or_update_package('@rollup/plugin-url', dev_dependency: true)
  #   npm_i.install_or_update_package('rollup-plugin-css-only', dev_dependency: true)
  #   npm_i.install_or_update_package('rollup-plugin-string', dev_dependency: true)
  #   npm_i.install_or_update_package('svelte-preprocess', dev_dependency: true)
  #   npm_i.install_or_update_package('pug', dev_dependency: true) # must be there because compile.js on the backend imports is
  #   puts '☝️ >>>'
     npm_i.link_local_package(NPM_PACKAGE_NAME, @local_npm_package_url)
  else
    npm_i.install_or_update_package(NPM_PACKAGE_NAME)
  end
  npm_i.install_or_update_package('typescript')
  npm_i.install_or_update_package('@types/node')
  # insert_initializer
  #uts = SvelteOnRails::Installer::Utils
  # add import statements
  js_i = SvelteOnRails::Installer::Javascript
  init_stat = '../initializers/svelte.js'
  js_i.append_import_statement(application_js_path, init_stat, "import '#{init_stat}';")
end