module SvelteOnRails::Installer::Utils
def self.create_svelte_hello_world
def self.create_svelte_hello_world file_path = Rails.root.join("app", "frontend", "javascript", "components", "HelloWorld.svelte") if File.exist?(file_path) puts "Hello World file already exists: file://#{file_path}" else File.write(file_path, <<~HTML) <script> export let items let count = 0; function increment() { count += 1; } </script> <h1>Greetings from svelte</h1> <button on:click={increment}>Increment: {count}</button> <ul> {#each items as item} <li>{item}</li> {/each} </ul> <style> button { background-color: darkred; color: white; padding: 10px; border: none; } </style> HTML puts "Hello World file at file://#{file_path}" end end