@ahoo-wang/godex 0.0.2 → 0.0.4

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/bin/godex CHANGED
@@ -6,8 +6,19 @@ import { spawnSync } from "node:child_process";
6
6
  import { accessSync, constants } from "node:fs";
7
7
  import { join, dirname } from "node:path";
8
8
  import { fileURLToPath } from "node:url";
9
+ import { createRequire } from "node:module";
9
10
 
10
11
  const __dirname = dirname(fileURLToPath(import.meta.url));
12
+ const require = createRequire(import.meta.url);
13
+
14
+ function detectPlatform() {
15
+ const plat = process.platform;
16
+ const arch = process.arch;
17
+ if (plat === "win32") return `win32-${arch}`;
18
+ if (plat === "darwin") return `darwin-${arch}`;
19
+ if (plat === "linux") return `linux-${arch}`;
20
+ return null;
21
+ }
11
22
 
12
23
  function findBinary() {
13
24
  // Binary is copied here by postinstall
@@ -16,8 +27,24 @@ function findBinary() {
16
27
  accessSync(nextToWrapper, constants.X_OK);
17
28
  return nextToWrapper;
18
29
  } catch {
19
- // not found, try dev fallback
30
+ // not found
20
31
  }
32
+
33
+ // Try resolving from the optional dependency (works with npm, yarn, and pnpm)
34
+ const platform = detectPlatform();
35
+ if (platform) {
36
+ const binaryName = platform.startsWith("win32") ? "godex.exe" : "godex";
37
+ const pkgName = `@ahoo-wang/godex-${platform}`;
38
+ try {
39
+ const pkgRoot = dirname(require.resolve(`${pkgName}/package.json`));
40
+ const binary = join(pkgRoot, "bin", binaryName);
41
+ accessSync(binary, constants.X_OK);
42
+ return binary;
43
+ } catch {
44
+ // platform package not installed or binary missing
45
+ }
46
+ }
47
+
21
48
  // Dev fallback — when running from source without postinstall
22
49
  try {
23
50
  const devPath = join(__dirname, "..", "dist", "index.js");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ahoo-wang/godex",
3
- "version": "0.0.2",
3
+ "version": "0.0.4",
4
4
  "description": "Make every model a Codex engine through an OpenAI-compatible Responses API gateway",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -45,12 +45,12 @@
45
45
  "node": ">=18.0.0"
46
46
  },
47
47
  "optionalDependencies": {
48
- "@ahoo-wang/godex-darwin-arm64": "0.0.2",
49
- "@ahoo-wang/godex-darwin-x64": "0.0.2",
50
- "@ahoo-wang/godex-linux-x64": "0.0.2",
51
- "@ahoo-wang/godex-linux-arm64": "0.0.2",
52
- "@ahoo-wang/godex-win32-x64": "0.0.2",
53
- "@ahoo-wang/godex-win32-arm64": "0.0.2"
48
+ "@ahoo-wang/godex-darwin-arm64": "0.0.4",
49
+ "@ahoo-wang/godex-darwin-x64": "0.0.4",
50
+ "@ahoo-wang/godex-linux-x64": "0.0.4",
51
+ "@ahoo-wang/godex-linux-arm64": "0.0.4",
52
+ "@ahoo-wang/godex-win32-x64": "0.0.4",
53
+ "@ahoo-wang/godex-win32-arm64": "0.0.4"
54
54
  },
55
55
  "devDependencies": {
56
56
  "@biomejs/biome": "^2.4.15",
@@ -21,7 +21,7 @@ function detectPlatform() {
21
21
  function findBinary(pkgName, platform) {
22
22
  const binaryName = platform.startsWith("win32") ? "godex.exe" : "godex";
23
23
 
24
- // 1. Production: optional dep installed by npm
24
+ // 1. Production: optional dep installed by npm/pnpm/yarn
25
25
  try {
26
26
  const pkgRoot = path.dirname(
27
27
  require.resolve(pkgName + "/package.json", {