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
npx cubejs-cli create APP-NAME -d DB-TYPE [-t TEMPLATE]| 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 called demo-app using default (docker) template and mysql
database:
npx cubejs-cli create demo-app -d mysqlCreate app called demo-app using express template and mysql database:
npx cubejs-cli create demo-app -t express -d mysqlgenerate
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
npx cubejs-cli generate -t TABLE-NAMES| 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 tables orders and customers:
npx cubejs-cli generate -t orders,customersvalidate
The validate command checks models in a Cube project for validation errors.
Usage
npx cubejs-cli validateExample
Example of a Cube project with models that fail validation:
npx cubejs-cli validate
❌ Cube Data Model validation failed
Cube Error ---------------------------------------
Orders cube: "dimensions.id" does not match any of the allowed types
Possible reasons (one of):
* (dimensions.id.case) is required
* (dimensions.id.latitude) is required
* (dimensions.id.sql) is required
LineItems cube: Cube Orders doesn't exist
Need some help? -------------------------------------
Ask this question in Cube Slack: https://slack.cube.dev
Post an issue: https://github.com/cube-js/cube/issuestoken
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
npx cubejs-cli token -e TOKEN-EXPIRY -s SECRET -p FOO=BAR| 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 }:
npx cubejs-cli token -e "1 day" -p appId=1 -p userId=2deploy
The deploy command uploads your Cube application to Cube Cloud. You can only
run this command from the Cube app directory.
Usage
npx cubejs-cli deploy --replace-env --directory PATH --token TOKEN| 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:
npx cubejs-cli deploy --upload-env --directory ./ --token 56e2636272ffc9cd8c19e9d1e9ffb52f