relayfile 0.1.8 → 0.1.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.
Binary file
Binary file
Binary file
Binary file
package/package.json CHANGED
@@ -1,12 +1,18 @@
1
1
  {
2
2
  "name": "relayfile",
3
- "version": "0.1.8",
3
+ "version": "0.1.10",
4
4
  "description": "CLI for relayfile — real-time filesystem for humans and agents",
5
5
  "bin": {
6
6
  "relayfile": "scripts/run.js"
7
7
  },
8
+ "files": [
9
+ "bin",
10
+ "scripts"
11
+ ],
8
12
  "scripts": {
9
- "postinstall": "node scripts/install.js || true"
13
+ "build": "node scripts/build-binaries.js",
14
+ "prepack": "npm run build",
15
+ "postinstall": "node scripts/install.js"
10
16
  },
11
17
  "publishConfig": {
12
18
  "access": "public"
@@ -0,0 +1,51 @@
1
+ #!/usr/bin/env node
2
+
3
+ const { execFileSync } = require("child_process");
4
+ const fs = require("fs");
5
+ const path = require("path");
6
+
7
+ const repoRoot = path.resolve(__dirname, "..", "..", "..");
8
+ const packageRoot = path.resolve(__dirname, "..");
9
+ const binDir = path.join(packageRoot, "bin");
10
+
11
+ const targets = [
12
+ { goos: "darwin", goarch: "amd64" },
13
+ { goos: "darwin", goarch: "arm64" },
14
+ { goos: "linux", goarch: "amd64" },
15
+ { goos: "linux", goarch: "arm64" },
16
+ { goos: "windows", goarch: "amd64", ext: ".exe" },
17
+ { goos: "windows", goarch: "arm64", ext: ".exe" },
18
+ ];
19
+
20
+ fs.rmSync(binDir, { recursive: true, force: true });
21
+ fs.mkdirSync(binDir, { recursive: true });
22
+
23
+ for (const target of targets) {
24
+ const filename = `relayfile-cli-${target.goos}-${target.goarch}${target.ext || ""}`;
25
+ const output = path.join(binDir, filename);
26
+ console.log(`Building ${filename}`);
27
+ execFileSync(
28
+ "go",
29
+ [
30
+ "build",
31
+ "-trimpath",
32
+ "-ldflags=-s -w",
33
+ "-o",
34
+ output,
35
+ "./cmd/relayfile-cli",
36
+ ],
37
+ {
38
+ cwd: repoRoot,
39
+ env: {
40
+ ...process.env,
41
+ CGO_ENABLED: "0",
42
+ GOOS: target.goos,
43
+ GOARCH: target.goarch,
44
+ },
45
+ stdio: "inherit",
46
+ }
47
+ );
48
+ if (target.goos !== "windows") {
49
+ fs.chmodSync(output, 0o755);
50
+ }
51
+ }
@@ -1,6 +1,5 @@
1
1
  #!/usr/bin/env node
2
2
 
3
- const { execSync } = require("child_process");
4
3
  const fs = require("fs");
5
4
  const path = require("path");
6
5
  const os = require("os");
@@ -24,7 +23,7 @@ function getBinaryFilename() {
24
23
  return os.platform() === "win32" ? "relayfile.exe" : "relayfile";
25
24
  }
26
25
 
27
- function getDownloadUrl() {
26
+ function getPlatformSuffix() {
28
27
  const platform = PLATFORM_MAP[os.platform()];
29
28
  const arch = ARCH_MAP[os.arch()];
30
29
 
@@ -35,8 +34,25 @@ function getDownloadUrl() {
35
34
  process.exit(1);
36
35
  }
37
36
 
38
- const ext = platform === "windows" ? ".exe" : "";
39
- return `https://github.com/AgentWorkforce/relayfile/releases/download/v${VERSION}/relayfile-${platform}-${arch}${ext}`;
37
+ return `${platform}-${arch}`;
38
+ }
39
+
40
+ function getPackagedBinaryFilename() {
41
+ const suffix = getPlatformSuffix();
42
+ const ext = suffix.startsWith("windows-") ? ".exe" : "";
43
+ return `relayfile-cli-${suffix}${ext}`;
44
+ }
45
+
46
+ function getDownloadUrl() {
47
+ return `https://github.com/AgentWorkforce/relayfile/releases/download/v${VERSION}/${getPackagedBinaryFilename()}`;
48
+ }
49
+
50
+ function isSourceCheckout() {
51
+ const repoRoot = path.resolve(__dirname, "..", "..", "..");
52
+ return (
53
+ fs.existsSync(path.join(repoRoot, "go.mod")) &&
54
+ fs.existsSync(path.join(repoRoot, "cmd", "relayfile-cli"))
55
+ );
40
56
  }
41
57
 
42
58
  function download(url, dest) {
@@ -63,11 +79,33 @@ function download(url, dest) {
63
79
  }
64
80
 
65
81
  async function main() {
66
- const url = getDownloadUrl();
67
82
  const binPath = path.join(BIN_DIR, getBinaryFilename());
68
83
 
69
84
  fs.mkdirSync(BIN_DIR, { recursive: true });
70
85
 
86
+ if (fs.existsSync(binPath)) {
87
+ fs.chmodSync(binPath, 0o755);
88
+ console.log("relayfile binary already installed.");
89
+ return;
90
+ }
91
+
92
+ if (isSourceCheckout()) {
93
+ console.log(
94
+ "Skipping relayfile binary install in source checkout; run npm run build --workspace=packages/cli to build package binaries."
95
+ );
96
+ return;
97
+ }
98
+
99
+ const packagedBinPath = path.join(BIN_DIR, getPackagedBinaryFilename());
100
+
101
+ if (fs.existsSync(packagedBinPath)) {
102
+ fs.copyFileSync(packagedBinPath, binPath);
103
+ fs.chmodSync(binPath, 0o755);
104
+ console.log("relayfile installed from packaged binary.");
105
+ return;
106
+ }
107
+
108
+ const url = getDownloadUrl();
71
109
  console.log(`Downloading relayfile v${VERSION}...`);
72
110
  try {
73
111
  await download(url, binPath);
package/scripts/run.js CHANGED
@@ -5,12 +5,41 @@ const fs = require("fs");
5
5
  const os = require("os");
6
6
  const path = require("path");
7
7
 
8
- const binName = os.platform() === "win32" ? "relayfile.exe" : "relayfile";
9
- const binPath = path.join(__dirname, "..", "bin", binName);
8
+ const PLATFORM_MAP = {
9
+ darwin: "darwin",
10
+ linux: "linux",
11
+ win32: "windows",
12
+ };
10
13
 
11
- if (!fs.existsSync(binPath)) {
14
+ const ARCH_MAP = {
15
+ x64: "amd64",
16
+ arm64: "arm64",
17
+ };
18
+
19
+ function getPlatformBinaryName() {
20
+ const platform = PLATFORM_MAP[os.platform()];
21
+ const arch = ARCH_MAP[os.arch()];
22
+
23
+ if (!platform || !arch) {
24
+ return null;
25
+ }
26
+
27
+ const ext = platform === "windows" ? ".exe" : "";
28
+ return `relayfile-cli-${platform}-${arch}${ext}`;
29
+ }
30
+
31
+ const genericBinName = os.platform() === "win32" ? "relayfile.exe" : "relayfile";
32
+ const packagedBinName = getPlatformBinaryName();
33
+ const candidates = [
34
+ path.join(__dirname, "..", "bin", genericBinName),
35
+ packagedBinName && path.join(__dirname, "..", "bin", packagedBinName),
36
+ ].filter(Boolean);
37
+
38
+ const binPath = candidates.find((candidate) => fs.existsSync(candidate));
39
+
40
+ if (!binPath) {
12
41
  console.error(
13
- `relayfile binary not found at ${binPath}. Reinstall the package or run postinstall again.`
42
+ `relayfile binary not found for ${os.platform()} ${os.arch()}. Reinstall the package or run postinstall again.`
14
43
  );
15
44
  process.exit(1);
16
45
  }