@xurxuo/claude-code-termux 2.1.142 → 2.1.143
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/cli-wrapper.cjs +35 -3
- package/install.cjs +14 -4
- package/package.json +1 -1
package/cli-wrapper.cjs
CHANGED
|
@@ -84,6 +84,14 @@ function readPackageJson(pkg) {
|
|
|
84
84
|
}
|
|
85
85
|
}
|
|
86
86
|
|
|
87
|
+
function getNativePackage(info) {
|
|
88
|
+
const native = readPackageJson(info.pkg)
|
|
89
|
+
return {
|
|
90
|
+
...native,
|
|
91
|
+
binaryPath: path.join(native.dir, info.bin),
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
87
95
|
function compareVersions(a, b) {
|
|
88
96
|
const left = String(a).split(/[.-]/).map((part) => Number.parseInt(part, 10) || 0)
|
|
89
97
|
const right = String(b).split(/[.-]/).map((part) => Number.parseInt(part, 10) || 0)
|
|
@@ -184,13 +192,23 @@ function getBinaryPath(options = {}) {
|
|
|
184
192
|
}
|
|
185
193
|
refreshNativePackage(info, options.forceUpdate)
|
|
186
194
|
try {
|
|
187
|
-
|
|
188
|
-
|
|
195
|
+
let native = getNativePackage(info)
|
|
196
|
+
if (!fs.existsSync(native.binaryPath)) {
|
|
197
|
+
console.error(
|
|
198
|
+
`[${WRAPPER_NAME}] Native binary missing; reinstalling ${info.pkg}@latest...`,
|
|
199
|
+
)
|
|
200
|
+
npmInstallLatest([info.pkg])
|
|
201
|
+
native = getNativePackage(info)
|
|
202
|
+
}
|
|
203
|
+
if (!fs.existsSync(native.binaryPath)) {
|
|
204
|
+
throw new Error('native binary missing after install')
|
|
205
|
+
}
|
|
206
|
+
return native.binaryPath
|
|
189
207
|
} catch {
|
|
190
208
|
console.error(
|
|
191
209
|
`[${WRAPPER_NAME}] Could not find native binary package "${info.pkg}".`,
|
|
192
210
|
)
|
|
193
|
-
console.error(' Try reinstalling with: npm install')
|
|
211
|
+
console.error(' Try reinstalling with: npm install -g --force ' + info.pkg + '@latest')
|
|
194
212
|
process.exit(1)
|
|
195
213
|
}
|
|
196
214
|
}
|
|
@@ -209,6 +227,20 @@ function main() {
|
|
|
209
227
|
stdio: 'inherit',
|
|
210
228
|
env: { ...process.env, CLAUDE_CODE_INSTALLED_VIA_NPM_WRAPPER: '1' },
|
|
211
229
|
})
|
|
230
|
+
if (result.error && result.error.code === 'ENOENT') {
|
|
231
|
+
const retryPath = getBinaryPath({ forceUpdate: true })
|
|
232
|
+
const retry = spawnSync(retryPath, args, {
|
|
233
|
+
stdio: 'inherit',
|
|
234
|
+
env: { ...process.env, CLAUDE_CODE_INSTALLED_VIA_NPM_WRAPPER: '1' },
|
|
235
|
+
})
|
|
236
|
+
if (!retry.error) {
|
|
237
|
+
if (retry.signal) {
|
|
238
|
+
const signum = constants.signals[retry.signal] ?? 0
|
|
239
|
+
process.exit(128 + signum)
|
|
240
|
+
}
|
|
241
|
+
process.exit(retry.status ?? 1)
|
|
242
|
+
}
|
|
243
|
+
}
|
|
212
244
|
if (result.error) {
|
|
213
245
|
console.error(
|
|
214
246
|
`[${WRAPPER_NAME}] Failed to execute native binary at ` + binaryPath,
|
package/install.cjs
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
// Patches: android -> linux for platform detection
|
|
4
4
|
|
|
5
5
|
const { spawnSync } = require('child_process')
|
|
6
|
+
const fs = require('fs')
|
|
6
7
|
const { arch } = require('os')
|
|
7
8
|
const path = require('path')
|
|
8
9
|
|
|
@@ -86,6 +87,13 @@ function installLatestNativePackage(pkg) {
|
|
|
86
87
|
return result.status === 0
|
|
87
88
|
}
|
|
88
89
|
|
|
90
|
+
function getNativePackage(pkg, bin) {
|
|
91
|
+
const pkgDir = path.dirname(require.resolve(pkg + '/package.json'))
|
|
92
|
+
const pkgJson = require(path.join(pkgDir, 'package.json'))
|
|
93
|
+
const binaryPath = path.join(pkgDir, bin)
|
|
94
|
+
return { pkgDir, pkgJson, binaryPath }
|
|
95
|
+
}
|
|
96
|
+
|
|
89
97
|
function npmViewLatest(pkg) {
|
|
90
98
|
const command = process.env.npm_execpath ? process.execPath : 'npm'
|
|
91
99
|
const args = process.env.npm_execpath
|
|
@@ -122,13 +130,15 @@ function main() {
|
|
|
122
130
|
}
|
|
123
131
|
|
|
124
132
|
try {
|
|
125
|
-
const
|
|
126
|
-
const pkgJson = require(path.join(pkgDir, 'package.json'))
|
|
133
|
+
const native = getNativePackage(info.pkg, info.bin)
|
|
127
134
|
console.error(
|
|
128
|
-
`[${WRAPPER_NAME} postinstall] Native package ready: ${info.pkg}@${pkgJson.version}`,
|
|
135
|
+
`[${WRAPPER_NAME} postinstall] Native package ready: ${info.pkg}@${native.pkgJson.version}`,
|
|
129
136
|
)
|
|
130
137
|
const latest = npmViewLatest(info.pkg)
|
|
131
|
-
if (
|
|
138
|
+
if (
|
|
139
|
+
!fs.existsSync(native.binaryPath) ||
|
|
140
|
+
(latest && compareVersions(latest, native.pkgJson.version) > 0)
|
|
141
|
+
) {
|
|
132
142
|
installLatestNativePackage(info.pkg)
|
|
133
143
|
}
|
|
134
144
|
} catch {
|