owned this note
owned this note
Published
Linked with GitHub
[Back to LOC CLI Guidebook](https://hackmd.io/4LIsNIuWQnuR70JMeuBAEA?view)
[Getting Started - JavaScript](https://hackmd.io/IiHvmAtjTTGFfakaH0dWuw?view)
[Getting Started - TypeScript](https://hackmd.io/kz93Th7vTCCbO3GFxp3r-A)
[LOC CLI Commands](https://hackmd.io/R4mrz2t1QSyTCHH73_2itg)
[Local Simple Runtime Execution](https://hackmd.io/JhAMB49rS4CrpNdhHed7YA)
# Setup LOC CLI Environment
## Download LOC CLI
Firstly, download **LOC CLI Executable Binary** with respect to your platform.
:::info
Please contact your window to download LOC CLI Executable Binary; you can also contact us for these files at support@fstk.io or (886) 223-213-806.
:::
Installation guide:
- [Windows](###Windows)
- [macOS](###macOS-x64)
- [Linux](###Linux-x64)
### Windows (x64)
1. Download **loc-windows.exe**.
2. Rename **loc-windows.exe** as **loc.exe**, for convenience purpose.
3. *(optional, for non-Windows 11 users)* Install [Windows Terminal](https://apps.microsoft.com/store/detail/windows-terminal/9N0DX20HK701).
4. Open Command Prompt, PowerShell or Windows Terminal, and make a directory where you are going to put *loc.exe* (for example, ```C:\FST```), by using the command `mkdir [directory name]`:
```bash
cd \
mkdir FST
cd FST
```
5. Add ```C:\FST``` to the $PATH environment variable. ([Windows instruction](https://docs.microsoft.com/en-us/previous-versions/office/developer/sharepoint-2010/ee537574(v=office.14)))
6. ==Re-open== a new console and test **loc.exe**:
(Command Prompt or Windows Terminal)
```bash
loc
```
(PowerShell)
```bash
./loc
```
If successful, you can expect to see the following outputs:
```
Usage: loc [options] [command]
Options:
-V, --version output the version number
-h, --help display help for command
Commands:
new [options] <name> create data process template including sample generic logics, aggregator logic and data process config files
deploy [options] <name> deploy data process template including logics and dataprocess config files
login [options] login
logic|l
dataprocess|dp
apiroute|ar
profile
help [command] display help for command
```
:::info
You can use ```loc [command] -h``` to find out more commands. See ++[**LOC CLI Commands**](https://hackmd.io/R4mrz2t1QSyTCHH73_2itg)++ for details.
If you have added LOC CLI to your ```$PATH```, you can execute it in Command Prompt or PowerShell from any other location with ```loc```.
:::
6. *(recommended but optional)* [Install VS Code](https://code.visualstudio.com/download) ([Windows instruction](https://code.visualstudio.com/docs/setup/windows)). In VS Code, install the **JavaScript and TypeScript Nightly** extension ([instruction](https://code.visualstudio.com/learn/get-started/extensions)).

:::info
The default Windows terminal in VS Code is PowerShell. If you haven't added LOC CLI to ```$PATH```, switch to the ```/FST``` folder and use ```./loc```.
:::
7. *(optional for TypeScript developers)* Install [Git](https://git-scm.com/downloads) and [Node.js](https://nodejs.org/en/download/) (using Windows installer; for the Node.js installer, DO NOT tick ```Automically install the necessary tools``` checkbox).
### macOS (x64)
1. Download **loc-macos-x64**.
2. Create a new directory, for example, ```/home/<user>/FST```, and copy **loc-macos-x64** into it: (If your terminal starts at ```/home/<user>```)
```bash
mkdir FST
```
3. Rename **loc-macos-x64** to **loc**, for convenience purpose:
```bash
mv loc-macos-x64 loc
```
4. Add ```/home/<user>/FST``` to $PATH environment variable. (see: [macOS instruction](https://www.architectryan.com/2012/10/02/add-to-the-path-on-mac-os-x-mountain-lion/).)
5. Open terminal and switch to ```/home/<user>/FST```:
```bash
cd FST
```
6. Add permission for **loc**:
```bash
chmod a+x ./loc
```
7. Test **loc** in terminal:
```bash
./loc
```
If successful, you can expect to see the following outputs:
```
Usage: loc [options] [command]
Options:
-V, --version output the version number
-h, --help display help for command
Commands:
new [options] <name> create data process template including sample generic logics, aggregator logic and data process config files
deploy [options] <name> deploy data process template including logics and dataprocess config files
login [options] login
logic|l
dataprocess|dp
apiroute|ar
profile
help [command] display help for command
```
:::info
You can use ```loc [command] -h``` to find out more commands. See ++[**LOC CLI Commands**](https://hackmd.io/R4mrz2t1QSyTCHH73_2itg)++ for details.
If you have added LOC CLI to your ```$PATH```, you can execute it in the terminal from any other location with ```loc```. If not, switch to the ```/FST``` dir and use ```./loc```.
:::
8. *(recommended but optional)* [Install VS Code](https://code.visualstudio.com/download) ([macOS instruction](https://code.visualstudio.com/docs/setup/mac)). In VS Code, install the **JavaScript and TypeScript Nightly** extension ([instruction](https://code.visualstudio.com/learn/get-started/extensions)).
9. *(optional for TypeScript developers)* Install [Git](https://git-scm.com/downloads) and [Node.js](https://nodejs.org/en/download/) (using macOS installer)
Or:
```bash
brew update
brew install git
brew install node
```
### Linux (x64)
1. Download **loc-linux-x64**.
2. Create a new directory, for example, ```/home/<user>/FST```, and copy **loc-linux-x64** into it: (If your terminal starts at ```/home/<user>```)
```bash
mkdir FST
```
3. Rename **loc-linux-x64** to **loc**, for convenience purpose:
```bash
mv loc-linux-x64 loc
```
4. Add ```/home/<user>/FST``` to $PATH environment variable:
```bash
sudo nano ~/.bashrc
```
Add the following line at the end of the file
```bash
export PATH="$PATH":"$HOME/FST"
```
Press ```Ctrl + X``` then ```Y``` to save. Next, make the new change to take effect:
```bash
source ~/.bashrc
```
5. Open terminal and switch to ```/home/<user>/FST```:
```bash
cd FST
```
6. Add permission for **loc**:
```bash
chmod a+x loc
```
7. Test **loc** in terminal:
```bash
loc
```
If successful, you can expect to see the following outputs:
```
Usage: loc [options] [command]
Options:
-V, --version output the version number
-h, --help display help for command
Commands:
new [options] <name> create data process template including sample generic logics, aggregator logic and data process config files
deploy [options] <name> deploy data process template including logics and dataprocess config files
login [options] login
logic|l
dataprocess|dp
apiroute|ar
profile
help [command] display help for command
```
:::info
You can use ```loc [command] -h``` to find out more commands. See ++[**LOC CLI Commands**](https://hackmd.io/R4mrz2t1QSyTCHH73_2itg)++ for details.
If you have added LOC CLI to your ```$PATH```, you can execute it in the terminal from any other location with ```loc```. If not, switch to the ```/FST``` dir and use ```./loc```.
:::
8. *(recommended but optional)* [Install VS Code](https://code.visualstudio.com/download) ([Linux instruction](https://code.visualstudio.com/docs/setup/linux)). In VS Code, install the **JavaScript and TypeScript Nightly** extension ([instruction](https://code.visualstudio.com/learn/get-started/extensions)).
9. *(optional for TypeScript developers)*
Install [Node.js](https://nodejs.org/en/download/):
```bash
sudo apt install curl
curl -fsSL https://deb.nodesource.com/setup_16.x | sudo -E bash -
sudo apt-get update
sudo apt install nodejs
```
Install [Git](https://git-scm.com/downloads):
```bash
sudo apt install git
```
## User Setup
### Profile
LOC CLI requires a **profile** file, which contains the environment information of the deployment and will be provided by FST Network. A .yaml profile (for example, ```example.yaml```) looks like this:
```yaml
baseURL: https://api.loc.xxxxx
namespace: xxxxxxxx
authURL: https://auth.xxxxx.xxxxxxx/auth
realm: xxxxx
clientId: xxxxx-xxxxx-xxxxx
```
:::info
Please contact your window for your profile details to complete the setup; you can also contact us for these details at support@fstk.io or (886) 223-213-806.
:::
1. Copy the profile into your LOC CLI workspace directory.
2. Add the profile to LOC CLI:
```bash
> loc profile set -f example.yaml -p example
Done!
```
3. Inspect the list of profiles:
```bash
> loc profile list
CURRENT NAME
------- ----------
* test
example
```
:::info
The added profile will be kept in your machine and can hence be accessed by LOC CLI.
:::
4. Set the profile you just added as defult:
```bash
> loc profile default example
Switched profile to 'example'.
```
### Login
Login to your LOC environment:
```bash
> loc login
? Username: user.name@email.com
? Password: ********
Successfully Login!
```
:::info
Login is required for accessing your LOC deployment environment. You will get a ```access token``` after login. LOC CLI will automatically log out the current user after 5 mins of inactivity.
You can inspect your tokens (keys) with this command:
```bash
loc profile get
```
:::
## Create a Data Process Template Folder
### Create a ```JavaScript``` Template (Default)
1. Create a new data process template ```hello-world```:
```bash
> loc new hello-world
🔍 Check Folder Name: hello-world...
🎉 Generating Data Process Template folder...
🔨 Building fresh packages...
✨ Successfully created Data Process Template in hello-world.
```
2. A sub-directory named ```hello-world``` should be create under your workspace:
```
FST
hello-world
generic-logic
1.js
2.js
aggregator-logic.js
api-route-config
config.yaml
package.json
```
You can create other new data process templates in the future in this way `./loc new [template name]`.
:::info
See ++[**Getting Started - Hello World (JavaScript)**](https://hackmd.io/IiHvmAtjTTGFfakaH0dWuw)++ for how to develop and deploy your first data process.
:::
### Create a ```TypeScript``` Template
1. LOC supports TypeScript in developing data processes as well. Create a new TypeScript template ```hello-world```:
```bash
> loc new hello-world -ts
🔍 Check Folder Name: hello-world...
🎉 Generating Data Process Template folder...
🔨 Building fresh packages...
✨ Successfully created Data Process Template in hello-world.
```
2. A sub-directory named ```hello-world``` should be create under your workspace:
```
FST
hello-world
generic-logic
1.ts
2.ts
aggregator-logic.ts
api-route-config
config.yaml
package.json
tsconfig.json
```
:::info
See ++[**Getting Started - Hello World (TypeScript)**](https://hackmd.io/kz93Th7vTCCbO3GFxp3r-A)++ for how to develop and deploy your first data process.
:::
---
<text style="font-size:17pt">**LOC CLI Guidebook Catalogue**</text>
<text style="font-size:13pt"> [LOC CLI Introduction](https://hackmd.io/J5r2l2OaRgKF9LACR5KHsg?view)</text>
<text style="font-size:13pt"> [LOC Concept](https://hackmd.io/mwTxDdBjSuiKrAmainQZAA?view)</text>
<text style="font-size:13pt"> [LOC CLI Commands](https://hackmd.io/R4mrz2t1QSyTCHH73_2itg?view)</text>
<text style="font-size:13pt"> [Getting Started - JavaScript](https://hackmd.io/IiHvmAtjTTGFfakaH0dWuw?view)</text>
<text style="font-size:13pt"> [Getting Started - TypeScript](https://hackmd.io/kz93Th7vTCCbO3GFxp3r-A?view)</text>
<text style="font-size:13pt"> [Reference - Agent List](https://hackmd.io/Uj-tC7l9Q82VyGr8R5PL2Q?view)</text>
<text style="font-size:13pt"> [Reference - Event Fields Comparison Table](https://hackmd.io/N2Km6-8kRI2tMR5X4tRHeQ?view)</text>
###### tags: `LOC CLI`