CLI API Reference
Complete API reference for @curisjs/cli package.
Commands
curis new
Create a new CurisJS project.
Syntax:
curis new <project-name> [options]Arguments:
project-name(required): Name of the project to create
Options:
| Option | Alias | Type | Default | Description |
|---|---|---|---|---|
--template | -t | string | default | Template to use (default, api, minimal) |
--database | -d | string | sqlite | Database type (sqlite, postgres, mysql) |
--package-manager | -p | string | auto-detect | Package manager (npm, pnpm, yarn, bun) |
--no-git | boolean | false | Skip git initialization | |
--no-install | boolean | false | Skip dependency installation |
Examples:
# Create basic project
curis new my-app
# Create API project with PostgreSQL
curis new my-api --template api --database postgres
# Create with Bun package manager
curis new my-app -p bun
# Create without git
curis new my-app --no-git
# Short form
curis new my-app -t api -d postgres -p pnpmExit Codes:
0: Success1: Project directory already exists2: Invalid template or database type
curis dev
Start development server with hot reload.
Syntax:
curis dev [options]Options:
| Option | Alias | Type | Default | Description |
|---|---|---|---|---|
--port | -p | number | 3000 | Port number |
--host | -h | string | localhost | Host address |
--watch | -w | boolean | true | Enable file watching |
--no-clear | boolean | false | Don't clear console on restart |
Examples:
# Start on default port
curis dev
# Custom port
curis dev -p 8080
# Listen on all interfaces
curis dev -h 0.0.0.0
# Disable watch mode
curis dev --no-watchcuris build
Build project for production.
Syntax:
curis build [options]Options:
| Option | Alias | Type | Default | Description |
|---|---|---|---|---|
--output | -o | string | dist | Output directory |
--target | -t | string | node | Target runtime |
--minify | boolean | false | Minify output | |
--sourcemap | boolean | false | Generate sourcemaps |
Target Runtimes:
node- Node.jsbun- Bundeno- Denocloudflare- Cloudflare Workersvercel- Vercel Edge
Examples:
# Build for Node.js
curis build
# Build for Bun with minification
curis build -t bun --minify
# Custom output directory
curis build -o ./build
# Build with sourcemaps
curis build --sourcemapcuris serve
Serve production build.
Syntax:
curis serve [options]Options:
| Option | Alias | Type | Default | Description |
|---|---|---|---|---|
--port | -p | number | 3000 | Port number |
--host | -h | string | localhost | Host address |
--dir | -d | string | dist | Build directory |
Examples:
# Serve default build
curis serve
# Serve on custom port
curis serve -p 8080
# Serve custom directory
curis serve -d ./buildcuris generate
Generate code scaffolding.
Alias: curis g
Syntax:
curis generate <type> <name> [options]
curis g <type> <name> [options]Types:
model- Generate a modelcontroller- Generate a controllermiddleware- Generate middlewaremigration- Generate a migrationvalidator- Generate a validatorservice- Generate a service
curis generate model
Generate a model file.
Syntax:
curis g model <name> [options]Options:
| Option | Type | Default | Description |
|---|---|---|---|
--table | string | pluralized name | Table name |
--timestamps | boolean | true | Include timestamps |
--soft-delete | boolean | false | Enable soft deletes |
Examples:
# Basic model
curis g model User
# With custom table
curis g model User --table app_users
# With soft delete
curis g model Post --soft-delete
# Without timestamps
curis g model Log --no-timestampsGenerated File:
src/app/models/User.tscuris generate controller
Generate a controller file.
Syntax:
curis g controller <name> [options]Options:
| Option | Type | Default | Description |
|---|---|---|---|
--resource | boolean | false | Generate resource controller (CRUD) |
--api | boolean | false | Generate API controller (JSON) |
Examples:
# Basic controller
curis g controller UserController
# Resource controller
curis g controller UserController --resource
# API controller
curis g controller UserController --apiGenerated File:
src/app/controllers/UserController.tscuris generate middleware
Generate a middleware file.
Syntax:
curis g middleware <name>Examples:
curis g middleware auth
curis g middleware rateLimitGenerated File:
src/app/middleware/auth.tscuris generate migration
Generate a database migration.
Syntax:
curis g migration <name>Examples:
curis g migration CreateUsersTable
curis g migration AddEmailToUsersGenerated File:
src/database/migrations/2024_11_17_100000_create_users_table.tscuris generate validator
Generate a validator schema.
Syntax:
curis g validator <name>Examples:
curis g validator UserValidator
curis g validator PostValidatorGenerated File:
src/app/validators/UserValidator.tscuris generate service
Generate a service class.
Syntax:
curis g service <name>Examples:
curis g service EmailService
curis g service PaymentServiceGenerated File:
src/app/services/EmailService.tscuris db:migrate
Run database migrations.
Syntax:
curis db:migrate [options]Options:
| Option | Type | Default | Description |
|---|---|---|---|
--rollback | boolean | false | Rollback last migration |
--reset | boolean | false | Reset all migrations |
--seed | boolean | false | Run seeders after migration |
--step | number | Number of migrations to run/rollback |
Examples:
# Run all pending migrations
curis db:migrate
# Rollback last migration
curis db:migrate --rollback
# Rollback 2 migrations
curis db:migrate --rollback --step 2
# Reset and migrate
curis db:migrate --reset
# Migrate and seed
curis db:migrate --seedcuris db:seed
Run database seeders.
Syntax:
curis db:seed [options]Options:
| Option | Alias | Type | Description |
|---|---|---|---|
--class | -c | string | Specific seeder class to run |
Examples:
# Run all seeders
curis db:seed
# Run specific seeder
curis db:seed -c UserSeedercuris db:reset
Reset the database.
Syntax:
curis db:resetWarning: This will drop all tables and data.
curis db:fresh
Drop all tables and re-run migrations.
Syntax:
curis db:fresh [options]Options:
| Option | Type | Default | Description |
|---|---|---|---|
--seed | boolean | false | Seed after fresh migration |
Examples:
# Fresh migration
curis db:fresh
# Fresh migration with seeding
curis db:fresh --seedcuris info
Display project and system information.
Syntax:
curis infoOutput:
CurisJS CLI Information
━━━━━━━━━━━━━━━━━━━━━━━
CurisJS Version: 0.1.0
CLI Version: 0.1.0
Node Version: v20.10.0
Package Manager: pnpm
OS: Linux
Architecture: x64
Runtime: Node.jscuris list
List all available commands.
Syntax:
curis listcuris version
Display CLI version.
Syntax:
curis version
curis -v
curis --versioncuris help
Display help information.
Syntax:
curis help [command]
curis <command> --helpExamples:
# General help
curis help
# Help for specific command
curis help generate
curis generate --helpConfiguration
curis.config.ts
Project configuration file.
Location: Project root
Schema:
import { defineConfig } from '@curisjs/cli';
export default defineConfig({
// Server configuration
server: {
port: number;
host: string;
},
// Build configuration
build: {
outDir: string;
target: 'node' | 'bun' | 'deno' | 'cloudflare' | 'vercel';
minify: boolean;
sourcemap: boolean;
},
// Database configuration
database: {
client: 'better-sqlite3' | 'pg' | 'mysql2';
connection: {
filename?: string;
host?: string;
port?: number;
user?: string;
password?: string;
database?: string;
};
migrations: {
directory: string;
};
seeds: {
directory: string;
};
},
// Generator configuration
generators: {
modelsDir: string;
controllersDir: string;
middlewareDir: string;
servicesDir: string;
validatorsDir: string;
},
});Example:
import { defineConfig } from '@curisjs/cli';
export default defineConfig({
server: {
port: 3000,
host: 'localhost',
},
build: {
outDir: 'dist',
target: 'node',
minify: true,
},
database: {
client: 'better-sqlite3',
connection: {
filename: './database.sqlite',
},
migrations: {
directory: './src/database/migrations',
},
},
generators: {
modelsDir: './src/app/models',
controllersDir: './src/app/controllers',
middlewareDir: './src/app/middleware',
servicesDir: './src/app/services',
validatorsDir: './src/app/validators',
},
});Environment Variables
The CLI respects the following environment variables:
| Variable | Description | Default |
|---|---|---|
NODE_ENV | Environment mode | development |
PORT | Server port | 3000 |
HOST | Server host | localhost |
DATABASE_URL | Database connection string | |
DB_CLIENT | Database client | better-sqlite3 |
Example .env file:
NODE_ENV=development
PORT=3000
HOST=localhost
DB_CLIENT=better-sqlite3
DB_FILENAME=./database.sqlite
# Or PostgreSQL
# DATABASE_URL=postgresql://user:pass@localhost:5432/mydbExit Codes
| Code | Description |
|---|---|
| 0 | Success |
| 1 | General error |
| 2 | Invalid arguments |
| 3 | Configuration error |
| 4 | Database error |
| 5 | File system error |
Template Variables
When generating code, these variables are available:
| Variable | Description | Example |
|---|---|---|
| Resource name | User |
| Lowercase name | user |
| Plural name | Users |
| Table name | users |
| Current timestamp | 2024_11_17_100000 |