CLI command reference
With this CLI utility, you can create a barebones Cube app, generate a data model, validate it, or generate a JSON web token. You can also use the CLI utility to deploy your Cube application to Cube Cloud. This is one of supported ways of continuous deployment.create
The create command generates a barebones Cube app.
Usage
| Parameter | Description | Values |
|---|---|---|
-d, --db-type <db-type> | Preconfigure Cube app for selected database. | postgres, mysql, athena, mongobi, bigquery, redshift, mssql, clickhouse, snowflake, presto, druid |
-t, --template <template> | Framework running Cube backend. | docker (default) |
Example
Create app calleddemo-app using default (docker) template and mysql
database:
demo-app using express template and mysql database:
generate
The generate command helps to build data models for existing database tables.
You can only run generate from the Cube app directory. This command requires
an active database connection.
Usage
| Parameter | Description | Values |
|---|---|---|
-t, --tables <tables> | Comma delimited list of tables to generate data models for. | TABLE-NAME-1,TABLE-NAME-2 |
Example
Generate data model files for tablesorders and customers:
validate
The validate command checks models in a Cube project for validation errors.
Usage
Example
Example of a Cube project with models that fail validation:token
The token command generates a JWT Cube token. It either uses the value of the
CUBEJS_API_SECRET environment variable or provided value with -s flag. You
can only run token command from the Cube app directory.
Use these manually generated tokens in production with caution. Please refer to the Security Guide for production security best practices.
Usage
| Parameter | Description | Example |
|---|---|---|
| -e, —expiry | Token expiry. Set to 0 for no expiry (default: “30 days”) | 1 day, 30 days |
| -s, —secret | Cube app secret. Also can be set via environment variable CUBEJS_API_SECRET | - |
| -p, —payload | Token Payload | foo=bar, userId=2 |
Example
Generate token with 1 day expiry and payload{ 'appId': 1, 'userId': 2 }:
deploy
The deploy command uploads your Cube application to Cube Cloud. You can only
run this command from the Cube app directory.
Usage
| Parameter | Required | Description |
|---|---|---|
--token <token> | ✅ Yes | Authentication token for Cube Cloud |
--directory <path> | ✅ Yes | Path to the Cube application directory |
--upload-env | ❌ No | Use .env file to populate environment variables in Cube Cloud. Only set them once during the very first upload for this deployment |
--replace-env | ❌ No | Use .env file to populate environment variables in Cube Cloud. Replace them with new ones during every upload for this deployment |
Example
Upload a Cube application from the current directory to Cube Cloud and pass its.env file as well: