Get Started
Step by step instructions on how to set up your Environment in order to start running your first Node.js program using Scramjet Cloud Platform (SCP), command-line and samples. Samples can be found under the Examples section. Be sure to check compatibility section down below before getting started. Login or registration is required before attempting to go through the Get Started steps. Upon completing those steps which includes running Scramjet GitHub /Hello sample, an expected output should be printed out on your terminal.
1. POSIX terminal interface compatible console
POSIX is required for the ability of a user to communicate with Scramjet Cloud Platform API's created dependency
-
For Windows install WSL2 if not installed. To verify installation use the following command-line.
_10wsl -l -v -
For Linux & Mac use Bash terminal
2. Install Node.js and NPM package manager. Node.js must be version 14 and above.
-
For Windows download the appropriate version from Nodejs.org
_10npm install -g npm -
For Linux
_10sudo apt install nodejs npm
3. Registration
In order for a user to retrieve their <Generated-Token>, registration for a Free Trial is required.
4. Install Scramjet Cloud Platform (SCP)
In order to install Command-Line Interface to communicate with Scramjet Cloud Platform a user must input the following command on their terminal.
_10npm i -g @scramjet/cli
5. Generate Scramjet Cloud Platform CLI Token
Tokens can only be generated after registration and a token is valid for 15 days only. Generate Token button is found under the user's Profile Settings section Generate Token. A user must copy and save the token on the local machine for later use.
6. Use Scramjet Cloud Platform CLI Token
After generating the token, a user must execute the copied command-line generated by Scramjet Cloud Panel onto a new terminal to configure and access the user's platform account, a token is valid for 15 days only, after that period a user must generate a new token and execute it in a terminal. An example below illustrate how a complete token might look like. A user can view the generated token at a later stage through the following command-line si config print
For example:
_10si config set json '{"middlewareApiUrl":_10"https://api.scramjet.cloud/api/v1", "env":_10"production", "token": "<GENERATEDTOKEN>"}'
For Windows escaping the quotation marks is a must.
For example:
_10si config set json "{\"middlewareApiUrl\":_10\"https://api.scramjet.cloud/api/v1\", \"env\":_10\"production\",\"token\": \"GENERATEDTOKEN\"}"
7. Download Samples
Scramjet GitHub repository provides you with sample programs for you as a user to run and explore. Use git clone
at your desired directory to obtain Scramjet GitHub samples repository on your machine.
_10git clone https://github.com/scramjetorg/platform-samples
- 7.1 index.js | index.py - The main file which includes the user's logic.
NOTE: Typescript source code must be transpiled into javascript before packaging - 7.2 package.json - Manifest file that describes this particular Sequence
- 7.3 dependencies - Using your terminal to preinstalled all dependencies that are needed to execute the Sequence in the same directory as the rest of the files.
- 7.4 files (Optionally) Any additional files your code needs must be in the same directory, in case those files are needed a user must add the file name and extension to package.json under the
Assets
property section (data files, text files, libs and binaries etc.) - 7.5 requirements.txt (for Python only) prerequisite file for packaging a Python program.
NOTE: All Python dependencies should be installed in the same directory as the rest of required files - 7.6 tsconfig.json (for TypeScript only) it is a crucial file for managing your project, it creates itself after running
tsc --init
command, which initializes the TypeScript project. This file is where you can set the compiler options. Basically this is an indicator for TypeScript, which says that the project in which this file lies and all the other sub folders should be managed by TypeScript and it also tells TypeScript how to compile all the *.ts files in the project.
8. Locate Samples directory
Usually for a cloned repository if the path is not defined, it would be defaulted to \Users\Sam\platform-samples
. A user must change the path of their terminal to be in the same directory as /Hello sample to be able to proceed with the below steps. The address may differ for different programming languages.
For example:
_10cd C:\Users\Sam\platform-samples\javascript\hello
9. Transpiling from TypeScript to JavaScript
If using the JavaScript or Python samples please skip this point. For the samples which are written in TypeScript as a user, you need to transpile those files into JavaScript before proceeding with the below steps. Transpiling will convert all .ts
files located in a given directory into JavaScript file for them to be packaged. Install dependencies e.g. npm install
before running the code below.
_10npm run build
10. Packaging a Sequence
For a user to be able to run a Sequence as an Instance on Scramjet Cloud Platform the files must be packed together for a successful result. After locating those files, type in your terminal the following command which will pack the below files into a tar.gz format also known as a linux tarball. Keep in mind that the below command will only check whether the package.json file is located in that directory or not but not the rest of required files.
_10si seq pack <path/to/folder>
11. Send the Sequence to Scramjet Cloud Platform (SCP)
A user can send the packaged tar.gz file to Scramjet Cloud Platform with the following command-line. A Sequence-id will be provided in return. Use--progress
at the end of the command-line in order to monitor the progress.
_10si seq send <path/to/filename.tar.gz> --progress
12. Check listed Sequences on Scramjet Cloud Platform (SCP)
One Sequence which have been already packed with the source code should be at least available in the list to be able to start a Sequence. A user can have a maximum of 5 Instances running at a given time on their Native Hub.
_10si seq list
13. Start a Sequence
After starting a Sequence an Instance-id which is the running Sequence (program) will be returned.
_10si seq start <Sequence-id>
Or use a hyphen (-) as a shortcut (alias) for an Sequence-id. Assigning last Sequence-id to the hyphen happens automatically and is saved in a session configuration. User can assign any other Sequence-id to hyphen if the last sent Sequence is not the desired one to be used as an alias (hyphen).
_10si seq start -
14. Send data to the Instance
Sending data to an Instance can either be sent from a file path/to/file
or by directly typing it on your terminal
_10si inst input <Instance-id> path/to/file
Or use a hyphen (-) as a shortcut (alias) for an Instance-id. Assigning last Instance-id to the hyphen happens automatically and is saved in a session configuration. User can assign any other Instance-id to hyphen if the last started Instance-id is not the desired one to be used as an alias (hyphen).
_10si inst input -
NOTE: if you do not specify the path of the input file you can insert the input by typing it directly on the terminal on a newline after executing si inst input <Instance-id>
and hitting Enter to send each input, Ctrl+C to exit sending data process. A user can continuously update the output by not executing the exit command Ctrl+C and instead opening a new parallel terminal and typing si inst output <Instance-id>
. With each additional input on the first terminal the output will be automatically updated on the second terminal where si inst output <Instance-id>
is being processed. This is more evident if you are typing your input through your keyboard on the first terminal instead of relating the input to a path/to/file. Similar method can be applied if an Instance requires several files to be processed as input.
A user will not be able to view the output for the new input if the Instance status is "completed" . A user can only retrieve the output of the transformed input if the Instance status is "running" use the following command-line to check the status.
_10si inst info <Instance-id>
15. View the output data of an Instance
Any Instance output can be visible for a duration of 3 minutes from the time the Instance has been completed. For information on Instance status use si inst info <instance-id>
to highlight whether Instance status has been completed or not.
_10si inst output <Instance-id>
Or use the hyphen as a shortcut
_10 si inst output -
16. Kill an Instance
After returning the output you can stop an Instance from running by the following command
_10si inst kill <Instance-id>
17. Save output (Optional)
The output will be saved to the file in the current directory.
_10si inst output <Instance-id> | tee filename.txt
Congratulations you have successful installed and run your first program, more sample programs are available in the sample section of Scramjet GitHub repository.
Compatibility
Scramjet Interface (SI) command-line should be compatible with the following operating systems. In case of an issues please contact our Team and Scramjet Team will gladly be of some assistance.
Any Linux based operating system - Ubuntu, Debian, Fedora, Centos, RedHat, Arch, SuSE and derivatives.
Any BSD compatible system - MacOS, FreeBSD, OpenBSD
Windows Subsystem for Linux (WSL)
MinGW, Git Bash and similar solutions on Windows.
STH should work on:
Any Linux based operating system - Ubuntu, Debian, Fedora, Centos, RedHat, Arch, SuSE and derivatives.
Any BSD compatible system - MacOS, FreeBSD, OpenBSD
Windows Subsystem for Linux (WSL)
Didn't find information needed?
Join our Scramjet Community on Discord, where you can get help from our engineers directly.