@choonkeat/agent-reverse-proxy 0.1.0 → 0.1.1

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.
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
 
3
- import { spawnSync } from "child_process";
3
+ import { spawnSync, execFileSync } from "child_process";
4
4
  import { createRequire } from "module";
5
5
  import { existsSync, chmodSync } from "fs";
6
6
  import { dirname, join } from "path";
@@ -34,27 +34,50 @@ if (!platform || !arch) {
34
34
  const pkgName = `@choonkeat/agent-reverse-proxy-${platform}-${arch}`;
35
35
  const binName = process.platform === "win32" ? "agent-reverse-proxy.exe" : "agent-reverse-proxy";
36
36
 
37
- let binPath;
38
- try {
39
- const pkgDir = dirname(require.resolve(`${pkgName}/package.json`));
40
- binPath = join(pkgDir, "bin", binName);
41
- } catch {
42
- // Fallback: check for local build in npm-platforms/ (development)
37
+ function resolveBinPath() {
38
+ try {
39
+ const pkgDir = dirname(require.resolve(`${pkgName}/package.json`));
40
+ return join(pkgDir, "bin", binName);
41
+ } catch {
42
+ return null;
43
+ }
44
+ }
45
+
46
+ let binPath = resolveBinPath();
47
+
48
+ // optionalDependencies may not be installed (e.g. npx) — install on demand
49
+ if (!binPath) {
50
+ try {
51
+ console.error(`Installing ${pkgName}...`);
52
+ execFileSync("npm", ["install", "--no-save", pkgName], {
53
+ stdio: "inherit",
54
+ cwd: join(__dirname, ".."),
55
+ });
56
+ binPath = resolveBinPath();
57
+ } catch {
58
+ // ignore — fall through to local/error path
59
+ }
60
+ }
61
+
62
+ // Fallback: check for local build in npm-platforms/ (development)
63
+ if (!binPath) {
43
64
  const localPath = join(__dirname, "..", "npm-platforms", `${platform}-${arch}`, "bin", binName);
44
65
  if (existsSync(localPath)) {
45
66
  binPath = localPath;
46
- } else {
47
- console.error(
48
- `Could not find package ${pkgName}.\n` +
49
- `Make sure it is installed — this usually means your platform is supported\n` +
50
- `but the optional dependency was not installed.\n\n` +
51
- `Try: npm install ${pkgName}\n` +
52
- `Or run: npx @choonkeat/agent-reverse-proxy`
53
- );
54
- process.exit(1);
55
67
  }
56
68
  }
57
69
 
70
+ if (!binPath) {
71
+ console.error(
72
+ `Could not find package ${pkgName}.\n` +
73
+ `Make sure it is installed — this usually means your platform is supported\n` +
74
+ `but the optional dependency was not installed.\n\n` +
75
+ `Try: npm install ${pkgName}\n` +
76
+ `Or run: npx @choonkeat/agent-reverse-proxy`
77
+ );
78
+ process.exit(1);
79
+ }
80
+
58
81
  if (!existsSync(binPath)) {
59
82
  console.error(`Binary not found at ${binPath}`);
60
83
  process.exit(1);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@choonkeat/agent-reverse-proxy",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "MCP server with reverse proxy and debug instrumentation for app preview",
5
5
  "type": "module",
6
6
  "bin": {
@@ -16,11 +16,11 @@
16
16
  },
17
17
  "license": "MIT",
18
18
  "optionalDependencies": {
19
- "@choonkeat/agent-reverse-proxy-linux-x64": "0.1.0",
20
- "@choonkeat/agent-reverse-proxy-linux-arm64": "0.1.0",
21
- "@choonkeat/agent-reverse-proxy-darwin-x64": "0.1.0",
22
- "@choonkeat/agent-reverse-proxy-darwin-arm64": "0.1.0",
23
- "@choonkeat/agent-reverse-proxy-win32-x64": "0.1.0",
24
- "@choonkeat/agent-reverse-proxy-win32-arm64": "0.1.0"
19
+ "@choonkeat/agent-reverse-proxy-linux-x64": "0.1.1",
20
+ "@choonkeat/agent-reverse-proxy-linux-arm64": "0.1.1",
21
+ "@choonkeat/agent-reverse-proxy-darwin-x64": "0.1.1",
22
+ "@choonkeat/agent-reverse-proxy-darwin-arm64": "0.1.1",
23
+ "@choonkeat/agent-reverse-proxy-win32-x64": "0.1.1",
24
+ "@choonkeat/agent-reverse-proxy-win32-arm64": "0.1.1"
25
25
  }
26
26
  }