@just-every/code 0.2.34 → 0.2.36
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/package.json +1 -1
- package/postinstall.js +80 -11
package/package.json
CHANGED
package/postinstall.js
CHANGED
|
@@ -186,8 +186,8 @@ async function main() {
|
|
|
186
186
|
const packageJson = JSON.parse(readFileSync(join(__dirname, 'package.json'), 'utf8'));
|
|
187
187
|
const version = packageJson.version;
|
|
188
188
|
|
|
189
|
-
//
|
|
190
|
-
const binaries = ['code'
|
|
189
|
+
// Download only the primary binary; we'll create wrappers for legacy names.
|
|
190
|
+
const binaries = ['code'];
|
|
191
191
|
|
|
192
192
|
console.log(`Installing @just-every/code v${version} for ${targetTriple}...`);
|
|
193
193
|
|
|
@@ -211,11 +211,58 @@ async function main() {
|
|
|
211
211
|
continue;
|
|
212
212
|
}
|
|
213
213
|
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
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
|
-
|
|
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,14 +276,14 @@ async function main() {
|
|
|
229
276
|
chmodSync(localPath, 0o755);
|
|
230
277
|
}
|
|
231
278
|
|
|
232
|
-
console.log(`✓
|
|
279
|
+
console.log(`✓ Installed ${binaryName}`);
|
|
233
280
|
} catch (error) {
|
|
234
|
-
console.error(`✗ Failed to
|
|
235
|
-
console.error(`
|
|
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
|
}
|
|
239
|
-
|
|
286
|
+
|
|
240
287
|
// Create platform-specific symlink/copy for main binary
|
|
241
288
|
const mainBinary = `code-${targetTriple}${binaryExt}`;
|
|
242
289
|
const mainBinaryPath = join(binDir, mainBinary);
|
|
@@ -265,7 +312,7 @@ async function main() {
|
|
|
265
312
|
console.warn('⚠ Main code binary not found. You may need to build from source.');
|
|
266
313
|
}
|
|
267
314
|
|
|
268
|
-
// With bin name = 'code', handle collisions
|
|
315
|
+
// With bin name = 'code', handle collisions (e.g., VS Code) and add legacy wrappers
|
|
269
316
|
try {
|
|
270
317
|
const isTTY = process.stdout && process.stdout.isTTY;
|
|
271
318
|
const isWindows = platform() === 'win32';
|
|
@@ -292,6 +339,28 @@ async function main() {
|
|
|
292
339
|
const codeResolved = resolveOnPath('code');
|
|
293
340
|
const collision = codeResolved && ourShim && codeResolved !== ourShim;
|
|
294
341
|
|
|
342
|
+
const ensureWrapper = (name, args) => {
|
|
343
|
+
if (!globalBin) return;
|
|
344
|
+
try {
|
|
345
|
+
const wrapperPath = join(globalBin, isWindows ? `${name}.cmd` : name);
|
|
346
|
+
if (isWindows) {
|
|
347
|
+
const content = `@echo off\r\n"%~dp0${collision ? 'coder' : 'code'}" ${args} %*\r\n`;
|
|
348
|
+
writeFileSync(wrapperPath, content);
|
|
349
|
+
} else {
|
|
350
|
+
const content = `#!/bin/sh\nexec "$(dirname \"$0\")/${collision ? 'coder' : 'code'}" ${args} "$@"\n`;
|
|
351
|
+
writeFileSync(wrapperPath, content);
|
|
352
|
+
chmodSync(wrapperPath, 0o755);
|
|
353
|
+
}
|
|
354
|
+
console.log(`✓ Created wrapper '${name}' -> ${collision ? 'coder' : 'code'} ${args}`);
|
|
355
|
+
} catch (e) {
|
|
356
|
+
console.log(`⚠ Failed to create '${name}' wrapper: ${e.message}`);
|
|
357
|
+
}
|
|
358
|
+
};
|
|
359
|
+
|
|
360
|
+
// Always create legacy wrappers so existing scripts keep working
|
|
361
|
+
ensureWrapper('code-tui', '');
|
|
362
|
+
ensureWrapper('code-exec', 'exec');
|
|
363
|
+
|
|
295
364
|
if (collision) {
|
|
296
365
|
console.log('⚠ Detected an existing `code` command on your PATH (likely VS Code).');
|
|
297
366
|
if (globalBin) {
|