bincode-cli 1.0.2 → 1.0.3
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/bincode +29 -25
- package/package.json +2 -2
package/bin/bincode
CHANGED
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
import { spawnSync } from "child_process"
|
|
4
|
+
import { existsSync, realpathSync, readdirSync } from "fs"
|
|
5
|
+
import { dirname, join } from "path"
|
|
6
|
+
import { platform, arch } from "os"
|
|
7
|
+
import { fileURLToPath } from "url"
|
|
8
|
+
|
|
9
|
+
const __filename = fileURLToPath(import.meta.url)
|
|
10
|
+
const __dirname = dirname(__filename)
|
|
7
11
|
|
|
8
12
|
function run(target) {
|
|
9
|
-
const result =
|
|
13
|
+
const result = spawnSync(target, process.argv.slice(2), {
|
|
10
14
|
stdio: "inherit",
|
|
11
15
|
})
|
|
12
16
|
if (result.error) {
|
|
@@ -22,8 +26,8 @@ if (envPath) {
|
|
|
22
26
|
run(envPath)
|
|
23
27
|
}
|
|
24
28
|
|
|
25
|
-
const scriptPath =
|
|
26
|
-
const scriptDir =
|
|
29
|
+
const scriptPath = realpathSync(__filename)
|
|
30
|
+
const scriptDir = dirname(scriptPath)
|
|
27
31
|
|
|
28
32
|
const platformMap = {
|
|
29
33
|
darwin: "darwin",
|
|
@@ -36,48 +40,48 @@ const archMap = {
|
|
|
36
40
|
arm: "arm",
|
|
37
41
|
}
|
|
38
42
|
|
|
39
|
-
let
|
|
40
|
-
if (!
|
|
41
|
-
|
|
43
|
+
let platformName = platformMap[platform()]
|
|
44
|
+
if (!platformName) {
|
|
45
|
+
platformName = platform()
|
|
42
46
|
}
|
|
43
|
-
let
|
|
44
|
-
if (!
|
|
45
|
-
|
|
47
|
+
let archName = archMap[arch()]
|
|
48
|
+
if (!archName) {
|
|
49
|
+
archName = arch()
|
|
46
50
|
}
|
|
47
|
-
const base = "bincode-" +
|
|
48
|
-
const binary =
|
|
51
|
+
const base = "bincode-cli-" + platformName + "-" + archName
|
|
52
|
+
const binary = platformName === "windows" ? "bincode.exe" : "bincode"
|
|
49
53
|
|
|
50
54
|
function findBinary(startDir) {
|
|
51
55
|
// First, try to find binary in local package binaries directory
|
|
52
|
-
const localBinariesPath =
|
|
53
|
-
if (
|
|
56
|
+
const localBinariesPath = join(startDir, "..", "binaries", base, "bin", binary)
|
|
57
|
+
if (existsSync(localBinariesPath)) {
|
|
54
58
|
return localBinariesPath
|
|
55
59
|
}
|
|
56
60
|
|
|
57
61
|
// Try baseline variant if available
|
|
58
62
|
const baselineBase = base + "-baseline"
|
|
59
|
-
const baselinePath =
|
|
60
|
-
if (
|
|
63
|
+
const baselinePath = join(startDir, "..", "binaries", baselineBase, "bin", binary)
|
|
64
|
+
if (existsSync(baselinePath)) {
|
|
61
65
|
return baselinePath
|
|
62
66
|
}
|
|
63
67
|
|
|
64
68
|
// Fallback: search in node_modules (for backward compatibility)
|
|
65
69
|
let current = startDir
|
|
66
70
|
for (;;) {
|
|
67
|
-
const modules =
|
|
68
|
-
if (
|
|
69
|
-
const entries =
|
|
71
|
+
const modules = join(current, "node_modules")
|
|
72
|
+
if (existsSync(modules)) {
|
|
73
|
+
const entries = readdirSync(modules)
|
|
70
74
|
for (const entry of entries) {
|
|
71
75
|
if (!entry.startsWith(base)) {
|
|
72
76
|
continue
|
|
73
77
|
}
|
|
74
|
-
const candidate =
|
|
75
|
-
if (
|
|
78
|
+
const candidate = join(modules, entry, "bin", binary)
|
|
79
|
+
if (existsSync(candidate)) {
|
|
76
80
|
return candidate
|
|
77
81
|
}
|
|
78
82
|
}
|
|
79
83
|
}
|
|
80
|
-
const parent =
|
|
84
|
+
const parent = dirname(current)
|
|
81
85
|
if (parent === current) {
|
|
82
86
|
return
|
|
83
87
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://json.schemastore.org/package.json",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.3",
|
|
4
4
|
"name": "bincode-cli",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"private": false,
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"deploy": "echo 'Deploying application...' && bun run build && echo 'Deployment completed successfully'"
|
|
20
20
|
},
|
|
21
21
|
"bin": {
|
|
22
|
-
"bincode": "
|
|
22
|
+
"bincode": "bin/bincode"
|
|
23
23
|
},
|
|
24
24
|
"files": [
|
|
25
25
|
"bin",
|