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.
@@ -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
- // On Linux, we need to move the app from self-extraction to the app directory
348
+ // Platform-specific path handling
349
349
  let newAppBundlePath: string;
350
- if (currentOS === 'linux') {
351
- // Get the parent directory (one level up from self-extraction)
352
- const parentDir = resolve(extractionFolder, "..");
353
- newAppBundlePath = join(parentDir, "app_new");
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
- // Remove app_new if it already exists
356
- try {
357
- rmdirSync(newAppBundlePath, { recursive: true });
358
- } catch {
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 naming and location
392
- let backupAppBundlePath: string;
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
- backupAppBundlePath = join(extractionFolder, "backup.app");
395
+ backupPath = join(extractionFolder, "backup.app");
396
396
  } else {
397
- // On Linux/Windows, keep backup in self-extraction folder
398
- backupAppBundlePath = join(extractionFolder, "backup");
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
- // Remove existing backup if it exists
403
- if (statSync(backupAppBundlePath, { throwIfNoEntry: false })) {
404
- rmdirSync(backupAppBundlePath, { recursive: true });
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
- console.log("backupAppBundlePath does not exist");
407
- }
408
-
409
- // Move current running app to backup
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "electrobun",
3
- "version": "0.0.19-beta.77",
3
+ "version": "0.0.19-beta.78",
4
4
  "description": "Build ultra fast, tiny, and cross-platform desktop apps with Typescript.",
5
5
  "license": "MIT",
6
6
  "author": "Blackboard Technologies Inc.",