electrobun 1.2.2-beta.1 → 1.2.2-beta.3
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/dist/api/bun/core/Updater.ts +50 -13
- package/package.json +1 -1
- package/src/cli/index.ts +4 -3
|
@@ -321,14 +321,40 @@ const Updater = {
|
|
|
321
321
|
);
|
|
322
322
|
|
|
323
323
|
const bunBinDir = dirname(process.execPath);
|
|
324
|
-
const
|
|
324
|
+
const bspatchBinName = currentOS === 'win' ? 'bspatch.exe' : 'bspatch';
|
|
325
|
+
const bspatchPath = join(bunBinDir, bspatchBinName);
|
|
325
326
|
|
|
326
327
|
emitStatus('applying-patch', `Applying patch ${patchesApplied + 1} for ${currentHash.slice(0, 8)}...`, {
|
|
327
328
|
currentHash,
|
|
328
329
|
patchNumber: patchesApplied + 1,
|
|
329
330
|
});
|
|
330
331
|
|
|
331
|
-
//
|
|
332
|
+
// Verify all files exist before invoking bspatch
|
|
333
|
+
if (!statSync(bspatchPath, { throwIfNoEntry: false })) {
|
|
334
|
+
emitStatus('patch-failed', `bspatch binary not found at ${bspatchPath}`, {
|
|
335
|
+
currentHash,
|
|
336
|
+
errorMessage: `bspatch not found: ${bspatchPath}`,
|
|
337
|
+
});
|
|
338
|
+
console.error("bspatch not found:", bspatchPath);
|
|
339
|
+
break;
|
|
340
|
+
}
|
|
341
|
+
if (!statSync(currentTarPath, { throwIfNoEntry: false })) {
|
|
342
|
+
emitStatus('patch-failed', `Old tar not found at ${currentTarPath}`, {
|
|
343
|
+
currentHash,
|
|
344
|
+
errorMessage: `old tar not found: ${currentTarPath}`,
|
|
345
|
+
});
|
|
346
|
+
console.error("old tar not found:", currentTarPath);
|
|
347
|
+
break;
|
|
348
|
+
}
|
|
349
|
+
if (!statSync(patchFilePath, { throwIfNoEntry: false })) {
|
|
350
|
+
emitStatus('patch-failed', `Patch file not found at ${patchFilePath}`, {
|
|
351
|
+
currentHash,
|
|
352
|
+
errorMessage: `patch not found: ${patchFilePath}`,
|
|
353
|
+
});
|
|
354
|
+
console.error("patch file not found:", patchFilePath);
|
|
355
|
+
break;
|
|
356
|
+
}
|
|
357
|
+
|
|
332
358
|
try {
|
|
333
359
|
const patchResult = Bun.spawnSync([
|
|
334
360
|
bspatchPath,
|
|
@@ -343,7 +369,7 @@ const Updater = {
|
|
|
343
369
|
if (updateInfo) {
|
|
344
370
|
updateInfo.error = stderr || `bspatch failed with exit code ${patchResult.exitCode}`;
|
|
345
371
|
}
|
|
346
|
-
emitStatus('patch-failed', `Patch application failed: ${stderr ||
|
|
372
|
+
emitStatus('patch-failed', `Patch application failed: ${stderr || `exit code ${patchResult.exitCode}`}`, {
|
|
347
373
|
currentHash,
|
|
348
374
|
errorMessage: stderr || `exit code ${patchResult.exitCode}`,
|
|
349
375
|
});
|
|
@@ -353,6 +379,10 @@ const Updater = {
|
|
|
353
379
|
exitCode: patchResult.exitCode,
|
|
354
380
|
stdout,
|
|
355
381
|
stderr,
|
|
382
|
+
bspatchPath,
|
|
383
|
+
oldTar: currentTarPath,
|
|
384
|
+
newTar: tmpPatchedTarFilePath,
|
|
385
|
+
patch: patchFilePath,
|
|
356
386
|
},
|
|
357
387
|
);
|
|
358
388
|
break;
|
|
@@ -362,7 +392,7 @@ const Updater = {
|
|
|
362
392
|
currentHash,
|
|
363
393
|
errorMessage: (error as Error).message,
|
|
364
394
|
});
|
|
365
|
-
console.error("bspatch threw", error);
|
|
395
|
+
console.error("bspatch threw", error, { bspatchPath });
|
|
366
396
|
break;
|
|
367
397
|
}
|
|
368
398
|
|
|
@@ -374,19 +404,20 @@ const Updater = {
|
|
|
374
404
|
|
|
375
405
|
emitStatus('extracting-version', 'Extracting version info from patched tar...', { currentHash });
|
|
376
406
|
|
|
377
|
-
let
|
|
407
|
+
let hashFilePath = "";
|
|
378
408
|
const untarDir = join(appDataFolder, "self-extraction", "tmpuntar");
|
|
379
409
|
mkdirSync(untarDir, { recursive: true });
|
|
380
410
|
|
|
381
|
-
//
|
|
382
|
-
|
|
411
|
+
// Extract the hash from the patched tar:
|
|
412
|
+
// - macOS/Windows: Resources/version.json (inside the app bundle directory)
|
|
413
|
+
// - Linux: metadata.json (alongside the AppImage, since AppImage is opaque)
|
|
414
|
+
const resourcesDir = 'Resources';
|
|
383
415
|
await tar.x({
|
|
384
|
-
// gzip: false,
|
|
385
416
|
file: tmpPatchedTarFilePath,
|
|
386
417
|
cwd: untarDir,
|
|
387
418
|
filter: (path: string) => {
|
|
388
|
-
if (path.endsWith(`${resourcesDir}/version.json`)) {
|
|
389
|
-
|
|
419
|
+
if (path.endsWith(`${resourcesDir}/version.json`) || path.endsWith('metadata.json')) {
|
|
420
|
+
hashFilePath = path;
|
|
390
421
|
return true;
|
|
391
422
|
} else {
|
|
392
423
|
return false;
|
|
@@ -394,10 +425,16 @@ const Updater = {
|
|
|
394
425
|
},
|
|
395
426
|
});
|
|
396
427
|
|
|
397
|
-
|
|
398
|
-
|
|
428
|
+
if (!hashFilePath) {
|
|
429
|
+
emitStatus('error', 'Could not find version/metadata file in patched tar', { currentHash });
|
|
430
|
+
console.error("Neither Resources/version.json nor metadata.json found in patched tar:", tmpPatchedTarFilePath);
|
|
431
|
+
break;
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
const hashFileJson = await Bun.file(
|
|
435
|
+
join(untarDir, hashFilePath)
|
|
399
436
|
).json();
|
|
400
|
-
const nextHash =
|
|
437
|
+
const nextHash = hashFileJson.hash;
|
|
401
438
|
|
|
402
439
|
if (seenHashes.includes(nextHash)) {
|
|
403
440
|
emitStatus('error', 'Cyclical update detected, falling back to full download', { currentHash: nextHash });
|
package/package.json
CHANGED
package/src/cli/index.ts
CHANGED
|
@@ -2065,7 +2065,7 @@ if (commandArg === "init") {
|
|
|
2065
2065
|
// 3. Icon file
|
|
2066
2066
|
// 4. Metadata
|
|
2067
2067
|
|
|
2068
|
-
const tempDirName = `${appFileName}-
|
|
2068
|
+
const tempDirName = `${appFileName}-tar-staging`;
|
|
2069
2069
|
const tempDirPath = join(buildFolder, tempDirName);
|
|
2070
2070
|
|
|
2071
2071
|
// Clean up any existing temp directory
|
|
@@ -2078,7 +2078,7 @@ if (commandArg === "init") {
|
|
|
2078
2078
|
const innerDirPath = join(tempDirPath, appFileName);
|
|
2079
2079
|
mkdirSync(innerDirPath, { recursive: true });
|
|
2080
2080
|
|
|
2081
|
-
// Copy AppImage
|
|
2081
|
+
// Copy AppImage (the inner app bundle on Linux)
|
|
2082
2082
|
const appImageDestPath = join(innerDirPath, `${appFileName}.AppImage`);
|
|
2083
2083
|
cpSync(appImagePath, appImageDestPath, { dereference: true });
|
|
2084
2084
|
|
|
@@ -2099,7 +2099,8 @@ if (commandArg === "init") {
|
|
|
2099
2099
|
identifier: config.app.identifier,
|
|
2100
2100
|
name: config.app.name,
|
|
2101
2101
|
version: config.app.version,
|
|
2102
|
-
channel: buildEnvironment
|
|
2102
|
+
channel: buildEnvironment,
|
|
2103
|
+
hash: hash,
|
|
2103
2104
|
};
|
|
2104
2105
|
writeFileSync(join(innerDirPath, 'metadata.json'), JSON.stringify(metadata, null, 2));
|
|
2105
2106
|
|