Skip to content

feat: unified rebar3 nova gen dispatcher with template system#63

Open
Taure wants to merge 39 commits into
novaframework:masterfrom
Taure:feat/unified-gen
Open

feat: unified rebar3 nova gen dispatcher with template system#63
Taure wants to merge 39 commits into
novaframework:masterfrom
Taure:feat/unified-gen

Conversation

@Taure

@Taure Taure commented Mar 19, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Add unified rebar3 nova gen <type> <name> [opts] entry point that dispatches to gen modules
  • Extract shared helpers to rebar3_nova_utils (singularize, pluralize, capitalize, timestamp, parse_fields, render_template)
  • Convert gen_controller, gen_test, gen_auth to bbmustache templates under priv/templates/gen/
  • Replace thoas:encode/decode with json:encode/decode in gen_auth
  • Name is now a positional arg: rebar3 nova gen controller users
  • Old gen_* commands still work but emit deprecation warnings
  • Add integration test suite that scaffolds a project, runs all generators, validates syntax of all generated .erl files, and compiles the project end-to-end

Test plan

  • rebar3 fmt --check passes
  • rebar3 xref passes
  • rebar3 ct — all 40 tests pass (4 suites)
  • Integration suite generates a full project with all generators and rebar3 compile succeeds
  • Manual: rebar3 nova gen controller users generates correct controller
  • Manual: rebar3 nova gen auth generates 9 files with json:encode (no thoas)
  • Manual: old rebar3 nova gen_controller --name users still works with deprecation warning

Taure and others added 10 commits March 14, 2026 06:28
* ci: add GitHub Actions workflow

* fix: remove dialyzer (rebar3 APIs not in PLT)

* fix: remove xref (rebar3 APIs not available as deps)
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).
Resolve merge conflicts in rebar.config and release.yml.
Restructure gen_* commands into a single `rebar3 nova gen <type> <name>`
entry point with bbmustache templates for code generation.

- Add rebar3_nova_gen.erl dispatcher routing to gen modules by type
- Extract shared helpers to rebar3_nova_utils (singularize, pluralize,
  capitalize, timestamp, parse_fields, render_template)
- Add run/1 and run/2 to each gen module; do/1 emits deprecation warning
- Convert gen_controller, gen_test, gen_auth to mustache templates
- Replace thoas:encode/decode with json:encode/decode in gen_auth
- Name is now a positional arg: `rebar3 nova gen controller users`
- Old gen_* commands still work for backward compatibility
- Add rebar3_nova_gen_SUITE (12 tests) and integration suite (7 tests)
- Integration suite scaffolds a project, runs all generators, validates
  syntax of 24 .erl files, and runs rebar3 compile end-to-end
Taure added 2 commits March 19, 2026 15:17
Export pure helper functions via -ifdef(TEST) and add test suites:
- audit: is_mutation, classify_findings, segment_to_binary, expand_methods (9 tests)
- openapi: build_spec, build_paths, extract_path_params, schema_ref,
  request_body, response_schema, swagger_html (15 tests)
- middleware: format_handler, format_methods (5 tests)
- serve: is_routefile (4 tests)

Also fix thoas:encode/decode -> json:encode/decode in openapi module.

Total: 73 tests across 8 suites, all passing.
Keep our Arizona API (parse_transform, arizona_view:new,
arizona_template:from_html) over upstream's older API.
@Taure Taure mentioned this pull request Mar 19, 2026
2 tasks
Taure added 16 commits March 19, 2026 20:18
Replace crashes with user-friendly abort messages showing usage,
examples, and available options. Fix silent crashes in template
rendering, file copying, and field parsing.
The {name, $n, "name", string, ...} option in opts interfered with
getopt's positional argument handling, causing bare args like
`rebar3 nova new myapp` to fail. Now uses purely positional args,
matching the pattern used by the gen dispatcher.
rebar3 puts the first positional arg into Opts as {task, Value},
not into Args. Check task key in Opts first, fall back to Args.
- Use {protocol => liveview} routing instead of controllers for Arizona
- Generate full layout/1 with HTML shell and Arizona JS bootstrap
- Use arizona_template:from_erl (Erlang terms) instead of from_html
- Use <<"">> binary strings instead of ~""
- Add arizona_core git dep from novaframework org
- Fix fullstack template missing arizona_core dep
- No controller generated for --arizona (views routed directly)
When --kura is set, the generated project now includes:
- Provider hook {kura, compile} in rebar.config
- Kura repo config in sys.config (dev + prod)
- kura_repo_worker:start + kura_migrator:migrate in _app:start/2
- Docker Compose PostgreSQL

Only the schema files need to be created manually.
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.

1 participant