dfcode 3.3.17 → 3.3.18
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/dfcode +25 -128
- package/package.json +23 -14
- package/platform.cjs +126 -0
- package/postinstall.mjs +30 -114
package/bin/dfcode
CHANGED
|
@@ -33,19 +33,21 @@ function run(target) {
|
|
|
33
33
|
|
|
34
34
|
function resetTerminal() {
|
|
35
35
|
if (!process.stdout.isTTY && process.env.DFCODE_FORCE_TERMINAL_RESET !== "1") return
|
|
36
|
-
process.stdout.write(
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
36
|
+
process.stdout.write(
|
|
37
|
+
[
|
|
38
|
+
"\x1b[0m",
|
|
39
|
+
"\x1b[?25h",
|
|
40
|
+
"\x1b[?1000l",
|
|
41
|
+
"\x1b[?1002l",
|
|
42
|
+
"\x1b[?1003l",
|
|
43
|
+
"\x1b[?1004l",
|
|
44
|
+
"\x1b[?1005l",
|
|
45
|
+
"\x1b[?1006l",
|
|
46
|
+
"\x1b[?1015l",
|
|
47
|
+
"\x1b[?2004l",
|
|
48
|
+
"\x1b[?1049l",
|
|
49
|
+
].join(""),
|
|
50
|
+
)
|
|
49
51
|
}
|
|
50
52
|
|
|
51
53
|
const envPath = process.env.DFCODE_BIN_PATH
|
|
@@ -56,124 +58,19 @@ if (envPath) {
|
|
|
56
58
|
const scriptPath = fs.realpathSync(__filename)
|
|
57
59
|
const scriptDir = path.dirname(scriptPath)
|
|
58
60
|
|
|
59
|
-
const
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
const archMap = {
|
|
65
|
-
x64: "x64",
|
|
66
|
-
arm64: "arm64",
|
|
67
|
-
arm: "arm",
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
const platformName = process.env.DFCODE_TEST_PLATFORM || os.platform()
|
|
71
|
-
const archName = process.env.DFCODE_TEST_ARCH || os.arch()
|
|
72
|
-
const platform = platformMap[platformName] || platformName
|
|
73
|
-
const arch = archMap[archName] || archName
|
|
74
|
-
const base = "dfcode-" + platform + "-" + arch
|
|
75
|
-
const binary = platform === "windows" ? "dfcode.exe" : "dfcode"
|
|
76
|
-
|
|
77
|
-
function supportsAvx2() {
|
|
78
|
-
if (arch !== "x64") return false
|
|
79
|
-
|
|
80
|
-
const override = process.env.DFCODE_TEST_AVX2
|
|
81
|
-
if (override === "1" || override === "true") return true
|
|
82
|
-
if (override === "0" || override === "false") return false
|
|
83
|
-
|
|
84
|
-
if (platform === "linux") {
|
|
85
|
-
const result = childProcess.spawnSync("cat", ["/proc/cpuinfo"], { encoding: "utf8" })
|
|
86
|
-
return result.status === 0 && /(^|\s)avx2(\s|$)/i.test(result.stdout || "")
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
if (platform === "darwin") {
|
|
90
|
-
const result = childProcess.spawnSync("sysctl", ["-n", "hw.optional.avx2_0"], {
|
|
91
|
-
encoding: "utf8",
|
|
92
|
-
timeout: 1500,
|
|
93
|
-
})
|
|
94
|
-
if (result.status !== 0) return false
|
|
95
|
-
return (result.stdout || "").trim() === "1"
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
if (platform === "windows") {
|
|
99
|
-
const command =
|
|
100
|
-
'(Add-Type -MemberDefinition "[DllImport(""kernel32.dll"")] public static extern bool IsProcessorFeaturePresent(int ProcessorFeature);" -Name Kernel32 -Namespace Win32 -PassThru)::IsProcessorFeaturePresent(40)'
|
|
101
|
-
|
|
102
|
-
for (const executable of ["powershell.exe", "pwsh.exe", "pwsh", "powershell"]) {
|
|
103
|
-
const result = childProcess.spawnSync(executable, ["-NoProfile", "-NonInteractive", "-Command", command], {
|
|
104
|
-
encoding: "utf8",
|
|
105
|
-
timeout: 3000,
|
|
106
|
-
windowsHide: true,
|
|
107
|
-
})
|
|
108
|
-
if (result.status !== 0 || result.error) continue
|
|
109
|
-
const output = (result.stdout || "").trim().toLowerCase()
|
|
110
|
-
if (output === "true" || output === "1") return true
|
|
111
|
-
if (output === "false" || output === "0") return false
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
return false
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
function isMusl() {
|
|
119
|
-
if (platform !== "linux") return false
|
|
120
|
-
|
|
121
|
-
const override = process.env.DFCODE_TEST_LIBC?.toLowerCase()
|
|
122
|
-
if (override) return override === "musl"
|
|
123
|
-
|
|
124
|
-
if (fs.existsSync("/etc/alpine-release")) return true
|
|
125
|
-
|
|
126
|
-
const result = childProcess.spawnSync("ldd", ["--version"], { encoding: "utf8" })
|
|
127
|
-
return `${result.stdout || ""}${result.stderr || ""}`.toLowerCase().includes("musl")
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
function packageNames() {
|
|
131
|
-
const baseline = arch === "x64" && !supportsAvx2()
|
|
132
|
-
|
|
133
|
-
if (platform === "linux") {
|
|
134
|
-
if (isMusl()) {
|
|
135
|
-
if (arch === "x64")
|
|
136
|
-
return baseline ? [`${base}-baseline-musl`] : [`${base}-musl`, `${base}-baseline-musl`]
|
|
137
|
-
return [`${base}-musl`]
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
if (arch === "x64") return baseline ? [`${base}-baseline`] : [base, `${base}-baseline`]
|
|
141
|
-
return [base]
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
if (arch === "x64") return baseline ? [`${base}-baseline`] : [base, `${base}-baseline`]
|
|
145
|
-
return [base]
|
|
146
|
-
}
|
|
61
|
+
const resolver = require(
|
|
62
|
+
fs.existsSync(path.join(scriptDir, "../platform.cjs"))
|
|
63
|
+
? path.join(scriptDir, "../platform.cjs")
|
|
64
|
+
: path.join(scriptDir, "../script/platform.cjs"),
|
|
65
|
+
)
|
|
147
66
|
|
|
148
67
|
function findBinary(startDir) {
|
|
149
|
-
|
|
150
|
-
const names = packageNames()
|
|
151
|
-
for (;;) {
|
|
152
|
-
const modules = path.join(current, "node_modules")
|
|
153
|
-
if (fs.existsSync(modules)) {
|
|
154
|
-
for (const name of names) {
|
|
155
|
-
const candidate = path.join(modules, name, "bin", binary)
|
|
156
|
-
if (fs.existsSync(candidate)) {
|
|
157
|
-
return candidate
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
const parent = path.dirname(current)
|
|
162
|
-
if (parent === current) {
|
|
163
|
-
return
|
|
164
|
-
}
|
|
165
|
-
current = parent
|
|
166
|
-
}
|
|
68
|
+
return resolver.findBinary(startDir).binaryPath
|
|
167
69
|
}
|
|
168
70
|
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
packageNames().join('" or "') +
|
|
174
|
-
'" package',
|
|
175
|
-
)
|
|
71
|
+
try {
|
|
72
|
+
run(findBinary(scriptDir))
|
|
73
|
+
} catch (error) {
|
|
74
|
+
console.error(error.message)
|
|
176
75
|
process.exit(1)
|
|
177
76
|
}
|
|
178
|
-
|
|
179
|
-
run(resolved)
|
package/package.json
CHANGED
|
@@ -1,23 +1,32 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dfcode",
|
|
3
|
+
"version": "3.3.18",
|
|
4
|
+
"license": "MIT",
|
|
3
5
|
"bin": {
|
|
4
6
|
"dfcode": "./bin/dfcode"
|
|
5
7
|
},
|
|
8
|
+
"engines": {
|
|
9
|
+
"node": ">=18"
|
|
10
|
+
},
|
|
6
11
|
"scripts": {
|
|
7
|
-
"postinstall": "
|
|
12
|
+
"postinstall": "node ./postinstall.mjs"
|
|
8
13
|
},
|
|
9
|
-
"
|
|
14
|
+
"files": [
|
|
15
|
+
"bin/dfcode",
|
|
16
|
+
"postinstall.mjs",
|
|
17
|
+
"platform.cjs"
|
|
18
|
+
],
|
|
10
19
|
"optionalDependencies": {
|
|
11
|
-
"dfcode-
|
|
12
|
-
"dfcode-
|
|
13
|
-
"dfcode-
|
|
14
|
-
"dfcode-linux-arm64
|
|
15
|
-
"dfcode-linux-
|
|
16
|
-
"dfcode-linux-x64
|
|
17
|
-
"dfcode-
|
|
18
|
-
"dfcode-
|
|
19
|
-
"dfcode-
|
|
20
|
-
"dfcode-windows-x64": "3.3.
|
|
21
|
-
"dfcode-windows-x64-baseline": "3.3.
|
|
20
|
+
"dfcode-darwin-arm64": "3.3.18",
|
|
21
|
+
"dfcode-darwin-x64": "3.3.18",
|
|
22
|
+
"dfcode-darwin-x64-baseline": "3.3.18",
|
|
23
|
+
"dfcode-linux-arm64": "3.3.18",
|
|
24
|
+
"dfcode-linux-arm64-musl": "3.3.18",
|
|
25
|
+
"dfcode-linux-x64": "3.3.18",
|
|
26
|
+
"dfcode-linux-x64-baseline": "3.3.18",
|
|
27
|
+
"dfcode-linux-x64-baseline-musl": "3.3.18",
|
|
28
|
+
"dfcode-linux-x64-musl": "3.3.18",
|
|
29
|
+
"dfcode-windows-x64": "3.3.18",
|
|
30
|
+
"dfcode-windows-x64-baseline": "3.3.18"
|
|
22
31
|
}
|
|
23
|
-
}
|
|
32
|
+
}
|
package/platform.cjs
ADDED
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
const childProcess = require("child_process")
|
|
2
|
+
const fs = require("fs")
|
|
3
|
+
const os = require("os")
|
|
4
|
+
const path = require("path")
|
|
5
|
+
|
|
6
|
+
function probe(command, args, timeout = 1500) {
|
|
7
|
+
return childProcess.spawnSync(command, args, {
|
|
8
|
+
encoding: "utf8",
|
|
9
|
+
timeout,
|
|
10
|
+
killSignal: "SIGKILL",
|
|
11
|
+
maxBuffer: 1024 * 1024,
|
|
12
|
+
windowsHide: true,
|
|
13
|
+
})
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
function supportsAvx2(platform, arch) {
|
|
17
|
+
if (arch !== "x64") return false
|
|
18
|
+
|
|
19
|
+
// Trusted test fixtures use these overrides to exercise selection on one host.
|
|
20
|
+
const override = process.env.DFCODE_TEST_AVX2
|
|
21
|
+
if (override === "1" || override === "true") return true
|
|
22
|
+
if (override === "0" || override === "false") return false
|
|
23
|
+
|
|
24
|
+
if (platform === "linux") {
|
|
25
|
+
const result = probe("cat", ["/proc/cpuinfo"])
|
|
26
|
+
return !result.error && result.status === 0 && /(^|\s)avx2(\s|$)/i.test(result.stdout || "")
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
if (platform === "darwin") {
|
|
30
|
+
const result = probe("sysctl", ["-n", "hw.optional.avx2_0"])
|
|
31
|
+
return !result.error && result.status === 0 && (result.stdout || "").trim() === "1"
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
if (platform === "windows") {
|
|
35
|
+
const command =
|
|
36
|
+
'(Add-Type -MemberDefinition "[DllImport(""kernel32.dll"")] public static extern bool IsProcessorFeaturePresent(int ProcessorFeature);" -Name Kernel32 -Namespace Win32 -PassThru)::IsProcessorFeaturePresent(40)'
|
|
37
|
+
for (const executable of ["powershell.exe", "pwsh.exe", "pwsh", "powershell"]) {
|
|
38
|
+
const result = probe(executable, ["-NoProfile", "-NonInteractive", "-Command", command], 3000)
|
|
39
|
+
if (result.error || result.status !== 0) continue
|
|
40
|
+
const output = (result.stdout || "").trim().toLowerCase()
|
|
41
|
+
if (output === "true" || output === "1") return true
|
|
42
|
+
if (output === "false" || output === "0") return false
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// An unavailable or inconclusive probe must never select an AVX2-only build.
|
|
47
|
+
return false
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function isMusl(platform) {
|
|
51
|
+
if (platform !== "linux") return false
|
|
52
|
+
const override = process.env.DFCODE_TEST_LIBC?.toLowerCase()
|
|
53
|
+
if (override === "musl" || override === "glibc") return override === "musl"
|
|
54
|
+
if (fs.existsSync("/etc/alpine-release")) return true
|
|
55
|
+
|
|
56
|
+
const result = probe("ldd", ["--version"])
|
|
57
|
+
const output = `${result.stdout || ""}${result.stderr || ""}`.toLowerCase()
|
|
58
|
+
if (!result.error && output.includes("musl")) return true
|
|
59
|
+
if (!result.error && /glibc|gnu libc|gnu c library/.test(output)) return false
|
|
60
|
+
if (process.platform === "linux" && process.report?.getReport().header.glibcVersionRuntime) return false
|
|
61
|
+
throw new Error("Could not determine Linux libc; refusing to select an incompatible dfcode binary")
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
function target() {
|
|
65
|
+
const system = process.env.DFCODE_TEST_PLATFORM || os.platform()
|
|
66
|
+
const platform = system === "win32" ? "windows" : system
|
|
67
|
+
const arch = process.env.DFCODE_TEST_ARCH || os.arch()
|
|
68
|
+
const base = `dfcode-${platform}-${arch}`
|
|
69
|
+
const baseline = arch === "x64" && !supportsAvx2(platform, arch)
|
|
70
|
+
const suffix = isMusl(platform) ? "-musl" : ""
|
|
71
|
+
const names =
|
|
72
|
+
arch === "x64"
|
|
73
|
+
? baseline
|
|
74
|
+
? [`${base}-baseline${suffix}`]
|
|
75
|
+
: [`${base}${suffix}`, `${base}-baseline${suffix}`]
|
|
76
|
+
: [`${base}${suffix}`]
|
|
77
|
+
return { platform, names, binary: platform === "windows" ? "dfcode.exe" : "dfcode" }
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
function readPackage(file) {
|
|
81
|
+
try {
|
|
82
|
+
return JSON.parse(fs.readFileSync(file, "utf8"))
|
|
83
|
+
} catch {
|
|
84
|
+
return undefined
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
function roots(startDir) {
|
|
89
|
+
const result = []
|
|
90
|
+
for (let current = startDir; ; current = path.dirname(current)) {
|
|
91
|
+
result.push(current)
|
|
92
|
+
if (path.dirname(current) === current) return result
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
function findBinary(startDir) {
|
|
97
|
+
const selected = target()
|
|
98
|
+
const directories = roots(startDir)
|
|
99
|
+
const pkg = directories
|
|
100
|
+
.map((directory) => readPackage(path.join(directory, "package.json")))
|
|
101
|
+
.find((pkg) => pkg?.name === "dfcode" && typeof pkg.version === "string")
|
|
102
|
+
const expectedVersion = pkg?.version
|
|
103
|
+
const rejected = []
|
|
104
|
+
|
|
105
|
+
for (const directory of directories) {
|
|
106
|
+
for (const name of selected.names) {
|
|
107
|
+
const root = path.join(directory, "node_modules", name)
|
|
108
|
+
const binaryPath = path.join(root, "bin", selected.binary)
|
|
109
|
+
if (!fs.existsSync(binaryPath)) continue
|
|
110
|
+
const candidate = readPackage(path.join(root, "package.json"))
|
|
111
|
+
if (expectedVersion && (candidate?.name !== name || candidate?.version !== expectedVersion)) {
|
|
112
|
+
rejected.push(`${name}: expected ${expectedVersion}, found ${candidate?.version || "missing package metadata"}`)
|
|
113
|
+
continue
|
|
114
|
+
}
|
|
115
|
+
return { ...selected, binaryPath, name, version: candidate?.version, expectedVersion }
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
throw new Error(
|
|
120
|
+
`Could not find a compatible dfcode platform package${expectedVersion ? ` at version ${expectedVersion}` : ""}. ` +
|
|
121
|
+
`Install ${selected.names.map((name) => `"${name}${expectedVersion ? `@${expectedVersion}` : ""}"`).join(" or ")}.` +
|
|
122
|
+
(rejected.length ? ` Rejected packages: ${rejected.join("; ")}` : ""),
|
|
123
|
+
)
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
module.exports = { findBinary }
|
package/postinstall.mjs
CHANGED
|
@@ -1,125 +1,41 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
-
import
|
|
3
|
+
import { spawnSync } from "child_process"
|
|
4
4
|
import path from "path"
|
|
5
|
-
import os from "os"
|
|
6
5
|
import { fileURLToPath } from "url"
|
|
7
|
-
import
|
|
8
|
-
|
|
9
|
-
const
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
case "x64":
|
|
34
|
-
arch = "x64"
|
|
35
|
-
break
|
|
36
|
-
case "arm64":
|
|
37
|
-
arch = "arm64"
|
|
38
|
-
break
|
|
39
|
-
case "arm":
|
|
40
|
-
arch = "arm"
|
|
41
|
-
break
|
|
42
|
-
default:
|
|
43
|
-
arch = os.arch()
|
|
44
|
-
break
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
return { platform, arch }
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
function findBinary() {
|
|
51
|
-
const { platform, arch } = detectPlatformAndArch()
|
|
52
|
-
const packageName = `dfcode-${platform}-${arch}`
|
|
53
|
-
const binaryName = platform === "windows" ? "dfcode.exe" : "dfcode"
|
|
54
|
-
|
|
55
|
-
try {
|
|
56
|
-
// Use require.resolve to find the package
|
|
57
|
-
const packageJsonPath = require.resolve(`${packageName}/package.json`)
|
|
58
|
-
const packageDir = path.dirname(packageJsonPath)
|
|
59
|
-
const binaryPath = path.join(packageDir, "bin", binaryName)
|
|
60
|
-
|
|
61
|
-
if (!fs.existsSync(binaryPath)) {
|
|
62
|
-
throw new Error(`Binary not found at ${binaryPath}`)
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
return { binaryPath, binaryName }
|
|
66
|
-
} catch (error) {
|
|
67
|
-
throw new Error(`Could not find package ${packageName}: ${error.message}`)
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
function prepareBinDirectory(binaryName) {
|
|
72
|
-
const binDir = path.join(__dirname, "bin")
|
|
73
|
-
const targetPath = path.join(binDir, binaryName)
|
|
74
|
-
|
|
75
|
-
// Ensure bin directory exists
|
|
76
|
-
if (!fs.existsSync(binDir)) {
|
|
77
|
-
fs.mkdirSync(binDir, { recursive: true })
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
// Remove existing binary/symlink if it exists
|
|
81
|
-
if (fs.existsSync(targetPath)) {
|
|
82
|
-
fs.unlinkSync(targetPath)
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
return { binDir, targetPath }
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
function symlinkBinary(sourcePath, binaryName) {
|
|
89
|
-
const { targetPath } = prepareBinDirectory(binaryName)
|
|
90
|
-
|
|
91
|
-
fs.symlinkSync(sourcePath, targetPath)
|
|
92
|
-
console.log(`dfcode binary symlinked: ${targetPath} -> ${sourcePath}`)
|
|
93
|
-
|
|
94
|
-
// Verify the file exists after operation
|
|
95
|
-
if (!fs.existsSync(targetPath)) {
|
|
96
|
-
throw new Error(`Failed to symlink binary to ${targetPath}`)
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
async function main() {
|
|
101
|
-
try {
|
|
102
|
-
if (os.platform() === "win32") {
|
|
103
|
-
// On Windows, the .exe is already included in the package and bin field points to it
|
|
104
|
-
// No postinstall setup needed
|
|
105
|
-
console.log("Windows detected: binary setup not needed (using packaged .exe)")
|
|
106
|
-
return
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
// On non-Windows platforms, just verify the binary package exists
|
|
110
|
-
// Don't replace the wrapper script - it handles binary execution
|
|
111
|
-
const { binaryPath } = findBinary()
|
|
112
|
-
console.log(`Platform binary verified at: ${binaryPath}`)
|
|
113
|
-
console.log("Wrapper script will handle binary execution")
|
|
114
|
-
} catch (error) {
|
|
115
|
-
console.error("Failed to setup dfcode binary:", error.message)
|
|
116
|
-
process.exit(1)
|
|
6
|
+
import resolver from "./platform.cjs"
|
|
7
|
+
|
|
8
|
+
const directory = path.dirname(fileURLToPath(import.meta.url))
|
|
9
|
+
|
|
10
|
+
function main() {
|
|
11
|
+
const resolved = resolver.findBinary(directory)
|
|
12
|
+
if (!resolved.expectedVersion)
|
|
13
|
+
throw new Error("Could not determine the dfcode package version for installation verification")
|
|
14
|
+
|
|
15
|
+
const env = { ...process.env }
|
|
16
|
+
if (resolved.platform === "windows" && env.BUN_JSC_useJIT === undefined) env.BUN_JSC_useJIT = "0"
|
|
17
|
+
const result = spawnSync(resolved.binaryPath, ["--version"], {
|
|
18
|
+
encoding: "utf8",
|
|
19
|
+
timeout: 15000,
|
|
20
|
+
killSignal: "SIGKILL",
|
|
21
|
+
maxBuffer: 1024 * 1024,
|
|
22
|
+
windowsHide: true,
|
|
23
|
+
env,
|
|
24
|
+
})
|
|
25
|
+
if (result.error) throw new Error(`Could not run ${resolved.name} --version: ${result.error.message}`)
|
|
26
|
+
if (result.status !== 0) throw new Error(`${resolved.name} --version failed (${result.signal || result.status})`)
|
|
27
|
+
const version = (result.stdout || "").trim()
|
|
28
|
+
if (version !== resolved.expectedVersion) {
|
|
29
|
+
throw new Error(
|
|
30
|
+
`${resolved.name} reported version ${JSON.stringify(version)}; expected ${resolved.expectedVersion}`,
|
|
31
|
+
)
|
|
117
32
|
}
|
|
33
|
+
console.log(`Verified ${resolved.name}@${version}: ${resolved.binaryPath}`)
|
|
118
34
|
}
|
|
119
35
|
|
|
120
36
|
try {
|
|
121
37
|
main()
|
|
122
38
|
} catch (error) {
|
|
123
|
-
console.error("
|
|
124
|
-
process.exit(
|
|
39
|
+
console.error("Failed to verify dfcode installation:", error.message)
|
|
40
|
+
process.exit(1)
|
|
125
41
|
}
|