The official Command Line Interface (CLI) for the Nexical framework.
This project serves as the primary entry point for managing Nexical projects, handling tasks such as project initialization, module management, and development workflows. It is designed to be extensible, fast, and developer-friendly, focusing on a clean architecture that allows for easy addition of new commands.
- Purpose
- Architecture & Design
- Getting Started
- Project Structure
- Development Workflow
- Adding New Commands
- Contributing
- License
The Nexical CLI allows developers to:
- Initialize new Nexical projects with best practices built-in.
- Manage project configuration and dependencies.
- Extend the framework functionality through modular commands.
It acts as a unification layer, bringing together various tools and configurations into a cohesive developer experience.
This CLI is built with TypeScript and follows a Class-Based Command Pattern to ensure type safety and maintainability.
- CAC (Command And Conquer): A lightweight, robust framework for building CLIs. It handles argument parsing, help generation, and command registration.
- Consola: Elegant console logging with fallback and structured output capabilities.
- Lilconfig: Configuration loading (searching for
nexical.yml,nexical.yaml) akin tocosmiconfigbut lighter. - Vitest: A blazing fast unit test framework powered by Vite.
CLIClass (src/core/CLI.ts): The orchestrator. It initializes the CAC instance, discovers commands using theCommandLoader, registers them, and handles the execution lifecycle.CommandLoader(src/core/CommandLoader.ts): Responsible for dynamically discovering and importing command files from the filesystem. It supports:- Recursive directory scanning.
- Nested commands (e.g.,
module/add.ts->module add). - Index files as parent commands (e.g.,
module/index.ts->module).
BaseCommand(src/core/BaseCommand.ts): The abstract base class that all commands MUST extend. It provides:- Standardized
init()andrun()lifecycle methods. - Built-in access to global options (like
--root-dir). - Helper methods for logging (
this.log,this.warn,this.error). - Project root detection (
this.projectRoot).
- Standardized
- Zero-Config Defaults: It should work out of the box but allow rich configuration via
nexical.yaml. - Extensibility: Adding a command should be as simple as adding a file.
- Testability: Every component is designed to be unit-testable, with dependency injection where appropriate (e.g.,
CommandLoaderimporter).
While currently in development, you can run the CLI from the repository source or link it.
# From within the package directory
npm install
npm run build# Run the built CLI
nexical <command> [options]
# Example: Initialize a new project
nexical init my-new-project
# Get help
nexical help
# Get help for a specific command
nexical help init
nexical help module addInitializes a new Nexical project. It clones a starter repository, sets up submodules, installs dependencies, and resets the Git history to provide a clean starting point.
Usage:
nexical init <directory> [options]Options:
--repo <url>: The Git repository URL of the starter template (Default:https://github.com/nexical/app-core).
Orchestrates the deployment of your applications by interacting with cloud providers and configuring your repository's CI/CD environment.
Usage:
nexical deploy [options]Options:
--env <environment>: Deployment environment (e.g.,production,staging). Defaults toproduction.--apps <apps>: Comma separated list of applications to deploy (e.g.,backend,frontend). If omitted, all applications are deployed.--dry-run: Simulate the deployment process without making API calls to providers or modifying repository secrets.
Process:
- Load Config: Reads
nexical.yamland validates the schema. - Provision: Concurrently calls providers to ensure resources exist.
- Sync Secrets: Collects necessary API tokens and credentials, syncing them to the repository (e.g., GitHub Secrets).
- Generate Workflows: Renders CI/CD workflow files into
.github/workflows/using standard templates.
Configuration (nexical.yaml):
deploy:
repository:
provider: github
apps:
backend:
provider: railway
projectName: my-api
target: apps/backend
artifactPath: dist
buildCommand: npm run build --workspace=@app/backend
secrets:
DB_PASSWORD: DATABASE_PASSWORD_ENV # Maps provider secret to local ENV var
env:
NODE_ENV: production # Literal value
frontend:
provider: cloudflare
projectName: my-web
target: apps/frontend
artifactPath: dist
buildCommand: npm run build --workspace=@app/frontendPackages the project context using repomix and runs AI-powered analysis or generation.
Usage:
nexical prompt [options]Options:
--output <path>: Path to save the packed context file.--config <path>: Custom configuration for the prompt runner.
Prepares the local development environment, ensuring all necessary tools and configurations are in place.
Usage:
nexical setupExecutes a command or script within the Nexical project context, handling environment variables and path resolution.
Usage:
nexical run <script> [args...]Manages the modular components of your project.
module add <url> [name]: Adds a new Git-based module as a submodule.module list: Displays a table of all installed modules.module update [name]: Updates a specific module or all modules to their latest remote versions.module remove <name>: Safely removes a module and cleans up Git metadata.
Standard development cycle commands inherited from the underlying app structure (typically Astro).
graph TD
src-->commands
src-->deploy
src-->core
src-->utils
commands-->deploy.ts
commands-->init.ts
commands-->module
deploy-->providers
deploy-->schema.ts
deploy-->template-manager.ts
src/commands/: Command implementation classes.src/deploy/: Core logic for the deployment orchestration system.src/core/: CLI framework (base classes, loader).src/utils/: Helper utilities.
- Node.js (v18+)
- NPM/PNPM
npm install
npm run build # Required to generate dist/ for local executionWe maintain strict 100% test coverage for all logic.
npm run test # All tests
npm run test:unit # Unit tests
npm run test:integration # Integration tests- Fork the repo and create a branch.
- Implement changes with accompanying tests.
- Ensure 100% coverage:
npm run test:unit. - Submit a PR.
Apache License 2.0