Setup CLI
LOC CLI is the command line tool for developers to deploy data processes and manage other assets in LOC.
Also see Command Reference.
Setup
CLI Executable Binary
FST Network provides CLI executable binaries to our clients, which is portable and can be used without any installation. The following platforms are supported:
- Linux (64-bit)
- macOS (64-bit)
- Windows (64-bit)
This hankbook is based on CLI v0.6.1
and LOC SDK v0.6.4
.
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 a+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 Environment
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_16.x | sudo -E bash -
sudo apt-get update
sudo apt install nodejs
brew update
brew install node
Windows users can simply download the installer. (You do not have to check the option "Automically install the necessary tools").
Docker Desktop
Docker Desktop is required only if you want to use the local simple runtime:
Optional Tools
Some other tools are not absolute necessary but are 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.
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.
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 festures and assets, you are also required to login with your LOC account.
To sign up, please contact your LOC Studio administrator. 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.
You can also use Local Simple Runtime, which does not require an account.
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-*****
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
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