Generates the full Svelte frontend layer for a Caravela domain:
a trio of Phoenix LiveView modules (index / show / form) per
frontend: :liveentitya Phoenix controller per
frontend: :restentitytyped Svelte components for every entity (same component tree under both render modes)
a TypeScript interfaces file per domain
ExUnit + Vitest test skeletons (opt out with
--no-tests)mix caravela.gen.live MyApp.Domains.Library
Generated files (single-version, non-tenant example with one
:live entity and one :rest entity):
lib/my_app_web/live/library/book_live/{index,show,form}.ex
lib/my_app_web/controllers/article_controller.ex
assets/svelte/library/{BookIndex,BookShow,BookForm}.svelte
assets/svelte/library/{ArticleIndex,ArticleShow,ArticleForm}.svelte
assets/svelte/library/*.test.ts
assets/svelte/types/library.ts
test/my_app_web/live/library/book_live_test.exs
test/my_app_web/controllers/article_controller_test.exsEvery LiveView and controller mounts / renders its Svelte component
via caravela_svelte (both <CaravelaSvelte.svelte> for :live
and CaravelaSvelte.render/3 for :rest), and delegates to the
generated context module for CRUD calls — authorization, hooks, and
multi-tenant scoping flow through for free.
Requires caravela_svelte in the consumer app:
{:caravela_svelte, "~> 0.1"}After mix deps.get, follow the caravela_svelte docs to wire the
client runtime into assets/js/app.js.
Flags:
--dry-run— print the generated files without writing--output DIR— write underDIRinstead of the project root--force— overwrite existing files without prompting--with-domain— also emit aCaravela.Live.Domaincompanion module per:liveentity and generateform.exfrom the Template-backed variant. Useful as an onramp to theCaravela.Live.*runtime.--frontend MODE— override the render transport for every entity in the domain.MODEislive(LiveView + WebSocket) orrest(Inertia-style HTTP viacaravela_svelte). Without the flag, each entity's DSL-declaredfrontend:is used, defaulting to:live.--no-tests— skip generating ExUnit + Vitest test skeletons. By default the generator emits one<entity>_live_test.exsper:liveentity, one<entity>_controller_test.exsper:restentity, and one*.test.tscolocated next to each Svelte file. Tests use standard Phoenix / Vitest idioms and carry# TODO:lines where fixtures need to be filled in.
Router registration
The task prints a one-line hint pointing at Caravela.Router.
Drop use Caravela.Router + caravela_routes MyApp.Domains.X
into your router and every route for every entity expands at
compile time — no paste-snippet necessary. See Caravela.Router
for the full API.
Regeneration preserves content below the # --- CUSTOM --- /
<!-- --- CUSTOM --- --> marker in every file.