@relay-core/cli 0.3.0 → 0.3.2
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/install.js +28 -11
- package/package.json +3 -2
package/README.md
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# @relay-core/cli
|
|
2
|
+
|
|
3
|
+
Standalone CLI and TUI for [RelayCore](https://github.com/relaycraft/relay-core) — a high-performance Rust traffic interception engine.
|
|
4
|
+
|
|
5
|
+
## Quick Start
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npx @relay-core/cli ca init && npx @relay-core/cli ca install
|
|
9
|
+
npx @relay-core/cli run --ui
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
The proxy listens on `127.0.0.1:8080`. Configure your system or browser to use it.
|
|
13
|
+
|
|
14
|
+
## Commands
|
|
15
|
+
|
|
16
|
+
| Command | Description |
|
|
17
|
+
|---------|-------------|
|
|
18
|
+
| `run` | Start the proxy server. Add `--ui` for TUI mode. |
|
|
19
|
+
| `ca {init,install,status,uninstall}` | Manage CA certificate for HTTPS interception |
|
|
20
|
+
| `metrics` | View runtime metrics (requires `--api-port`) |
|
|
21
|
+
|
|
22
|
+
For a full command reference: `npx @relay-core/cli run --help`
|
|
23
|
+
|
|
24
|
+
## License
|
|
25
|
+
|
|
26
|
+
MIT
|
package/install.js
CHANGED
|
@@ -1,13 +1,22 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
const { execSync } = require("child_process");
|
|
3
|
-
const { existsSync, mkdirSync } = require("fs");
|
|
3
|
+
const { existsSync, mkdirSync, readFileSync } = require("fs");
|
|
4
4
|
const { createWriteStream } = require("fs");
|
|
5
5
|
const { pipeline } = require("stream/promises");
|
|
6
6
|
const { join } = require("path");
|
|
7
7
|
const https = require("https");
|
|
8
8
|
|
|
9
|
+
const getVersion = () => {
|
|
10
|
+
try {
|
|
11
|
+
const pkg = JSON.parse(readFileSync(join(__dirname, "package.json"), "utf-8"));
|
|
12
|
+
return pkg.version;
|
|
13
|
+
} catch {
|
|
14
|
+
return "0.3.0";
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
|
|
9
18
|
const PACKAGE = process.env.npm_package_name || "@relay-core/cli";
|
|
10
|
-
const VERSION =
|
|
19
|
+
const VERSION = getVersion();
|
|
11
20
|
|
|
12
21
|
// Map (os, arch) → GitHub release target
|
|
13
22
|
function getTarget() {
|
|
@@ -17,11 +26,12 @@ function getTarget() {
|
|
|
17
26
|
"darwin-x64": "x86_64-apple-darwin",
|
|
18
27
|
"darwin-arm64": "aarch64-apple-darwin",
|
|
19
28
|
"linux-x64": "x86_64-unknown-linux-gnu",
|
|
29
|
+
"win32-x64": "x86_64-pc-windows-msvc",
|
|
20
30
|
};
|
|
21
31
|
const key = `${os}-${arch}`;
|
|
22
32
|
const target = map[key];
|
|
23
33
|
if (!target) {
|
|
24
|
-
console.error(`Unsupported platform: ${key}.
|
|
34
|
+
console.error(`Unsupported platform: ${key}. Supported: macOS (x64/arm64), Linux (x64), Windows (x64).`);
|
|
25
35
|
process.exit(1);
|
|
26
36
|
}
|
|
27
37
|
return target;
|
|
@@ -31,6 +41,12 @@ function getBinaryName() {
|
|
|
31
41
|
return PACKAGE.endsWith("mcp") ? "relay-core-probe" : "relay-core-cli";
|
|
32
42
|
}
|
|
33
43
|
|
|
44
|
+
function getBinaryPath(binaryName) {
|
|
45
|
+
return process.platform === "win32"
|
|
46
|
+
? join(__dirname, "bin", binaryName + ".exe")
|
|
47
|
+
: join(__dirname, "bin", binaryName);
|
|
48
|
+
}
|
|
49
|
+
|
|
34
50
|
async function download(url, dest) {
|
|
35
51
|
console.log(`Downloading ${url} → ${dest}`);
|
|
36
52
|
return new Promise((resolve, reject) => {
|
|
@@ -54,8 +70,9 @@ async function download(url, dest) {
|
|
|
54
70
|
(async () => {
|
|
55
71
|
try {
|
|
56
72
|
const binDir = join(__dirname, "bin");
|
|
73
|
+
mkdirSync(binDir, { recursive: true });
|
|
57
74
|
const binaryName = getBinaryName();
|
|
58
|
-
const binaryPath =
|
|
75
|
+
const binaryPath = getBinaryPath(binaryName);
|
|
59
76
|
|
|
60
77
|
// Skip download if binary already exists (re-install)
|
|
61
78
|
if (existsSync(binaryPath)) {
|
|
@@ -64,17 +81,17 @@ async function download(url, dest) {
|
|
|
64
81
|
}
|
|
65
82
|
|
|
66
83
|
const target = getTarget();
|
|
67
|
-
const
|
|
68
|
-
const
|
|
84
|
+
const ext = process.platform === "win32" ? "zip" : "tar.gz";
|
|
85
|
+
const url = `https://github.com/relaycraft/relay-core/releases/download/v${VERSION}/${binaryName}-${target}.${ext}`;
|
|
86
|
+
const archivePath = join(binDir, `${binaryName}.${ext}`);
|
|
69
87
|
|
|
70
|
-
mkdirSync(binDir, { recursive: true });
|
|
71
88
|
await download(url, archivePath);
|
|
72
89
|
|
|
73
90
|
console.log("Extracting...");
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
91
|
+
if (process.platform === "win32") {
|
|
92
|
+
execSync(`powershell -Command "Expand-Archive -Path '${archivePath}' -DestinationPath '${binDir}' -Force"`, { stdio: "inherit" });
|
|
93
|
+
} else {
|
|
94
|
+
execSync(`tar xzf ${archivePath} -C ${binDir}`, { stdio: "inherit" });
|
|
78
95
|
execSync(`chmod +x ${binaryPath}`, { stdio: "inherit" });
|
|
79
96
|
}
|
|
80
97
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@relay-core/cli",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.2",
|
|
4
4
|
"description": "RelayCore CLI — high-performance Rust traffic interception proxy with TUI",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": "github:relaycraft/relay-core",
|
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
},
|
|
10
10
|
"files": [
|
|
11
11
|
"install.js",
|
|
12
|
+
"README.md",
|
|
12
13
|
"bin/"
|
|
13
14
|
],
|
|
14
15
|
"scripts": {
|
|
@@ -17,6 +18,6 @@
|
|
|
17
18
|
"engines": {
|
|
18
19
|
"node": ">=18"
|
|
19
20
|
},
|
|
20
|
-
"os": ["darwin", "linux"],
|
|
21
|
+
"os": ["darwin", "linux", "win32"],
|
|
21
22
|
"cpu": ["x64", "arm64"]
|
|
22
23
|
}
|