Developers LinkApi

About our CLI

With our CLI you can create your own catalog of components like components, functions and data-transformations. You can also consume the global components provided by LinkApi.

Our CLI (Command Line Interface) offers you a series of tools dedicated to developing and managing your projects on LinkApi.

Setup

Before installing LinkApi CLI, you’ll need to install Node.js(8.12.0+). Having it installed, you can use NPM, which is Node package manager, to install our CLI executing the following command:

npm i -g @linkapi.solutions/linkapi-cli

Now you have a linkapi global command, which can be executed on any terminal window. After installing the CLI, you’ll need to login on your Google account, using:

linkapi login

This command allows your local machine to connect to your LinkApi account, as well as access to your projects. In order to test if the automation worked, you can execute linkapi project list to see your whole project list. It needs to have the same projects that you can see on you LinkApi’s portal.

How to get the latest version?

To check if your CLI is updated, you have to execute the installation command once again:

npm i -g @linkapi.solutions/linkapi-cli

Projects

Creating a project

In order to perform recurrent tasks with our CLI, like creating a project on LinkApi, you need a projects directory. To create one, use the following command:

linkapi project init <name> or  $ lkp p init <name>

After executing this command, your directory will have the following structure:

├─ automation 
├─ data-transformation
└─ functions
readme.md
linkapi.json 
.gitignore

linkapi.json File

The configuration file linkapi.json, located at your project’s root, has the purpose of identifying which project is being used, and if it’s a valid one.

Notice: if you delete or change this file, your project might lose all of its compatibility with the CLI and LinkApi’s portal.

readme.md File

This is a glossary, with all of the technical terms we use on our platform.
Automations, functions and data transformation folders

These contain the needed files in any kind of execution on your project. For each folder, there is also a .js example file. It’s worth mentioning our projects only support Javascript.

Notice: When creating folders within the aforementioned folder, renaming or deleting them might cause compatibility loss from the project with our platform.

Cloning a project

The first thing you need is a created project (via CLI or Portal). Now, to clone a project via CLI, you should use the following command:

linkapi project clone <name>

If you need to access your created projects list, use the command linkapi project list. After executing it, your project will be cloned to the directory which the command was executed on.

Generate files from templates on a project.

To generate a file from automation, function or data-transformation template, you should execute the following command:

linkapi project generate <type> <name>

Mandatory:

<type> Valid values: automation, function or data-transformation <name> file name

After executing this command, the file will be created from a template according to the declared type. Example:

linkapi project generate automation test

Executing files from a project

To execute a file in a project, you can use this command:

linkapi project run or  $ lkp p r

Mandatory:
-a, --automation <name> -f, --function <name>
*-d, --data-transformation <name>
-t, --tenant <name>
-p, -params <parameter>

After executing this command, the response will be redirected to your terminal, like the following example:

This example shows how you can use a JSON file as parameter. It's worth mentioning that this file must be in the mockups folder.

Depending on the depth of the returned object properties, something like the following may be shown:

In this case, we strongly advise you to use the --log flag, then a log file will be created in the logs folder with the returned value, as shown in the following example:

Notice: you can execute only one type of file per time, so, it's possible testing automation, function or data-transformation at each command execution.

Saving a project’s changes

To save the changes you made into a project, you can use the following command:

linkapi project commit [message]

After executing this command, all of the changes will be saved on the platform.
Notice: When committing a project, the message is optional.

Discard project changes

To discard all of the changes made on a project at once, you can execute this command:

linkapi project discard

Publishing your project

To publish a project via CLI, use this command:

linkapi project publish or  $ lkp p p

After executing it, all of the changes will be moved to the master branch (in production).
Notice: when publishing a project, only development branch will be moved to the master one, thus, creating more branches won’t affect the project.

Sync Projects

To merge changes of a project using CLI, use the following command:

linkapi project sync

After executing this command, your project will be synced and all of the changes will be merged in its directory

This is the list off all commands that you can run with the CLI.

Command "parameter"
Description

login

Log in to your account.

logout

Log out of your account.

generate "type" "name"

Create functions, data-transformations, components, and automation to your project.

init "name"

Create a new project.

commit project

Save your project for the development branch.

publish "message"

Publish your project or catalog, adding a message to it and uploading it to the master branch.

sync

Sync your local project or catalog with your online repository from the chosen branch.

clone "type" "id" "branch"

Clone project or catalog from your online repository.
type can be a project, for example.
id is the name of your project.
branch: Not required. If is not set, will clone from the development branch, but you can set "master" or just "m" to make a clone from the master branch.

discard

Discard your changes.

--help

See the list of commands of CLI.

--version

See the CLI version.

About our CLI


With our CLI you can create your own catalog of components like components, functions and data-transformations. You can also consume the global components provided by LinkApi.

Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.