@just-every/code 0.2.34 → 0.2.35

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 +1 -1
  2. package/postinstall.js +55 -8
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@just-every/code",
3
- "version": "0.2.34",
3
+ "version": "0.2.35",
4
4
  "license": "Apache-2.0",
5
5
  "description": "Lightweight coding agent that runs in your terminal - fork of OpenAI Codex",
6
6
  "bin": {
package/postinstall.js CHANGED
@@ -186,7 +186,7 @@ async function main() {
186
186
  const packageJson = JSON.parse(readFileSync(join(__dirname, 'package.json'), 'utf8'));
187
187
  const version = packageJson.version;
188
188
 
189
- // Binary names to download (new naming is 'code*')
189
+ // Binary names to download (standardized 'code-*' naming)
190
190
  const binaries = ['code', 'code-tui', 'code-exec'];
191
191
 
192
192
  console.log(`Installing @just-every/code v${version} for ${targetTriple}...`);
@@ -211,11 +211,58 @@ async function main() {
211
211
  continue;
212
212
  }
213
213
 
214
- const downloadUrl = `https://github.com/just-every/code/releases/download/v${version}/${binaryName}`;
215
-
216
- console.log(`Downloading ${binaryName}...`);
214
+ // Decide archive format per OS with fallback on macOS/Linux:
215
+ // - Windows: .zip
216
+ // - macOS/Linux: prefer .zst if `zstd` CLI is available; otherwise use .tar.gz
217
+ const isWin = isWindows;
218
+ let useZst = false;
219
+ if (!isWin) {
220
+ try {
221
+ execSync('zstd --version', { stdio: 'ignore', shell: true });
222
+ useZst = true;
223
+ } catch {
224
+ useZst = false;
225
+ }
226
+ }
227
+ const archiveName = isWin ? `${binaryName}.zip` : (useZst ? `${binaryName}.zst` : `${binaryName}.tar.gz`);
228
+ const downloadUrl = `https://github.com/just-every/code/releases/download/v${version}/${archiveName}`;
229
+
230
+ console.log(`Downloading ${archiveName}...`);
217
231
  try {
218
- await downloadBinary(downloadUrl, localPath);
232
+ const tmpPath = join(binDir, `.${archiveName}.part`);
233
+ await downloadBinary(downloadUrl, tmpPath);
234
+
235
+ if (isWin) {
236
+ // Unzip the single-file archive using PowerShell (built-in)
237
+ try {
238
+ const psCmd = `powershell -NoProfile -NonInteractive -Command "Expand-Archive -Path '${tmpPath}' -DestinationPath '${binDir}' -Force"`;
239
+ execSync(psCmd, { stdio: 'ignore' });
240
+ } catch (e) {
241
+ throw new Error(`failed to unzip archive: ${e.message}`);
242
+ } finally {
243
+ try { unlinkSync(tmpPath); } catch {}
244
+ }
245
+ } else {
246
+ if (useZst) {
247
+ // Decompress .zst via system zstd
248
+ try {
249
+ execSync(`zstd -d '${tmpPath}' -o '${localPath}'`, { stdio: 'ignore', shell: true });
250
+ } catch (e) {
251
+ try { unlinkSync(tmpPath); } catch {}
252
+ throw new Error(`failed to decompress .zst (need zstd CLI): ${e.message}`);
253
+ }
254
+ try { unlinkSync(tmpPath); } catch {}
255
+ } else {
256
+ // Extract .tar.gz using system tar
257
+ try {
258
+ execSync(`tar -xzf '${tmpPath}' -C '${binDir}'`, { stdio: 'ignore', shell: true });
259
+ } catch (e) {
260
+ try { unlinkSync(tmpPath); } catch {}
261
+ throw new Error(`failed to extract .tar.gz: ${e.message}`);
262
+ }
263
+ try { unlinkSync(tmpPath); } catch {}
264
+ }
265
+ }
219
266
 
220
267
  // Validate header to avoid corrupt binaries causing spawn EFTYPE/ENOEXEC
221
268
  const valid = validateDownloadedBinary(localPath);
@@ -229,10 +276,10 @@ async function main() {
229
276
  chmodSync(localPath, 0o755);
230
277
  }
231
278
 
232
- console.log(`✓ Downloaded ${binaryName}`);
279
+ console.log(`✓ Installed ${binaryName}`);
233
280
  } catch (error) {
234
- console.error(`✗ Failed to download ${binaryName}: ${error.message}`);
235
- console.error(` URL: ${downloadUrl}`);
281
+ console.error(`✗ Failed to install ${binaryName}: ${error.message}`);
282
+ console.error(` Downloaded from: ${downloadUrl}`);
236
283
  // Continue with other binaries even if one fails
237
284
  }
238
285
  }