Skip to content

Commit 66a0971

Browse files
authored
Merge pull request #51 from Taure/remove-gen-router
feat: remove gen_router, add gen_auth command
2 parents eb515a4 + 90bd426 commit 66a0971

File tree

8 files changed

+762
-93
lines changed

8 files changed

+762
-93
lines changed

.github/workflows/erlang.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ on: [push, pull_request]
55
jobs:
66
build:
77
runs-on: ubuntu-24.04
8-
name: OTP ${{matrix.otp}} / rebar3 ${{matrix.rebar3}}
98
strategy:
109
fail-fast: false
1110
matrix:

CLAUDE.md

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# rebar3_nova
2+
3+
Rebar3 plugin for scaffolding and managing Nova framework projects.
4+
5+
## Build
6+
```bash
7+
rebar3 compile
8+
```
9+
10+
## Commands provided
11+
```bash
12+
rebar3 new nova myapp # Create new Nova project
13+
rebar3 nova serve # Dev server with file watching + hot reload
14+
rebar3 nova routes # Display routing tree
15+
rebar3 nova gen_controller # Generate controller module
16+
rebar3 nova gen_resource # Generate controller + schema + route snippets
17+
rebar3 nova gen_test # Generate CT test suite
18+
rebar3 nova gen_auth # Generate email/password auth scaffolding
19+
rebar3 nova openapi # Generate OpenAPI spec to priv/assets/
20+
rebar3 nova middleware # Show plugin/middleware chains
21+
rebar3 nova config # Show Nova configuration
22+
rebar3 nova audit # Security audit of routes
23+
rebar3 nova release # Build release (regenerates OpenAPI if schemas exist)
24+
```
25+
26+
## Key modules
27+
- `rebar3_nova.erl` — plugin registration, rebar3 version check
28+
- `rebar3_nova_prv.erl` — base provider (help)
29+
- `rebar3_nova_serve.erl` — dev server with inotify file watching, hot reload via `code:load_binary/3`
30+
- `rebar3_nova_routes.erl` — route tree display with Unicode box-drawing
31+
- `rebar3_nova_gen_controller.erl` — controller scaffolding
32+
- `rebar3_nova_gen_resource.erl` — full resource scaffolding (controller + schema + routes)
33+
- `rebar3_nova_gen_test.erl` — CT test suite generation
34+
- `rebar3_nova_gen_auth.erl` — email/password auth scaffolding (9 files)
35+
- `rebar3_nova_openapi.erl` — OpenAPI 3.0.3 spec + Swagger UI HTML (outputs to priv/assets/)
36+
- `rebar3_nova_middleware.erl` — middleware/plugin chain display
37+
- `rebar3_nova_config.erl` — Nova config display
38+
- `rebar3_nova_audit.erl` — route security audit
39+
- `rebar3_nova_release.erl` — release builder (wraps rebar3 release)
40+
- `rebar3_nova_utils.erl` — shared helpers (app name/dir, ensure_dir, file writing)
41+
42+
## Templates
43+
- `priv/templates/nova/` — Erlang project scaffold
44+
- `priv/templates/nova_lfe/` — LFE project scaffold
45+
- `priv/templates/nova_plugin.template` — plugin module
46+
- `priv/templates/nova_websocket.template` — WebSocket module
47+
48+
## Architecture
49+
Uses rebar3 provider pattern. Each command is a separate provider module in the `nova` namespace. All depend on `{default, compile}`.
50+
51+
## Git workflow
52+
Default branch is `master`. NEVER push directly — always create a PR.

README.md

Lines changed: 6 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -69,22 +69,6 @@ Generated functions return stub responses:
6969

7070
If the file already exists, the command skips it with a warning.
7171

72-
### `nova gen_router` — Generate a router module
73-
74-
Scaffolds a router module implementing the `nova_router` behaviour with an empty routes list.
75-
76-
```
77-
$ rebar3 nova gen_router --name api_v1 --prefix /api/v1
78-
===> Created src/myapp_api_v1_router.erl
79-
```
80-
81-
**Options:**
82-
83-
| Flag | Required | Default | Description |
84-
|------|----------|---------|-------------|
85-
| `--name`, `-n` | yes || Router name |
86-
| `--prefix`, `-p` | no | `""` | URL prefix for routes |
87-
8872
### `nova gen_resource` — Generate a full resource
8973

9074
Combines controller generation, JSON schema creation, and prints route snippets to add to your router.
@@ -129,21 +113,22 @@ Generates an OpenAPI 3.0.3 JSON specification from compiled routes and any JSON
129113

130114
```
131115
$ rebar3 nova openapi
132-
===> OpenAPI spec written to openapi.json
133-
===> Swagger UI written to swagger.html
116+
===> OpenAPI spec written to /path/to/myapp/priv/assets/openapi.json
117+
===> Swagger UI written to /path/to/myapp/priv/assets/swagger.html
134118
135-
$ rebar3 nova openapi --output priv/assets/openapi.json --title "My API" --api-version 1.0.0
119+
$ rebar3 nova openapi --title "My API" --api-version 1.0.0
120+
$ rebar3 nova openapi --output custom/path/openapi.json
136121
```
137122

138123
**Options:**
139124

140125
| Flag | Required | Default | Description |
141126
|------|----------|---------|-------------|
142-
| `--output`, `-o` | no | `openapi.json` | Output file path |
127+
| `--output`, `-o` | no | `priv/assets/openapi.json` | Output file path |
143128
| `--title`, `-t` | no | app name | API title |
144129
| `--api-version`, `-v` | no | `0.1.0` | API version string |
145130

146-
A `swagger.html` file is also generated alongside the spec for quick browser-based exploration.
131+
A `swagger.html` file is also generated alongside the spec for quick browser-based exploration. The output directory is created automatically if it doesn't exist.
147132

148133
### `nova middleware` — Show plugin/middleware chains
149134

src/rebar3_nova.erl

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,16 @@ init(State) ->
1010
Minor > "15" ->
1111
lists:foldl(fun provider_init/2, {ok, State},
1212
[rebar3_nova_prv, rebar3_nova_serve, rebar3_nova_routes, rebar3_nova_openapi,
13-
rebar3_nova_gen_controller, rebar3_nova_gen_router, rebar3_nova_gen_resource,
14-
rebar3_nova_gen_test, rebar3_nova_middleware, rebar3_nova_config,
15-
rebar3_nova_audit, rebar3_nova_release]);
13+
rebar3_nova_gen_controller, rebar3_nova_gen_resource,
14+
rebar3_nova_gen_test, rebar3_nova_gen_auth, rebar3_nova_middleware,
15+
rebar3_nova_config, rebar3_nova_audit, rebar3_nova_release]);
1616
["git"] ->
1717
rebar_api:info("Compiling with rebar3 from git - make sure you know what you are doing"),
1818
lists:foldl(fun provider_init/2, {ok, State},
1919
[rebar3_nova_prv, rebar3_nova_serve, rebar3_nova_routes, rebar3_nova_openapi,
20-
rebar3_nova_gen_controller, rebar3_nova_gen_router, rebar3_nova_gen_resource,
21-
rebar3_nova_gen_test, rebar3_nova_middleware, rebar3_nova_config,
22-
rebar3_nova_audit, rebar3_nova_release]);
20+
rebar3_nova_gen_controller, rebar3_nova_gen_resource,
21+
rebar3_nova_gen_test, rebar3_nova_gen_auth, rebar3_nova_middleware,
22+
rebar3_nova_config, rebar3_nova_audit, rebar3_nova_release]);
2323
SomethingElse ->
2424
rebar_api:abort("Nova needs Rebar > 3.15 to function. Your version is: ~p. Please consider upgrading.", [SomethingElse])
2525
end.

0 commit comments

Comments
 (0)