or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

docs

ace-commands.mdapplication.mdauth-hash.mdcommands.mdconfig-env.mdevents.mdhelpers.mdhttp-server.mdindex.mdlogging.mdtest-utils.md
tile.json

commands.mddocs/

Built-in Commands

AdonisJS Core includes numerous built-in commands for development workflows, code generation, package management, and application lifecycle management. All commands are executed through the Ace CLI system.

Capabilities

Development Commands

Commands for local development and server management.

/**
 * Start development server with hot reloading
 */
class ServeCommand extends BaseCommand {
  static commandName = "serve";
  static description = "Start the development server";

  /** Enable file watching for auto-restart */
  @flags.boolean({ description: "Enable file watching" })
  declare watch: boolean;

  /** Port number to bind server */
  @flags.number({ description: "Port number" })
  declare port: number;

  /** Host to bind server */
  @flags.string({ description: "Host to bind" })
  declare host: string;

  /** Enable Node.js inspector */
  @flags.boolean({ description: "Enable Node.js inspector" })
  declare inspect: boolean;

  /** Node arguments to pass */
  @flags.array({ description: "Node arguments" })
  declare nodeArgs: string[];

  async run(): Promise<void>;
}

/**
 * Start interactive REPL session
 */
class ReplCommand extends BaseCommand {
  static commandName = "repl";
  static description = "Start the application REPL";

  async run(): Promise<void>;
}

Usage Examples:

# Start development server
node ace serve

# Start with file watching
node ace serve --watch

# Start on custom port
node ace serve --port=4000

# Start with Node.js inspector
node ace serve --inspect

# Start REPL session
node ace repl

Build Commands

Commands for building and preparing applications for production.

/**
 * Build application for production
 */
class BuildCommand extends BaseCommand {
  static commandName = "build";
  static description = "Build the application for production";

  /** Enable production optimizations */
  @flags.boolean({ description: "Enable production mode", default: true })
  declare production: boolean;

  /** Output directory */
  @flags.string({ description: "Output directory" })
  declare outDir: string;

  /** Enable source maps */
  @flags.boolean({ description: "Generate source maps" })
  declare sourceMaps: boolean;

  /** Enable minification */
  @flags.boolean({ description: "Minify output" })
  declare minify: boolean;

  async run(): Promise<void>;
}

/**
 * Generate application encryption key
 */
class GenerateKeyCommand extends BaseCommand {
  static commandName = "generate:key";
  static description = "Generate application encryption key";

  /** Show key without saving */
  @flags.boolean({ description: "Show key without saving to .env" })
  declare show: boolean;

  /** Force overwrite existing key */
  @flags.boolean({ description: "Force overwrite existing key" })
  declare force: boolean;

  async run(): Promise<void>;
}

Usage Examples:

# Build for production
node ace build

# Build with custom output directory
node ace build --out-dir=dist

# Generate new encryption key
node ace generate:key

# Show key without saving
node ace generate:key --show

# Force overwrite existing key
node ace generate:key --force

Testing Commands

Commands for running tests and test-related operations.

/**
 * Run application test suite
 */
class TestCommand extends BaseCommand {
  static commandName = "test";
  static description = "Run the application test suite";

  /** Test files pattern */
  @args.spread({ description: "Test files to run" })
  declare files: string[];

  /** Enable file watching */
  @flags.boolean({ description: "Watch files for changes" })
  declare watch: boolean;

  /** Minimum coverage threshold */
  @flags.number({ description: "Minimum coverage threshold" })  
  declare coverage: number;

  /** Test timeout in milliseconds */
  @flags.number({ description: "Test timeout" })
  declare timeout: number;

  /** Number of parallel test suites */
  @flags.number({ description: "Concurrency level" })
  declare concurrency: number;

  /** Generate coverage report */
  @flags.boolean({ description: "Generate coverage report" })
  declare coverageReport: boolean;

  async run(): Promise<void>;
}

Usage Examples:

# Run all tests
node ace test

# Run specific test files
node ace test tests/unit/user.spec.ts

# Run tests with coverage
node ace test --coverage-report

# Run tests in watch mode
node ace test --watch

# Run tests with custom timeout
node ace test --timeout=30000

Package Management Commands

Commands for adding, configuring, and managing packages.

/**
 * Add packages to the application
 */
class AddCommand extends BaseCommand {
  static commandName = "add";
  static description = "Add packages to the application";

  /** Package names to add */
  @args.spread({ description: "Package names", required: true })
  declare packages: string[];

  /** Install as dev dependency */
  @flags.boolean({ description: "Install as dev dependency" })
  declare dev: boolean;

  /** Skip package configuration */
  @flags.boolean({ description: "Skip package configuration" })
  declare skipConfig: boolean;

  /** Use specific package manager */
  @flags.string({ description: "Package manager to use" })
  declare packageManager: string;

  async run(): Promise<void>;
}

/**
 * Configure packages post-installation
 */
class ConfigureCommand extends BaseCommand {
  static commandName = "configure";
  static description = "Configure packages";

  /** Package name to configure */
  @args.string({ description: "Package name", required: true })
  declare packageName: string;

  /** Force reconfiguration */
  @flags.boolean({ description: "Force reconfiguration" })
  declare force: boolean;

  async run(): Promise<void>;
}

Usage Examples:

# Add production package
node ace add @adonisjs/lucid

# Add development package
node ace add @types/node --dev

# Add multiple packages
node ace add @adonisjs/session @adonisjs/auth

# Configure package
node ace configure @adonisjs/lucid

# Force reconfigure package
node ace configure @adonisjs/lucid --force

Code Generation Commands

Commands for generating boilerplate code and project files.

/**
 * Generate controllers
 */
class MakeControllerCommand extends BaseCommand {
  static commandName = "make:controller";
  static description = "Create a new HTTP controller";

  /** Controller name */
  @args.string({ description: "Controller name", required: true })
  declare name: string;

  /** Create resource controller */
  @flags.boolean({ description: "Create resource controller" })
  declare resource: boolean;

  /** Create API controller */
  @flags.boolean({ description: "Create API controller" })
  declare api: boolean;

  async run(): Promise<void>;
}

/**
 * Generate middleware
 */
class MakeMiddlewareCommand extends BaseCommand {
  static commandName = "make:middleware";
  static description = "Create a new middleware";

  /** Middleware name */
  @args.string({ description: "Middleware name", required: true })
  declare name: string;

  async run(): Promise<void>;
}

/**
 * Generate commands
 */
class MakeCommandCommand extends BaseCommand {
  static commandName = "make:command";
  static description = "Create a new Ace command";

  /** Command name */
  @args.string({ description: "Command name", required: true })
  declare name: string;

  async run(): Promise<void>;
}

/**
 * Generate event classes
 */
class MakeEventCommand extends BaseCommand {
  static commandName = "make:event";
  static description = "Create a new event class";

  /** Event name */
  @args.string({ description: "Event name", required: true })
  declare name: string;

  async run(): Promise<void>;
}

/**
 * Generate exception classes
 */
class MakeExceptionCommand extends BaseCommand {
  static commandName = "make:exception";
  static description = "Create a new exception class";

  /** Exception name */
  @args.string({ description: "Exception name", required: true })
  declare name: string;

  async run(): Promise<void>;
}

/**
 * Generate event listeners
 */
class MakeListenerCommand extends BaseCommand {
  static commandName = "make:listener";
  static description = "Create a new event listener";

  /** Listener name */
  @args.string({ description: "Listener name", required: true })
  declare name: string;

  async run(): Promise<void>;
}

/**
 * Generate preload files
 */
class MakePreloadCommand extends BaseCommand {
  static commandName = "make:preload";
  static description = "Create a new preload file";

  /** Preload file name */
  @args.string({ description: "Preload file name", required: true })
  declare name: string;

  async run(): Promise<void>;
}

/**
 * Generate service providers
 */
class MakeProviderCommand extends BaseCommand {
  static commandName = "make:provider";
  static description = "Create a new service provider";

  /** Provider name */
  @args.string({ description: "Provider name", required: true })
  declare name: string;

  async run(): Promise<void>;
}

/**
 * Generate service classes
 */
class MakeServiceCommand extends BaseCommand {
  static commandName = "make:service";
  static description = "Create a new service class";

  /** Service name */
  @args.string({ description: "Service name", required: true })
  declare name: string;

  async run(): Promise<void>;
}

/**
 * Generate test files
 */
class MakeTestCommand extends BaseCommand {
  static commandName = "make:test";
  static description = "Create a new test file";

  /** Test name */
  @args.string({ description: "Test name", required: true })
  declare name: string;

  /** Create unit test */
  @flags.boolean({ description: "Create unit test" })
  declare unit: boolean;

  async run(): Promise<void>;
}

/**
 * Generate validators
 */
class MakeValidatorCommand extends BaseCommand {
  static commandName = "make:validator";
  static description = "Create a new validator";

  /** Validator name */
  @args.string({ description: "Validator name", required: true })
  declare name: string;

  async run(): Promise<void>;
}

/**
 * Generate view templates
 */
class MakeViewCommand extends BaseCommand {
  static commandName = "make:view";
  static description = "Create a new view template";

  /** View name */
  @args.string({ description: "View name", required: true })
  declare name: string;

  async run(): Promise<void>;
}

Usage Examples:

# Generate controller
node ace make:controller User

# Generate resource controller
node ace make:controller User --resource

# Generate API controller  
node ace make:controller Api/User --api

# Generate middleware
node ace make:middleware Auth

# Generate command
node ace make:command SendEmails

# Generate event
node ace make:event UserRegistered

# Generate exception
node ace make:exception InvalidCredentials

# Generate listener
node ace make:listener SendWelcomeEmail

# Generate preload file
node ace make:preload bootstrap

# Generate provider
node ace make:provider DatabaseProvider

# Generate service
node ace make:service UserService

# Generate test
node ace make:test UserController

# Generate unit test
node ace make:test UserService --unit

# Generate validator
node ace make:validator CreateUserValidator

# Generate view
node ace make:view welcome

Environment Commands

Commands for managing environment variables and configuration.

/**
 * Add environment variable
 */
class EnvAddCommand extends BaseCommand {
  static commandName = "env:add";
  static description = "Add environment variable to .env file";

  /** Variable name */
  @args.string({ description: "Variable name", required: true })
  declare name: string;

  /** Variable value */
  @args.string({ description: "Variable value", required: true })
  declare value: string;

  async run(): Promise<void>;
}

/**
 * Remove environment variable
 */
class EnvRemoveCommand extends BaseCommand {
  static commandName = "env:remove";
  static description = "Remove environment variable from .env file";

  /** Variable name */
  @args.string({ description: "Variable name", required: true })
  declare name: string;

  async run(): Promise<void>;
}

/**
 * Get environment variable
 */
class EnvGetCommand extends BaseCommand {
  static commandName = "env:get";
  static description = "Get environment variable value";

  /** Variable name */
  @args.string({ description: "Variable name", required: true })
  declare name: string;

  async run(): Promise<void>;
}

Usage Examples:

# Add environment variable
node ace env:add DB_HOST localhost

# Remove environment variable
node ace env:remove DEPRECATED_VAR  

# Get environment variable
node ace env:get DB_HOST

Inspection Commands

Commands for inspecting application configuration and structure.

/**
 * Inspect AdonisJS RC file
 */
class InspectRcFileCommand extends BaseCommand {
  static commandName = "inspect:rcfile";
  static description = "Inspect the adonisrc.ts file";

  async run(): Promise<void>;
}

/**
 * List registered commands
 */
class ListCommandsCommand extends BaseCommand {
  static commandName = "list:commands";
  static description = "List all registered commands";

  /** Show command details */
  @flags.boolean({ description: "Show command details" })
  declare details: boolean;

  async run(): Promise<void>;
}

/**
 * List service providers
 */
class ListProvidersCommand extends BaseCommand {
  static commandName = "list:providers";
  static description = "List all service providers";

  async run(): Promise<void>;
}

Usage Examples:

# Inspect RC file
node ace inspect:rcfile

# List all commands
node ace list:commands

# List commands with details
node ace list:commands --details  

# List service providers
node ace list:providers

Utility Commands

Additional utility commands for various development tasks.

/**
 * Eject framework files to user space
 */
class EjectCommand extends BaseCommand {
  static commandName = "eject";
  static description = "Eject framework files";

  /** Files to eject */
  @args.spread({ description: "Files to eject" })
  declare files: string[];

  async run(): Promise<void>;
}

Usage Examples:

# Eject specific files
node ace eject webpack.config.js

# List available files to eject
node ace eject --help

Command Execution

All commands are executed through the Ace CLI system with consistent patterns.

/**
 * Execute Ace command programmatically
 * @param commandName - Command to execute
 * @param args - Command arguments
 * @param options - Execution options
 */
function executeCommand(
  commandName: string,
  args?: string[],
  options?: CommandExecutionOptions
): Promise<CommandResult>;

/**
 * Command execution result
 */
interface CommandResult {
  /** Exit code */
  exitCode: number;
  /** Command output */
  output: string;
  /** Error output */
  error?: string;
  /** Execution duration */
  duration: [number, number];
}

/**
 * Command execution options
 */
interface CommandExecutionOptions {
  /** Working directory */
  cwd?: string;
  /** Environment variables */
  env?: Record<string, string>;
  /** Timeout in milliseconds */
  timeout?: number;
}

Usage Examples:

// Execute commands programmatically
import { executeCommand } from "@adonisjs/core/ace";

// Build application
const buildResult = await executeCommand('build', ['--production']);

// Run tests
const testResult = await executeCommand('test', ['tests/unit'], {
  timeout: 60000
});

// Generate key
const keyResult = await executeCommand('generate:key', ['--show']);
console.log('Generated key:', keyResult.output);

Types

interface BaseCommand {
  static commandName: string;
  static description: string;
  static options: CommandOptions;
  
  app: ApplicationService;
  kernel: Kernel;
  logger: Logger;
  
  run(): Promise<void>;
}

interface CommandOptions {
  staysAlive?: boolean;
  startApp?: boolean;
}

interface ApplicationService {
  container: Container;
  config: ConfigManager;
  env: Env;
  makePath(relativePath: string): string;
}