@ahoo-wang/godex 0.0.2 → 0.0.5
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 +28 -1
- package/package.json +7 -7
- package/scripts/install.cjs +1 -1
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
|
|
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.
|
|
3
|
+
"version": "0.0.5",
|
|
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.
|
|
49
|
-
"@ahoo-wang/godex-darwin-x64": "0.0.
|
|
50
|
-
"@ahoo-wang/godex-linux-x64": "0.0.
|
|
51
|
-
"@ahoo-wang/godex-linux-arm64": "0.0.
|
|
52
|
-
"@ahoo-wang/godex-win32-x64": "0.0.
|
|
53
|
-
"@ahoo-wang/godex-win32-arm64": "0.0.
|
|
48
|
+
"@ahoo-wang/godex-darwin-arm64": "0.0.5",
|
|
49
|
+
"@ahoo-wang/godex-darwin-x64": "0.0.5",
|
|
50
|
+
"@ahoo-wang/godex-linux-x64": "0.0.5",
|
|
51
|
+
"@ahoo-wang/godex-linux-arm64": "0.0.5",
|
|
52
|
+
"@ahoo-wang/godex-win32-x64": "0.0.5",
|
|
53
|
+
"@ahoo-wang/godex-win32-arm64": "0.0.5"
|
|
54
54
|
},
|
|
55
55
|
"devDependencies": {
|
|
56
56
|
"@biomejs/biome": "^2.4.15",
|
package/scripts/install.cjs
CHANGED
|
@@ -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", {
|