nocobase
v0.1.5
Published
NocoBase CLI
Downloads
852
Readme
NocoBase CLI
NocoBase CLI combines:
- built-in commands for environment management and generic resource access
- runtime-generated commands loaded from your NocoBase application's Swagger schema
This allows the CLI to stay aligned with the target application instead of relying on a fixed command list.
Install
Install dependencies for local development:
pnpm installRun in development mode:
node ./bin/dev.js --helpBuild the CLI:
pnpm buildRun the built CLI:
node ./bin/run.js --helpAfter packaging or linking, the executable name is:
nocobaseQuick Start
Add an environment:
nocobase env add --name local --base-url http://localhost:13000/api --token <token>Show the current environment:
nocobase envList configured environments:
nocobase env listSwitch the current environment:
nocobase env use localUpdate the runtime command cache from swagger:get:
nocobase env update
nocobase env update -e localUse the generic resource commands:
nocobase resource list --resource users
nocobase resource get --resource users --filter-by-tk 1
nocobase resource create --resource users --values '{"nickname":"Ada"}'Runtime Commands
When you execute a runtime command, the CLI will:
- resolve the target environment
- read the application's Swagger schema from
swagger:get - generate or reuse a cached runtime command set for that application version
- execute the requested command
If the API documentation plugin is disabled, the CLI will prompt to enable it.
Environment Selection
Use -e, --env to temporarily select an environment:
nocobase env update -e prod
nocobase resource list --resource users -e prodThis does not change the current environment unless you explicitly run:
nocobase env use <name>Config Scope
The env command supports two config scopes:
project: use./.nocobase-cliin the current working directoryglobal: use the global.nocobase-clidirectory
Use -s, --scope to select one explicitly:
nocobase env list -s project
nocobase env add -s global --name prod --base-url http://example.com/api --token <token>
nocobase env use local -s projectIf you do not pass --scope, the CLI uses automatic resolution:
- current working directory if
./.nocobase-cliexists NOCOBASE_HOME_CLI- your home directory
Built-in Commands
Current built-in topics:
envresource
Check available commands at any time:
nocobase --help
nocobase env --help
nocobase resource --helpCommon Flags
-e, --env: temporary environment selection-s, --scope: config scope forenvcommands-t, --token: token override-j, --json-output: print raw JSON response
Example:
nocobase env update -e prod -s global
nocobase resource list --resource users -e prod -jLocal Data
The CLI stores its local state in .nocobase-cli, including:
config.json: environment definitions and current selectionversions/<version>/commands.json: cached runtime commands for a generated version
