electrobun 0.0.19-beta.77 → 0.0.19-beta.78
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 +51 -38
- package/package.json +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { join, dirname, resolve } from "path";
|
|
1
|
+
import { join, dirname, resolve, basename } from "path";
|
|
2
2
|
import { homedir } from "os";
|
|
3
|
-
import { renameSync, unlinkSync, mkdirSync, rmdirSync, statSync } from "fs";
|
|
3
|
+
import { renameSync, unlinkSync, mkdirSync, rmdirSync, statSync, readdirSync } from "fs";
|
|
4
4
|
import tar from "tar";
|
|
5
5
|
import { ZstdInit } from "@oneidentity/zstd-js/wasm";
|
|
6
6
|
import { OS as currentOS, ARCH as currentArch } from '../../shared/platform';
|
|
@@ -345,23 +345,23 @@ const Updater = {
|
|
|
345
345
|
join(extractionFolder, appBundleSubpath)
|
|
346
346
|
);
|
|
347
347
|
|
|
348
|
-
//
|
|
348
|
+
// Platform-specific path handling
|
|
349
349
|
let newAppBundlePath: string;
|
|
350
|
-
if (currentOS === 'linux') {
|
|
351
|
-
//
|
|
352
|
-
|
|
353
|
-
|
|
350
|
+
if (currentOS === 'linux' || currentOS === 'win') {
|
|
351
|
+
// On Linux/Windows, the actual app is inside a subdirectory
|
|
352
|
+
// named <appname>-<channel> (e.g., "test1-canary")
|
|
353
|
+
// Use same sanitization as extractor: remove spaces and dots
|
|
354
|
+
const sanitizedName = localInfo.name.replace(/ /g, "").replace(/\./g, "-");
|
|
355
|
+
const appBundleName = `${sanitizedName}-${localInfo.channel}`;
|
|
356
|
+
newAppBundlePath = join(extractionFolder, appBundleName);
|
|
354
357
|
|
|
355
|
-
//
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
// Ignore if it doesn't exist
|
|
358
|
+
// Verify the extracted app exists
|
|
359
|
+
if (!statSync(newAppBundlePath, { throwIfNoEntry: false })) {
|
|
360
|
+
console.error(`Extracted app not found at: ${newAppBundlePath}`);
|
|
361
|
+
return;
|
|
360
362
|
}
|
|
361
|
-
|
|
362
|
-
// Move the extracted app to a temporary location
|
|
363
|
-
renameSync(extractedAppPath, newAppBundlePath);
|
|
364
363
|
} else {
|
|
364
|
+
// On macOS, use the extracted app path directly
|
|
365
365
|
newAppBundlePath = extractedAppPath;
|
|
366
366
|
}
|
|
367
367
|
// Platform-specific app path calculation
|
|
@@ -388,37 +388,50 @@ const Updater = {
|
|
|
388
388
|
".."
|
|
389
389
|
);
|
|
390
390
|
}
|
|
391
|
-
// Platform-specific backup
|
|
392
|
-
let
|
|
391
|
+
// Platform-specific backup handling
|
|
392
|
+
let backupPath: string;
|
|
393
393
|
if (currentOS === 'macos') {
|
|
394
394
|
// On macOS, backup in extraction folder with .app extension
|
|
395
|
-
|
|
395
|
+
backupPath = join(extractionFolder, "backup.app");
|
|
396
396
|
} else {
|
|
397
|
-
// On Linux/Windows,
|
|
398
|
-
|
|
397
|
+
// On Linux/Windows, create a tar backup of the current app
|
|
398
|
+
backupPath = join(extractionFolder, "backup.tar");
|
|
399
399
|
}
|
|
400
400
|
|
|
401
401
|
try {
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
402
|
+
if (currentOS === 'macos') {
|
|
403
|
+
// On macOS, use rename approach
|
|
404
|
+
// Remove existing backup if it exists
|
|
405
|
+
if (statSync(backupPath, { throwIfNoEntry: false })) {
|
|
406
|
+
rmdirSync(backupPath, { recursive: true });
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
// Move current running app to backup
|
|
410
|
+
renameSync(runningAppBundlePath, backupPath);
|
|
411
|
+
|
|
412
|
+
// Move new app to running location
|
|
413
|
+
renameSync(newAppBundlePath, runningAppBundlePath);
|
|
405
414
|
} else {
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
renameSync(runningAppBundlePath, backupAppBundlePath);
|
|
411
|
-
|
|
412
|
-
// Move new app to running location
|
|
413
|
-
renameSync(newAppBundlePath, runningAppBundlePath);
|
|
414
|
-
|
|
415
|
-
// On Linux, clean up the temporary app_new if it wasn't already moved
|
|
416
|
-
if (currentOS === 'linux') {
|
|
417
|
-
try {
|
|
418
|
-
rmdirSync(newAppBundlePath, { recursive: true });
|
|
419
|
-
} catch {
|
|
420
|
-
// Ignore if already moved
|
|
415
|
+
// On Linux/Windows, create tar backup and replace
|
|
416
|
+
// Remove existing backup.tar if it exists
|
|
417
|
+
if (statSync(backupPath, { throwIfNoEntry: false })) {
|
|
418
|
+
unlinkSync(backupPath);
|
|
421
419
|
}
|
|
420
|
+
|
|
421
|
+
// Create tar backup of current app
|
|
422
|
+
await tar.c(
|
|
423
|
+
{
|
|
424
|
+
file: backupPath,
|
|
425
|
+
cwd: dirname(runningAppBundlePath),
|
|
426
|
+
},
|
|
427
|
+
[basename(runningAppBundlePath)]
|
|
428
|
+
);
|
|
429
|
+
|
|
430
|
+
// Remove current app
|
|
431
|
+
rmdirSync(runningAppBundlePath, { recursive: true });
|
|
432
|
+
|
|
433
|
+
// Move new app to app location
|
|
434
|
+
renameSync(newAppBundlePath, runningAppBundlePath);
|
|
422
435
|
}
|
|
423
436
|
} catch (error) {
|
|
424
437
|
console.error("Failed to replace app with new version", error);
|
package/package.json
CHANGED