A tool that makes working with Fluence network more convenient
- Linux or MacOS (currently have some bugs on windows)
- Node.js >=16.0.0
$ npm install -g @fluencelabs/cli $ fluence COMMAND running command... $ fluence (--version) @fluencelabs/cli/0.0.0 linux-x64 node-v16.14.0 $ fluence --help [COMMAND] USAGE $ fluence COMMAND ...A lot of what is described next will be improved and automated in the future (key-management etc.) Currently Fluence CLI is a convenience wrapper around Aqua CLI and Marine
- Run
fluence initto initialize new project - Run
fluence service add 'https://github.com/fluencelabs/services/blob/master/adder.tar.gz?raw=true'. Configfluence.yamlin the root of the project directory will be updated to look like this:
version: 1 services: adder: get: https://github.com/fluencelabs/services/blob/master/adder.tar.gz?raw=true deploy: - deployId: defaultdeployId can be any string. It must start with a lowercase letter and contain only letters, numbers, and underscores. It also must be unique service-wise. It is used in aqua to access ids of deployed services as you will see in a moment. You can edit fluence.yaml manually if you want to deploy multiple times, deploy on specific network, deploy on specific peerId or if you want to override service.yaml
- Run
fluence service new ./src/services/newServiceto generate new service template. You will be asked if you want to add the service tofluence.yaml- say yes. - Run
fluence service repl newServiceto get service into the repl - Run
fluence deployto deploy the application you described influence.yaml. Services written in rust will be automatically built before deployment. User-level secret key from~/.fluence/secrets.yamlwill be used to deploy each service (can be overridden using-kflag). You can also add project-level secret key to your project.fluence/secrets.yamlmanually (key-pair management coming soon) - Write some aqua in
src/aqua/main.aqua. Examplesrc/aqua/main.aqua:
module Main import App from "deployed.app.aqua" export App, add_one service AddOne: add_one: u64 -> u64 func add_one(value: u64) -> u64: services <- App.services() on services.adder.default!.peerId: AddOne services.adder.default!.serviceId res <- AddOne.add_one(value) <- res "deployed.app.aqua" file is located at .fluence/aqua/deployed.app.aqua. App.services() method returns ids of the previously deployed services that you can use in your aqua code (this info is stored at .fluence/app.yaml.
- Run
fluence run -f 'add_one(1)'. (function with this name will be searched inside thesrc/aqua/main.aqua(can be overridden with--inputflag) and executed). Alternatively, if you are js developer - import generatedregisterAppfunction from.fluence/ts/app.tsor.fluence/js/app.jsand execute it afterFluence.run()in your js application in order to give access to deployed services ids to your aqua code. Then compilesrc/aqua/main.aquausing Aqua CLI. Import and runadd_one(1)in your js code. - Run
fluence removeto remove the previously deployed fluence application
To run cli in development mode use: ./bin/dev
To run cli in production mode run npm run build first, then use: ./bin/run
If you are using nvm and want to commit using VSCode - place .huskyrc file to your Home directory
Don't name arguments or flags with names that contain underscore symbols, because autogenerated links in markdown will not work
pre-commit runs each time before you commit. It includes prettier and generates this README.md file. If you want README.md file to be correctly generated please don't forget to run npm run build before committing
Pull request and release process:
- Run
npm run checkto make sure everything ok with the code - Only after that commit your changes to trigger pre-commit hook that updates
README.md. ReadREADME.mdto make sure it is correctly updated - Push your changes
- Create pull request and merge your changes to
main - Switch to
mainlocally and pull merged changes - Run
git tag -a v0.0.0 -m ""with version number that you want instead of0.0.0 - Run
git push origin v0.0.0with version number that you want instead of0.0.0to trigger release
fluence aquafluence autocomplete [SHELL]fluence dependency [NAME]fluence deployfluence help [COMMAND]fluence init [PATH]fluence key default [NAME]fluence key new [NAME]fluence key remove [NAME]fluence module add [PATH | URL]fluence module new [PATH]fluence module remove [NAME | PATH | URL]fluence removefluence runfluence service add [PATH | URL]fluence service new [PATH]fluence service remove [NAME | PATH | URL]fluence service repl [NAME | PATH | URL]
Compile aqua file or directory that contains your .aqua files
USAGE $ fluence aqua [-i <value>] [-o <value>] [--import <value>] [--air | --js] [--log-level <value>] [--const <value>] [--no-relay] [--no-xor] [--dry] [--scheduled] [-w] [--no-input] FLAGS -i, --input=<path> Path to an aqua file or an input directory that contains your .aqua files -o, --output=<path> Path to the output directory. Will be created if it doesn't exists -w, --watch Watch aqua file or folder for changes and recompile --air Generate .air file instead of .ts --const=<NAME=value> Set log level --dry Checks if compilation is succeeded, without output --import=<path>... Path to a directory to import from. May be used several times --js Generate .js file instead of .ts --log-level=<level> Set log level --no-input Don't interactively ask for any input from the user --no-relay Do not generate a pass through the relay node --no-xor Do not generate a wrapper that catches and displays errors --scheduled Generate air code for script storage. Without error handling wrappers and hops on relay. Will ignore other options DESCRIPTION Compile aqua file or directory that contains your .aqua files EXAMPLES $ fluence aqua See code: dist/commands/aqua.ts
display autocomplete installation instructions
USAGE $ fluence autocomplete [SHELL] [-r] ARGUMENTS SHELL shell type FLAGS -r, --refresh-cache Refresh cache (ignores displaying instructions) DESCRIPTION display autocomplete installation instructions EXAMPLES $ fluence autocomplete $ fluence autocomplete bash $ fluence autocomplete zsh $ fluence autocomplete --refresh-cache See code: @oclif/plugin-autocomplete
Manage dependencies stored inside .fluence directory of the current user
USAGE $ fluence dependency [NAME] [-v | --use <value>] [--no-input] ARGUMENTS NAME Dependency name. One of: aqua, marine, mrepl. If you omit NAME argument and include --use recommended - all dependencies will be reset to recommended versions FLAGS -v, --version Show current version of the dependency --no-input Don't interactively ask for any input from the user --use=<version | recommended> Set dependency version. Use recommended keyword to set recommended version for the dependency. If you omit NAME argument and include --use recommended - all dependencies will be reset to recommended versions DESCRIPTION Manage dependencies stored inside .fluence directory of the current user EXAMPLES $ fluence dependency See code: dist/commands/dependency.ts
Deploy application, described in fluence.yaml
USAGE $ fluence deploy [--relay <value>] [--force] [--timeout <value>] [-k <value>] [--no-input] FLAGS -k, --key-pair-name=<name> Key pair name --force Force removing of previously deployed app --no-input Don't interactively ask for any input from the user --relay=<multiaddr> Relay node multiaddr --timeout=<milliseconds> Timeout used for command execution DESCRIPTION Deploy application, described in fluence.yaml EXAMPLES $ fluence deploy See code: dist/commands/deploy.ts
Display help for fluence.
USAGE $ fluence help [COMMAND] [-n] ARGUMENTS COMMAND Command to show help for. FLAGS -n, --nested-commands Include all nested commands in the output. DESCRIPTION Display help for fluence. See code: @oclif/plugin-help
Initialize fluence project
USAGE $ fluence init [PATH] [--no-input] ARGUMENTS PATH Project path FLAGS --no-input Don't interactively ask for any input from the user DESCRIPTION Initialize fluence project EXAMPLES $ fluence init See code: dist/commands/init.ts
Set default key-pair for user or project
USAGE $ fluence key default [NAME] [--no-input] [--user] ARGUMENTS NAME Key-pair name FLAGS --no-input Don't interactively ask for any input from the user --user Set default key-pair for current user instead of current project DESCRIPTION Set default key-pair for user or project EXAMPLES $ fluence key default Generate key-pair and store it in user's or project's .fluence/secrets.yaml
USAGE $ fluence key new [NAME] [--no-input] [--user] ARGUMENTS NAME Key-pair name FLAGS --no-input Don't interactively ask for any input from the user --user Generate key-pair for current user instead of generating key-pair for current project DESCRIPTION Generate key-pair and store it in user's or project's .fluence/secrets.yaml EXAMPLES $ fluence key new Remove key-pair from user's or project's .fluence/secrets.yaml
USAGE $ fluence key remove [NAME] [--no-input] [--user] ARGUMENTS NAME Key-pair name FLAGS --no-input Don't interactively ask for any input from the user --user Remove key-pair from current user instead of removing key-pair from current project DESCRIPTION Remove key-pair from user's or project's .fluence/secrets.yaml EXAMPLES $ fluence key remove Add module to service.yaml
USAGE $ fluence module add [PATH | URL] [--no-input] [--name <value>] [--service <value>] ARGUMENTS PATH | URL Path to a module or url to .tar.gz archive FLAGS --name=<name> Override module name --no-input Don't interactively ask for any input from the user --service=<name | path> Service name from fluence.yaml or path to the service directory DESCRIPTION Add module to service.yaml EXAMPLES $ fluence module add Create new marine module template
USAGE $ fluence module new [PATH] [--no-input] ARGUMENTS PATH Module path FLAGS --no-input Don't interactively ask for any input from the user DESCRIPTION Create new marine module template EXAMPLES $ fluence module new Remove module from service.yaml
USAGE $ fluence module remove [NAME | PATH | URL] [--no-input] [--service <value>] ARGUMENTS NAME | PATH | URL Module name from service.yaml, path to a module or url to .tar.gz archive FLAGS --no-input Don't interactively ask for any input from the user --service=<name | path> Service name from fluence.yaml or path to the service directory DESCRIPTION Remove module from service.yaml EXAMPLES $ fluence module remove Remove previously deployed config
USAGE $ fluence remove [--relay <value>] [--timeout <value>] [--no-input] FLAGS --no-input Don't interactively ask for any input from the user --relay=<multiaddr> Relay node multiaddr --timeout=<milliseconds> Timeout used for command execution DESCRIPTION Remove previously deployed config EXAMPLES $ fluence remove See code: dist/commands/remove.ts
Run aqua script
USAGE $ fluence run [--relay <value>] [--data <value>] [--data-path <value>] [--import <value>] [--plugin <value>] [--const <value>] [--json-service <value>] [--on <value>] [-i <value>] [-f <value>] [--timeout <value>] [--no-input] [-k <value>] FLAGS -f, --func=<function-call> Function call -i, --input=<path> Path to an aqua file or to a directory that contains aqua files -k, --key-pair-name=<name> Key pair name --const=<NAME = value>... Constant that will be used in the aqua code that you run (example of aqua code: SOME_CONST ?= "default_value"). Constant name must be upper cased. --data=<json> JSON in { [argumentName]: argumentValue } format. You can call a function using these argument names --data-path=<path> Path to a JSON file in { [argumentName]: argumentValue } format. You can call a function using these argument names --import=<path>... Path to a directory to import from. May be used several times --json-service=<path>... Path to a file that contains a JSON formatted service --no-input Don't interactively ask for any input from the user --on=<peer_id> PeerId of a peer where you want to run the function --plugin=<path> [experimental] Path to a directory with JS plugins (Read more: https://doc.fluence.dev/aqua-book/aqua-cli/plugins) --relay=<multiaddr> Relay node multiaddr --timeout=<milliseconds> Timeout used for command execution DESCRIPTION Run aqua script EXAMPLES $ fluence run See code: dist/commands/run.ts
Add service to fluence.yaml
USAGE $ fluence service add [PATH | URL] [--no-input] [--name <value>] ARGUMENTS PATH | URL Path to a service or url to .tar.gz archive FLAGS --name=<name> Override service name (must start with a lowercase letter and contain only letters, numbers, and underscores) --no-input Don't interactively ask for any input from the user DESCRIPTION Add service to fluence.yaml EXAMPLES $ fluence service add Create new marine service template
USAGE $ fluence service new [PATH] [--no-input] [--name <value>] ARGUMENTS PATH Path to a service FLAGS --name=<name> Unique service name (must start with a lowercase letter and contain only letters, numbers, and underscores) --no-input Don't interactively ask for any input from the user DESCRIPTION Create new marine service template EXAMPLES $ fluence service new Remove service from fluence.yaml
USAGE $ fluence service remove [NAME | PATH | URL] [--no-input] ARGUMENTS NAME | PATH | URL Service name from fluence.yaml, path to a service or url to .tar.gz archive FLAGS --no-input Don't interactively ask for any input from the user DESCRIPTION Remove service from fluence.yaml EXAMPLES $ fluence service remove Open service inside repl (downloads and builds modules if necessary)
USAGE $ fluence service repl [NAME | PATH | URL] [--no-input] ARGUMENTS NAME | PATH | URL Service name from fluence.yaml, path to a service or url to .tar.gz archive FLAGS --no-input Don't interactively ask for any input from the user DESCRIPTION Open service inside repl (downloads and builds modules if necessary) EXAMPLES $ fluence service repl