mix caravela.gen.live (Caravela v0.5.0)

Copy Markdown View Source

Generates the frontend layer for a Caravela domain: a trio of LiveView modules (index/show/form) per entity, plus typed Svelte components and a TypeScript interfaces file.

mix caravela.gen.live MyApp.Domains.Library

Generated files (single-version, non-tenant example):

lib/my_app_web/live/library/book_live/{index,show,form}.ex
assets/svelte/library/{BookIndex,BookShow,BookForm}.svelte
assets/svelte/types/library.ts

Every LiveView mounts its Svelte component via <LiveSvelte.render>, and delegates to the generated context module for CRUD calls — authorization, hooks, and multi-tenant scoping flow through for free.

Requires LiveSvelte in the consumer app:

{:live_svelte, "~> 0.19"}

After mix deps.get, follow the LiveSvelte docs to wire it into assets/js/app.js.

Flags:

  • --dry-run — print the generated files without writing
  • --output DIR — write under DIR instead of the project root
  • --force — overwrite existing files without prompting
  • --with-domain — also emit a Caravela.Live.Domain companion module per entity and generate form.ex from the Template-backed variant. Useful as an onramp to the Caravela.Live.* runtime.

Regeneration preserves content below the # --- CUSTOM --- / <!-- --- CUSTOM --- --> marker in every file.