This guide will introduce the wapm-cli tool and show a few common workflows. The wapm client can install packages, manage WebAssembly dependencies, and expose WebAssembly behavior with commands.
The wapm ecosystem makes WebAssembly more accessible to developers. The system is enabled by a couple tools:
The tool comes bundled with wasmer: the WebAssembly runtime, but it works great with the other server-side runtimes and the web!
The name wapm is an abbreviation for WebAssembly Package Manager, but then name represents the ecosystem of packages and the tools.
The wapm-cli tool be installed using the Wasmer installer. Wasmer is useful for running WebAssembly modules installed by wapm-cli. See installation instructions for installing wapm-cli.
With the tools installed, one can easily start using universal wasm binaries by using the install
command of wapm-cli:
$ wapm install cowsay
Installing a package creates a local package directory called wapm_packages
where all packages are installed. While
in a directory with wapm packages, one may execute them with the run
command:
$ wapm run cowsay hello wapm!
_____________
< hello wapm! >
-------------
\ ^__^
\ (oo)\_______
(__)\ )\/\
||----w |
|| ||
wapm.toml
The manifest file enables one to publish a package to the wapm.io public registry.
Login is required for publishing. Signup for an account at wapm.io and login to the server with login
command.
The reference shows all the required fields for the manifest, but it's easy to get started with init
command. init
will guide you through the process of setting up a wapm manifest.
$ wapm init
This command generates a wapm manifest file with the information you've provided:
[package]
name = "username/my_package"
version = "0.1.0"
description = ""
license = "MIT"
[[module]]
name = "my_app"
source = "path/to/app.wasm"
Publish the project to wapm.io!
$ wapm publish
Commands (not to be confused with wapm-cli subcommands) are a feature that enables easily executing wasm code from a wapm package.
Commands are what allows one to call the run
subcommand, like above when running wapm run cowsay hello wapm!
.
A command requires a name and module to reference:
[[command]]
name = "my_cmd"
module = "my_app"
Now called wapm run my_cmd
will execute the module defined with the name my_app
. Under the hood, wapm-cli calls
wasmer, the WebAssembly server runtime.