Core · Framework · Runtimes and extension mechanisms

Command-line runtime

@nocobase/app-cli combines framework commands, application business commands and plugin commands into one tree. Application metadata determines whether it loads source or deployment entries.

Locating the application

The source entry searches upward from the working directory for application package.json. nocobase.templateKind identifies source; nocobase.buildTarget identifies deployment output. NOCOBASE_APP_ROOT selects an application without changing the working directory.

A deployment's dist/cli/index.js supplies its own location and needs neither a global CLI nor pnpm. Use the entry from the actual release to avoid resolving another project's command version.

Bash
pnpm nocobase commands --json
node dist/cli/index.js commands --json

Business command namespaces

SourceDeclarationExample
Applicationcli/commands/orders/sync.tsnocobase app orders sync
PluginCLI contributions in cli/plugins.tsnocobase orders info
Development toolingPlugin devCommands and hooksRetained only in source environments

A plugin topic normally strips the scope and app-plugin- prefix. Packages producing the same topic conflict; registration order is not an override mechanism.

Starting only needed services

Commands extending AppCommand can use withApp() to create, use and dispose an application. Configuration reads and migrations usually do not need all background consumers. Call app.start() only when business behavior requires the complete lifecycle.

Importing a module should only declare commands. Top-level database connections would make help and discovery commands perform work. Development hooks are collected through the registered CLI; do not invoke internal build scripts around it.

Output and delivery

Returned command data becomes the JSON envelope's result; progress belongs on stderr. Callers check exit codes, ok, status and warnings. Rebuild after adding commands to include them in deployment output.

For application-side authoring and registration, see Write application commands and Integrate plugin commands. Plugin declarations are covered in Extend the CLI, and built-in options in CLI reference. For a standalone HTTP client, see Provide an application CLI client.

Interfaces and implementation

NocoBase docs assistant

Ask anything about NocoBase…

Each question is answered independently, without earlier questions or answers. Include all relevant context.