Functions CLI SDK

Functions CLI is a tool that allows to develop and deploy Functions to Jitsu.

Installing Jitsu CLI

To download and install Jitsu CLI, run the following command:

npm i -g jitsu-cli

Creating a new project

Run the following command to initialize the project

jitsu-cli init

arguments:

  • --name – the name of the project. (Optional). By default, interactive prompt is shown to enter the name.
  • --displayname – human-readable function name that will be used in Jitsu. (Optional). By default, interactive prompt is shown to enter the name.
  • --parent – the parent directory of project. (Optional). By default, interactive prompt is shown to enter the parent directory.

Project structure

myfunc
├── src
   ├── __tests__
   └── functions
       └── myfunc.test.ts
   ├── functions
   └── myfunc.ts 
   └── profiles
       └── profile.ts
├── tsconfig.json
└── package.json

Development

Use following commands to develop and test your functions locally:

Install dependencies

cd myfunc # go to the project directory
npm install # install dependencies with 'npm' or any other compatible package manager

Build functions

jitsu-cli build

Run tests

jitsu-cli test

Test provided by project template is a simple test that checks that function doesn't crash and returns some event. You may need to extend test to check that function returns correct result.

Adding Functions to Jitsu

Login to Jitsu (Run once)

jitsu-cli login

arguments:

  • --host – Jitsu host (optional). Default: https://use.jitsu.com
  • --apikey – Jitsu user's Api Key (optional). Disables interactive login.

login command remembers credentials in ~/.jitsu/jitsu-cli.json file.

Deploy functions to Jitsu project

jitsu-cli deploy

arguments:

  • --workspace – Id of workspace where to deploy function (Optional). By default, interactive prompt is shown to select workspace
  • --type – entity type to deploy (optional). Default: function

Deploy command creates new functions or updates existing functions in Jitsu project.