electrobun 0.0.19-beta.76 → 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';
@@ -14,8 +14,8 @@ function getAppDataDir(): string {
14
14
  // Use LOCALAPPDATA to match extractor location
15
15
  return process.env.LOCALAPPDATA || join(homedir(), "AppData", "Local");
16
16
  case 'linux':
17
- // Use XDG_CONFIG_HOME or fallback to ~/.config
18
- return process.env.XDG_CONFIG_HOME || join(homedir(), ".config");
17
+ // Use XDG_DATA_HOME or fallback to ~/.local/share to match extractor
18
+ return process.env.XDG_DATA_HOME || join(homedir(), ".local", "share");
19
19
  default:
20
20
  // Fallback to home directory with .config
21
21
  return join(homedir(), ".config");
@@ -345,16 +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
- // Move the extracted app to a temporary location
356
- renameSync(extractedAppPath, newAppBundlePath);
358
+ // Verify the extracted app exists
359
+ if (!statSync(newAppBundlePath, { throwIfNoEntry: false })) {
360
+ console.error(`Extracted app not found at: ${newAppBundlePath}`);
361
+ return;
362
+ }
357
363
  } else {
364
+ // On macOS, use the extracted app path directly
358
365
  newAppBundlePath = extractedAppPath;
359
366
  }
360
367
  // Platform-specific app path calculation
@@ -381,37 +388,50 @@ const Updater = {
381
388
  ".."
382
389
  );
383
390
  }
384
- // Platform-specific backup naming and location
385
- let backupAppBundlePath: string;
391
+ // Platform-specific backup handling
392
+ let backupPath: string;
386
393
  if (currentOS === 'macos') {
387
394
  // On macOS, backup in extraction folder with .app extension
388
- backupAppBundlePath = join(extractionFolder, "backup.app");
395
+ backupPath = join(extractionFolder, "backup.app");
389
396
  } else {
390
- // On Linux/Windows, keep backup in self-extraction folder
391
- backupAppBundlePath = join(extractionFolder, "backup");
397
+ // On Linux/Windows, create a tar backup of the current app
398
+ backupPath = join(extractionFolder, "backup.tar");
392
399
  }
393
400
 
394
401
  try {
395
- // Remove existing backup if it exists
396
- if (statSync(backupAppBundlePath, { throwIfNoEntry: false })) {
397
- 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);
398
414
  } else {
399
- console.log("backupAppBundlePath does not exist");
400
- }
401
-
402
- // Move current running app to backup
403
- renameSync(runningAppBundlePath, backupAppBundlePath);
404
-
405
- // Move new app to running location
406
- renameSync(newAppBundlePath, runningAppBundlePath);
407
-
408
- // On Linux, clean up the temporary app_new if it wasn't already moved
409
- if (currentOS === 'linux') {
410
- try {
411
- rmdirSync(newAppBundlePath, { recursive: true });
412
- } catch {
413
- // 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);
414
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);
415
435
  }
416
436
  } catch (error) {
417
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.76",
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.",