Our CLI (Command Line Interface) offers you a series of tools dedicated to developing and managing your projects on LinkApi.
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:
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.
To check if your CLI is updated, you have to execute the installation command once again:
npm i -g @linkapi.solutions/linkapi-cli
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
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.
This is a glossary, with all of the technical terms we use on our platform.
Automations, functions and data transformation folders
Notice: When creating folders within the aforementioned folder, renaming or deleting them might cause compatibility loss from the project with our platform.
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.
To generate a file from automation, function or data-transformation template, you should execute the following command:
linkapi project generate <type> <name>
<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
linkapi project run or $ lkp p r
-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.
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.
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.
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.
Log in to your account.
Log out of your account.
generate "type" "name"
Create functions, data-transformations, apps, and automation to your project.
Create a new project.
Save your project for the development branch.
Publish your project or catalog, adding a message to it and uploading it to the master branch.
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 your changes.
See the list of commands of CLI.
See the CLI version.