Skip to content

feat: add rebar3 nova gen_live command#62

Closed
Taure wants to merge 2 commits into
novaframework:masterfrom
Taure:feat/gen-live
Closed

feat: add rebar3 nova gen_live command#62
Taure wants to merge 2 commits into
novaframework:masterfrom
Taure:feat/gen-live

Conversation

@Taure

@Taure Taure commented Mar 19, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Adds rebar3 nova gen_live command that generates Arizona LiveView CRUD views mapped to Kura schemas (similar to mix phx.gen.live)
  • Fixes the nova new --arizona home_view scaffold to use the current Arizona API (arizona_view:new/3, arizona_template:from_html, arizona_parse_transform)

Usage

rebar3 nova gen_live --name users --fields name:string,email:string,active:boolean

Generated files

File Purpose
src/views/{app}_user_index_view.erl Table listing with delete
src/views/{app}_user_show_view.erl Detail view
src/views/{app}_user_new_view.erl Create form
src/views/{app}_user_edit_view.erl Edit form with pre-filled values
src/schemas/{app}_user.erl Kura schema
src/migrations/m{ts}_create_users.erl Kura migration
test/{app}_user_live_SUITE.erl CT test suite

Flags

  • --actions index,show,new,edit — select which views to generate
  • --no-schema — skip schema + migration generation
  • Field types: string, text, integer, float, boolean, date, utc_datetime, uuid, jsonb

Key design decisions

  • Views call kura_repo_worker / kura_changeset directly (no context layer)
  • Uses ~"""" (4-quote) outer templates with ~""" (3-quote) inner templates for render_list callbacks
  • Correct Arizona state API: arizona_view:get_state/update_state + arizona_stateful:put_binding/get_binding

Depends on #62 (feat/nova-new)

Test plan

  • rebar3 ct — all 21 tests pass (10 gen_live + 11 nova_new)
  • End-to-end: generate project with --arizona --kura, run gen_live, verify rebar3 compile succeeds

Taure added 2 commits March 19, 2026 09:55
Single command replaces multiple templates with composable flags:
rebar3 nova new myapp [--kura] [--pgo] [--arizona] [--lfe] [--ci] [--docker] [--otel]

- --kura/--pgo mutually exclusive, all others freely combinable
- Each flag conditionally adds deps, plugins, config, and source files
- Adds write_file/2 and copy_priv_file/2 to rebar3_nova_utils
- 11 CT tests covering all flags and combinations
Generates Arizona LiveView CRUD views, Kura schema, migration, and
test suite for a resource. Similar to Phoenix's phx.gen.live.

Usage:
  rebar3 nova gen_live --name users --fields name:string,email:string

Generated files:
- src/views/{app}_{resource}_{action}_view.erl (index/show/new/edit)
- src/schemas/{app}_{resource}.erl (Kura schema)
- src/migrations/m{ts}_create_{table}.erl (Kura migration)
- test/{app}_{resource}_live_SUITE.erl (CT test suite)

Also fixes the home_view scaffold in `nova new --arizona` to use
the current Arizona API (arizona_view:new/3, arizona_template:from_html,
arizona_parse_transform).

@burbas burbas left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that we don't need a new command for each type of sub-component we are generating. It would make more sense to have something similar to

rebar3 nova gen live users -- fields name:string, email:string,active:boolean

The name (In this example users) will always be required so don't see any point of having that as a flag. And we might want to be able to generate controllers, plugins etc. So just calling rebar3 nova gen would then result in a help-section describing all different modules to generate.

@Taure

Taure commented Mar 19, 2026

Copy link
Copy Markdown
Contributor Author

Superseded by #63 which includes gen_live plus the unified gen dispatcher, template system, and tests.

@Taure Taure closed this Mar 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants