@rockboxd/cli 0.1.0 → 0.1.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/README.md CHANGED
@@ -17,13 +17,20 @@ rockboxd # start the daemon
17
17
  rockbox --help # control it from the CLI
18
18
  ```
19
19
 
20
+ Or without installing (runs the `rockboxd` daemon):
21
+
22
+ ```sh
23
+ npx @rockboxd/cli
24
+ ```
25
+
20
26
  ## How it works
21
27
 
22
28
  The `postinstall` script resolves the latest release of
23
29
  `tsirysndr/rockboxd`, downloads the tarball matching your platform, verifies
24
30
  its sha256 checksum against the published `.sha256` asset, and extracts the
25
31
  `rockbox` and `rockboxd` binaries into the package's `native/` directory. The
26
- `rockbox` / `rockboxd` commands are thin Node shims that exec those binaries.
32
+ `rockbox` / `rockboxd` commands are thin Node shims that exec those binaries;
33
+ `npx @rockboxd/cli` runs the daemon.
27
34
 
28
35
  ## Supported platforms
29
36
 
package/bin/run.js ADDED
@@ -0,0 +1,37 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * Single dispatcher for both bin entries. Both `rockbox` and `rockboxd`
4
+ * point here: pointing every bin at one file is what lets npx run
5
+ * `npx @rockboxd/cli` at all (it refuses packages with several distinct
6
+ * bin targets). The invoked name picks the native binary; anything else
7
+ * (including plain `npx @rockboxd/cli`) defaults to the rockboxd daemon.
8
+ */
9
+
10
+ "use strict";
11
+
12
+ const fs = require("fs");
13
+ const path = require("path");
14
+ const { spawn } = require("child_process");
15
+
16
+ const invoked = path.basename(process.argv[1] || "", ".js");
17
+ const name = invoked === "rockbox" ? "rockbox" : "rockboxd";
18
+
19
+ const bin = path.join(__dirname, "..", "native", name);
20
+ if (!fs.existsSync(bin)) {
21
+ console.error(
22
+ `@rockboxd/cli: ${name} binary not found. Reinstall the package ` +
23
+ "(the postinstall step downloads it), or run `node install.js` " +
24
+ "inside the package directory."
25
+ );
26
+ process.exit(1);
27
+ }
28
+
29
+ const child = spawn(bin, process.argv.slice(2), { stdio: "inherit" });
30
+ child.on("exit", (code, signal) => {
31
+ if (signal) process.kill(process.pid, signal);
32
+ process.exit(code === null ? 1 : code);
33
+ });
34
+ child.on("error", (err) => {
35
+ console.error(`@rockboxd/cli: failed to launch ${name}: ${err.message}`);
36
+ process.exit(1);
37
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rockboxd/cli",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "Rockbox Daemon — installs the rockbox CLI and rockboxd daemon binaries from GitHub releases",
5
5
  "license": "GPL-2.0",
6
6
  "repository": {
@@ -21,16 +21,15 @@
21
21
  "cli"
22
22
  ],
23
23
  "bin": {
24
- "rockbox": "bin/rockbox.js",
25
- "rockboxd": "bin/rockboxd.js"
24
+ "rockboxd": "bin/run.js",
25
+ "rockbox": "bin/run.js"
26
26
  },
27
27
  "scripts": {
28
28
  "postinstall": "node install.js"
29
29
  },
30
30
  "files": [
31
31
  "install.js",
32
- "bin/rockbox.js",
33
- "bin/rockboxd.js",
32
+ "bin/run.js",
34
33
  "README.md"
35
34
  ],
36
35
  "os": [
package/bin/rockbox.js DELETED
@@ -1,26 +0,0 @@
1
- #!/usr/bin/env node
2
- "use strict";
3
-
4
- const fs = require("fs");
5
- const path = require("path");
6
- const { spawn } = require("child_process");
7
-
8
- const bin = path.join(__dirname, "..", "native", "rockbox");
9
- if (!fs.existsSync(bin)) {
10
- console.error(
11
- "@rockboxd/cli: rockbox binary not found. Reinstall the package " +
12
- "(the postinstall step downloads it), or run `node install.js` " +
13
- "inside the package directory."
14
- );
15
- process.exit(1);
16
- }
17
-
18
- const child = spawn(bin, process.argv.slice(2), { stdio: "inherit" });
19
- child.on("exit", (code, signal) => {
20
- if (signal) process.kill(process.pid, signal);
21
- process.exit(code === null ? 1 : code);
22
- });
23
- child.on("error", (err) => {
24
- console.error(`@rockboxd/cli: failed to launch rockbox: ${err.message}`);
25
- process.exit(1);
26
- });
package/bin/rockboxd.js DELETED
@@ -1,26 +0,0 @@
1
- #!/usr/bin/env node
2
- "use strict";
3
-
4
- const fs = require("fs");
5
- const path = require("path");
6
- const { spawn } = require("child_process");
7
-
8
- const bin = path.join(__dirname, "..", "native", "rockboxd");
9
- if (!fs.existsSync(bin)) {
10
- console.error(
11
- "@rockboxd/cli: rockboxd binary not found. Reinstall the package " +
12
- "(the postinstall step downloads it), or run `node install.js` " +
13
- "inside the package directory."
14
- );
15
- process.exit(1);
16
- }
17
-
18
- const child = spawn(bin, process.argv.slice(2), { stdio: "inherit" });
19
- child.on("exit", (code, signal) => {
20
- if (signal) process.kill(process.pid, signal);
21
- process.exit(code === null ? 1 : code);
22
- });
23
- child.on("error", (err) => {
24
- console.error(`@rockboxd/cli: failed to launch rockboxd: ${err.message}`);
25
- process.exit(1);
26
- });