rhx 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 ADDED
@@ -0,0 +1,27 @@
1
+ # rhx
2
+
3
+ Thin npm launcher for the `rhx` Python CLI.
4
+
5
+ ## Why this exists
6
+
7
+ `rhx` is implemented in Python. This package exists so agent workflows that prefer npm can run it via `npx`.
8
+
9
+ ## Usage
10
+
11
+ ```bash
12
+ npx rhx --help
13
+ npx rhx quote get AAPL
14
+ ```
15
+
16
+ The launcher tries:
17
+
18
+ 1. `uvx --from rhx rhx ...`
19
+ 2. `pipx run rhx rhx ...`
20
+ 3. `python3 -m pipx run rhx rhx ...`
21
+ 4. `python -m pipx run rhx rhx ...`
22
+
23
+ Set `RHX_PYPI_PACKAGE` to override the default PyPI package name:
24
+
25
+ ```bash
26
+ RHX_PYPI_PACKAGE=robinhood-cli-rhx npx rhx --help
27
+ ```
@@ -0,0 +1,49 @@
1
+ const { spawnSync } = require("node:child_process");
2
+
3
+ function buildLaunchers(pypiPackage, argv) {
4
+ return [
5
+ { command: "uvx", args: ["--from", pypiPackage, "rhx", ...argv] },
6
+ { command: "pipx", args: ["run", pypiPackage, "rhx", ...argv] },
7
+ { command: "python3", args: ["-m", "pipx", "run", pypiPackage, "rhx", ...argv] },
8
+ { command: "python", args: ["-m", "pipx", "run", pypiPackage, "rhx", ...argv] }
9
+ ];
10
+ }
11
+
12
+ function runWithLaunchers({
13
+ argv,
14
+ env = process.env,
15
+ spawn = spawnSync,
16
+ stderr = process.stderr
17
+ }) {
18
+ const pypiPackage = env.RHX_PYPI_PACKAGE || "rhx";
19
+ const launchers = buildLaunchers(pypiPackage, argv);
20
+
21
+ for (const launcher of launchers) {
22
+ const result = spawn(launcher.command, launcher.args, { stdio: "inherit", env });
23
+
24
+ if (result.error && result.error.code === "ENOENT") {
25
+ continue;
26
+ }
27
+ if (result.error) {
28
+ stderr.write(`rhx launcher failed via ${launcher.command}: ${result.error.message}\n`);
29
+ return 1;
30
+ }
31
+ if (typeof result.status === "number") {
32
+ return result.status;
33
+ }
34
+ if (result.signal) {
35
+ stderr.write(`rhx launcher terminated by signal ${result.signal}\n`);
36
+ return 1;
37
+ }
38
+ return 1;
39
+ }
40
+
41
+ stderr.write("Unable to find a Python tool launcher (uvx/pipx).\n");
42
+ stderr.write("Install uv or pipx, then retry `npx rhx --help`.\n");
43
+ return 1;
44
+ }
45
+
46
+ module.exports = {
47
+ buildLaunchers,
48
+ runWithLaunchers
49
+ };
package/bin/rhx.cjs ADDED
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env node
2
+
3
+ const { runWithLaunchers } = require("./rhx-lib.cjs");
4
+
5
+ const exitCode = runWithLaunchers({ argv: process.argv.slice(2) });
6
+ process.exit(exitCode);
package/package.json ADDED
@@ -0,0 +1,35 @@
1
+ {
2
+ "name": "rhx",
3
+ "version": "0.1.0",
4
+ "description": "npx launcher for the rhx Python CLI",
5
+ "license": "MIT",
6
+ "type": "commonjs",
7
+ "publishConfig": {
8
+ "access": "public"
9
+ },
10
+ "bin": {
11
+ "rhx": "bin/rhx.cjs"
12
+ },
13
+ "files": [
14
+ "bin",
15
+ "README.md"
16
+ ],
17
+ "engines": {
18
+ "node": ">=18"
19
+ },
20
+ "repository": {
21
+ "type": "git",
22
+ "url": "git+https://github.com/finlayi/robinhood-cli.git",
23
+ "directory": "npm"
24
+ },
25
+ "keywords": [
26
+ "robinhood",
27
+ "cli",
28
+ "python",
29
+ "npx",
30
+ "trading"
31
+ ],
32
+ "scripts": {
33
+ "test": "node --test test/**/*.test.cjs"
34
+ }
35
+ }