@net-mesh/cli 0.20.1

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/LICENSE ADDED
@@ -0,0 +1,3 @@
1
+ Apache-2.0
2
+
3
+ See https://github.com/ai-2070/net/blob/master/LICENSE for the full text.
package/README.md ADDED
@@ -0,0 +1,35 @@
1
+ # @net-mesh/cli
2
+
3
+ Unified command-line interface for the Net mesh — the operational
4
+ counterpart to [`@net-mesh/deck`](https://www.npmjs.com/package/@net-mesh/deck).
5
+
6
+ ```sh
7
+ npm install -g @net-mesh/cli
8
+ # or:
9
+ npx @net-mesh/cli --help
10
+ ```
11
+
12
+ `@net-mesh/cli` is a thin Node.js shim — installing it pulls in
13
+ the right per-platform binary package as an `optionalDependency`
14
+ (npm refuses to install packages that don't match the host's
15
+ `os` / `cpu` / `libc`). The shim resolves the installed package
16
+ at runtime and `exec`s the bundled `net-mesh` binary.
17
+
18
+ Supported targets:
19
+
20
+ - linux x86_64 (glibc + musl)
21
+ - linux aarch64 (glibc + musl)
22
+ - macOS x86_64 + aarch64
23
+ - Windows x86_64 + aarch64
24
+
25
+ ## Other install paths
26
+
27
+ - **crates.io** — `cargo install net-cli`
28
+ - **cargo-binstall** — `cargo binstall net-cli` (downloads the
29
+ prebuilt tarball from GitHub Releases, no compile)
30
+ - **GitHub Releases** — download the tarball / zip directly from
31
+ [the releases page](https://github.com/ai-2070/net/releases)
32
+ - **PyPI** — `pip install net-mesh-cli`
33
+
34
+ See the [main README](https://github.com/ai-2070/net) for the
35
+ full surface.
@@ -0,0 +1,119 @@
1
+ #!/usr/bin/env node
2
+ // Shim that locates the platform-specific @net-mesh/cli-<triple>
3
+ // package npm installed alongside this one (via the parent's
4
+ // optionalDependencies) and execs its bundled `net-mesh` binary,
5
+ // forwarding argv + stdio.
6
+ //
7
+ // Mirrors the pattern used by esbuild / swc / biome:
8
+ // - One parent package (this file) is the only thing users
9
+ // reference (`npm i @net-mesh/cli`, `npx net-mesh`).
10
+ // - One per-platform binary package per supported triple. Each
11
+ // pins `os` / `cpu` / `libc` so npm refuses to install it on
12
+ // a non-matching host; only the matching one ends up in
13
+ // node_modules.
14
+ // - This shim resolves whichever one landed and execs the
15
+ // binary. No build step, no postinstall, no compile-time
16
+ // download.
17
+
18
+ 'use strict';
19
+
20
+ const child_process = require('node:child_process');
21
+ const fs = require('node:fs');
22
+ const path = require('node:path');
23
+
24
+ // Detect musl vs glibc on Linux. Mirrors the napi-rs heuristic:
25
+ // the official Node.js binaries are linked against glibc, so
26
+ // `process.report.getReport()` exposes the libc family. Fall back
27
+ // to inspecting `/usr/bin/ldd` since alpine's musl ldd prints
28
+ // 'musl' in its output, and finally to assuming glibc.
29
+ function detectLibc() {
30
+ if (process.platform !== 'linux') return null;
31
+ try {
32
+ const report = process.report.getReport();
33
+ if (report && report.header && report.header.glibcVersionRuntime) {
34
+ return 'gnu';
35
+ }
36
+ } catch (_) {}
37
+ try {
38
+ const ldd = child_process.execFileSync('/usr/bin/ldd', ['--version'], {
39
+ encoding: 'utf8',
40
+ stdio: ['ignore', 'pipe', 'pipe'],
41
+ });
42
+ if (/musl/i.test(ldd)) return 'musl';
43
+ } catch (_) {}
44
+ // Default to glibc — covers Debian/Ubuntu/RHEL/Fedora out of the
45
+ // box; alpine users hit the musl branch above.
46
+ return 'gnu';
47
+ }
48
+
49
+ function resolvePlatformPackage() {
50
+ const platform = process.platform;
51
+ const arch = process.arch;
52
+ const libc = detectLibc();
53
+ // Mapping from (platform, arch[, libc]) to the npm package name.
54
+ // Stays in sync with the parent's optionalDependencies list and
55
+ // the release workflow's matrix.
56
+ if (platform === 'linux') {
57
+ if (arch === 'x64') return `@net-mesh/cli-linux-x64-${libc}`;
58
+ if (arch === 'arm64') return `@net-mesh/cli-linux-arm64-${libc}`;
59
+ }
60
+ if (platform === 'darwin') {
61
+ if (arch === 'x64') return '@net-mesh/cli-darwin-x64';
62
+ if (arch === 'arm64') return '@net-mesh/cli-darwin-arm64';
63
+ }
64
+ if (platform === 'win32') {
65
+ if (arch === 'x64') return '@net-mesh/cli-win32-x64';
66
+ if (arch === 'arm64') return '@net-mesh/cli-win32-arm64';
67
+ }
68
+ throw new Error(
69
+ `Unsupported platform: ${platform}-${arch}${libc ? `-${libc}` : ''}. ` +
70
+ 'See https://github.com/ai-2070/net for the list of supported targets.',
71
+ );
72
+ }
73
+
74
+ function findBinary() {
75
+ const pkg = resolvePlatformPackage();
76
+ const binName = process.platform === 'win32' ? 'net-mesh.exe' : 'net-mesh';
77
+ // `require.resolve` finds the package.json of the platform
78
+ // package; its directory contains the bin/.
79
+ let pkgJsonPath;
80
+ try {
81
+ pkgJsonPath = require.resolve(`${pkg}/package.json`);
82
+ } catch (err) {
83
+ throw new Error(
84
+ `Failed to locate ${pkg}. The optional dependency may not have ` +
85
+ 'installed — check your npm install logs. ' +
86
+ `Underlying error: ${err.message}`,
87
+ );
88
+ }
89
+ const binPath = path.join(path.dirname(pkgJsonPath), 'bin', binName);
90
+ if (!fs.existsSync(binPath)) {
91
+ throw new Error(
92
+ `Binary missing at ${binPath}. The platform package is malformed.`,
93
+ );
94
+ }
95
+ return binPath;
96
+ }
97
+
98
+ function main() {
99
+ let binPath;
100
+ try {
101
+ binPath = findBinary();
102
+ } catch (err) {
103
+ process.stderr.write(`net-mesh: ${err.message}\n`);
104
+ process.exit(127);
105
+ }
106
+ // `spawnSync` with stdio: 'inherit' gives us transparent
107
+ // stdin/stdout/stderr forwarding + signal propagation.
108
+ const result = child_process.spawnSync(binPath, process.argv.slice(2), {
109
+ stdio: 'inherit',
110
+ windowsHide: false,
111
+ });
112
+ if (result.error) {
113
+ process.stderr.write(`net-mesh: ${result.error.message}\n`);
114
+ process.exit(1);
115
+ }
116
+ process.exit(result.status === null ? 1 : result.status);
117
+ }
118
+
119
+ main();
package/package.json ADDED
@@ -0,0 +1,39 @@
1
+ {
2
+ "name": "@net-mesh/cli",
3
+ "version": "0.20.1",
4
+ "description": "net-mesh — unified command-line interface for the Net mesh",
5
+ "license": "Apache-2.0",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "https://github.com/ai-2070/net"
9
+ },
10
+ "keywords": [
11
+ "net-mesh",
12
+ "mesh",
13
+ "cli",
14
+ "event-bus",
15
+ "operator"
16
+ ],
17
+ "bin": {
18
+ "net-mesh": "bin/net-mesh.js"
19
+ },
20
+ "files": [
21
+ "bin/net-mesh.js",
22
+ "README.md",
23
+ "LICENSE"
24
+ ],
25
+ "engines": {
26
+ "node": ">=18"
27
+ },
28
+ "//": "Per-platform binary packages are listed as optionalDependencies. npm fetches only the one whose `os`/`cpu`/`libc` constraints match the install host; bin/net-mesh.js resolves whichever landed at runtime and execs the bundled binary.",
29
+ "optionalDependencies": {
30
+ "@net-mesh/cli-linux-x64-gnu": "0.20.1",
31
+ "@net-mesh/cli-linux-x64-musl": "0.20.1",
32
+ "@net-mesh/cli-linux-arm64-gnu": "0.20.1",
33
+ "@net-mesh/cli-linux-arm64-musl": "0.20.1",
34
+ "@net-mesh/cli-darwin-x64": "0.20.1",
35
+ "@net-mesh/cli-darwin-arm64": "0.20.1",
36
+ "@net-mesh/cli-win32-x64": "0.20.1",
37
+ "@net-mesh/cli-win32-arm64": "0.20.1"
38
+ }
39
+ }