electrobun 0.0.19-beta.78 → 0.0.19-beta.80

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.
@@ -349,10 +349,9 @@ const Updater = {
349
349
  let newAppBundlePath: string;
350
350
  if (currentOS === 'linux' || currentOS === 'win') {
351
351
  // On Linux/Windows, the actual app is inside a subdirectory
352
- // named <appname>-<channel> (e.g., "test1-canary")
353
352
  // Use same sanitization as extractor: remove spaces and dots
354
- const sanitizedName = localInfo.name.replace(/ /g, "").replace(/\./g, "-");
355
- const appBundleName = `${sanitizedName}-${localInfo.channel}`;
353
+ // Note: localInfo.name already includes the channel (e.g., "test1-canary")
354
+ const appBundleName = localInfo.name.replace(/ /g, "").replace(/\./g, "-");
356
355
  newAppBundlePath = join(extractionFolder, appBundleName);
357
356
 
358
357
  // Verify the extracted app exists
@@ -381,7 +380,8 @@ const Updater = {
381
380
  ".."
382
381
  );
383
382
  } else {
384
- // On Windows, executable is at app/bin/launcher.exe (same as Linux)
383
+ // On Windows, handle versioned app folders
384
+ // Current executable is at app-<hash>/bin/launcher.exe
385
385
  runningAppBundlePath = resolve(
386
386
  dirname(process.execPath),
387
387
  "..",
@@ -411,8 +411,8 @@ const Updater = {
411
411
 
412
412
  // Move new app to running location
413
413
  renameSync(newAppBundlePath, runningAppBundlePath);
414
- } else {
415
- // On Linux/Windows, create tar backup and replace
414
+ } else if (currentOS === 'linux') {
415
+ // On Linux, create tar backup and replace
416
416
  // Remove existing backup.tar if it exists
417
417
  if (statSync(backupPath, { throwIfNoEntry: false })) {
418
418
  unlinkSync(backupPath);
@@ -432,6 +432,43 @@ const Updater = {
432
432
 
433
433
  // Move new app to app location
434
434
  renameSync(newAppBundlePath, runningAppBundlePath);
435
+ } else {
436
+ // On Windows, use versioned app folders
437
+ const parentDir = dirname(runningAppBundlePath);
438
+ const newVersionDir = join(parentDir, `app-${latestHash}`);
439
+
440
+ // Move new app to versioned directory
441
+ renameSync(newAppBundlePath, newVersionDir);
442
+
443
+ // Create/update the launcher batch file
444
+ const launcherPath = join(parentDir, "run.bat");
445
+ const launcherContent = `@echo off
446
+ :: Electrobun App Launcher
447
+ :: This file launches the current version and cleans up old versions
448
+
449
+ :: Set current version
450
+ set CURRENT_HASH=${latestHash}
451
+ set APP_DIR=%~dp0app-%CURRENT_HASH%
452
+
453
+ :: Clean up old app versions (keep current and one backup)
454
+ for /d %%D in ("%~dp0app-*") do (
455
+ if not "%%~nxD"=="app-%CURRENT_HASH%" (
456
+ echo Removing old version: %%~nxD
457
+ rmdir /s /q "%%D" 2>nul
458
+ )
459
+ )
460
+
461
+ :: Launch the app
462
+ cd /d "%APP_DIR%\\bin"
463
+ start "" launcher.exe
464
+ `;
465
+
466
+ await Bun.write(launcherPath, launcherContent);
467
+
468
+ // Update desktop shortcuts to point to run.bat
469
+ // This is handled by the running app, not the updater
470
+
471
+ runningAppBundlePath = newVersionDir;
435
472
  }
436
473
  } catch (error) {
437
474
  console.error("Failed to replace app with new version", error);
@@ -444,9 +481,10 @@ const Updater = {
444
481
  await Bun.spawn(["open", runningAppBundlePath]);
445
482
  break;
446
483
  case 'win':
447
- // On Windows, launch the launcher.exe inside the app directory
448
- const windowsLauncher = join(runningAppBundlePath, "bin", "launcher.exe");
449
- await Bun.spawn([windowsLauncher]);
484
+ // On Windows, launch the run.bat file which handles versioning
485
+ const parentDir = dirname(runningAppBundlePath);
486
+ const runBatPath = join(parentDir, "run.bat");
487
+ await Bun.spawn(["cmd", "/c", runBatPath], { detached: true });
450
488
  break;
451
489
  case 'linux':
452
490
  // On Linux, launch the launcher inside the app directory
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "electrobun",
3
- "version": "0.0.19-beta.78",
3
+ "version": "0.0.19-beta.80",
4
4
  "description": "Build ultra fast, tiny, and cross-platform desktop apps with Typescript.",
5
5
  "license": "MIT",
6
6
  "author": "Blackboard Technologies Inc.",
package/src/cli/index.ts CHANGED
@@ -1503,7 +1503,8 @@ if (commandArg === "init") {
1503
1503
  compressedTarPath,
1504
1504
  appFileName,
1505
1505
  targetPaths,
1506
- buildEnvironment
1506
+ buildEnvironment,
1507
+ hash
1507
1508
  );
1508
1509
 
1509
1510
  // Wrap Windows installer files in zip for distribution
@@ -1878,7 +1879,8 @@ async function createWindowsSelfExtractingExe(
1878
1879
  compressedTarPath: string,
1879
1880
  appFileName: string,
1880
1881
  targetPaths: any,
1881
- buildEnvironment: string
1882
+ buildEnvironment: string,
1883
+ hash: string
1882
1884
  ): Promise<string> {
1883
1885
  console.log("Creating Windows installer with separate archive...");
1884
1886
 
@@ -1897,7 +1899,8 @@ async function createWindowsSelfExtractingExe(
1897
1899
  const metadata = {
1898
1900
  identifier: config.app.identifier,
1899
1901
  name: config.app.name,
1900
- channel: buildEnvironment
1902
+ channel: buildEnvironment,
1903
+ hash: hash
1901
1904
  };
1902
1905
  const metadataJson = JSON.stringify(metadata, null, 2);
1903
1906
  const metadataFileName = setupFileName.replace('.exe', '.metadata.json');