Today we see CLI from everywhere, everybody wants itโs own CLI: Heroku, Vue.js, React, and so on.
At Kuzzle we also wondered what we would get out of having a nice CLI full of features, because we were a bit fed up with curl and wscat.
So we started to develop a CLI to allow us to work more efficiently in our daily projects, and now we would like to officially share it with all our users :-)
Kourou is therefore a command line interface that allows you to administer your Kuzzle.
But why Kourou? The French who read us may know this name: it is the launch base for the Ariane rockets in French Guiana.
It's a multi-command CLI that uses Oclif, Heroku's CLI framework, and bonus to be even more hype: we even developed it in Typescript.
Currently Kourou is still under heavy development and we are adding features every week.
Of course, these commands interact with the Kuzzle API by logging in and logging in, but not only that!
Letโs install it:
$ npm install -g kourou
The first command is of course a command that launches a complete Kuzzle stack!
You can even launch several of them, the port numbers will be automatically shifted (7512, 7513, ...).
And you can even see the logs of your instances ;-)
$ kourou instance:spawn $ kourou instance:logs
You may not know it but since Kuzzle v2 you can connect with API keys.
Kourou offers to create, delete and list them from your terminal.
$ kourou api-key:create aschen --description "Awesome API key" ๐ Kourou - Creates a new API Key for a user [โน] Connecting to http://localhost:7512 ... Successfully created API Key "8Og2wnABna5MX9iEmgsX" for user "aschen" eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJfaWQiOiJhc2NoZW4iLCJpYXQiOjE1ODM4MDYzMjN9.hWV3Y2QJKH_AFYa9DoFRRmzM4EvMFWzeIzYEDwUpCYU
$ kourou api-key:search aschen ๐ Kourou - Lists a user's API Keys. [โน] Connecting to http://localhost:7512 ... 2 API Keys found for user aschen - Key "8Og2wnABna5MX9iEmgsX" Description: Awesome API key Expires at: -1 - Key "8ug3wnABna5MX9iEtwua" Description: Too lazy to login key Expires at: -1
Given the simplicity, you have no more excuses not to use them ;-)
We all know the frustration of a bug present on the server but not reproducible locally because of database differences.
With Kourou it is possible to easily dump an entire index, or a collection, and then re-import it elsewhere!
$ kourou index:export corona-data --path /backups ๐ Kourou - Dump an entire index content (JSONL format) [โน] Connecting to https://localhost:7512 ... Dumping index "corona-data" in ./backups/corona-data/ ... Dumping france |========================================| 100% || 42/42 documents Dumping italie |========================================| 100% || 21/21 documents Dumping espagne |========================================| 100% || 84/84 documents [โ] Index corona-data dumped
$ kourou index:import /backups/corona-data ๐ Kourou - Restore the content of a previously dumped index [โน] Connecting to http://localhost:7512 ... [โ] Start importing dump from /backups/corona-data in same index [โน] Successfully imported 42 documents in "corona-data:france" [โน] Successfully imported 21 documents in "corona-data:italie" [โน] Successfully imported 84 documents in "corona-data:espagne" [โ] Dump directory /backups/corona-data successfully imported
The format used is JSONL, portable and readable. Kourou handles large volumes, allowing millions of documents to be imported or exported easily.
Using the Vault to share the secrets of a project is cool but using Kourou to manage it is totally hype!
You can easily add a key to an existing file without having to decrypt everything and then encrypt it again.
$ kourou vault:add secrets.enc.json kuzzle.apiKey some-key --vault-key vault-password ๐ Kourou - Adds an encrypted key to a secrets file [โ] Key "kuzzle.apiKey" has been securely added "secrets.enc.json"
And if you have forgotten what was in a particular API key, you can display the content of a key in a single line.
$ kourou vault:show secrets.enc.json kuzzle.apiKey --vault-key vault-password ๐ Kourou - Prints an encrypted key. [โ] Key "kuzzle.apiKey" content: some-key
The Kuzzle API is quite huge and we're not going to reproduce it identically in Kourou (at least not right away).
But don't panic, we've added the query command which allows to send a request directly by specifying controller, action, arguments and body ;-)
$ kourou query index:create --arg index=corona-data ๐ Kourou - Executes an API query [โน] Connecting to http://localhost:7512 ... Successfully executed "index:create"
$ kourou query admin:loadMappings < mappings.json ๐ Kourou - Executes an API query [โน] Connecting to http://localhost:7512 ... Successfully executed "admin:loadMappings"
New commands are added as soon as they are useful, for example you can manage your documents or send requests directly to Elasticsearch.
The complete list is available in the README on Github or by typing kourou --help
You'll have understood, Kourou is the tool you need to be even more productive with Kuzzle ;-)
If you have ideas of features to add, don't hesitate to propose it to us by opening an issue on Github!
Or even better, try to develop it yourself and do a PR, we love it :-)