Arcade CLI
The arcade_cli package provides a powerful command-line interface for creating, developing, and managing Arcade applications. It includes tools for project scaffolding, development server with hot reload, and route inspection.
Installation
Section titled “Installation”Install the CLI globally:
dart pub global activate arcade_cliOr add it as a dev dependency:
dev_dependencies: arcade_cli: ^<latest-version>Available Commands
Section titled “Available Commands”create - Project Scaffolding
Section titled “create - Project Scaffolding”Create a new Arcade project from a starter template:
# Create a new projectarcade create my-app
# Create in current directoryarcade create .
# Specify custom template (coming soon)arcade create my-app --template apiThe create command:
- Clones the official Arcade starter template
- Customizes the project name throughout the codebase
- Runs initial setup (
dart pub get,dart fix,dart format) - Creates a ready-to-run Arcade application
Project Structure
Section titled “Project Structure”The create command generates a comprehensive starter template:
my-app/├── bin/ # Application entry points├── lib/│ ├── core/ # Core application setup│ ├── modules/ # Feature modules│ │ └── todos/ # Example Todo API (can be deleted)│ └── shared/ # Shared utilities├── docker-compose.yml # Development services├── dpk.yaml # Development scripts└── scripts/ # Utility scriptsWhat You Get
Section titled “What You Get”- Example Todo API: Complete CRUD implementation that can be deleted once you understand the pattern
- Database Setup: PostgreSQL with Drift ORM
- Caching: Redis integration
- Object Storage: MinIO for file storage
- Docker Services: All dependencies containerized
- Code Generation: Build runner configuration
- API Documentation: Swagger UI with authentication
serve - Development Server
Section titled “serve - Development Server”Run your application with automatic restart:
# Start development serverarcade serveFeatures:
- Auto Restart: Automatically restarts on file changes
- Smart Watching: Monitors
bin/andlib/directories - Fast Compilation: Uses Dart compilation server for quick restarts
- Graceful Shutdown: Handles process signals properly
How It Works
Section titled “How It Works”- Automatically finds your server file at
bin/{app_name}.dart - Starts a Dart compilation server for faster restarts
- Watches for file changes in
bin/andlib/ - Restarts the server from scratch when changes are detected (with 500ms debounce)
routes - Route Inspection
Section titled “routes - Route Inspection”List all registered routes in your application:
arcade routesDevelopment Workflow
Section titled “Development Workflow”1. Create New Project
Section titled “1. Create New Project”# Create projectarcade create todo-apicd todo-api
# Copy environment configurationcp .env.example .env
# Generate code (required before first run)dpk run build
# Start Docker servicesdpk run docker
# Start development serverdpk run dev2. Inspect Routes
Section titled “2. Inspect Routes”# During developmentarcade routesConfiguration
Section titled “Configuration”The CLI works out of the box with no configuration needed. It automatically detects your project structure from pubspec.yaml.
Advanced Usage
Section titled “Advanced Usage”Custom Templates
Section titled “Custom Templates”# Use custom Git templatearcade create my-app --git-url https://github.com/user/arcade-template# orarcade create my-app -g https://github.com/user/arcade-templateDocker Integration
Section titled “Docker Integration”# Development DockerfileFROM dart:stable AS dev
WORKDIR /app
# Install Arcade CLIRUN dart pub global activate arcade_cli
# Copy project filesCOPY pubspec.* ./RUN dart pub get
COPY . .
# Use arcade serve for developmentCMD ["arcade", "serve"]CI/CD Integration
Section titled “CI/CD Integration”# GitHub Actionsname: Routes Check
on: [push, pull_request]
jobs: check-routes: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - uses: dart-lang/setup-dart@v1
- name: Install Arcade CLI run: dart pub global activate arcade_cli
- name: Generate route metadata run: arcade routes --export
- name: Check for uncommitted route changes run: | if [ -n "$(git status --porcelain)" ]; then echo "Route metadata is out of date" exit 1 fiTroubleshooting
Section titled “Troubleshooting”Command Not Found
Section titled “Command Not Found”# Ensure pub global bin is in PATHexport PATH="$PATH:$HOME/.pub-cache/bin"
# Or run directlydart pub global run arcade_cli:arcade create my-appPort Already in Use
Section titled “Port Already in Use”# Kill the process using the portlsof -ti:7331 | xargs kill
# Then restartarcade serveAuto Restart Not Working
Section titled “Auto Restart Not Working”# Check file watching limits (Linux/macOS)ulimit -n
# Increase if neededulimit -n 8192
# Restart arcade servearcade serveCompilation Errors
Section titled “Compilation Errors”# Clear Dart cachedart pub cache clean
# Reinstall dependenciesdart pub get
# Try againarcade serveNext Steps
Section titled “Next Steps”- Learn about Configuration options
- Explore Logging for debugging
- See Basic Routing guide
- Read about Development Workflow best practices