Every CLI Usage
Installation
npm i -g @everywhere-computer/every-cli
Creating the Everywhere Computer environment
Running the Every CLI will start a Homestar node, API gateway, CloudFlare tunnel and locally running copy of the Everywhere Computer control panel.
To create a single function Homestar workflow
every dev <PATH_TO_FUNCTION_FILE>
To create a multi-function Homestar workflow
every dev <PATH_TO_FUNCTION_FILE> <PATH_TO_OTHER_FUNCTION_FILE>
Function development loop
Creating TypeScript functions
Write a TypeScript function with clearly specified argument and return types
/** * Hello world function that will take a `name` param and return `Hello <name>` */export function hello(name: string): string { return `Hello ${name}`;}
Start the CLI and point it to your custom TypeScript function
every cli dev <PATH_TO_YOUR_FUNCTION_DIR>/hello.ts
Creating Wasm components in Rust
Install the latest stable version of Rust. The install should make the cargo
and rustup
commands available for you.
Install cargo-component
and add the wasm32-wasi
target:
cargo install cargo-componentrustup target add wasm32-wasi
Initialize a new component library:
cargo component new --lib hello
This command generates a wit/world.wit
WIT world:
package component:hello;
/// An example world for the component to target.world example { export hello-world: func() -> string;}
It also generates Rust code in src/lib.rs
that implements the WIT world:
#[allow(warnings)]mod bindings;
use bindings::Guest;
struct Component;
impl Guest for Component { /// Say hello! fn hello_world() -> String { "Hello, World!".to_string() }}
bindings::export!(Component with_types_in bindings);
Running a build generates a set of bindings that produce a Guest
trait that requires us to implement the functions from the WIT world.
Build for the debug target:
cargo component build
Build for release:
cargo component build --release
The builds target wasm32-wasi
and are compiled to rust/target/wasm32-wasi/debug/math.wasm
and rust/target/wasm32-wasi/release/math.wasm
respectively.
Note that the build generates src/bindings.rs
. Check that the wit-bindgen
version referenced at the top the file matches the wit-bindgen-rt
version in the Cargo manifest if you see errors.
Creating Wasm components in Python
Install the latest version of Python. Python 3.10 is the minimum required version for componentize-py
.
Create a virtual environment, activate the environment, and install componentize-py
:
python -m venv .venvsource .venv/bin/activatepip install componentize-py
Write a WIT world in a world.wit
file:
package example:hello;
world hello { export hello: func() -> string;}
Write an app.py
that implements the WIT world:
import hello
class Hello(hello.Hello): def hello(self) -> str: return "Hello, World!"
Build the Wasm component:
componentize-py -d world.wit -w hello componentize app -o hello.wasm
This command will produce a hello.wasm
component.
Start the CLI and point it to your custom Wasm function
every cli dev <PATH_TO_YOUR_FUNCTION_DIR>/hello.wasm
Setting up a tunnel
By default the every-cli will start a CloudFlare tunnel for you.
If youβre familiar with ngrok or tailscale, you can also use those to expose your local node server to the public Internet.
Passing your own Homestar config
By default the every-cli will use the default homestar.toml values to specify configuration settings for your Homestar node.
If you would like to specify your own toml
file to be used as the configuration for Homestar, you can use the --config
argument:
every cli dev <PATH_TO_YOUR_FUNCTION_DIR>/hello.wasm --config ../<YOUR_CONFIG_FILE_NAME>.toml
You can specify as many or as few values in your toml
file as you like and the every-cli will prioritize the values from your config over the default values.
This means, if you only want to specify a different IPFS port, you simply need to create a toml
file with
[node.network.ipfs]port = 5002
and the every-cli will upload your functions to IPFS on port 5002
and configure Homestar to use IPFS port 5002
, as well.
If you have specified your own config file, the control panel will run locally so its .env
file can be overwritten if necessary:
β IPFS is running at http://127.0.0.1:5002/debug/varsβ Functions parsed and compiledβ Homestar is running at http://127.0.0.1:8020β Control Panel is running at http://127.0.0.1:5178
β Starting cloudflared tunnel to http://127.0.0.1:3000/
... a QR code ...
β Local: http://127.0.0.1:3000/β Tunnel: https://sometimes-comical-word-set.trycloudflare.com