feat: unified rebar3 nova gen dispatcher with template system#63
Open
Taure wants to merge 39 commits into
Open
feat: unified rebar3 nova gen dispatcher with template system#63Taure wants to merge 39 commits into
rebar3 nova gen dispatcher with template system#63Taure wants to merge 39 commits into
Conversation
* 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
7 tasks
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.
2 tasks
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
rebar3 nova gen <type> <name> [opts]entry point that dispatches to gen modulesrebar3_nova_utils(singularize, pluralize, capitalize, timestamp, parse_fields, render_template)priv/templates/gen/thoas:encode/decodewithjson:encode/decodein gen_authrebar3 nova gen controller usersgen_*commands still work but emit deprecation warnings.erlfiles, and compiles the project end-to-endTest plan
rebar3 fmt --checkpassesrebar3 xrefpassesrebar3 ct— all 40 tests pass (4 suites)rebar3 compilesucceedsrebar3 nova gen controller usersgenerates correct controllerrebar3 nova gen authgenerates 9 files withjson:encode(no thoas)rebar3 nova gen_controller --name usersstill works with deprecation warning