|
| 1 | +<div align="center"> |
| 2 | + <h1><code>wasmo</code></h1> |
| 3 | + |
| 4 | +<strong>A <a href="https://github.com/MAIF/">MAIF</a> opensource project</strong> |
| 5 | + |
| 6 | + <p> |
| 7 | + <strong>Wasmo CLI brings WASM to your architecture</strong> |
| 8 | + </p> |
| 9 | + |
| 10 | + <p> |
| 11 | + Wasmo CLI can be combined with the power of <a href="https://hub.docker.com/r/maif/wasmo">Docker Wasmo server images</a> to build locally and remotely WASM binaries. |
| 12 | + </p> |
| 13 | +</div> |
| 14 | + |
| 15 | + |
| 16 | +# Installation |
| 17 | + |
| 18 | +This project can be installed and compiled from source with this Cargo command: |
| 19 | + |
| 20 | +``` |
| 21 | +$ cargo install wasmo |
| 22 | +or |
| 23 | +$ brew tap maif/wasmo |
| 24 | +$ brew install wasmo |
| 25 | +``` |
| 26 | + |
| 27 | +Additionally there are [precompiled artifacts built on CI][artifacts] which are |
| 28 | +available for download as well. |
| 29 | + |
| 30 | +[artifacts]: https://github.com/MAIF/wasmo/releases |
| 31 | + |
| 32 | +Installation can be confirmed with: |
| 33 | + |
| 34 | +``` |
| 35 | +$ wasmo --version |
| 36 | +``` |
| 37 | + |
| 38 | +Subcommands can be explored with: |
| 39 | + |
| 40 | +``` |
| 41 | +$ wasmo help |
| 42 | +``` |
| 43 | + |
| 44 | +# Core commands |
| 45 | + |
| 46 | +The `wasmo` CLI internally contains a number of subcommands for working |
| 47 | +with wasm modules: |
| 48 | + |
| 49 | +| Tool | Arguments | Description | |
| 50 | +| ---------------------------- | -- | ------------------------------------------------------------- | |
| 51 | +| `wasmo config set` | path | server | clientId | clientSecret | Globally configure the CLI with the path where the configuration file will be stored and the server to reach during the build. These parameters are optional and can be passed when running the build command. | |
| 52 | +| `wasmo config get` | | Get the configuration from the configured path file or from `$HOME/.wasmo` | |
| 53 | +| `wasmo config reset` | | Clean configuration and reset to default settings. The default file path configuration will be `$HOME/.wasmo` || |
| 54 | +| `wasmo init` | template | name | path | Initialize a WASM plugin to the specific path. You can choose between many templates, javascript/typescript (js/ts), Open Policy Agent (opa), Rust or Golang (go). | |
| 55 | +| `wasmo build` | path | host | server | clientId | clientSecret | Build the plugin by sending the contents to the remote or local Wasmo server. As soon as the build is complete, the WASM binary is donwloaded and saved in the plugin folder. | |
| 56 | + |
| 57 | +# Quick start |
| 58 | + |
| 59 | +``` |
| 60 | +wasmo init --name=my-first-plugin --template=js |
| 61 | +wasmo build --host=OneShotDocker --path=my-first-plugin |
| 62 | +``` |
| 63 | + |
| 64 | +Then open the content of your `my-first-plugin` folder. You should find the generated WASM binary named `my-first-plugin-1.0.0.wasm`. |
| 65 | + |
| 66 | +## Selecting a template |
| 67 | + |
| 68 | +You can now optionally start a new plugin from a template by appending `--template=[template-name]` to the creation command. |
| 69 | + |
| 70 | +If you don't pass a template, Wasmo will list the available templates: `js`, `ts`, `opa`, `go` and `rust`. |
| 71 | + |
| 72 | +``` |
| 73 | +wasmo init --name=my-first-plugin --template=[template-name] --path=[output-directory] |
| 74 | +``` |
| 75 | + |
| 76 | +Running this command with any of theses templates will create a directory called `my-first-plugin` inside the specified output directory (or the current if omitted). Inside that directory, it will generate the initial project structure with the metadata file pre-filled with the name of your plugin. |
| 77 | + |
| 78 | +## Creating a production WASM binary |
| 79 | + |
| 80 | +`wasmo build` starts the process to build a WASM binary of your plugin. Inside the plugin directory will be your WASM binary and sources. |
| 81 | + |
| 82 | +You have two ways to build your plugin: |
| 83 | + - locally with Docker |
| 84 | + - remotely by deploying a [Wasmo server][wasmoserver] |
| 85 | + |
| 86 | +[wasmoserver]: https://github.com/MAIF/wasmo |
| 87 | + |
| 88 | +Assuming we want to build our `my-first-plugin` locally. Enter `wasmo build --host=OneShotDocker --path=my-first-plugin` to start the build. |
| 89 | + |
| 90 | +Let's explain these 3 parameters: |
| 91 | + - the `path` parameter is explicitly used to indicate the plugin to build |
| 92 | + - the `host` indicates which kind of Wasmo server used. The pratical way is to use `Docker` or `OneShotDocker` because it prevents to install a Wasmo server by deploying, inside your locally Docker, a new Wasmo container. The last possible value is `Remote` and can be used to specify with a URI the remote Wasmo server used. |
| 93 | +<!-- |
| 94 | +[](https://www.youtube.com/watch?v=NdbQR6vQ5Sk) --> |
| 95 | + |
| 96 | +## Configure your configuration file |
| 97 | + |
| 98 | +``` |
| 99 | +wasmo config get |
| 100 | +wasmo config reset |
| 101 | +wasmo config set <key>=<value> |
| 102 | +``` |
| 103 | +Note: This command is unaware of workspaces. |
| 104 | + |
| 105 | +### Description |
| 106 | + |
| 107 | +wasmo gets its config from the command line, environment variables, `.wasmo` files, and in some cases, directly from the build command. |
| 108 | + |
| 109 | +The `wasmo config` command can be used to update and edit the contents of the user and global wasmo files. |
| 110 | + |
| 111 | +### Sub-commands |
| 112 | + |
| 113 | +#### set |
| 114 | + |
| 115 | +``` |
| 116 | +wasmo config set <key>=<value> |
| 117 | +``` |
| 118 | + |
| 119 | +Sets each of the config keys to the value provided. |
| 120 | + |
| 121 | +If value is omitted, then it sets it to an empty string. |
| 122 | + |
| 123 | +The available keys are: |
| 124 | + - `path`: configure the path where the wasmo configuration will be stored |
| 125 | + - `server`: the Wasmo server to build your plugins (an URL format value is expected) |
| 126 | + - `clientId`: the client id used in Basic and Otoroshi Auth |
| 127 | + - `clientSecret`: the client secret used in Basic and Otoroshi Auth |
| 128 | + |
| 129 | +You can also edit the configuration file manually. In this case, the following values are : |
| 130 | + - `path` = WASMO_PATH |
| 131 | + - `server` = WASMO_SERVER |
| 132 | + |
| 133 | +#### get |
| 134 | + |
| 135 | +``` |
| 136 | +wasmo config get |
| 137 | +``` |
| 138 | + |
| 139 | +Show all the config settings. |
| 140 | + |
| 141 | + |
| 142 | +#### reset |
| 143 | + |
| 144 | +``` |
| 145 | +wasmo config get |
| 146 | +``` |
| 147 | + |
| 148 | +Reset the configuration file with the default settings. The custom user `.wasmo` files will not be deleted. |
| 149 | + |
| 150 | +# License |
| 151 | + |
| 152 | +This project is licensed under the Apache 2.0 license with the LLVM exception. |
| 153 | + |
| 154 | +### Contribution |
| 155 | + |
| 156 | +Unless you explicitly state otherwise, any contribution intentionally submitted |
| 157 | +for inclusion in this project by you, as defined in the Apache-2.0 license, |
| 158 | +shall be licensed as above, without any additional terms or conditions. |
0 commit comments