@xurxuo/claude-code-termux 2.1.141 → 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/README.md +3 -1
- package/cli-wrapper.cjs +36 -4
- package/install.cjs +17 -7
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -34,7 +34,9 @@ claude update # Force update to latest Claude Code packages
|
|
|
34
34
|
|
|
35
35
|
The wrapper checks npm at most once per day. If
|
|
36
36
|
`@anthropic-ai/claude-code-linux-arm64` has a newer version, it automatically
|
|
37
|
-
installs the latest Claude Code packages before launching.
|
|
37
|
+
installs the latest Claude Code packages before launching. The native package
|
|
38
|
+
uses npm `--force` because Termux reports `os=android` while the official
|
|
39
|
+
binary package is tagged `os=linux`. Set
|
|
38
40
|
`CLAUDE_CODE_TERMUX_NO_AUTO_UPDATE=1` to disable the daily check.
|
|
39
41
|
|
|
40
42
|
## Auth
|
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)
|
|
@@ -132,7 +140,7 @@ function npmViewLatest(pkg) {
|
|
|
132
140
|
|
|
133
141
|
function npmInstallLatest(packages) {
|
|
134
142
|
const command = process.env.npm_execpath ? process.execPath : 'npm'
|
|
135
|
-
const installArgs = ['install', '-g', ...packages.map((pkg) => pkg + '@latest')]
|
|
143
|
+
const installArgs = ['install', '-g', '--force', ...packages.map((pkg) => pkg + '@latest')]
|
|
136
144
|
const args = process.env.npm_execpath
|
|
137
145
|
? [process.env.npm_execpath, ...installArgs]
|
|
138
146
|
: installArgs
|
|
@@ -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
|
|
|
@@ -77,8 +78,8 @@ function installLatestNativePackage(pkg) {
|
|
|
77
78
|
console.error(`[${WRAPPER_NAME} postinstall] Installing ${pkg}@latest...`)
|
|
78
79
|
const command = process.env.npm_execpath ? process.execPath : 'npm'
|
|
79
80
|
const args = process.env.npm_execpath
|
|
80
|
-
? [process.env.npm_execpath, 'install', '-g', pkg + '@latest']
|
|
81
|
-
: ['install', '-g', pkg + '@latest']
|
|
81
|
+
? [process.env.npm_execpath, 'install', '-g', '--force', pkg + '@latest']
|
|
82
|
+
: ['install', '-g', '--force', pkg + '@latest']
|
|
82
83
|
const result = spawnSync(command, args, {
|
|
83
84
|
stdio: 'inherit',
|
|
84
85
|
shell: process.platform === 'win32',
|
|
@@ -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 {
|
|
@@ -136,7 +146,7 @@ function main() {
|
|
|
136
146
|
console.error(
|
|
137
147
|
`[${WRAPPER_NAME} postinstall] Native package "${info.pkg}" not found and latest install failed.`,
|
|
138
148
|
)
|
|
139
|
-
console.error(' Try again with: npm install -g ' + info.pkg + '@latest')
|
|
149
|
+
console.error(' Try again with: npm install -g --force ' + info.pkg + '@latest')
|
|
140
150
|
process.exitCode = 1
|
|
141
151
|
}
|
|
142
152
|
}
|