onemessagebus-cli 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,17 @@
1
+ # onemessagebus-cli
2
+
3
+ The `onemessagebus` command, as a prebuilt binary.
4
+
5
+ ```bash
6
+ npm install -g onemessagebus-cli
7
+ onemessagebus --help
8
+ ```
9
+
10
+ The binary ships inside a per-platform package that npm selects by `os`/`cpu`, so
11
+ there is no compile step and no Rust toolchain to install. The same binary is on
12
+ [PyPI](https://pypi.org/project/onemessagebus-cli/) (`pip install
13
+ onemessagebus-cli`), and builds from source with `cargo install --git
14
+ https://github.com/nickderobertis/onemessagebus onemessagebus-cli --locked`.
15
+
16
+ See [the repository](https://github.com/nickderobertis/onemessagebus) for what it
17
+ does and the contract it implements.
@@ -0,0 +1,90 @@
1
+ #!/usr/bin/env node
2
+ // Launcher for the `onemessagebus` command installed from the
3
+ // `onemessagebus-cli` npm package.
4
+ //
5
+ // Like the PyPI wheels (maturin `bindings = "bin"`, see pyproject.toml), the npm
6
+ // distribution carries the *prebuilt* Rust binary — no Rust toolchain, no
7
+ // compile, no download at install time. The platform-specific binary ships
8
+ // inside a per-platform package (`onemessagebus-cli-<platform>-<arch>`) the
9
+ // published package lists in its `optionalDependencies`; npm installs only the
10
+ // one whose `os`/`cpu` match the host, and this shim resolves it and execs it
11
+ // with the caller's argv.
12
+ //
13
+ // This file is committed source; the version and the optionalDependencies are
14
+ // written at publish time by scripts/npm-build.mjs, from Cargo.toml and its
15
+ // TARGETS table, and that script also generates the per-platform packages from
16
+ // the release binaries.
17
+
18
+ const path = require("node:path");
19
+ const { spawnSync } = require("node:child_process");
20
+
21
+ // process.platform-process.arch -> the platform package that carries the binary.
22
+ // The keys mirror the Rust target matrix in .github/workflows/release.yml and
23
+ // the TARGETS table in scripts/npm-build.mjs, which generates the published
24
+ // optionalDependencies; npm/test/platform-matrix.test.mjs holds them in lockstep.
25
+ const PACKAGES = {
26
+ "linux-x64": "onemessagebus-cli-linux-x64",
27
+ "linux-arm64": "onemessagebus-cli-linux-arm64",
28
+ "darwin-x64": "onemessagebus-cli-darwin-x64",
29
+ "darwin-arm64": "onemessagebus-cli-darwin-arm64",
30
+ "win32-x64": "onemessagebus-cli-win32-x64",
31
+ };
32
+
33
+ // Every failure here is a failed install, so say what to do about it rather than
34
+ // only what went wrong.
35
+ const OTHER_INSTALLS =
36
+ "Install another way instead: 'pip install onemessagebus-cli', or " +
37
+ "'cargo install --git https://github.com/nickderobertis/onemessagebus onemessagebus-cli --locked'.";
38
+
39
+ function fail(message) {
40
+ process.stderr.write(`onemessagebus: ${message}\n`);
41
+ process.exit(1);
42
+ }
43
+
44
+ function binaryPath() {
45
+ const key = `${process.platform}-${process.arch}`;
46
+ const pkg = PACKAGES[key];
47
+ // llmlint: ignore-block[changed_behavior_has_e2e] reaching this branch means running
48
+ // where no prebuilt package exists, and a test could only get there by lying to node
49
+ // about process.platform — which would prove the lie. The sibling branches are driven
50
+ // for real by npm/e2e/launcher.test.mjs, and npm's own os/cpu fields keep a user from
51
+ // installing a platform package this map does not name.
52
+ if (!pkg) {
53
+ fail(
54
+ `unsupported platform ${key}. Prebuilt binaries exist for: ` +
55
+ `${Object.keys(PACKAGES).join(", ")}. ${OTHER_INSTALLS}`,
56
+ );
57
+ }
58
+ // llmlint: ignore-end[changed_behavior_has_e2e]
59
+
60
+ const binName = process.platform === "win32" ? "onemessagebus.exe" : "onemessagebus";
61
+ try {
62
+ // Resolve the platform package's manifest, then locate the binary beside it.
63
+ // Resolving package.json (rather than the binary file directly) is portable
64
+ // across Node resolution modes and does not require an `exports` entry for a
65
+ // non-JS asset.
66
+ const manifest = require.resolve(`${pkg}/package.json`);
67
+ return path.join(path.dirname(manifest), "bin", binName);
68
+ } catch (_err) {
69
+ return fail(
70
+ `the platform package ${pkg} is not installed. This usually means npm ` +
71
+ "skipped optional dependencies (e.g. --no-optional / --omit=optional) " +
72
+ "or the install was for a different platform. Reinstall with optional " +
73
+ `dependencies enabled. ${OTHER_INSTALLS}`,
74
+ );
75
+ }
76
+ }
77
+
78
+ const result = spawnSync(binaryPath(), process.argv.slice(2), { stdio: "inherit" });
79
+
80
+ if (result.error) {
81
+ fail(`failed to launch the onemessagebus binary: ${result.error.message}`);
82
+ }
83
+
84
+ // Re-raise a terminating signal so callers observe the true cause; otherwise
85
+ // propagate the child's exit code verbatim — the contract assigns meaning to 1
86
+ // and 2, and a caller reads them.
87
+ if (result.signal) {
88
+ process.kill(process.pid, result.signal);
89
+ }
90
+ process.exit(result.status === null ? 1 : result.status);
package/package.json ADDED
@@ -0,0 +1,36 @@
1
+ {
2
+ "name": "onemessagebus-cli",
3
+ "version": "0.4.0",
4
+ "description": "A typed NDJSON message bus: schema registry verbs and stream verbs over the agent profile.",
5
+ "keywords": [
6
+ "ndjson",
7
+ "events",
8
+ "message-bus",
9
+ "schema",
10
+ "cli"
11
+ ],
12
+ "homepage": "https://github.com/nickderobertis/onemessagebus",
13
+ "bugs": "https://github.com/nickderobertis/onemessagebus/issues",
14
+ "repository": {
15
+ "type": "git",
16
+ "url": "git+https://github.com/nickderobertis/onemessagebus.git"
17
+ },
18
+ "license": "MIT",
19
+ "author": "Nick DeRobertis",
20
+ "bin": {
21
+ "onemessagebus": "bin/onemessagebus.js"
22
+ },
23
+ "files": [
24
+ "bin/onemessagebus.js"
25
+ ],
26
+ "engines": {
27
+ "node": ">=18"
28
+ },
29
+ "optionalDependencies": {
30
+ "onemessagebus-cli-linux-x64": "0.4.0",
31
+ "onemessagebus-cli-linux-arm64": "0.4.0",
32
+ "onemessagebus-cli-darwin-x64": "0.4.0",
33
+ "onemessagebus-cli-darwin-arm64": "0.4.0",
34
+ "onemessagebus-cli-win32-x64": "0.4.0"
35
+ }
36
+ }