relayfile 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.
Files changed (2) hide show
  1. package/package.json +31 -0
  2. package/scripts/install.js +79 -0
package/package.json ADDED
@@ -0,0 +1,31 @@
1
+ {
2
+ "name": "relayfile",
3
+ "version": "0.1.0",
4
+ "description": "CLI for relayfile — real-time filesystem for humans and agents",
5
+ "bin": {
6
+ "relayfile": "bin/relayfile"
7
+ },
8
+ "scripts": {
9
+ "postinstall": "node scripts/install.js || true"
10
+ },
11
+ "publishConfig": {
12
+ "access": "public"
13
+ },
14
+ "repository": {
15
+ "type": "git",
16
+ "url": "git+https://github.com/AgentWorkforce/relayfile.git",
17
+ "directory": "packages/relayfile"
18
+ },
19
+ "license": "MIT",
20
+ "keywords": [
21
+ "relayfile",
22
+ "filesystem",
23
+ "sync",
24
+ "agent",
25
+ "collaboration",
26
+ "cli"
27
+ ],
28
+ "engines": {
29
+ "node": ">=18"
30
+ }
31
+ }
@@ -0,0 +1,79 @@
1
+ #!/usr/bin/env node
2
+
3
+ const { execSync } = require("child_process");
4
+ const fs = require("fs");
5
+ const path = require("path");
6
+ const os = require("os");
7
+ const https = require("https");
8
+
9
+ const VERSION = require("../package.json").version;
10
+ const BIN_DIR = path.join(__dirname, "..", "bin");
11
+ const BIN_PATH = path.join(BIN_DIR, "relayfile");
12
+
13
+ const PLATFORM_MAP = {
14
+ darwin: "darwin",
15
+ linux: "linux",
16
+ win32: "windows",
17
+ };
18
+
19
+ const ARCH_MAP = {
20
+ x64: "amd64",
21
+ arm64: "arm64",
22
+ };
23
+
24
+ function getDownloadUrl() {
25
+ const platform = PLATFORM_MAP[os.platform()];
26
+ const arch = ARCH_MAP[os.arch()];
27
+
28
+ if (!platform || !arch) {
29
+ console.error(
30
+ `Unsupported platform: ${os.platform()} ${os.arch()}`
31
+ );
32
+ process.exit(1);
33
+ }
34
+
35
+ const ext = platform === "windows" ? ".exe" : "";
36
+ return `https://github.com/AgentWorkforce/relayfile/releases/download/v${VERSION}/relayfile-${platform}-${arch}${ext}`;
37
+ }
38
+
39
+ function download(url, dest) {
40
+ return new Promise((resolve, reject) => {
41
+ const follow = (url) => {
42
+ https.get(url, (res) => {
43
+ if (res.statusCode >= 300 && res.statusCode < 400 && res.headers.location) {
44
+ follow(res.headers.location);
45
+ return;
46
+ }
47
+ if (res.statusCode !== 200) {
48
+ reject(new Error(`Download failed: HTTP ${res.statusCode} from ${url}`));
49
+ return;
50
+ }
51
+ const file = fs.createWriteStream(dest);
52
+ res.pipe(file);
53
+ file.on("finish", () => {
54
+ file.close(resolve);
55
+ });
56
+ }).on("error", reject);
57
+ };
58
+ follow(url);
59
+ });
60
+ }
61
+
62
+ async function main() {
63
+ const url = getDownloadUrl();
64
+
65
+ fs.mkdirSync(BIN_DIR, { recursive: true });
66
+
67
+ console.log(`Downloading relayfile v${VERSION}...`);
68
+ try {
69
+ await download(url, BIN_PATH);
70
+ fs.chmodSync(BIN_PATH, 0o755);
71
+ console.log("relayfile installed successfully.");
72
+ } catch (err) {
73
+ console.error(`Failed to download relayfile: ${err.message}`);
74
+ console.error("You can install manually from https://github.com/AgentWorkforce/relayfile/releases");
75
+ process.exit(1);
76
+ }
77
+ }
78
+
79
+ main();