mirror of https://github.com/vacp2p/zerokit.git
chore: use cargo-make for building and publishing rln-wasm (#48)
This commit is contained in:
parent
c401c0b21d
commit
14f41d5340
|
@ -0,0 +1,6 @@
|
|||
/target
|
||||
**/*.rs.bk
|
||||
Cargo.lock
|
||||
bin/
|
||||
pkg/
|
||||
wasm-pack.log
|
|
@ -1,11 +1,15 @@
|
|||
[package]
|
||||
name = "rln-wasm"
|
||||
version = "0.1.0"
|
||||
version = "0.0.2"
|
||||
edition = "2021"
|
||||
license = "MIT or Apache2"
|
||||
|
||||
[lib]
|
||||
crate-type = ["cdylib", "rlib"]
|
||||
|
||||
[features]
|
||||
default = ["console_error_panic_hook"]
|
||||
|
||||
[dependencies]
|
||||
rln = { path = "../rln", default-features = false, features = ["wasm"] }
|
||||
num-bigint = { version = "0.4", default-features = false, features = ["rand", "serde"] }
|
||||
|
@ -15,13 +19,18 @@ getrandom = { version = "0.2.7", default-features = false, features = ["js"] }
|
|||
wasm-bindgen = "0.2.63"
|
||||
serde-wasm-bindgen = "0.4"
|
||||
js-sys = "0.3.59"
|
||||
console_error_panic_hook = "0.1.7"
|
||||
serde_json = "1.0.85"
|
||||
|
||||
# The `console_error_panic_hook` crate provides better debugging of panics by
|
||||
# logging them with `console.error`. This is great for development, but requires
|
||||
# all the `std::fmt` and `std::panicking` infrastructure, so isn't great for
|
||||
# code size when deploying.
|
||||
console_error_panic_hook = { version = "0.1.7", optional = true }
|
||||
|
||||
[dev-dependencies]
|
||||
wasm-bindgen-test = "0.3.0"
|
||||
wasm-bindgen-test = "0.3.13"
|
||||
wasm-bindgen-futures = "0.4.33"
|
||||
|
||||
[profile.release]
|
||||
debug = true
|
||||
|
||||
# Tell `rustc` to optimize for small code size.
|
||||
opt-level = "s"
|
||||
|
|
|
@ -0,0 +1,29 @@
|
|||
[env]
|
||||
CARGO_MAKE_EXTEND_WORKSPACE_MAKEFILE = true
|
||||
|
||||
[tasks.pack-build]
|
||||
command = "wasm-pack"
|
||||
args = ["build", "--release", "--target", "web", "--scope", "waku"]
|
||||
|
||||
[tasks.pack-rename]
|
||||
script = "sed -i 's/rln-wasm/zerokit-rln-wasm/g' pkg/package.json"
|
||||
|
||||
[tasks.build]
|
||||
clear = true
|
||||
dependencies = [
|
||||
"pack-build",
|
||||
"pack-rename"
|
||||
]
|
||||
|
||||
[tasks.test]
|
||||
command = "wasm-pack"
|
||||
args = ["test", "--release", "--node"]
|
||||
dependencies = ["build"]
|
||||
|
||||
[tasks.login]
|
||||
command = "wasm-pack"
|
||||
args = ["login"]
|
||||
|
||||
[tasks.publish]
|
||||
command = "wasm-pack"
|
||||
args = ["publish", "--access", "public", "--target", "web"]
|
|
@ -2,19 +2,29 @@
|
|||
This library is used in [waku-org/js-rln](https://github.com/waku-org/js-rln/)
|
||||
|
||||
## Building the library
|
||||
1. Make sure you have nodejs installed and the `build-essential` package if using ubuntu.
|
||||
2. Install wasm-pack
|
||||
1. Install `wasm-pack`
|
||||
```
|
||||
curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh
|
||||
```
|
||||
2. Install `cargo-make`
|
||||
```
|
||||
cargo install cargo-make
|
||||
```
|
||||
3. Compile zerokit for `wasm32-unknown-unknown`:
|
||||
```
|
||||
cd rln-wasm
|
||||
wasm-pack build --release
|
||||
cargo make build
|
||||
```
|
||||
|
||||
## Running tests
|
||||
```
|
||||
cd rln-wasm
|
||||
wasm-pack test --node --release
|
||||
cargo make test
|
||||
```
|
||||
|
||||
## Publishing a npm package
|
||||
```
|
||||
cd rln-wasm
|
||||
cargo make login
|
||||
cargo make publish
|
||||
```
|
|
@ -1,3 +1,5 @@
|
|||
#![cfg(target_arch = "wasm32")]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
extern crate web_sys;
|
||||
|
||||
|
|
Loading…
Reference in New Issue