Skip to content

Commit

Permalink
working on documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
Zwiterrion committed Nov 16, 2023
1 parent fbf349f commit ce597c5
Show file tree
Hide file tree
Showing 27 changed files with 542 additions and 45 deletions.
4 changes: 4 additions & 0 deletions docs/documentation/app/builder/getting-started/page.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ export default function Home() {
title: 'Wasmo - Getting started',
href: '/builder/getting-started'
}}
previous={{
href: "/builder/overview",
title: "Builder - Overview"
}}
next={{
href: "/builder/your-first-plugin",
title: "Wasmo CLI"
Expand Down
4 changes: 4 additions & 0 deletions docs/documentation/app/builder/overview/page.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ export default function Home() {
title: 'Wasmo - Overview',
href: '/builder/overview'
}}
previous={{
href: "/",
title: "Wasmo - Overview"
}}
next={{
href: "/builder/getting-started",
title: "Getting started"
Expand Down
4 changes: 4 additions & 0 deletions docs/documentation/app/builder/plugin-structure/page.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ export default function Home() {
title: 'Wasmo - Plugin Structure',
href: '/builder/plugin-structure'
}}
previous={{
href: "/builder/your-first-plugin",
title: "Your first plugin"
}}
next={{
href: "/builder/ui",
title: "User Interface"
Expand Down
4 changes: 4 additions & 0 deletions docs/documentation/app/builder/ui/page.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ export default function Home() {
title: 'Wasmo - User Interface',
href: '/builder/ui'
}}
previous={{
href: "/builder/plugin-structure",
title: "Plugin Structure"
}}
next={{
href: "/cli/overview",
title: "Wasmo CLI"
Expand Down
5 changes: 0 additions & 5 deletions docs/documentation/app/builder/your-first-plugin/_page.mdx
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
export const meta = {
title: 'COUCOU'
}


# Write your first plugin

## Prerequisites
Expand Down
4 changes: 4 additions & 0 deletions docs/documentation/app/builder/your-first-plugin/page.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ export default function Home() {
metadata={{
href: '/builder/your-first-plugin'
}}
previous={{
href: "/builder/overview",
title: "Builder - Overview"
}}
next={{
href: "/builder/plugin-structure",
title: "Plugin Structure"
Expand Down
55 changes: 55 additions & 0 deletions docs/documentation/app/cli/configuration-file/_page.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# Configure your configuration file

```
wasmo config get
wasmo config reset
wasmo config set <key>=<value>
```
Note: This command is unaware of workspaces.

## Description

wasmo gets its config from the command line, environment variables, `.wasmo` files, and in some cases, directly from the build command.

The `wasmo config` command can be used to update and edit the contents of the user and global wasmo files.

## Sub-commands

### set

```
wasmo config set <key>=<value>
```

Sets each of the config keys to the value provided.

If value is omitted, then it sets it to an empty string.

The available keys are:
- `path`: configure the path where the wasmo configuration will be stored
- `server`: the Wasmo server to build your plugins (an URL format value is expected)
- `token`: the token, pass to the Wasmo server, to authenticate the CLI
- `docker_authorization`: the token value accepted by Docker instances

You can also edit the configuration file manually. In this case, the following values are :
- `path` = WASMO_PATH
- `server` = WASMO_SERVER
- `token` = WASMO_TOKEN
- `docker_authorization` = DOCKER_AUTHORIZATION

### get

```
wasmo config get
```

Show all the config settings.


### reset

```
wasmo config get
```

Reset the configuration file with the default settings. The custom user `.wasmo` files will not be deleted.
24 changes: 24 additions & 0 deletions docs/documentation/app/cli/configuration-file/page.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
"use client"

import Layout from '@/components/Layout';
import Page from './_page.mdx';

export default function Home() {

return <Layout
metadata={{
title: 'CLI - Configuration file',
href: '/cli/configuration-file'
}}
previous={{
href: "/cli/core-commands",
title: "Wasmo - Core commands"
}}
next={{
href: "/integrations/otoroshi",
title: "Integration - Otoroshi"
}}>
<Page />
</Layout>

}
22 changes: 22 additions & 0 deletions docs/documentation/app/cli/core-commands/_page.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import Badges from '../../../components/Badges'

# Core commands

The `wasmo` CLI internally contains a number of subcommands for working
with wasm modules:

## wasmo config set <Badges values={['token', 'path', 'server']} />

Globally configure the CLI with the authorization token, 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. |

## wasmo config get
Get the configuration from the configured path file or from `$HOME/.wasmo` |

## wasmo config reset
Clean configuration and reset to default settings. The default file path configuration will be `$HOME/.wasmo` ||

## wasmo init <Badges values={['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). |

## wasmo build <Badges values={['path', 'host', 'server', 'token']} />
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. |
24 changes: 24 additions & 0 deletions docs/documentation/app/cli/core-commands/page.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
"use client"

import Layout from '@/components/Layout';
import Page from './_page.mdx';

export default function Home() {

return <Layout
metadata={{
title: 'CLI - Getting started',
href: '/cli/getting-started'
}}
previous={{
href: "/cli/getting-started",
title: "CLI - Getting started"
}}
next={{
href: "/cli/configuration-file",
title: "CLI - Configuration fle"
}}>
<Page />
</Layout>

}
70 changes: 70 additions & 0 deletions docs/documentation/app/cli/getting-started/_page.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
import Badges from '../../../components/Badges'

# Wasmo CLI

# Installation

This project can be installed and compiled from source with this Cargo command:

```
$ cargo install wasmo
or
$ brew install wasmo (coming soon)
```

Additionally there are [precompiled artifacts built on CI][artifacts] which are
available for download as well.

[artifacts]: https://github.com/MAIF/wasmo/releases

Installation can be confirmed with:

```
$ wasmo --version
```

Subcommands can be explored with:

```
$ wasmo help
```

# Quick start

```
wasmo init --name=my-first-plugin --templates=js
wasmo build --host=OneShotDocker --path=my-first-plugin --token=foobar
```

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`.

## Selecting a template

You can now optionally start a new plugin from a template by appending `--template=[template-name]` to the creation command.

If you don't pass a template, Wasmo will list the available templates: `js`, `ts`, `opa`, `go` and `rust`.

```
wasmo init --name=my-first-plugin --templates=[template-name] --path=[output-directory]
```

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.

## Creating a production WASM binary

`wasmo build` starts the process to build a WASM binary of your plugin. Inside the plugin directory will be your WASM binary and sources.

You have two ways to build your plugin:
- locally with Docker
- remotely by deploying a [Wasmo server][wasmoserver]

[wasmoserver]: https://github.com/MAIF/wasmo

Assuming we want to build our `my-first-plugin` locally. Enter `wasmo build --host=OneShotDocker --path=my-first-plugin --token=foobar` to start the build.

Let's explain these 3 parameters:
- the `path` parameter is explicitly used to indicate the plugin to build
- 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.
- the `token` argument is passed to the Wasmo server to authenticate the CLI. It can also be set up in the [configuration file][#configure-your-configuration-file]

[![IMAGE ALT TEXT HERE](https://img.youtube.com/vi/NdbQR6vQ5Sk/0.jpg)](https://www.youtube.com/watch?v=NdbQR6vQ5Sk)
24 changes: 24 additions & 0 deletions docs/documentation/app/cli/getting-started/page.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
"use client"

import Layout from '@/components/Layout';
import Page from './_page.mdx';

export default function Home() {

return <Layout
metadata={{
title: 'CLI - Getting started',
href: '/cli/getting-started'
}}
previous={{
href: "/builder/ui",
title: "Builder - UI"
}}
next={{
href: "/cli/core-commands",
title: "CLI - Core commands"
}}>
<Page />
</Layout>

}
1 change: 1 addition & 0 deletions docs/documentation/app/integrations/otoroshi/_page.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Integration with Otoroshi
20 changes: 20 additions & 0 deletions docs/documentation/app/integrations/otoroshi/page.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
"use client"

import Layout from '@/components/Layout';
import Page from './_page.mdx';

export default function Home() {

return <Layout
metadata={{
title: 'Integrations - Otoroshi',
href: '/integrations/otoroshi'
}}
previous={{
href: "/cli/configuration-file",
title: "CLI - Configuration file"
}}>
<Page />
</Layout>

}
2 changes: 1 addition & 1 deletion docs/documentation/app/page.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export default function Home() {
title: "Wasmo - Overview"
}}
next={{
href: "/builder",
href: "/builder/overview",
title: "Builder"
}}>
<Page />
Expand Down
7 changes: 7 additions & 0 deletions docs/documentation/components/Badges.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export default function Badges({ values }) {
return <div className="inline-flex ms-6 flex items-center mt-2" style={{ gap: '.5rem' }}>
{values.map(value => <span key={value} className="whitespace-nowrap rounded-full bg-purple-100 px-2.5 py-0.5 text-sm text-purple-700">
{`<${value}>`}
</span>)}
</div>
}
Loading

0 comments on commit ce597c5

Please sign in to comment.