From f4f2ff22cd6fec4bb5594f924c0773b9d92effa6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kat=20March=C3=A1n?= Date: Wed, 27 Sep 2023 16:19:00 -0700 Subject: [PATCH] feat(wasm): publish NPM packages for nassun and node-maintainer as part of release --- CONTRIBUTING.md | 4 +++- Makefile.toml | 56 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 59 insertions(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 986d3ed5..ba09dc1d 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -62,7 +62,9 @@ standalone binary but, **on Linux**, does require a valid installation of ### Building WASM packages There's currently two packages with support for WASM, only one of which should -really be used right now: `crates/nassun` and `crates/node-maintainer`. +really be used right now: `crates/nassun` and `crates/node-maintainer`. Both +of them are published to the NPM registry as part of `orogene`'s release +process. `node-maintainer` is orogene's dependency resolver and is responsible for calculating dependency trees based on package.json, lockfiles, etc. Extraction diff --git a/Makefile.toml b/Makefile.toml index a61d1d32..21114c4b 100644 --- a/Makefile.toml +++ b/Makefile.toml @@ -10,10 +10,66 @@ dependencies = ["changelog", "readmes"] [tasks.release] workspace = false +dependencies = ["cargo-release", "wasm-publish"] + +[tasks.cargo-release] +workspace = false install_crate = "cargo-release" command = "cargo" args = ["release", "--workspace", "${@}"] +[tasks.wasm-publish] +workspace = false +dependencies = ["publish-npm-nassun", "publish-npm-node-maintainer"] + +[tasks.publish-npm-nassun] +env = { "npm_config_registry" = "https://registry.npmjs.org/" } +workspace = false +dependencies = ["wasm-build-nassun"] +command = "wasm-pack" +args = ["publish", "crates/nassun", "--target", "web"] + +[tasks.publish-npm-node-maintainer] +env = { "npm_config_registry" = "https://registry.npmjs.org/" } +workspace = false +dependencies = ["wasm-build-node-maintainer"] +command = "wasm-pack" +args = ["publish", "crates/node-maintainer", "--target", "web"] + +[tasks.wasm-build-nassun] +workspace = false +dependencies = ["wasm-build-nassun-base"] +command = "node" +args = ["-e", """ +const jsonPath = './crates/nassun/pkg/package.json'; +const fs = require('node:fs'); +const pkg = require(jsonPath); +pkg["files"].push("nassun_bg.wasm.d.ts"); +fs.writeFileSync(jsonPath, JSON.stringify(pkg, null, 2)); +"""] + +[tasks.wasm-build-node-maintainer] +workspace = false +dependencies = ["wasm-build-node-maintainer-base"] +command = "node" +args = ["-e", """ +const jsonPath = './crates/node-maintainer/pkg/package.json'; +const fs = require('node:fs'); +const pkg = require(jsonPath); +pkg["files"].push("node_maintainer_bg.wasm.d.ts"); +fs.writeFileSync(jsonPath, JSON.stringify(pkg, null, 2)); +"""] + +[tasks.wasm-build-nassun-base] +workspace = false +command = "wasm-pack" +args = ["build", "crates/nassun", "--target", "web"] + +[tasks.wasm-build-node-maintainer-base] +workspace = false +command = "wasm-pack" +args = ["build", "crates/node-maintainer", "--target", "web"] + [tasks.readmes] workspace = false dependencies = ["workspace-readmes", "root-readme"]