@opencode/cli-node 0.0.0-dev-20855 → 0.0.0-dev-20858
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/package.json +6 -6
- package/postinstall.mjs +16 -3
package/package.json
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
"scripts": {
|
|
7
7
|
"postinstall": "node ./postinstall.mjs"
|
|
8
8
|
},
|
|
9
|
-
"version": "0.0.0-dev-
|
|
9
|
+
"version": "0.0.0-dev-20858",
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"repository": {
|
|
12
12
|
"type": "git",
|
|
@@ -22,10 +22,10 @@
|
|
|
22
22
|
"x64"
|
|
23
23
|
],
|
|
24
24
|
"optionalDependencies": {
|
|
25
|
-
"@opencode/cli-node-
|
|
26
|
-
"@opencode/cli-node-
|
|
27
|
-
"@opencode/cli-node-
|
|
28
|
-
"@opencode/cli-node-
|
|
29
|
-
"@opencode/cli-node-
|
|
25
|
+
"@opencode/cli-node-windows-arm64": "0.0.0-dev-20858",
|
|
26
|
+
"@opencode/cli-node-windows-x64": "0.0.0-dev-20858",
|
|
27
|
+
"@opencode/cli-node-linux-x64": "0.0.0-dev-20858",
|
|
28
|
+
"@opencode/cli-node-darwin-arm64": "0.0.0-dev-20858",
|
|
29
|
+
"@opencode/cli-node-linux-arm64": "0.0.0-dev-20858"
|
|
30
30
|
}
|
|
31
31
|
}
|
package/postinstall.mjs
CHANGED
|
@@ -15,7 +15,14 @@ if (!command) throw new Error("OpenCode package does not declare a binary")
|
|
|
15
15
|
const sourceCommand = packageJson.opencodeSourceBinary ?? command
|
|
16
16
|
|
|
17
17
|
const platform = { darwin: "darwin", linux: "linux", win32: "windows" }[os.platform()] ?? os.platform()
|
|
18
|
-
const
|
|
18
|
+
const nodeArch = { x64: "x64", arm64: "arm64", arm: "arm" }[os.arch()] ?? os.arch()
|
|
19
|
+
// x64 Node runs emulated on Windows ARM64, but PROCESSOR_IDENTIFIER still names the host CPU.
|
|
20
|
+
const arch =
|
|
21
|
+
platform === "windows" && nodeArch === "x64" && process.env.PROCESSOR_IDENTIFIER?.startsWith("ARM")
|
|
22
|
+
? "arm64"
|
|
23
|
+
: nodeArch
|
|
24
|
+
// Windows cannot spawn npm's .cmd shim directly, so reuse the npm CLI that runs this script.
|
|
25
|
+
const npm = process.env.npm_execpath?.endsWith("npm-cli.js") ? [process.execPath, process.env.npm_execpath] : ["npm"]
|
|
19
26
|
const sourceBinary = platform === "windows" ? `${sourceCommand}.exe` : sourceCommand
|
|
20
27
|
const targetBinary = path.resolve(directory, packageJson.bin[command])
|
|
21
28
|
const dependencies = packageJson.optionalDependencies ?? {}
|
|
@@ -95,7 +102,10 @@ function packageNames() {
|
|
|
95
102
|
? [`${base}-baseline`, base]
|
|
96
103
|
: [base, `${base}-baseline`]
|
|
97
104
|
: [base]
|
|
98
|
-
|
|
105
|
+
// Windows 11 on ARM64 can still run the x64 binary under emulation when the native one fails.
|
|
106
|
+
const x64 = base.replace(/-arm64$/, "-x64")
|
|
107
|
+
const emulated = platform === "windows" && arch === "arm64" ? [`${x64}-baseline`, x64] : []
|
|
108
|
+
return [...names, ...emulated].filter((name) => dependencies[name])
|
|
99
109
|
}
|
|
100
110
|
|
|
101
111
|
function copyBinary(source) {
|
|
@@ -127,12 +137,15 @@ function installPackage(name) {
|
|
|
127
137
|
const temp = fs.mkdtempSync(path.join(os.tmpdir(), "opencode-install-"))
|
|
128
138
|
try {
|
|
129
139
|
const result = childProcess.spawnSync(
|
|
130
|
-
|
|
140
|
+
npm[0],
|
|
131
141
|
[
|
|
142
|
+
...npm.slice(1),
|
|
132
143
|
"install",
|
|
133
144
|
"--ignore-scripts",
|
|
134
145
|
"--no-save",
|
|
135
146
|
"--loglevel=error",
|
|
147
|
+
// npm rejects a package built for another CPU, such as arm64 under emulated x64 Node, unless forced.
|
|
148
|
+
...(name.includes(`-${platform}-${nodeArch}`) ? [] : ["--force"]),
|
|
136
149
|
"--prefix",
|
|
137
150
|
temp,
|
|
138
151
|
`${name}@${dependencies[name]}`,
|