@just-every/code 0.2.117 → 0.2.119
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/coder.js +38 -14
- package/package.json +6 -6
- package/postinstall.js +44 -40
package/bin/coder.js
CHANGED
|
@@ -177,9 +177,12 @@ const tryBootstrapBinary = async () => {
|
|
|
177
177
|
if (existsSync(cachePath)) {
|
|
178
178
|
const v = validateBinary(cachePath);
|
|
179
179
|
if (v.ok) {
|
|
180
|
-
|
|
181
|
-
if (platform !== "win32")
|
|
182
|
-
|
|
180
|
+
// Prefer running directly from cache; mirror into node_modules on Unix
|
|
181
|
+
if (platform !== "win32") {
|
|
182
|
+
copyFileSync(cachePath, binaryPath);
|
|
183
|
+
try { chmodSync(binaryPath, 0o755); } catch {}
|
|
184
|
+
}
|
|
185
|
+
return true;
|
|
183
186
|
}
|
|
184
187
|
}
|
|
185
188
|
|
|
@@ -202,11 +205,13 @@ const tryBootstrapBinary = async () => {
|
|
|
202
205
|
const pkgDir = path.dirname(pkgJson);
|
|
203
206
|
const src = path.join(pkgDir, "bin", `code-${targetTriple}${platform === "win32" ? ".exe" : ""}`);
|
|
204
207
|
if (existsSync(src)) {
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
208
|
+
// Always ensure cache has the binary; on Unix mirror into node_modules
|
|
209
|
+
copyFileSync(src, cachePath);
|
|
210
|
+
if (platform !== "win32") {
|
|
211
|
+
copyFileSync(cachePath, binaryPath);
|
|
212
|
+
try { chmodSync(binaryPath, 0o755); } catch {}
|
|
213
|
+
}
|
|
214
|
+
return true;
|
|
210
215
|
}
|
|
211
216
|
} catch { /* ignore and fall back */ }
|
|
212
217
|
}
|
|
@@ -239,10 +244,19 @@ const tryBootstrapBinary = async () => {
|
|
|
239
244
|
try { unlinkSync(tmp); } catch {}
|
|
240
245
|
}
|
|
241
246
|
}
|
|
242
|
-
|
|
247
|
+
// On Windows, prefer cache and avoid leaving the executable in node_modules
|
|
248
|
+
if (platform === "win32") {
|
|
249
|
+
try {
|
|
250
|
+
copyFileSync(binaryPath, cachePath);
|
|
251
|
+
} catch {}
|
|
252
|
+
try { unlinkSync(binaryPath); } catch {}
|
|
253
|
+
} else {
|
|
254
|
+
try { copyFileSync(binaryPath, cachePath); } catch {}
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
const v = validateBinary(platform === "win32" ? cachePath : binaryPath);
|
|
243
258
|
if (!v.ok) throw new Error(`invalid binary (${v.reason})`);
|
|
244
|
-
if (platform !== "win32") chmodSync(binaryPath, 0o755);
|
|
245
|
-
try { copyFileSync(binaryPath, cachePath); } catch {}
|
|
259
|
+
if (platform !== "win32") try { chmodSync(binaryPath, 0o755); } catch {}
|
|
246
260
|
return true;
|
|
247
261
|
})
|
|
248
262
|
.catch((_e) => false);
|
|
@@ -262,9 +276,19 @@ if (!existsSync(binaryPath) && !existsSync(legacyBinaryPath)) {
|
|
|
262
276
|
}
|
|
263
277
|
}
|
|
264
278
|
|
|
265
|
-
//
|
|
266
|
-
|
|
267
|
-
|
|
279
|
+
// Prefer cached binary when available
|
|
280
|
+
try {
|
|
281
|
+
const pkg = JSON.parse(readFileSync(path.join(__dirname, "..", "package.json"), "utf8"));
|
|
282
|
+
const version = pkg.version;
|
|
283
|
+
const cached = getCachedBinaryPath(version);
|
|
284
|
+
const v = existsSync(cached) ? validateBinary(cached) : { ok: false };
|
|
285
|
+
if (v.ok) {
|
|
286
|
+
binaryPath = cached;
|
|
287
|
+
} else if (!existsSync(binaryPath) && existsSync(legacyBinaryPath)) {
|
|
288
|
+
binaryPath = legacyBinaryPath;
|
|
289
|
+
}
|
|
290
|
+
} catch {
|
|
291
|
+
// ignore
|
|
268
292
|
}
|
|
269
293
|
|
|
270
294
|
// Check if binary exists and try to fix permissions if needed
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@just-every/code",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.119",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"description": "Lightweight coding agent that runs in your terminal - fork of OpenAI Codex",
|
|
6
6
|
"bin": {
|
|
@@ -32,10 +32,10 @@
|
|
|
32
32
|
"prettier": "^3.3.3"
|
|
33
33
|
},
|
|
34
34
|
"optionalDependencies": {
|
|
35
|
-
"@just-every/code-darwin-arm64": "0.2.
|
|
36
|
-
"@just-every/code-darwin-x64": "0.2.
|
|
37
|
-
"@just-every/code-linux-x64-musl": "0.2.
|
|
38
|
-
"@just-every/code-linux-arm64-musl": "0.2.
|
|
39
|
-
"@just-every/code-win32-x64": "0.2.
|
|
35
|
+
"@just-every/code-darwin-arm64": "0.2.119",
|
|
36
|
+
"@just-every/code-darwin-x64": "0.2.119",
|
|
37
|
+
"@just-every/code-linux-x64-musl": "0.2.119",
|
|
38
|
+
"@just-every/code-linux-arm64-musl": "0.2.119",
|
|
39
|
+
"@just-every/code-win32-x64": "0.2.119"
|
|
40
40
|
}
|
|
41
41
|
}
|
package/postinstall.js
CHANGED
|
@@ -227,30 +227,23 @@ async function main() {
|
|
|
227
227
|
const localPath = join(binDir, binaryName);
|
|
228
228
|
const cachePath = getCachedBinaryPath(version, targetTriple, isWindows);
|
|
229
229
|
|
|
230
|
-
//
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
chmodSync(localPath, 0o755);
|
|
236
|
-
console.log(`✓ ${binaryName} already exists (permissions fixed)`);
|
|
237
|
-
} catch (e) {
|
|
238
|
-
console.log(`✓ ${binaryName} already exists`);
|
|
239
|
-
}
|
|
240
|
-
} else {
|
|
241
|
-
console.log(`✓ ${binaryName} already exists`);
|
|
242
|
-
}
|
|
243
|
-
continue;
|
|
244
|
-
}
|
|
230
|
+
// On Windows we avoid placing the executable inside node_modules to prevent
|
|
231
|
+
// EBUSY/EPERM during global upgrades when the binary is in use.
|
|
232
|
+
// We treat the user cache path as the canonical home of the native binary.
|
|
233
|
+
// For macOS/Linux we keep previous behavior and also place a copy in binDir
|
|
234
|
+
// for convenience.
|
|
245
235
|
|
|
246
236
|
// Fast path: if a valid cached binary exists for this version+triple, reuse it.
|
|
247
237
|
try {
|
|
248
238
|
if (existsSync(cachePath)) {
|
|
249
239
|
const valid = validateDownloadedBinary(cachePath);
|
|
250
240
|
if (valid.ok) {
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
241
|
+
if (!isWindows) {
|
|
242
|
+
// Mirror into local bin for Unix-like platforms
|
|
243
|
+
copyFileSync(cachePath, localPath);
|
|
244
|
+
try { chmodSync(localPath, 0o755); } catch {}
|
|
245
|
+
}
|
|
246
|
+
console.log(`✓ ${binaryName} ready from user cache`);
|
|
254
247
|
continue; // next binary
|
|
255
248
|
}
|
|
256
249
|
}
|
|
@@ -288,15 +281,14 @@ async function main() {
|
|
|
288
281
|
if (!existsSync(src)) {
|
|
289
282
|
throw new Error(`platform package missing binary: ${platformPkg.name}`);
|
|
290
283
|
}
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
} catch {}
|
|
284
|
+
// Populate cache first (canonical location)
|
|
285
|
+
copyFileSync(src, cachePath);
|
|
286
|
+
if (!isWindows) {
|
|
287
|
+
// Mirror into local bin for Unix-like platforms only
|
|
288
|
+
copyFileSync(cachePath, localPath);
|
|
289
|
+
try { chmodSync(localPath, 0o755); } catch {}
|
|
290
|
+
}
|
|
291
|
+
console.log(`✓ Installed ${binaryName} from ${platformPkg.name} (cached)`);
|
|
300
292
|
continue; // next binary
|
|
301
293
|
} catch (e) {
|
|
302
294
|
console.warn(`⚠ Failed platform package install (${e.message}), falling back to GitHub download`);
|
|
@@ -357,9 +349,22 @@ async function main() {
|
|
|
357
349
|
}
|
|
358
350
|
|
|
359
351
|
// Validate header to avoid corrupt binaries causing spawn EFTYPE/ENOEXEC
|
|
360
|
-
|
|
352
|
+
// On Windows, archive extraction writes to binDir; move the result to cache
|
|
353
|
+
// and remove the copy from node_modules to avoid future locks. On Unix,
|
|
354
|
+
// we keep a copy in binDir and also ensure cache is populated.
|
|
355
|
+
if (isWindows) {
|
|
356
|
+
try {
|
|
357
|
+
// Ensure the extracted file is at localPath; then move it to cachePath
|
|
358
|
+
copyFileSync(localPath, cachePath);
|
|
359
|
+
try { unlinkSync(localPath); } catch {}
|
|
360
|
+
} catch (e) {
|
|
361
|
+
throw new Error(`failed to move binary to cache: ${e.message}`);
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
const valid = validateDownloadedBinary(isWindows ? cachePath : localPath);
|
|
361
366
|
if (!valid.ok) {
|
|
362
|
-
try { unlinkSync(localPath); } catch {}
|
|
367
|
+
try { isWindows ? unlinkSync(cachePath) : unlinkSync(localPath); } catch {}
|
|
363
368
|
throw new Error(`invalid binary (${valid.reason})`);
|
|
364
369
|
}
|
|
365
370
|
|
|
@@ -368,11 +373,11 @@ async function main() {
|
|
|
368
373
|
chmodSync(localPath, 0o755);
|
|
369
374
|
}
|
|
370
375
|
|
|
371
|
-
console.log(`✓ Installed ${binaryName}`);
|
|
372
|
-
//
|
|
373
|
-
|
|
374
|
-
copyFileSync(localPath, cachePath);
|
|
375
|
-
}
|
|
376
|
+
console.log(`✓ Installed ${binaryName}${isWindows ? ' (cached)' : ''}`);
|
|
377
|
+
// Ensure persistent cache holds the binary (already true for Windows path)
|
|
378
|
+
if (!isWindows) {
|
|
379
|
+
try { copyFileSync(localPath, cachePath); } catch {}
|
|
380
|
+
}
|
|
376
381
|
} catch (error) {
|
|
377
382
|
console.error(`✗ Failed to install ${binaryName}: ${error.message}`);
|
|
378
383
|
console.error(` Downloaded from: ${downloadUrl}`);
|
|
@@ -384,13 +389,12 @@ async function main() {
|
|
|
384
389
|
const mainBinary = `code-${targetTriple}${binaryExt}`;
|
|
385
390
|
const mainBinaryPath = join(binDir, mainBinary);
|
|
386
391
|
|
|
387
|
-
if (existsSync(mainBinaryPath)) {
|
|
392
|
+
if (existsSync(mainBinaryPath) || existsSync(getCachedBinaryPath(version, targetTriple, platform() === 'win32'))) {
|
|
388
393
|
try {
|
|
389
|
-
const
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
const valid = validateDownloadedBinary(mainBinaryPath);
|
|
394
|
+
const probePath = existsSync(mainBinaryPath) ? mainBinaryPath : getCachedBinaryPath(version, targetTriple, platform() === 'win32');
|
|
395
|
+
const stats = statSync(probePath);
|
|
396
|
+
if (!stats.size) throw new Error('binary is empty (download likely failed)');
|
|
397
|
+
const valid = validateDownloadedBinary(probePath);
|
|
394
398
|
if (!valid.ok) {
|
|
395
399
|
console.warn(`⚠ Main code binary appears invalid: ${valid.reason}`);
|
|
396
400
|
console.warn(' Try reinstalling or check your network/proxy settings.');
|