@just-every/code 0.2.35 → 0.2.37

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.
Files changed (2) hide show
  1. package/package.json +8 -1
  2. package/postinstall.js +67 -5
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@just-every/code",
3
- "version": "0.2.35",
3
+ "version": "0.2.37",
4
4
  "license": "Apache-2.0",
5
5
  "description": "Lightweight coding agent that runs in your terminal - fork of OpenAI Codex",
6
6
  "bin": {
@@ -33,5 +33,12 @@
33
33
  },
34
34
  "devDependencies": {
35
35
  "prettier": "^3.3.3"
36
+ },
37
+ "optionalDependencies": {
38
+ "@just-every/code-darwin-arm64": "0.2.37",
39
+ "@just-every/code-darwin-x64": "0.2.37",
40
+ "@just-every/code-linux-x64-musl": "0.2.37",
41
+ "@just-every/code-linux-arm64-musl": "0.2.37",
42
+ "@just-every/code-win32-x64": "0.2.37"
36
43
  }
37
44
  }
package/postinstall.js CHANGED
@@ -1,12 +1,13 @@
1
1
  #!/usr/bin/env node
2
2
  // Non-functional change to trigger release workflow
3
3
 
4
- import { existsSync, mkdirSync, createWriteStream, chmodSync, readFileSync, readSync, writeFileSync, unlinkSync, statSync, openSync, closeSync } from 'fs';
4
+ import { existsSync, mkdirSync, createWriteStream, chmodSync, readFileSync, readSync, writeFileSync, unlinkSync, statSync, openSync, closeSync, copyFileSync } from 'fs';
5
5
  import { join, dirname } from 'path';
6
6
  import { fileURLToPath } from 'url';
7
7
  import { get } from 'https';
8
8
  import { platform, arch } from 'os';
9
9
  import { execSync } from 'child_process';
10
+ import { createRequire } from 'module';
10
11
 
11
12
  const __dirname = dirname(fileURLToPath(import.meta.url));
12
13
 
@@ -186,8 +187,8 @@ async function main() {
186
187
  const packageJson = JSON.parse(readFileSync(join(__dirname, 'package.json'), 'utf8'));
187
188
  const version = packageJson.version;
188
189
 
189
- // Binary names to download (standardized 'code-*' naming)
190
- const binaries = ['code', 'code-tui', 'code-exec'];
190
+ // Download only the primary binary; we'll create wrappers for legacy names.
191
+ const binaries = ['code'];
191
192
 
192
193
  console.log(`Installing @just-every/code v${version} for ${targetTriple}...`);
193
194
 
@@ -211,6 +212,45 @@ async function main() {
211
212
  continue;
212
213
  }
213
214
 
215
+ // First try platform package via npm optionalDependencies (fast path on npm CDN).
216
+ const require = createRequire(import.meta.url);
217
+ const platformPkg = (() => {
218
+ const name = (() => {
219
+ if (isWindows) return '@just-every/code-win32-x64';
220
+ const plt = platform();
221
+ const cpu = arch();
222
+ if (plt === 'darwin' && cpu === 'arm64') return '@just-every/code-darwin-arm64';
223
+ if (plt === 'darwin' && cpu === 'x64') return '@just-every/code-darwin-x64';
224
+ if (plt === 'linux' && cpu === 'x64') return '@just-every/code-linux-x64-musl';
225
+ if (plt === 'linux' && cpu === 'arm64') return '@just-every/code-linux-arm64-musl';
226
+ return null;
227
+ })();
228
+ if (!name) return null;
229
+ try {
230
+ const pkgJsonPath = require.resolve(`${name}/package.json`);
231
+ const pkgDir = dirname(pkgJsonPath);
232
+ return { name, dir: pkgDir };
233
+ } catch {
234
+ return null;
235
+ }
236
+ })();
237
+
238
+ if (platformPkg) {
239
+ try {
240
+ // Expect binary inside platform package bin directory
241
+ const src = join(platformPkg.dir, 'bin', binaryName);
242
+ if (!existsSync(src)) {
243
+ throw new Error(`platform package missing binary: ${platformPkg.name}`);
244
+ }
245
+ copyFileSync(src, localPath);
246
+ if (!isWindows) chmodSync(localPath, 0o755);
247
+ console.log(`✓ Installed ${binaryName} from ${platformPkg.name}`);
248
+ continue; // next binary
249
+ } catch (e) {
250
+ console.warn(`⚠ Failed platform package install (${e.message}), falling back to GitHub download`);
251
+ }
252
+ }
253
+
214
254
  // Decide archive format per OS with fallback on macOS/Linux:
215
255
  // - Windows: .zip
216
256
  // - macOS/Linux: prefer .zst if `zstd` CLI is available; otherwise use .tar.gz
@@ -283,7 +323,7 @@ async function main() {
283
323
  // Continue with other binaries even if one fails
284
324
  }
285
325
  }
286
-
326
+
287
327
  // Create platform-specific symlink/copy for main binary
288
328
  const mainBinary = `code-${targetTriple}${binaryExt}`;
289
329
  const mainBinaryPath = join(binDir, mainBinary);
@@ -312,7 +352,7 @@ async function main() {
312
352
  console.warn('⚠ Main code binary not found. You may need to build from source.');
313
353
  }
314
354
 
315
- // With bin name = 'code', handle collisions with existing 'code' (e.g., VS Code)
355
+ // With bin name = 'code', handle collisions (e.g., VS Code) and add legacy wrappers
316
356
  try {
317
357
  const isTTY = process.stdout && process.stdout.isTTY;
318
358
  const isWindows = platform() === 'win32';
@@ -339,6 +379,28 @@ async function main() {
339
379
  const codeResolved = resolveOnPath('code');
340
380
  const collision = codeResolved && ourShim && codeResolved !== ourShim;
341
381
 
382
+ const ensureWrapper = (name, args) => {
383
+ if (!globalBin) return;
384
+ try {
385
+ const wrapperPath = join(globalBin, isWindows ? `${name}.cmd` : name);
386
+ if (isWindows) {
387
+ const content = `@echo off\r\n"%~dp0${collision ? 'coder' : 'code'}" ${args} %*\r\n`;
388
+ writeFileSync(wrapperPath, content);
389
+ } else {
390
+ const content = `#!/bin/sh\nexec "$(dirname \"$0\")/${collision ? 'coder' : 'code'}" ${args} "$@"\n`;
391
+ writeFileSync(wrapperPath, content);
392
+ chmodSync(wrapperPath, 0o755);
393
+ }
394
+ console.log(`✓ Created wrapper '${name}' -> ${collision ? 'coder' : 'code'} ${args}`);
395
+ } catch (e) {
396
+ console.log(`⚠ Failed to create '${name}' wrapper: ${e.message}`);
397
+ }
398
+ };
399
+
400
+ // Always create legacy wrappers so existing scripts keep working
401
+ ensureWrapper('code-tui', '');
402
+ ensureWrapper('code-exec', 'exec');
403
+
342
404
  if (collision) {
343
405
  console.log('⚠ Detected an existing `code` command on your PATH (likely VS Code).');
344
406
  if (globalBin) {