@relay-core/cli 0.3.7 → 0.3.10
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 +21 -12
- package/bin/relay-core +13 -3
- package/lib/resolve-binary.js +25 -0
- package/package.json +21 -8
- package/install.js +0 -89
package/README.md
CHANGED
|
@@ -1,25 +1,34 @@
|
|
|
1
1
|
# @relay-core/cli
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
CLI and TUI for **[RelayCore](https://relaycore.dev)** — a high-performance traffic interception proxy (MITM, rules, HAR, scripts).
|
|
4
4
|
|
|
5
|
-
##
|
|
5
|
+
## Install
|
|
6
6
|
|
|
7
7
|
```bash
|
|
8
|
-
|
|
9
|
-
npx @relay-core/cli
|
|
8
|
+
npm i -g @relay-core/cli
|
|
9
|
+
# or: npx @relay-core/cli --help
|
|
10
10
|
```
|
|
11
11
|
|
|
12
|
-
|
|
12
|
+
- **Node** ≥ 18
|
|
13
|
+
- **Platforms:** macOS (x64, arm64), Linux (x64, arm64), Windows (x64)
|
|
14
|
+
- Native binaries ship via `@relay-core/binaries-*` on the npm registry (proxy/mirror friendly)
|
|
13
15
|
|
|
14
|
-
##
|
|
16
|
+
## Quick start
|
|
15
17
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
18
|
+
```bash
|
|
19
|
+
relay-core ca init && relay-core ca install # HTTPS interception
|
|
20
|
+
relay-core run --ui # proxy @ 127.0.0.1:8080
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
Point your system or browser at the proxy port. Full CLI reference: `relay-core run --help`.
|
|
24
|
+
|
|
25
|
+
## Links
|
|
21
26
|
|
|
22
|
-
|
|
27
|
+
| | |
|
|
28
|
+
|---|---|
|
|
29
|
+
| Docs | [relaycore.dev](https://relaycore.dev) |
|
|
30
|
+
| MCP | [`@relay-core/mcp`](https://www.npmjs.com/package/@relay-core/mcp) |
|
|
31
|
+
| Source | [github.com/relaycraft/relay-core](https://github.com/relaycraft/relay-core) |
|
|
23
32
|
|
|
24
33
|
## License
|
|
25
34
|
|
package/bin/relay-core
CHANGED
|
@@ -1,6 +1,16 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
|
|
2
4
|
const { spawnSync } = require("child_process");
|
|
3
|
-
const
|
|
4
|
-
|
|
5
|
-
|
|
5
|
+
const { resolveBinary } = require("../lib/resolve-binary");
|
|
6
|
+
|
|
7
|
+
let binary;
|
|
8
|
+
try {
|
|
9
|
+
binary = resolveBinary("relay-core-cli");
|
|
10
|
+
} catch (err) {
|
|
11
|
+
console.error(err.message);
|
|
12
|
+
process.exit(1);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const result = spawnSync(binary, process.argv.slice(2), { stdio: "inherit" });
|
|
6
16
|
process.exit(result.status ?? 1);
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Resolve a RelayCore native binary from the matching @relay-core/binaries-* optional dependency.
|
|
5
|
+
* @param {string} name - e.g. "relay-core-cli" or "relay-core-probe"
|
|
6
|
+
* @returns {string} Absolute path to the binary
|
|
7
|
+
*/
|
|
8
|
+
function resolveBinary(name) {
|
|
9
|
+
const platformPkg = `@relay-core/binaries-${process.platform}-${process.arch}`;
|
|
10
|
+
const file = process.platform === "win32" ? `${name}.exe` : name;
|
|
11
|
+
try {
|
|
12
|
+
return require.resolve(`${platformPkg}/bin/${file}`);
|
|
13
|
+
} catch (err) {
|
|
14
|
+
if (process.env.RELAY_CORE_DEBUG) {
|
|
15
|
+
console.error("[relay-core] resolveBinary:", err);
|
|
16
|
+
}
|
|
17
|
+
throw new Error(
|
|
18
|
+
`RelayCore native binary "${name}" is not installed for ${process.platform}-${process.arch}.\n` +
|
|
19
|
+
`Expected optional package ${platformPkg} (install or upgrade from the npm registry).\n` +
|
|
20
|
+
`Supported: macOS (x64, arm64), Linux (x64, arm64), Windows (x64). See https://relaycore.dev`
|
|
21
|
+
);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
module.exports = { resolveBinary };
|
package/package.json
CHANGED
|
@@ -1,23 +1,36 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@relay-core/cli",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.10",
|
|
4
4
|
"description": "RelayCore CLI — high-performance Rust traffic interception proxy with TUI",
|
|
5
5
|
"license": "MIT",
|
|
6
|
+
"homepage": "https://relaycore.dev",
|
|
7
|
+
"bugs": "https://github.com/relaycraft/relay-core/issues",
|
|
6
8
|
"repository": "github:relaycraft/relay-core",
|
|
7
9
|
"bin": {
|
|
8
10
|
"relay-core": "./bin/relay-core"
|
|
9
11
|
},
|
|
10
12
|
"files": [
|
|
11
|
-
"
|
|
12
|
-
"
|
|
13
|
-
"
|
|
13
|
+
"bin/",
|
|
14
|
+
"lib/",
|
|
15
|
+
"README.md"
|
|
14
16
|
],
|
|
15
|
-
"
|
|
16
|
-
"
|
|
17
|
+
"optionalDependencies": {
|
|
18
|
+
"@relay-core/binaries-darwin-arm64": "0.3.10",
|
|
19
|
+
"@relay-core/binaries-darwin-x64": "0.3.10",
|
|
20
|
+
"@relay-core/binaries-linux-arm64": "0.3.10",
|
|
21
|
+
"@relay-core/binaries-linux-x64": "0.3.10",
|
|
22
|
+
"@relay-core/binaries-win32-x64": "0.3.10"
|
|
17
23
|
},
|
|
18
24
|
"engines": {
|
|
19
25
|
"node": ">=18"
|
|
20
26
|
},
|
|
21
|
-
"os": [
|
|
22
|
-
|
|
27
|
+
"os": [
|
|
28
|
+
"darwin",
|
|
29
|
+
"linux",
|
|
30
|
+
"win32"
|
|
31
|
+
],
|
|
32
|
+
"cpu": [
|
|
33
|
+
"x64",
|
|
34
|
+
"arm64"
|
|
35
|
+
]
|
|
23
36
|
}
|
package/install.js
DELETED
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
"use strict";
|
|
3
|
-
|
|
4
|
-
const { execSync } = require("child_process");
|
|
5
|
-
const { existsSync, mkdirSync, readFileSync, createWriteStream } = require("fs");
|
|
6
|
-
const { pipeline } = require("stream/promises");
|
|
7
|
-
const { join } = require("path");
|
|
8
|
-
const https = require("https");
|
|
9
|
-
|
|
10
|
-
const PKG_DIR = join(__dirname, "..");
|
|
11
|
-
const BINARY_NAME = "relay-core-cli";
|
|
12
|
-
|
|
13
|
-
function getVersion() {
|
|
14
|
-
try {
|
|
15
|
-
return JSON.parse(readFileSync(join(PKG_DIR, "package.json"), "utf-8")).version;
|
|
16
|
-
} catch { return "0.3.0"; }
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
function getTarget() {
|
|
20
|
-
const map = {
|
|
21
|
-
"darwin-x64": "x86_64-apple-darwin",
|
|
22
|
-
"darwin-arm64": "aarch64-apple-darwin",
|
|
23
|
-
"linux-x64": "x86_64-unknown-linux-gnu",
|
|
24
|
-
"linux-arm64": "aarch64-unknown-linux-gnu",
|
|
25
|
-
"win32-x64": "x86_64-pc-windows-msvc",
|
|
26
|
-
};
|
|
27
|
-
const target = map[`${process.platform}-${process.arch}`];
|
|
28
|
-
if (!target) {
|
|
29
|
-
console.error(`Unsupported platform: ${process.platform}-${process.arch}. macOS/Linux/Windows (x64/arm64) supported.`);
|
|
30
|
-
process.exit(1);
|
|
31
|
-
}
|
|
32
|
-
return target;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
async function download(url, dest) {
|
|
36
|
-
console.log(`Downloading ${url} → ${dest}`);
|
|
37
|
-
return new Promise((resolve, reject) => {
|
|
38
|
-
const file = createWriteStream(dest);
|
|
39
|
-
https.get(url, (response) => {
|
|
40
|
-
if (response.statusCode === 302 || response.statusCode === 301) {
|
|
41
|
-
https.get(response.headers.location, (rr) => pipeline(rr, file).then(resolve, reject));
|
|
42
|
-
return;
|
|
43
|
-
}
|
|
44
|
-
if (response.statusCode !== 200) return reject(new Error(`HTTP ${response.statusCode}`));
|
|
45
|
-
pipeline(response, file).then(resolve, reject);
|
|
46
|
-
}).on("error", reject);
|
|
47
|
-
});
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
(async () => {
|
|
51
|
-
try {
|
|
52
|
-
const binDir = join(PKG_DIR, "bin");
|
|
53
|
-
mkdirSync(binDir, { recursive: true });
|
|
54
|
-
|
|
55
|
-
const ext = process.platform === "win32" ? ".exe" : "";
|
|
56
|
-
const binaryPath = join(binDir, BINARY_NAME + ext);
|
|
57
|
-
const version = getVersion();
|
|
58
|
-
|
|
59
|
-
if (existsSync(binaryPath)) {
|
|
60
|
-
try {
|
|
61
|
-
const out = execSync(`"${binaryPath}" --version`, { encoding: "utf-8", timeout: 5000 }).trim();
|
|
62
|
-
if (out.includes(version)) {
|
|
63
|
-
console.log(`${BINARY_NAME} v${version} already installed.`);
|
|
64
|
-
return;
|
|
65
|
-
}
|
|
66
|
-
console.log(`Installed ${out}, updating to v${version}...`);
|
|
67
|
-
} catch { console.log("Re-downloading..."); }
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
const target = getTarget();
|
|
71
|
-
const archiveExt = process.platform === "win32" ? "zip" : "tar.gz";
|
|
72
|
-
const url = `https://github.com/relaycraft/relay-core/releases/download/v${version}/${BINARY_NAME}-${target}.${archiveExt}`;
|
|
73
|
-
const archivePath = join(binDir, `${BINARY_NAME}.${archiveExt}`);
|
|
74
|
-
|
|
75
|
-
await download(url, archivePath);
|
|
76
|
-
console.log("Extracting...");
|
|
77
|
-
|
|
78
|
-
if (process.platform === "win32") {
|
|
79
|
-
execSync(`powershell -Command "Expand-Archive -Path '${archivePath}' -DestinationPath '${binDir}' -Force"`, { stdio: "inherit" });
|
|
80
|
-
} else {
|
|
81
|
-
execSync(`tar xzf ${archivePath} -C ${binDir}`, { stdio: "inherit" });
|
|
82
|
-
execSync(`chmod +x ${binaryPath}`, { stdio: "inherit" });
|
|
83
|
-
}
|
|
84
|
-
console.log(`${BINARY_NAME} v${version} installed.`);
|
|
85
|
-
} catch (err) {
|
|
86
|
-
console.error("Install failed:", err.message);
|
|
87
|
-
process.exit(1);
|
|
88
|
-
}
|
|
89
|
-
})();
|