Skip to content

Commit

Permalink
feat(wasm): publish NPM packages for nassun and node-maintainer as pa…
Browse files Browse the repository at this point in the history
…rt of release
  • Loading branch information
zkat committed Sep 27, 2023
1 parent ed07d10 commit f4f2ff2
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 1 deletion.
4 changes: 3 additions & 1 deletion CONTRIBUTING.md
Expand Up @@ -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
Expand Down
56 changes: 56 additions & 0 deletions Makefile.toml
Expand Up @@ -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"]
Expand Down

0 comments on commit f4f2ff2

Please sign in to comment.