A CLI for ZendroStarterPack.
A quick installation would be this command: npm install -g Zendro-dev/zendro.
However, if you would like to customize your Zendro CLI, you can set it up as the following:
$ git clone https://github.com/Zendro-dev/zendro.git
$ cd zendro
$ npm install
$ npm link
For example, you can customize the version of each repository by editing zendro_dependencies.json file in your local Zendro CLI repository.
zendro new <your_application_name>
Usage: zendro new [options] <your_application_name>
Options:
-d, --dockerize: Keep Docker files (default: false).
Hints:
- If you don't have local database or you want to dockerize Zendro App, you can keep docker files. These are examples for dockerizing a Zendro App.
- If you want to modify environment variables or database configuration, you can edit the following files:
- without docker setup: ./graphql-server/config/data_models_storage_config.json
- with docker setup: ./config/data_models_storage_config.json
- ./graphql-server/.env
- SPA in development mode: ./single-page-app/.env.development
- SPA in production mode: ./single-page-app/.env.production
- GraphiQL in development mode: ./graphql-server/.env.development
- GraphiQL in production mode: ./graphql-server/.env.production
zendro generate
Usage: zendro generate [options]
Options:
-f, --data_model_definitions: Input directory or a JSON file (default: current directory path + "/data_model_definitions").
-o, --output_dir: Output directory (default: current directory path + "/graphql_server").
-m, --migrations: Generate migrations (default: false).
zendro dockerize
Usage: zendro dockerize [options]
Options:
-u, --up: Start docker service (default: false).
-d, --down: Stop docker service (default: false).
-p, --production: start or stop GQS and SPA with production mode (default: false).
-v, --volume: remove volumes (default: false).
zendro start [service...]
Usage: zendro start [options] [service...]
Options:
-p, --production: start GQS and SPA with production mode (default: false).
Hints:
- start all service by default
- start specified service with the following abbreviations:
- gqs: graphql-server
- spa: single-page-app
- giql: graphiql
zendro stop [service…]
Usage: zendro stop [service…]
Options:
-p, --production: stop GQS and SPA with production mode (default: false).
Hints:
- stop all service by default
- stop specified service
zendro migration:generate
Usage: zendro migration:generate [options]
Options:
-f, --data_model_definitions: Input directory or a JSON file (default: current directory path + "/../data_model_definitions").
-o, --output_dir: Output directory (default: current directory path + "/migrations").
Note: all generated migrations would be stored in a directory called migrations.
zendro migration:up
Usage: zendro migration:up
Note: execute migrations which are generated after the last executed migration. Moreover, the last executed migration is recorded in zendro_migration_state.json and the log of migrations is in the file zendro_migration_log.json.
zendro migration:down
Usage: zendro migration:down
zendro bulk-create
Usage: zendro bulk-create [options]
Options:
-f, --file_path: File path. Supported file format: CSV, XLSX, JSON
-n, --model_name: Model name.
-s, --sheet_name: Sheet name for XLSX file. By default process the first sheet.
-r, --remote_server: Upload to a remote server (default: false).
zendro set-up
Usage: zendro set-up [options] <name>
Options:
-d, --dockerize: Keep Docker files (default: false).
Please go to Quickstart guide to set up a Zendro Sandbox.
Please go to Getting started guide to set up a Zendro Instance.
If a user has new data model definitions, it is convinient to use Zendro CLI for dealing with migrations. And the following procedure shows how to generate, perform or drop migrations:
- in
graphql-serverfolder, executezendro migration:generate -f <data_model_definitions>. The migrations are automatically generated in the/graphql-server/migrationsfolder. By default, every migration file has two functions, namelyupanddown. Theupfunction creates a table, thedownfunction deletes the existing table. Furthermore it is possible to customize the migration functions. - in
graphql-serverfolder, it is possible to perform new generated migrations, which are generated after the last executed migration, by executingzendro migration:up. After that, the last executed migration and migration log are updated. - in
graphql-serverfolder, the last executed migration can be dropped by executingzendro migration:down. This will update the latest successful migration and add the dropped operation to the migration log. If there are some remaining records and associations in the table, by default an error is thrown. To forcefully drop the table, in spite of remaining records, set the environment variableDOWN_MIGRATIONtotruein/graphql-server/.envfile and re-execute this down-migration.
Data to populate each model in your schema must be in a separate CSV file, following the format requirements below:
- Column names in the first row must correspond to model attributes.
- Empty values should be represented as
"NULL". - All fields should be quoted by
". However, if field delimiter and array delimiter do not occur in fields with String type, namely characters could be split without ambiguity, then no quotes are necessary. For example, if the field delimiter is,and one String field is likeZendro, excellent!, then without the quotation mark, this field will be split as two fields. So in such case these String fields must be quoted. - Default configuration: BATCH_SIZE=20, RECORD_DELIMITER="\n", FIELD_DELIMITER=",", ARRAY_DELIMITER=";". They can be changed in the config file for environment variables.
- Date and time formats must follow the RFC 3339 standard.
There are two ways to upload a file via zendro CLI:
- If the Zendro instance is on your local machine, you can directly go into the folder
graphql-serverand executezendro bulk-create -f <filename> -n <modelname> -s <sheetname>, e.g.zendro bulk-create -f ./country.csv -n country. Three formats are supported here, namely CSV, XLSX and JSON. And the paramtersheetnameis only used for XLSX file. If it is empty, by default records in the first sheet would be imported. And the default configuration for delimiters and batch size, you can find them ingraphql-server/.env. - If you want to upload a file to a remote Zendro server, it is also possible via Zendro CLI. All configuration could be modified in the file
zendro/.env.migration. After the configuration, you can executezendro bulk-create -f <filename> -n <modelname> -s <sheetname> -r, e.g.zendro bulk-create -f ./country.csv -n country -r.
In general, it is possible to download all data into CSV format in two ways, either using the Zendro CLI or the Zendro Single Page App. Here every attribute will be quoted to avoid ambiguity and enable seamless integration with the zendro bulk creation functionalities.
-
If the Zendro instance is installed locally, then user can execute the command in the
graphql-serverfolder:zendro bulk-download -f <filename> -n <modelname>. To configure delimiters (ARRAY_DELIMITER,FIELD_DELIMITERandRECORD_DELIMITER) and record-limit (LIMIT_RECORDS), set the according environment variables ingraphql-server/.env -
If the Zendro instance is accessible remotely, modify the
zendro/.env.migrationconfiguration file to map to the remote Zendro instance. After that, executezendro bulk-create -f <filename> -n <modelname> -rto download the records to CSV.