Appearance
AdonisJS Commands
A comprehensive guide to AdonisJS CLI commands used in Jubiloop development.
Ace CLI
AdonisJS uses the Ace CLI for various development tasks. All commands are run from the apps/server directory.
bash
cd apps/server
node ace <command>Development Commands
Starting the Server
bash
# Start development server with HMR
node ace serve --hmr
# Start with specific port
node ace serve --port=4000
# Start with debugging
node ace serve --node-args="--inspect"Building for Production
bash
# Build the application
node ace build
# Build with production flag
node ace build --production
# Start production server
node bin/server.jsDatabase Commands
Migrations
bash
# Run pending migrations
node ace migration:run
# Rollback migrations
node ace migration:rollback
# Rollback specific batch
node ace migration:rollback --batch=2Forbidden
migration:rollback --batch=0 drops every table in the database. It is explicitly prohibited. Use migration:fresh to reset locally.
bash
# Check migration status
node ace migration:status
# Preview migration SQL
node ace migration:run --dry-run
# Create new migration
node ace make:migration create_users_table
# Create migration for existing table
node ace make:migration add_avatar_to_users --table=usersSeeders
bash
# Run all seeders
node ace db:seed
# Run specific seeder
node ace db:seed --files="./database/seeders/user_seeder.ts"
# Create new seeder
node ace make:seeder user
# Create seeder in subdirectory
node ace make:seeder demo/demo_usersDatabase Management
bash
# Wipe database (drop all tables)
node ace db:wipe
# Wipe and migrate fresh
node ace migration:fresh
# Fresh migration with seeders
node ace migration:fresh --seedGenerators
Models
bash
# Create a model
node ace make:model User
# Model with migration
node ace make:model Event -m
# Model with controller
node ace make:model Organization -c
# Model with factory
node ace make:model Product -f
# All options
node ace make:model Post -mcfControllers
bash
# Create a controller
node ace make:controller users
# Resource controller (CRUD)
node ace make:controller events --resource
# API controller (no view methods)
node ace make:controller api/events --api
# Singular resource
node ace make:controller profile --singularValidators
bash
# Create a validator
node ace make:validator create_user
# Validator in subdirectory
node ace make:validator auth/registerMiddleware
bash
# Create middleware
node ace make:middleware auth
# Create in subdirectory
node ace make:middleware admin/verify_roleServices & Providers
bash
# Create a service
node ace make:service user_service
# Create a provider
node ace make:provider app_providerEvents & Listeners
bash
# Create an event
node ace make:event user_registered
# Create a listener
node ace make:listener send_welcome_email
# Create prldfile
node ace make:prldfile start/eventsMails
bash
# Create a mail class
node ace make:mail welcome_email
# Create with markdown view
node ace make:mail promotional --markdownAuthentication Commands
Setup Auth
Not used in Jubiloop
@adonisjs/auth is not installed. Jubiloop uses Better Auth instead — these commands do not apply.
bash
# These commands are NOT used in Jubiloop:
# node ace configure @adonisjs/auth
# node ace auth:scaffoldREPL & Testing
REPL (Interactive Console)
bash
# Start REPL
node ace repl
# In REPL, you can:
# > const user = await models.user.find(1)
# > await user.load('events')Testing
The server uses Japa as its test runner (not Vitest or Jest). See Testing with Japa for a full guide.
bash
# Run all suites
node ace test
# Run a specific suite
node ace test --suite unit
node ace test --suite functional
# Run a single file
node ace test --files tests/functional/events.spec.ts
# Run multiple files (comma-separated, no spaces)
node ace test --files "tests/unit/a.spec.ts,tests/unit/b.spec.ts"Japa does not support
--coverage,--watch, or--grepflags. Use--filesto narrow scope.
List & Help
Available Commands
bash
# List all commands
node ace list
# List make commands
node ace list make
# Get help for specific command
node ace migration:run --helpCustom Commands
Creating Custom Commands
bash
# Create a command
node ace make:command greet_user
# Command with custom signature
node ace make:command send_newsletterCommand Structure
typescript
import { BaseCommand } from '@adonisjs/core/ace'
import { CommandOptions } from '@adonisjs/core/types/ace'
export default class GreetUser extends BaseCommand {
static commandName = 'greet:user'
static description = 'Greet a user by name'
static options: CommandOptions = {
startApp: true, // Start the application
}
async run() {
const name = await this.prompt.ask('Enter your name')
this.logger.info(`Hello ${name}!`)
}
}Environment Commands
Configuration
bash
# Generate app key
node ace generate:key
# Validate environment variables
node ace env:validatePackage Management
Installing Packages
bash
# Configure a package
node ace configure @adonisjs/lucid
# Install and configure
npm install @adonisjs/redis
node ace configure @adonisjs/redisDevelopment Workflow
Common Sequences
Setting up a new feature:
bash
# 1. Create migration
node ace make:migration create_posts_table
# 2. Run migration
node ace migration:run
# 3. Create model
node ace make:model Post
# 4. Create controller
node ace make:controller posts --resource
# 5. Create validator
node ace make:validator create_postResetting database:
bash
# Drop all tables and re-run migrations
node ace migration:fresh
# With seeders
node ace migration:fresh --seedDebugging:
bash
# Start with Node debugging
node ace serve --node-args="--inspect"
# Use REPL for testing
node ace replTips & Tricks
Aliases
Add to your shell profile:
bash
alias ace="node ace"
alias serve="node ace serve --hmr"
alias migrate="node ace migration:run"
alias seed="node ace db:seed"Common Patterns
- Always use migrations for schema changes
- Create validators for user input
- Use seeders for demo data
- Run tests before committing
- Use REPL for quick debugging
Troubleshooting
Command not found:
- Ensure you're in
apps/serverdirectory - Check if
@adonisjs/coreis installed
Migration errors:
- Check database connection
- Verify migration syntax
- Use
--dry-runto debug
Build errors:
- Clear build cache:
rm -rf build - Check TypeScript errors
- Verify dependencies