Publishing your Package
Let's say you have a WebAssembly application, and you would like to publish it to WAPM so more people can use it easily.
You might have a similar project structure:
1
/
2
my_program_wasi.wasm
3
my_other_program_wasi.wasm
4
README.md
5
LICENSE
Copied!
Now, in the root of your project, you can simply run
1
wapm init
Copied!
And it will guide you the process of creating a new wapm.toml file for your project. At the end, it should have generated a manifest like the following:
1
[package]
2
name = "username/my_package"
3
version = "0.1.0"
4
description = "The description of the package"
5
​
6
[[module]]
7
name = "my_program_wasi"
8
source = "my_program_wasi.wasm"
9
​
10
[[module]]
11
name = "my_other_program_wasi"
12
source = "my_other_program_wasi.wasm"
Copied!
Now, you will need to:

Creating an account in WAPM

Creating an account in WAPM is very easy, just go to the following url and sign up!
wapm | Sign up

Login from the wapm CLI into your local account

Now that you are registered, you can just run the following command and it will ask for your credentials
1
wapm login
Copied!

Publish the package to WAPM

Now that you have successfully created a wapm.toml manifest file for your project and have logged in into WAPM, you just need to run one more command!
1
wapm publish
Copied!
And you package should now be live in wapm.io πŸŽ‰
All packages on wapm.io are namespaced by username.
If your program is a WASI program, it will be automatically available in the WebAssembly shell​

Commands

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:
1
[[command]]
2
name = "my_cmd"
3
module = "my_program_wasi"
Copied!
Now called wapm run my_cmd will execute the module defined with the name my_program_wasi. Under the hood, wapm calls wasmer, the WebAssembly server runtime.
If you want to learn more about the manifest format, please jump into the next article!
Last modified 25d ago