@aurora/cli (0.3.3)
Published 2025-12-27 10:44:51 +00:00 by vlad
Installation
@aurora:registry=npm install @aurora/cli@0.3.3"@aurora/cli": "0.3.3"About this package
@aurora/cli
Command-line interface for Aurora development - codegen, dev server, and build tools.
Installation
bun add -D @aurora/cli
Commands
aurora codegen
Generate code from schema definitions:
aurora codegen [options]
Options:
--force- Force full regeneration (bypass cache)--no-react- Skip React hooks generation--no-zustand- Skip Zustand store generation
Example:
aurora codegen
Generates:
- TypeScript types
- Validators (Zod schemas)
- Repository interfaces
- API route handlers
- Client SDK
- React hooks (optional)
- Zustand stores (optional)
aurora dev
Start development server with hot reload:
aurora dev [options]
Options:
--port <port>- HTTP port (default: 3000)--workers- Start projection workers--watch- Enable watch mode with auto-reload--natsUrl <url>- NATS JetStream URL (default: nats://localhost:4222)--storagePath <path>- Storage directory (default: ./data)
Example:
# HTTP server only
aurora dev
# HTTP server + workers
aurora dev --workers
# With watch mode
aurora dev --watch
# Custom configuration
aurora dev --port 3001 --natsUrl nats://localhost:4222 --storagePath ./data/projections
aurora build
Build application for production:
aurora build
Generates production-ready code and bundles.
aurora check
Validate schemas before code generation:
aurora check
Validates:
- Event versioning
- Projection handlers
- API routes
- Auth rules
- Sharding keys
Exit codes:
0- No errors1- Errors found2- Warnings only
Example:
aurora check
# Schema validation passed!
aurora admin
Admin commands for sharding and operations:
aurora admin <command> [options]
Commands:
# List all shards
aurora admin shards list
# List shard assignments
aurora admin shards assign
# Rebalance shards
aurora admin shards rebalance
# List nodes
aurora admin nodes list
# Add replica
aurora admin replicas add --shard <shardId> --node <nodeId>
# Remove replica
aurora admin replicas remove --shard <shardId> --node <nodeId>
# Migrate shard
aurora admin migrate --shard <shardId> --from <nodeId> --to <nodeId>
# Failover
aurora admin failover --shard <shardId>
Watch Mode
Watch mode automatically regenerates code and restarts servers on schema changes:
aurora dev --watch
Features:
- 300ms debouncing
- Auto-code generation on schema changes
- Graceful server restart
- Failed codegen doesn't crash watch process
- Clean shutdown on SIGINT/SIGTERM
Schema Validation
Pre-commit validation catches errors before runtime:
# Validate schemas
aurora check
# Only proceed if valid
if [ $? -eq 0 ]; then
aurora codegen
git add .
git commit -m "Add new event"
fi
CI/CD Integration
name: Build and Test
on: [push]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: oven-sh/setup-bun@v1
- run: bun install
- run: aurora check
- run: aurora codegen
- run: bun test
- run: aurora build
Environment Variables
| Variable | Default | Description |
|---|---|---|
AURORA_PORT |
3000 |
HTTP server port |
AURORA_NATS_URL |
nats://localhost:4222 |
NATS JetStream URL |
AURORA_STORAGE_PATH |
./data |
Storage directory |
NODE_ENV |
development |
Environment |
Project Structure
Aurora expects this structure:
my-app/
├── schemas/
│ ├── events.schema.ts
│ ├── projections.schema.ts
│ └── api.schema.ts
├── src/
│ ├── app/
│ │ └── usecases/
│ └── main/
│ └── bootstrap.ts
├── generated/ # Generated by aurora codegen
├── package.json
└── tsconfig.json
Configuration
Create aurora.config.ts in project root:
import { defineConfig } from "@aurora/cli";
export default defineConfig({
schemas: ["./schemas/**/*.schema.ts"],
output: "./generated",
codegen: {
react: true,
zustand: false,
client: true,
},
dev: {
port: 3000,
natsUrl: "nats://localhost:4222",
storagePath: "./data",
},
});
Troubleshooting
Code generation fails
# Validate schemas first
aurora check
# Force regeneration
aurora codegen --force
Workers not connecting to NATS
# Check NATS is running
curl http://localhost:8222/varz
# Verify URL
aurora dev --workers --natsUrl nats://localhost:4222
Watch mode not detecting changes
# Check file permissions
ls -la schemas/
# Restart watch mode
# Ctrl+C then: aurora dev --watch
License
MIT
Dependencies
Dependencies
| ID | Version |
|---|---|
| @aurora/codegen | 0.3.3 |
| nats | ^2.28.2 |