Class: UniversalRenderer::InstallGenerator
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- UniversalRenderer::InstallGenerator
- Defined in:
- lib/generators/universal_renderer/install_generator.rb
Overview
Scaffolds a working SSR setup: the initializer, the two renderer entry points, the SSR Vite build, the precompile hook, and the web-dyno launcher. Each file encodes something that is wrong by default and fails silently.
Instance Method Summary collapse
- #copy_deploy_files ⇒ Object
- #copy_frontend ⇒ Object
- #copy_initializer ⇒ Object
- #show_installation_notes ⇒ Object
Instance Method Details
#copy_deploy_files ⇒ Object
39 40 41 42 43 44 45 |
# File 'lib/generators/universal_renderer/install_generator.rb', line 39 def copy_deploy_files return if [:skip_deploy] || [:skip_frontend] template "ssr.rake", "lib/tasks/ssr.rake" template "web", "bin/web" chmod "bin/web", 0o755 end |
#copy_frontend ⇒ Object
29 30 31 32 33 34 35 36 37 |
# File 'lib/generators/universal_renderer/install_generator.rb', line 29 def copy_frontend return if [:skip_frontend] template "ssr/globals.ts", "#{frontend_dir}/ssr/globals.ts" template "ssr/config.ts", "#{frontend_dir}/ssr/config.ts" template "ssr/server.ts", "#{frontend_dir}/ssr/server.ts" template "ssr/dev.ts", "#{frontend_dir}/ssr/dev.ts" template "vite.config.ssr.mts", "vite.config.ssr.mts" end |
#copy_initializer ⇒ Object
25 26 27 |
# File 'lib/generators/universal_renderer/install_generator.rb', line 25 def copy_initializer template "initializer.rb", "config/initializers/universal_renderer.rb" end |
#show_installation_notes ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/generators/universal_renderer/install_generator.rb', line 47 def show_installation_notes say_status "info", "Universal Renderer installed." say_status "note", "Next steps:" if [:skip_frontend] say_status "", " 1. Review config/initializers/universal_renderer.rb" say_status "", " 2. Connect your existing renderer to that endpoint" say_status "", " 3. Opt a controller in with `enable_ssr` or `render_ssr`" return end say_status "", " 1. bun add universal-renderer (or npm/yarn)" say_status "", " 2. Fill in #{frontend_dir}/ssr/config.ts — the render itself" say_status "", " 3. Add the renderer to Procfile.dev:" say_status "", " ssr: bun #{frontend_dir}/ssr/dev.ts" say_status "", " 4. Add a build script to package.json:" say_status "", ' "build:ssr": "vite -c vite.config.ssr.mts build"' say_status "", " 5. Opt a controller in with `enable_ssr` or `render_ssr`" return if [:skip_deploy] say_status "", " 6. Point Procfile's web process at bin/web, which runs" say_status "", " the renderer alongside your app server" end |