nbt-cli 0.1.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 +26 -0
- package/bin/nbt.js +36 -0
- package/package.json +26 -0
package/README.md
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# nbt-cli
|
|
2
|
+
|
|
3
|
+
The `nbt` command-line tool — a Rust binary distributed over npm.
|
|
4
|
+
|
|
5
|
+
```sh
|
|
6
|
+
npm install -g nbt-cli
|
|
7
|
+
# or, no install:
|
|
8
|
+
npx nbt-cli --help
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
Rust users can instead:
|
|
12
|
+
|
|
13
|
+
```sh
|
|
14
|
+
cargo install nbt-cli
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## How it works
|
|
18
|
+
|
|
19
|
+
This package ships no binary itself. It lists per-platform packages
|
|
20
|
+
(`@neurobeat/nbt-darwin-arm64`, `@neurobeat/nbt-linux-x64`, `@neurobeat/nbt-win32-x64`, …) as
|
|
21
|
+
`optionalDependencies`; npm installs only the one matching your `os`/`cpu`, and
|
|
22
|
+
the `nbt` command shim execs that binary. No postinstall script, no download at
|
|
23
|
+
install time.
|
|
24
|
+
|
|
25
|
+
Requires npm >= 7. If you install with `--omit=optional`, the platform binary is
|
|
26
|
+
skipped and `nbt` will tell you how to recover.
|
package/bin/nbt.js
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// Router shim: locate the platform-specific @neurobeat/nbt-<os>-<arch> package that npm
|
|
3
|
+
// installed (selected via its os/cpu fields) and exec its binary, forwarding
|
|
4
|
+
// argv, stdio and the exit code/signal. No postinstall, no download at runtime.
|
|
5
|
+
"use strict";
|
|
6
|
+
|
|
7
|
+
const { spawnSync } = require("node:child_process");
|
|
8
|
+
const path = require("node:path");
|
|
9
|
+
|
|
10
|
+
const pkg = `@neurobeat/nbt-${process.platform}-${process.arch}`;
|
|
11
|
+
const exe = process.platform === "win32" ? "nbt.exe" : "nbt";
|
|
12
|
+
|
|
13
|
+
let bin;
|
|
14
|
+
try {
|
|
15
|
+
// Resolve via the package's manifest, then join bin/<exe>. Robust against
|
|
16
|
+
// the binary not being declared as a package "bin".
|
|
17
|
+
bin = path.join(path.dirname(require.resolve(`${pkg}/package.json`)), "bin", exe);
|
|
18
|
+
} catch {
|
|
19
|
+
console.error(
|
|
20
|
+
`nbt: no prebuilt binary for ${process.platform}-${process.arch}.\n` +
|
|
21
|
+
`This usually means the optional platform package (${pkg}) was skipped.\n` +
|
|
22
|
+
`If you installed with --omit=optional / --no-optional, reinstall without it,\n` +
|
|
23
|
+
`or build from source: cargo install nbt-cli`
|
|
24
|
+
);
|
|
25
|
+
process.exit(1);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const result = spawnSync(bin, process.argv.slice(2), { stdio: "inherit" });
|
|
29
|
+
if (result.error) {
|
|
30
|
+
console.error(`nbt: failed to run ${bin}: ${result.error.message}`);
|
|
31
|
+
process.exit(1);
|
|
32
|
+
}
|
|
33
|
+
if (result.signal) {
|
|
34
|
+
process.kill(process.pid, result.signal);
|
|
35
|
+
}
|
|
36
|
+
process.exit(result.status === null ? 1 : result.status);
|
package/package.json
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "nbt-cli",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "nbt command-line tool (Rust binary distributed via npm)",
|
|
5
|
+
"bin": {
|
|
6
|
+
"nbt": "bin/nbt.js"
|
|
7
|
+
},
|
|
8
|
+
"files": [
|
|
9
|
+
"bin/nbt.js"
|
|
10
|
+
],
|
|
11
|
+
"engines": {
|
|
12
|
+
"node": ">=16"
|
|
13
|
+
},
|
|
14
|
+
"license": "MIT OR Apache-2.0",
|
|
15
|
+
"repository": {
|
|
16
|
+
"type": "git",
|
|
17
|
+
"url": "git+https://github.com/NeurobeatHQ/nbt-cli.git"
|
|
18
|
+
},
|
|
19
|
+
"optionalDependencies": {
|
|
20
|
+
"@neurobeat/nbt-darwin-arm64": "0.1.0",
|
|
21
|
+
"@neurobeat/nbt-darwin-x64": "0.1.0",
|
|
22
|
+
"@neurobeat/nbt-linux-x64": "0.1.0",
|
|
23
|
+
"@neurobeat/nbt-linux-arm64": "0.1.0",
|
|
24
|
+
"@neurobeat/nbt-win32-x64": "0.1.0"
|
|
25
|
+
}
|
|
26
|
+
}
|