@bash0816/claude-code 2.1.159-3 → 2.1.159-9
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 +14 -61
- package/bin/claude +2 -2
- package/config/claude-native-audited-versions.json +22 -10
- package/config/claude-termux-release-manifest.json +7 -2
- package/lib/check-updates.js +123 -13
- package/lib/postinstall.js +2 -1
- package/lib/preinstall.js +6 -0
- package/lib/prepare-native.js +9 -51
- package/lib/termux-run-claude-native.sh +196 -539
- package/package.json +5 -15
- package/lib/native-update-guard.js +0 -257
- package/lib/native-update-guard.test.js +0 -310
- package/lib/version-utils.js +0 -24
- package/lib/version-utils.test.js +0 -25
package/README.md
CHANGED
|
@@ -1,78 +1,31 @@
|
|
|
1
|
-
# @bash0816/
|
|
1
|
+
# @bash0816/cluade-code
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
> **This package has been renamed.**
|
|
4
|
+
> Please migrate to the canonical package: [@bash0816/claude-code](https://www.npmjs.com/package/@bash0816/claude-code)
|
|
4
5
|
|
|
5
|
-
|
|
6
|
+
## Migration / 移行
|
|
6
7
|
|
|
7
|
-
|
|
8
|
+
Run the following command to migrate:
|
|
8
9
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
## Install / インストール
|
|
10
|
+
移行するには以下を実行してください:
|
|
12
11
|
|
|
13
12
|
```sh
|
|
13
|
+
npm uninstall -g @bash0816/cluade-code
|
|
14
14
|
npm install -g @bash0816/claude-code@latest
|
|
15
15
|
```
|
|
16
16
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
この repository の古い監査済み launcher が `$PREFIX/bin/claude` にある場合は、更新済み launcher 経由で移行します。
|
|
20
|
-
|
|
21
|
-
```sh
|
|
22
|
-
claude update
|
|
23
|
-
```
|
|
24
|
-
|
|
25
|
-
If npm reports `EEXIST` before package scripts run, use a one-time forced migration.
|
|
26
|
-
|
|
27
|
-
package script 実行前に npm が `EEXIST` を返す場合は、初回だけ forced migration を使います。
|
|
28
|
-
|
|
29
|
-
```sh
|
|
30
|
-
npm install -g --force @bash0816/claude-code@latest
|
|
31
|
-
```
|
|
32
|
-
|
|
33
|
-
After npm owns the `claude` bin link, normal `npm install -g` updates work.
|
|
34
|
-
|
|
35
|
-
npm が `claude` bin link を管理する状態になれば、通常の `npm install -g` 更新が使えます。
|
|
17
|
+
Or use the built-in migration:
|
|
36
18
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
監査済みの固定 version:
|
|
40
|
-
|
|
41
|
-
Current quick examples:
|
|
42
|
-
|
|
43
|
-
現在の quick example:
|
|
44
|
-
|
|
45
|
-
```sh
|
|
46
|
-
npm install -g @bash0816/claude-code@2.1.157
|
|
47
|
-
```
|
|
48
|
-
|
|
49
|
-
## Update / 更新
|
|
19
|
+
内蔵の migration を使う場合:
|
|
50
20
|
|
|
51
21
|
```sh
|
|
52
22
|
claude update
|
|
53
23
|
```
|
|
54
24
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
`claude update` は最新の監査済み package version を install します。
|
|
58
|
-
|
|
59
|
-
```sh
|
|
60
|
-
npm install -g @bash0816/claude-code@<latest_audited_version>
|
|
61
|
-
```
|
|
62
|
-
|
|
63
|
-
Normal launch also checks the same manifest with a short timeout and prints a notice when a newer audited version is available.
|
|
64
|
-
|
|
65
|
-
通常起動時も、同じ manifest を短い timeout で確認し、新しい監査済み version があれば通知します。
|
|
25
|
+
## Note
|
|
66
26
|
|
|
67
|
-
|
|
27
|
+
This is a legacy compatibility package with a typo in the package name.
|
|
28
|
+
All new releases are published under [@bash0816/claude-code](https://www.npmjs.com/package/@bash0816/claude-code).
|
|
68
29
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
- `2.1.118`, `2.1.119`, `2.1.121`, `2.1.122`, `2.1.123`, `2.1.126`, `2.1.128`, `2.1.136`, `2.1.137`, `2.1.138`, `2.1.139`, `2.1.140`, `2.1.141`, `2.1.142`, `2.1.143`, `2.1.144`, `2.1.150`, `2.1.150-1`, `2.1.150-2`, `2.1.150-3`, `2.1.153`, `2.1.153-1`, `2.1.153-2`, `2.1.153-3`, `2.1.153-4`, `2.1.157` are included in the package metadata.
|
|
72
|
-
- `2.1.118`、`2.1.119`、`2.1.121`、`2.1.122`、`2.1.123`、`2.1.126`、`2.1.128`、`2.1.136`、`2.1.137`、`2.1.138`、`2.1.139`、`2.1.140`、`2.1.141`、`2.1.142`、`2.1.143`、`2.1.144`、`2.1.150`、`2.1.150-1`、`2.1.150-2`、`2.1.150-3`、`2.1.153`、`2.1.153-1`、`2.1.153-2`、`2.1.153-3`、`2.1.153-4`、`2.1.157` を package metadata に含めています。
|
|
73
|
-
- The metadata file is the source of truth for the currently audited set.
|
|
74
|
-
- 現在の監査済み version 集合の source of truth は metadata file です。
|
|
75
|
-
- Native artifacts are cached under `${HOME}/.claude-termux-native-package`.
|
|
76
|
-
- native artifact は `${HOME}/.claude-termux-native-package` に cache します。
|
|
77
|
-
- If native preparation fails, the command exits with an error.
|
|
78
|
-
- native preparation に失敗した場合、command は error で終了します。
|
|
30
|
+
このパッケージはパッケージ名に typo がある legacy 互換パッケージです。
|
|
31
|
+
新しいリリースはすべて [@bash0816/claude-code](https://www.npmjs.com/package/@bash0816/claude-code) で公開されています。
|
package/bin/claude
CHANGED
|
@@ -14,7 +14,8 @@ done
|
|
|
14
14
|
PACKAGE_DIR=$(CDPATH= cd -- "$(dirname -- "${SELF}")/.." && pwd)
|
|
15
15
|
CONFIG_FILE="${PACKAGE_DIR}/config/claude-native-audited-versions.json"
|
|
16
16
|
PACKAGE_VERSION=$(node -e 'const fs=require("fs"); const path=require("path"); const p=JSON.parse(fs.readFileSync(path.join(process.argv[1],"package.json"),"utf8")); process.stdout.write(p.version)' "${PACKAGE_DIR}")
|
|
17
|
-
|
|
17
|
+
DEFAULT_NATIVE_VERSION=$(node -e 'const fs=require("fs"); const path=require("path"); const p=JSON.parse(fs.readFileSync(path.join(process.argv[1],"config","claude-termux-release-manifest.json"),"utf8")); process.stdout.write(String(p.default_native_version || p.latest_audited_version || ""))' "${PACKAGE_DIR}")
|
|
18
|
+
CLAUDE_VERSION="${CLAUDE_TERMUX_CLAUDE_VERSION:-${DEFAULT_NATIVE_VERSION:-${PACKAGE_VERSION}}}"
|
|
18
19
|
UPDATE_HELPER="${PACKAGE_DIR}/lib/check-updates.js"
|
|
19
20
|
|
|
20
21
|
if [ "${1:-}" = "update" ]; then
|
|
@@ -57,6 +58,5 @@ WORKDIR="${CACHE_DIR}/launcher-workdir" \
|
|
|
57
58
|
ENTRY_JS_OFFSET="${ENTRY_JS_OFFSET}" \
|
|
58
59
|
ENTRY_END_OFFSET="${ENTRY_END_OFFSET}" \
|
|
59
60
|
CURRENT_CLAUDE_VERSION="${CLAUDE_VERSION}" \
|
|
60
|
-
CLAUDE_TERMUX_PACKAGE_DIR="${PACKAGE_DIR}" \
|
|
61
61
|
CLAUDE_NATIVE_UPDATE_CHECK=0 \
|
|
62
62
|
exec sh "${PACKAGE_DIR}/lib/termux-run-claude-native.sh" "$@"
|
|
@@ -175,6 +175,20 @@
|
|
|
175
175
|
"entry_end_offset": 237958345,
|
|
176
176
|
"status": "termux_verified"
|
|
177
177
|
},
|
|
178
|
+
"2.1.154": {
|
|
179
|
+
"wrapper_spec": "@anthropic-ai/claude-code@2.1.154",
|
|
180
|
+
"native_spec": "@anthropic-ai/claude-code-linux-arm64@2.1.154",
|
|
181
|
+
"entry_js_offset": 222957396,
|
|
182
|
+
"entry_end_offset": 238482842,
|
|
183
|
+
"status": "termux_verified"
|
|
184
|
+
},
|
|
185
|
+
"2.1.156": {
|
|
186
|
+
"wrapper_spec": "@anthropic-ai/claude-code@2.1.156",
|
|
187
|
+
"native_spec": "@anthropic-ai/claude-code-linux-arm64@2.1.156",
|
|
188
|
+
"entry_js_offset": 222957812,
|
|
189
|
+
"entry_end_offset": 238483519,
|
|
190
|
+
"status": "termux_verified"
|
|
191
|
+
},
|
|
178
192
|
"2.1.157": {
|
|
179
193
|
"wrapper_spec": "@anthropic-ai/claude-code@2.1.157",
|
|
180
194
|
"native_spec": "@anthropic-ai/claude-code-linux-arm64@2.1.157",
|
|
@@ -182,23 +196,21 @@
|
|
|
182
196
|
"entry_end_offset": 238725072,
|
|
183
197
|
"status": "termux_verified"
|
|
184
198
|
},
|
|
185
|
-
"2.1.159-
|
|
199
|
+
"2.1.159-9": {
|
|
186
200
|
"wrapper_spec": "@anthropic-ai/claude-code@2.1.159",
|
|
187
201
|
"native_spec": "@anthropic-ai/claude-code-linux-arm64@2.1.159",
|
|
188
202
|
"entry_js_offset": 223232708,
|
|
189
203
|
"entry_end_offset": 238749397,
|
|
190
204
|
"tarball_integrity": "sha512-c8dXbuQdrotGWll46GlnXm5IPpORK2VrBSosCmI6f8t7Snc/3F58fX0MbIjJ/ycXpY0aaKuOnufCuxf7wi1Xqw==",
|
|
191
205
|
"tarball_sha256": "0b551634f11742310ba3b6344fb7912ba1ed8ee0ef4702eab0099d31b4eeb070",
|
|
192
|
-
"status": "
|
|
206
|
+
"status": "candidate"
|
|
193
207
|
},
|
|
194
|
-
"2.1.
|
|
195
|
-
"wrapper_spec": "@anthropic-ai/claude-code@2.1.
|
|
196
|
-
"native_spec": "@anthropic-ai/claude-code-linux-arm64@2.1.
|
|
197
|
-
"entry_js_offset":
|
|
198
|
-
"entry_end_offset":
|
|
199
|
-
"
|
|
200
|
-
"tarball_sha256": "0b551634f11742310ba3b6344fb7912ba1ed8ee0ef4702eab0099d31b4eeb070",
|
|
201
|
-
"status": "offset_discovered"
|
|
208
|
+
"2.1.157-1": {
|
|
209
|
+
"wrapper_spec": "@anthropic-ai/claude-code@2.1.157",
|
|
210
|
+
"native_spec": "@anthropic-ai/claude-code-linux-arm64@2.1.157",
|
|
211
|
+
"entry_js_offset": 223210916,
|
|
212
|
+
"entry_end_offset": 238725072,
|
|
213
|
+
"status": "candidate"
|
|
202
214
|
}
|
|
203
215
|
}
|
|
204
216
|
}
|
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"manifest_version": 1,
|
|
3
3
|
"package_name": "@bash0816/claude-code",
|
|
4
|
+
"canonical_package_name": "@bash0816/claude-code",
|
|
5
|
+
"canonical_manifest_url": "https://raw.githubusercontent.com/bash0816/ClaudeCode-Termux/main/config/claude-termux-release-manifest.json",
|
|
6
|
+
"canonical_repository_url": "https://github.com/bash0816/ClaudeCode-Termux",
|
|
7
|
+
"bridge_package_version": "2.1.159-9",
|
|
8
|
+
"default_native_version": "2.1.159-9",
|
|
4
9
|
"latest_audited_version": "2.1.157",
|
|
5
|
-
"latest_candidate_version": "2.1.159-
|
|
6
|
-
"previous_stable_version": "2.1.
|
|
10
|
+
"latest_candidate_version": "2.1.159-9",
|
|
11
|
+
"previous_stable_version": "2.1.157-1",
|
|
7
12
|
"manifest_url": "https://raw.githubusercontent.com/bash0816/ClaudeCode-Termux/main/config/claude-termux-release-manifest.json"
|
|
8
13
|
}
|
package/lib/check-updates.js
CHANGED
|
@@ -10,7 +10,6 @@ const path = require('path');
|
|
|
10
10
|
const packageDir = path.resolve(__dirname, '..');
|
|
11
11
|
const pkg = require(path.join(packageDir, 'package.json'));
|
|
12
12
|
const localManifest = require(path.join(packageDir, 'config', 'claude-termux-release-manifest.json'));
|
|
13
|
-
const { compareVersions } = require('./version-utils');
|
|
14
13
|
const mode = process.argv[2] || 'notify';
|
|
15
14
|
const currentVersion = process.argv[3] || pkg.version;
|
|
16
15
|
const dryRun = process.argv.includes('--dry-run');
|
|
@@ -20,6 +19,26 @@ const timeoutMs = Number(process.env.CLAUDE_TERMUX_UPDATE_TIMEOUT_MS || '1200');
|
|
|
20
19
|
const ttlMs = Number(process.env.CLAUDE_TERMUX_UPDATE_CACHE_TTL_MS || String(24 * 60 * 60 * 1000));
|
|
21
20
|
const skipCheck = process.env.CLAUDE_TERMUX_SKIP_UPDATE_CHECK === '1';
|
|
22
21
|
const manifestUrl = process.env.CLAUDE_TERMUX_MANIFEST_URL || localManifest.manifest_url;
|
|
22
|
+
const canonicalManifestUrl = process.env.CLAUDE_TERMUX_CANONICAL_MANIFEST_URL || localManifest.canonical_manifest_url || '';
|
|
23
|
+
const canonicalPackageName = process.env.CLAUDE_TERMUX_CANONICAL_PACKAGE_NAME || localManifest.canonical_package_name || '';
|
|
24
|
+
const canonicalRepositoryUrl = process.env.CLAUDE_TERMUX_CANONICAL_REPOSITORY_URL || localManifest.canonical_repository_url || '';
|
|
25
|
+
|
|
26
|
+
function compareVersions(a, b) {
|
|
27
|
+
const parse = v => {
|
|
28
|
+
const [main, patch] = String(v).split('-');
|
|
29
|
+
const parts = main.split('.').map(Number);
|
|
30
|
+
parts.push(patch !== undefined ? Number(patch) : 0);
|
|
31
|
+
return parts;
|
|
32
|
+
};
|
|
33
|
+
const aParts = parse(a);
|
|
34
|
+
const bParts = parse(b);
|
|
35
|
+
const len = Math.max(aParts.length, bParts.length);
|
|
36
|
+
for (let index = 0; index < len; index += 1) {
|
|
37
|
+
const diff = (aParts[index] || 0) - (bParts[index] || 0);
|
|
38
|
+
if (diff !== 0) return diff;
|
|
39
|
+
}
|
|
40
|
+
return 0;
|
|
41
|
+
}
|
|
23
42
|
|
|
24
43
|
function readCache() {
|
|
25
44
|
try {
|
|
@@ -92,10 +111,64 @@ async function resolveManifest(forceRefresh) {
|
|
|
92
111
|
}
|
|
93
112
|
}
|
|
94
113
|
|
|
95
|
-
function
|
|
114
|
+
async function resolveCanonicalManifest() {
|
|
115
|
+
if (!canonicalManifestUrl || !canonicalPackageName || canonicalPackageName === pkg.name) {
|
|
116
|
+
return null;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
if (skipCheck) {
|
|
120
|
+
return {
|
|
121
|
+
packageName: canonicalPackageName,
|
|
122
|
+
latestVersion: localManifest.latest_audited_version || pkg.version,
|
|
123
|
+
repositoryUrl: canonicalRepositoryUrl,
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
try {
|
|
128
|
+
const manifest = await fetchManifest(canonicalManifestUrl);
|
|
129
|
+
return {
|
|
130
|
+
packageName: manifest.package_name || canonicalPackageName,
|
|
131
|
+
latestVersion: manifest.latest_audited_version || localManifest.latest_audited_version || pkg.version,
|
|
132
|
+
repositoryUrl: canonicalRepositoryUrl,
|
|
133
|
+
};
|
|
134
|
+
} catch {
|
|
135
|
+
return {
|
|
136
|
+
packageName: canonicalPackageName,
|
|
137
|
+
latestVersion: localManifest.latest_audited_version || pkg.version,
|
|
138
|
+
repositoryUrl: canonicalRepositoryUrl,
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
async function resolveTarget(forceRefresh) {
|
|
144
|
+
const base = await resolveManifest(forceRefresh);
|
|
145
|
+
const canonical = await resolveCanonicalManifest();
|
|
146
|
+
if (!canonical) {
|
|
147
|
+
return {
|
|
148
|
+
manifest: base.manifest,
|
|
149
|
+
cache: base.cache,
|
|
150
|
+
packageName: base.manifest.package_name || pkg.name,
|
|
151
|
+
targetVersion: base.manifest.latest_audited_version || localManifest.latest_audited_version || pkg.version,
|
|
152
|
+
repositoryUrl: '',
|
|
153
|
+
migration: false,
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
return {
|
|
158
|
+
manifest: base.manifest,
|
|
159
|
+
cache: base.cache,
|
|
160
|
+
packageName: canonical.packageName,
|
|
161
|
+
targetVersion: canonical.latestVersion,
|
|
162
|
+
repositoryUrl: canonical.repositoryUrl,
|
|
163
|
+
migration: canonical.packageName !== pkg.name,
|
|
164
|
+
};
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
function updateNoticeCache(cache, packageName, latestVersion) {
|
|
96
168
|
const nextCache = {
|
|
97
169
|
...cache,
|
|
98
170
|
last_notice: {
|
|
171
|
+
package_name: packageName,
|
|
99
172
|
current_version: currentVersion,
|
|
100
173
|
latest_audited_version: latestVersion,
|
|
101
174
|
notified_at: Date.now(),
|
|
@@ -104,9 +177,10 @@ function updateNoticeCache(cache, latestVersion) {
|
|
|
104
177
|
writeCache(nextCache);
|
|
105
178
|
}
|
|
106
179
|
|
|
107
|
-
function shouldNotify(cache, latestVersion) {
|
|
180
|
+
function shouldNotify(cache, packageName, latestVersion) {
|
|
108
181
|
const lastNotice = cache.last_notice;
|
|
109
182
|
if (!lastNotice) return true;
|
|
183
|
+
if (lastNotice.package_name !== packageName) return true;
|
|
110
184
|
if (lastNotice.current_version !== currentVersion) return true;
|
|
111
185
|
if (lastNotice.latest_audited_version !== latestVersion) return true;
|
|
112
186
|
return Date.now() - Number(lastNotice.notified_at || 0) >= ttlMs;
|
|
@@ -130,26 +204,62 @@ function installTarget(packageName, targetVersion) {
|
|
|
130
204
|
}
|
|
131
205
|
|
|
132
206
|
async function runNotify() {
|
|
133
|
-
const
|
|
134
|
-
const latest =
|
|
135
|
-
|
|
136
|
-
|
|
207
|
+
const target = await resolveTarget(false);
|
|
208
|
+
const latest = target.targetVersion;
|
|
209
|
+
const packageName = target.packageName;
|
|
210
|
+
const migration = target.migration;
|
|
211
|
+
if (!migration && compareVersions(currentVersion, latest) >= 0) return 0;
|
|
212
|
+
if (!shouldNotify(target.cache, packageName, latest)) return 0;
|
|
213
|
+
|
|
214
|
+
if (migration) {
|
|
215
|
+
console.error(`Legacy package detected: ${pkg.name}`);
|
|
216
|
+
console.error(`Canonical package available: ${packageName}@${latest}`);
|
|
217
|
+
if (target.repositoryUrl) {
|
|
218
|
+
console.error(`Canonical repository: ${target.repositoryUrl}`);
|
|
219
|
+
}
|
|
220
|
+
console.error('Run: claude update');
|
|
221
|
+
updateNoticeCache(target.cache, packageName, latest);
|
|
222
|
+
return 0;
|
|
223
|
+
}
|
|
137
224
|
|
|
138
225
|
console.error(`Audited update available: ${currentVersion} -> ${latest}`);
|
|
139
226
|
console.error('Run: claude update');
|
|
140
|
-
updateNoticeCache(cache, latest);
|
|
227
|
+
updateNoticeCache(target.cache, packageName, latest);
|
|
141
228
|
return 0;
|
|
142
229
|
}
|
|
143
230
|
|
|
144
231
|
async function runUpdate() {
|
|
145
|
-
const
|
|
146
|
-
|
|
147
|
-
const target = manifest.latest_audited_version || localManifest.latest_audited_version || pkg.version;
|
|
148
|
-
if (compareVersions(currentVersion, target) >= 0) {
|
|
232
|
+
const target = await resolveTarget(true);
|
|
233
|
+
if (!target.migration && compareVersions(currentVersion, target.targetVersion) >= 0) {
|
|
149
234
|
console.error(`Already on latest audited version: ${currentVersion}`);
|
|
150
235
|
return 0;
|
|
151
236
|
}
|
|
152
|
-
|
|
237
|
+
if (target.migration) {
|
|
238
|
+
console.error(`Migrating from ${pkg.name} to ${target.packageName}@${target.targetVersion}`);
|
|
239
|
+
if (dryRun) {
|
|
240
|
+
console.log(`npm uninstall -g ${pkg.name}`);
|
|
241
|
+
console.log(`npm install -g ${target.packageName}@${target.targetVersion}`);
|
|
242
|
+
return 0;
|
|
243
|
+
}
|
|
244
|
+
console.error(`Step 1: Uninstalling ${pkg.name}...`);
|
|
245
|
+
const uninstall = cp.spawnSync('npm', ['uninstall', '-g', pkg.name], { stdio: 'inherit', env: process.env });
|
|
246
|
+
if (uninstall.status !== 0) {
|
|
247
|
+
console.error(`Uninstall failed (exit ${uninstall.status}). Cannot safely continue migration.`);
|
|
248
|
+
console.error(`Run manually:`);
|
|
249
|
+
console.error(` npm uninstall -g ${pkg.name}`);
|
|
250
|
+
console.error(` npm install -g ${target.packageName}@${target.targetVersion}`);
|
|
251
|
+
return 1;
|
|
252
|
+
}
|
|
253
|
+
console.error(`Step 2: Installing ${target.packageName}@${target.targetVersion}...`);
|
|
254
|
+
const result = cp.spawnSync('npm', ['install', '-g', `${target.packageName}@${target.targetVersion}`], { stdio: 'inherit', env: process.env });
|
|
255
|
+
if (result.status !== 0) {
|
|
256
|
+
console.error(`Install failed. To restore, run:`);
|
|
257
|
+
console.error(` npm install -g ${target.packageName}@${target.targetVersion}`);
|
|
258
|
+
console.error(` # or to restore legacy: npm install -g ${pkg.name}@${pkg.version}`);
|
|
259
|
+
}
|
|
260
|
+
return result.status === null ? 1 : result.status;
|
|
261
|
+
}
|
|
262
|
+
return installTarget(target.packageName, target.targetVersion);
|
|
153
263
|
}
|
|
154
264
|
|
|
155
265
|
async function main() {
|
package/lib/postinstall.js
CHANGED
|
@@ -10,8 +10,9 @@ if (process.env.CLAUDE_TERMUX_SKIP_POSTINSTALL === '1') {
|
|
|
10
10
|
|
|
11
11
|
const packageDir = path.resolve(__dirname, '..');
|
|
12
12
|
const pkg = require(path.join(packageDir, 'package.json'));
|
|
13
|
+
const manifest = require(path.join(packageDir, 'config', 'claude-termux-release-manifest.json'));
|
|
13
14
|
const script = path.join(__dirname, 'prepare-native.js');
|
|
14
|
-
const version = process.env.CLAUDE_TERMUX_CLAUDE_VERSION || pkg.version;
|
|
15
|
+
const version = process.env.CLAUDE_TERMUX_CLAUDE_VERSION || manifest.default_native_version || manifest.latest_audited_version || pkg.version;
|
|
15
16
|
|
|
16
17
|
const result = cp.spawnSync(process.execPath, [script, version], {
|
|
17
18
|
stdio: 'inherit',
|
package/lib/preinstall.js
CHANGED
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
4
|
+
const [_nodeMajor] = process.versions.node.split('.').map(Number);
|
|
5
|
+
if (_nodeMajor < 20) {
|
|
6
|
+
process.stderr.write('@bash0816/claude-code requires Node.js v20 or later. Found: v' + process.versions.node + '\n');
|
|
7
|
+
process.exit(1);
|
|
8
|
+
}
|
|
9
|
+
|
|
4
10
|
const cp = require('child_process');
|
|
5
11
|
const fs = require('fs');
|
|
6
12
|
const os = require('os');
|
package/lib/prepare-native.js
CHANGED
|
@@ -9,11 +9,9 @@ const path = require('path');
|
|
|
9
9
|
const packageDir = path.resolve(__dirname, '..');
|
|
10
10
|
const config = require(path.join(packageDir, 'config', 'claude-native-audited-versions.json'));
|
|
11
11
|
const pkg = require(path.join(packageDir, 'package.json'));
|
|
12
|
-
const
|
|
12
|
+
const manifest = require(path.join(packageDir, 'config', 'claude-termux-release-manifest.json'));
|
|
13
|
+
const version = process.argv[2] || manifest.default_native_version || manifest.latest_audited_version || pkg.version;
|
|
13
14
|
const item = config.versions[version];
|
|
14
|
-
const curlRetries = process.env.CLAUDE_TERMUX_FETCH_RETRIES || '4';
|
|
15
|
-
const curlConnectTimeout = process.env.CLAUDE_TERMUX_FETCH_CONNECT_TIMEOUT || '20';
|
|
16
|
-
const curlMaxTime = process.env.CLAUDE_TERMUX_FETCH_MAX_TIME || '300';
|
|
17
15
|
|
|
18
16
|
if (!item) {
|
|
19
17
|
console.error(`Unsupported audited Claude Code version: ${version}`);
|
|
@@ -31,14 +29,18 @@ if (fs.existsSync(sourceBin)) {
|
|
|
31
29
|
}
|
|
32
30
|
|
|
33
31
|
fs.mkdirSync(versionDir, { recursive: true });
|
|
34
|
-
const packDir = fs.mkdtempSync(path.join(os.tmpdir(), `
|
|
32
|
+
const packDir = fs.mkdtempSync(path.join(os.tmpdir(), `cluade-code-${version}-`));
|
|
35
33
|
|
|
36
34
|
try {
|
|
37
|
-
|
|
35
|
+
run('npm', ['pack', item.native_spec, '--pack-destination', packDir]);
|
|
36
|
+
const tgz = fs.readdirSync(packDir).find(name => name.endsWith('.tgz'));
|
|
37
|
+
if (!tgz) {
|
|
38
|
+
throw new Error('npm pack did not produce a tgz');
|
|
39
|
+
}
|
|
38
40
|
|
|
39
41
|
const extractDir = path.join(packDir, 'native');
|
|
40
42
|
fs.mkdirSync(extractDir, { recursive: true });
|
|
41
|
-
run('tar', ['-xzf',
|
|
43
|
+
run('tar', ['-xzf', path.join(packDir, tgz), '-C', extractDir]);
|
|
42
44
|
|
|
43
45
|
fs.rmSync(nativeDest, { recursive: true, force: true });
|
|
44
46
|
fs.mkdirSync(path.dirname(nativeDest), { recursive: true });
|
|
@@ -55,50 +57,6 @@ function run(command, args) {
|
|
|
55
57
|
}
|
|
56
58
|
}
|
|
57
59
|
|
|
58
|
-
function runCapture(command, args) {
|
|
59
|
-
const result = cp.spawnSync(command, args, {
|
|
60
|
-
stdio: ['ignore', 'pipe', 'inherit'],
|
|
61
|
-
encoding: 'utf8',
|
|
62
|
-
});
|
|
63
|
-
if (result.status !== 0) {
|
|
64
|
-
throw new Error(`${command} ${args.join(' ')} failed`);
|
|
65
|
-
}
|
|
66
|
-
return result.stdout.trim();
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
function fetchNativeTarball(spec, packDir) {
|
|
70
|
-
const directTarball = path.join(packDir, 'native-package.tgz');
|
|
71
|
-
|
|
72
|
-
try {
|
|
73
|
-
const tarballUrl = runCapture('npm', ['view', spec, 'dist.tarball', '--json']).replace(/^"|"$/g, '');
|
|
74
|
-
if (!tarballUrl) {
|
|
75
|
-
throw new Error(`npm view did not return dist.tarball for ${spec}`);
|
|
76
|
-
}
|
|
77
|
-
run('curl', [
|
|
78
|
-
'--fail',
|
|
79
|
-
'--location',
|
|
80
|
-
'--retry', String(curlRetries),
|
|
81
|
-
'--connect-timeout', String(curlConnectTimeout),
|
|
82
|
-
'--max-time', String(curlMaxTime),
|
|
83
|
-
'--output', directTarball,
|
|
84
|
-
tarballUrl,
|
|
85
|
-
]);
|
|
86
|
-
if (fs.existsSync(directTarball)) {
|
|
87
|
-
return directTarball;
|
|
88
|
-
}
|
|
89
|
-
} catch (error) {
|
|
90
|
-
console.error(`Direct tarball fetch failed for ${spec}; falling back to npm pack.`);
|
|
91
|
-
console.error(error && error.message ? error.message : String(error));
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
run('npm', ['pack', spec, '--pack-destination', packDir]);
|
|
95
|
-
const tgz = fs.readdirSync(packDir).find(name => name.endsWith('.tgz'));
|
|
96
|
-
if (!tgz) {
|
|
97
|
-
throw new Error('npm pack did not produce a tgz');
|
|
98
|
-
}
|
|
99
|
-
return path.join(packDir, tgz);
|
|
100
|
-
}
|
|
101
|
-
|
|
102
60
|
function validateOffsets(file, audited) {
|
|
103
61
|
const buf = fs.readFileSync(file);
|
|
104
62
|
const start = Number(audited.entry_js_offset);
|