Introduction and Setup
LOC CLI is the dedicated command line tool for developers to create data processes/other assets and deploy/manage them remotely in LOC. Combined with TypeScript support, local runtime and powerful IDEs like Visual Studio Code, CLI makes coding and debug much easier than doing so in LOC Studio.
Also see Command Reference.
Setup
To develop with CLI locally, you'll need to setup a profile and some tools.
CLI Executable Binary
FST Network provides CLI executable binaries to our licensed clients and partners, which is portable and can be used without any installation. The following platforms are supported:
- Linux (x86 64-bit)
- macOS (x86 64-bit)
- Windows (x86 64-bit)
This hankbook is based on CLI v0.7.0
and LOC SDK v0.7.0
.
The hand book also assumes that you have renamed your file to loc
(or loc.exe
in Windows), and copy it to a local directory (for example, /CLI
).
We'll often refer this directory as local workspace. You can add the dir to the system variable $PATH
if you want to access it globally.
Now open a terminal (PowerShell or Windows Terminal on Windows), switch to the local workspace and test the binary:
./loc -h
macOS and Linux users would have to mark the binary as executable:
sudo chmod +x ./loc
Or if you are using Command Prompt on Windows or accessing it via $PATH
:
loc -h
You should see CLI print out a list of available commands.
Local Development Prerequisites
Node.js
Firstly you'll need to install Node.js on your machine.
- Linux
- macOS
- Windows
sudo apt install curl
curl -fsSL https://deb.nodesource.com/setup_18.x | sudo -E bash -
sudo apt install nodejs
brew update
brew install node
Windows users can simply download and run the installer. (You do not have to check the option "Automically install the necessary tools").
Docker Desktop
Docker Desktop is required only if you are developing using the local simple runtime:
Docker Desktop only supports x86 64-bit platforms.
For Ubuntu/Debian users, you need to install Docker engine first then install Docker Desktop.
Optional Tools
Some other tools are not required for developing data processes on LOC but are highly recommended:
- A code editor that supports JavaScript and TypeScript IntelliSense, for example, Visual Studio Code with JavaScript and TypeScript Nightly extension installed.
- Windows 10 users can also install Windows Terminal to replace Command Prompt and PowerShell.
- A HTTP client like Insomnia or Postman.
- Git for using Github repositories for project source code/versioning control.
Tip on developing in VS Code
- Go to
File
->New Window
- Click
Open Folder...
- Select local workspace (the directory where the CLI binary is)
- Open a new terminal with
Terminal
->New Terminal
. Now you can use CLI commands.
Install SDK
Started from LOC v0.7.0
, the LOC SDK is required for importing agents and all kinds of helper classes. Even though JavaScript does not enforce typing, you still need to import functionalities from it.
Open a terminal, switch to the data process directory and install SDK for it:
- Use NPM
- Use Yarn
npm i -g npm@latest
npm i @fstnetwork/loc-logic-sdk@0.7.0-2 tslib@latest
npm prune
npm i -g yarn@latest
yarn add @fstnetwork/loc-logic-sdk@0.7.0-2 tslib@latest
For Linux users, use sudo
with npm i
or yarn add
.
If you are a Windows user and uses Yarn, open PowerShell as Administrator and modify the execution policy permission with:
Set-ExecutionPolicy -Scope CurrentUser -ExecutionPolicy Unrestricted
Install Additional Dependencies (Optional)
You can install other packages and type definitions locally depending on your data process' needs.
Like SDK, You'll have to install these packages under the data process directory.
For example, the following commands install lodash
and its type definition:
- Use NPM
- Use Yarn
npm i lodash
npm i -D @types/lodash
npm prune
yarn add lodash
yarn add -D @types/lodash
Setting Up a Profile
CLI connects to your LOC environment with a profile, which contains connection information like base and authentication URLs, etc.
For any operations involving LOC assets, you are also required to login with your LOC account.
Please contact your LOC owner or the member who has the right authorisation to create an account for you. You'll receive an email with a temporary password (which you are required to change it by logging in Studio). You can use it for CLI login after that.
To be able to login, the LOC license has to be activated as well.
You can also use Local Simple Runtime, which does not require an account or cloud environment.
An example of profile file (again provided by FST Network) looks like this:
baseURL: https://api.loc-***.fst.network
namespace: ********
ArthurL: https://auth.*****.fst.network/auth
realm: *****
clientId: loc-*****
Profiles are required since in most cases LOC is deployed on Amacon Web Services (AWS).
Tip on creating blank files
You can either copy the profile from your team or create a blank file then copy/paste the content.
macOS and Linux users can do this with
touch <profile name>.yaml
Or (for Windows users)
type nul > <profile name>.yaml
Then open the file with an editor, copy/paste the profile and save it.
We recommend you to save profile files in a sub-directory like /profiles
, which makes your file at /profiles/myprofile.yaml
.
Then run the following command to setup your profile to CLI:
./loc p set -f ./profiles/myprofile.yaml -p myprofile
./loc p use myprofile
If a profile file is updated, you need to use loc p set
to update it to CLI as well.
Now myprofile is setuped as your default profile. You can then login LOC (if your LOC account has been created by your team and you've changed your password):
./loc login