Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .github/workflows/erlang.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ on: [push, pull_request]
jobs:
build:
runs-on: ubuntu-24.04
name: OTP ${{matrix.otp}} / rebar3 ${{matrix.rebar3}}
strategy:
fail-fast: false
matrix:
Expand Down
52 changes: 52 additions & 0 deletions CLAUDE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# rebar3_nova

Rebar3 plugin for scaffolding and managing Nova framework projects.

## Build
```bash
rebar3 compile
```

## Commands provided
```bash
rebar3 new nova myapp # Create new Nova project
rebar3 nova serve # Dev server with file watching + hot reload
rebar3 nova routes # Display routing tree
rebar3 nova gen_controller # Generate controller module
rebar3 nova gen_resource # Generate controller + schema + route snippets
rebar3 nova gen_test # Generate CT test suite
rebar3 nova gen_auth # Generate email/password auth scaffolding
rebar3 nova openapi # Generate OpenAPI spec to priv/assets/
rebar3 nova middleware # Show plugin/middleware chains
rebar3 nova config # Show Nova configuration
rebar3 nova audit # Security audit of routes
rebar3 nova release # Build release (regenerates OpenAPI if schemas exist)
```

## Key modules
- `rebar3_nova.erl` — plugin registration, rebar3 version check
- `rebar3_nova_prv.erl` — base provider (help)
- `rebar3_nova_serve.erl` — dev server with inotify file watching, hot reload via `code:load_binary/3`
- `rebar3_nova_routes.erl` — route tree display with Unicode box-drawing
- `rebar3_nova_gen_controller.erl` — controller scaffolding
- `rebar3_nova_gen_resource.erl` — full resource scaffolding (controller + schema + routes)
- `rebar3_nova_gen_test.erl` — CT test suite generation
- `rebar3_nova_gen_auth.erl` — email/password auth scaffolding (9 files)
- `rebar3_nova_openapi.erl` — OpenAPI 3.0.3 spec + Swagger UI HTML (outputs to priv/assets/)
- `rebar3_nova_middleware.erl` — middleware/plugin chain display
- `rebar3_nova_config.erl` — Nova config display
- `rebar3_nova_audit.erl` — route security audit
- `rebar3_nova_release.erl` — release builder (wraps rebar3 release)
- `rebar3_nova_utils.erl` — shared helpers (app name/dir, ensure_dir, file writing)

## Templates
- `priv/templates/nova/` — Erlang project scaffold
- `priv/templates/nova_lfe/` — LFE project scaffold
- `priv/templates/nova_plugin.template` — plugin module
- `priv/templates/nova_websocket.template` — WebSocket module

## Architecture
Uses rebar3 provider pattern. Each command is a separate provider module in the `nova` namespace. All depend on `{default, compile}`.

## Git workflow
Default branch is `master`. NEVER push directly — always create a PR.
27 changes: 6 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,22 +69,6 @@ Generated functions return stub responses:

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

### `nova gen_router` — Generate a router module

Scaffolds a router module implementing the `nova_router` behaviour with an empty routes list.

```
$ rebar3 nova gen_router --name api_v1 --prefix /api/v1
===> Created src/myapp_api_v1_router.erl
```

**Options:**

| Flag | Required | Default | Description |
|------|----------|---------|-------------|
| `--name`, `-n` | yes | — | Router name |
| `--prefix`, `-p` | no | `""` | URL prefix for routes |

### `nova gen_resource` — Generate a full resource

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

```
$ rebar3 nova openapi
===> OpenAPI spec written to openapi.json
===> Swagger UI written to swagger.html
===> OpenAPI spec written to /path/to/myapp/priv/assets/openapi.json
===> Swagger UI written to /path/to/myapp/priv/assets/swagger.html

$ rebar3 nova openapi --output priv/assets/openapi.json --title "My API" --api-version 1.0.0
$ rebar3 nova openapi --title "My API" --api-version 1.0.0
$ rebar3 nova openapi --output custom/path/openapi.json
```

**Options:**

| Flag | Required | Default | Description |
|------|----------|---------|-------------|
| `--output`, `-o` | no | `openapi.json` | Output file path |
| `--output`, `-o` | no | `priv/assets/openapi.json` | Output file path |
| `--title`, `-t` | no | app name | API title |
| `--api-version`, `-v` | no | `0.1.0` | API version string |

A `swagger.html` file is also generated alongside the spec for quick browser-based exploration.
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.

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

Expand Down
12 changes: 6 additions & 6 deletions src/rebar3_nova.erl
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,16 @@ init(State) ->
Minor > "15" ->
lists:foldl(fun provider_init/2, {ok, State},
[rebar3_nova_prv, rebar3_nova_serve, rebar3_nova_routes, rebar3_nova_openapi,
rebar3_nova_gen_controller, rebar3_nova_gen_router, rebar3_nova_gen_resource,
rebar3_nova_gen_test, rebar3_nova_middleware, rebar3_nova_config,
rebar3_nova_audit, rebar3_nova_release]);
rebar3_nova_gen_controller, rebar3_nova_gen_resource,
rebar3_nova_gen_test, rebar3_nova_gen_auth, rebar3_nova_middleware,
rebar3_nova_config, rebar3_nova_audit, rebar3_nova_release]);
["git"] ->
rebar_api:info("Compiling with rebar3 from git - make sure you know what you are doing"),
lists:foldl(fun provider_init/2, {ok, State},
[rebar3_nova_prv, rebar3_nova_serve, rebar3_nova_routes, rebar3_nova_openapi,
rebar3_nova_gen_controller, rebar3_nova_gen_router, rebar3_nova_gen_resource,
rebar3_nova_gen_test, rebar3_nova_middleware, rebar3_nova_config,
rebar3_nova_audit, rebar3_nova_release]);
rebar3_nova_gen_controller, rebar3_nova_gen_resource,
rebar3_nova_gen_test, rebar3_nova_gen_auth, rebar3_nova_middleware,
rebar3_nova_config, rebar3_nova_audit, rebar3_nova_release]);
SomethingElse ->
rebar_api:abort("Nova needs Rebar > 3.15 to function. Your version is: ~p. Please consider upgrading.", [SomethingElse])
end.
Expand Down
Loading