Overview
The CLI covers init, scaffolding, import, export, and sync.
| Task | Command | Docs |
|---|---|---|
| Scaffold config and an empty bundle | accorudo init | below |
| Add a model type | accorudo model add | Scaffolding |
| Add a route and register it | accorudo route add | Scaffolding |
| OpenAPI → Accorudo | accorudo import | Import |
| Accorudo → OpenAPI | accorudo export | Export |
| Import or export from config | accorudo sync | below |
Run via pnpm exec or add scripts to your package.json:
{
"scripts": {
"accorudo:import": "accorudo import openapi/main.yaml --out contracts/main",
"accorudo:export": "accorudo export contracts/main --out openapi/main.yaml"
}
}
Init
Scaffold config and an empty bundle directory:
accorudo init
Creates:
accorudo.config.ts
contracts/main/
openapi/main.yaml # placeholder path: point at your real spec
Commands
accorudo import <spec>
Generate a complete contract set from an OpenAPI file. See Import.
accorudo import ./openapi/main.yaml --out ./contracts/main
| Flag | Description |
|---|---|
-o, --out <dir> | Output directory (required) |
-n, --name <name> | Bundle name for config entries (default: derived from spec info.title) |
--only <tags> | Limit to comma-separated OpenAPI tags (e.g. widget,admin) |
--dry-run | Print planned files without writing |
accorudo export <contracts>
Generate an OpenAPI spec from an Accorudo contract bundle. See Export.
accorudo export ./contracts/main --out ./openapi/main.yaml
| Flag | Description |
|---|---|
-o, --out <file> | Output path: .yaml, .yml, or .json (required) |
--title <title> | Override info.title in the generated spec |
--dry-run | Print spec to stdout instead of writing |
accorudo sync [bundle]
Run import or export for bundles defined in accorudo.config.ts.
accorudo sync # import all bundles (openapi → contracts)
accorudo sync main # import one bundle
accorudo sync main --reverse # export one bundle (contracts → openapi)
accorudo sync --reverse # export all bundles
| Flag | Description |
|---|---|
--reverse | Export contracts to OpenAPI instead of importing |
--dry-run | Preview changes without writing |
accorudo model add <name>
Append a model type to models/<domain>.ts. See Scaffolding.
accorudo route add <key>
Append a route, update routes/<tag>.ts, and register it in api.ts. See Scaffolding.
Configuration
accorudo.config.ts pairs each bundle with its spec:
import { defineConfig } from "accorudo/cli";
export default defineConfig({
bundles: {
main: {
contracts: "./contracts/main",
openapi: "./openapi/main.yaml",
},
payments: {
contracts: "./contracts/payments",
openapi: "./openapi/payments.yaml",
},
},
});
After init, accorudo sync main replaces a long import command. Add bundles as your API surface grows.
Typical workflow
# 1. Bootstrap from backend spec
accorudo import ./openapi/main.yaml --out ./contracts/main
# 2. Review generated files, hand-edit where needed
# 3. Use accorudo/client in your app
# 4. Later: re-import to pick up new endpoints
accorudo sync main
# 5. Or push contract changes back to a shared spec
accorudo sync main --reverse
Use --dry-run before overwriting hand-edited files. The CLI prints a summary of files to create, update, or skip.