electrobun 0.0.19-beta.90 → 0.0.19-beta.91

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,7 @@
1
1
  import { join, dirname, resolve, basename } from "path";
2
2
  import { homedir } from "os";
3
3
  import { renameSync, unlinkSync, mkdirSync, rmdirSync, statSync, readdirSync, cpSync } from "fs";
4
+ import { execSync } from "child_process";
4
5
  import tar from "tar";
5
6
  import { ZstdInit } from "@oneidentity/zstd-js/wasm";
6
7
  import { OS as currentOS, ARCH as currentArch } from '../../shared/platform';
@@ -321,26 +322,55 @@ const Updater = {
321
322
  let appBundleSubpath: string = "";
322
323
 
323
324
  if (await Bun.file(latestTarPath).exists()) {
324
- await tar.x({
325
- // gzip: false,
326
- file: latestTarPath,
327
- cwd: extractionFolder,
328
- onentry: (entry) => {
329
- if (currentOS === 'macos') {
330
- // find the first .app bundle in the tarball
331
- // Some apps may have nested .app bundles
332
- if (!appBundleSubpath && entry.path.endsWith(".app/")) {
333
- appBundleSubpath = entry.path;
334
- }
335
- } else {
336
- // For Windows/Linux, look for the main executable
337
- // This assumes the tarball contains the app at the root
338
- if (!appBundleSubpath) {
339
- appBundleSubpath = "./";
325
+ // Windows needs a temporary directory to avoid file locking issues
326
+ const extractionDir = currentOS === 'win'
327
+ ? join(extractionFolder, `temp-${latestHash}`)
328
+ : extractionFolder;
329
+
330
+ if (currentOS === 'win') {
331
+ mkdirSync(extractionDir, { recursive: true });
332
+ }
333
+
334
+ // Use Windows native tar.exe on Windows due to npm tar library issues (same as CLI)
335
+ if (currentOS === 'win') {
336
+ console.log(`Using Windows native tar.exe to extract ${latestTarPath} to ${extractionDir}...`);
337
+ try {
338
+ execSync(`tar -xf "${latestTarPath}" -C "${extractionDir}"`, {
339
+ stdio: 'inherit',
340
+ cwd: extractionDir
341
+ });
342
+ console.log('Windows tar.exe extraction completed successfully');
343
+
344
+ // For Windows/Linux, the app bundle is at root level
345
+ appBundleSubpath = "./";
346
+ } catch (error) {
347
+ console.error('Windows tar.exe extraction failed:', error);
348
+ throw error;
349
+ }
350
+ } else {
351
+ // Use npm tar library on macOS/Linux (keep original behavior)
352
+ await tar.x({
353
+ // gzip: false,
354
+ file: latestTarPath,
355
+ cwd: extractionDir,
356
+ onentry: (entry) => {
357
+ if (currentOS === 'macos') {
358
+ // find the first .app bundle in the tarball
359
+ // Some apps may have nested .app bundles
360
+ if (!appBundleSubpath && entry.path.endsWith(".app/")) {
361
+ appBundleSubpath = entry.path;
362
+ }
363
+ } else {
364
+ // For Linux, look for the main executable
365
+ if (!appBundleSubpath) {
366
+ appBundleSubpath = "./";
367
+ }
340
368
  }
341
- }
342
- },
343
- });
369
+ },
370
+ });
371
+ }
372
+
373
+ console.log(`Tar extraction completed. Found appBundleSubpath: ${appBundleSubpath}`);
344
374
 
345
375
  if (!appBundleSubpath) {
346
376
  console.error("Failed to find app in tarball");
@@ -349,7 +379,7 @@ const Updater = {
349
379
 
350
380
  // Note: resolve here removes the extra trailing / that the tar file adds
351
381
  const extractedAppPath = resolve(
352
- join(extractionFolder, appBundleSubpath)
382
+ join(extractionDir, appBundleSubpath)
353
383
  );
354
384
 
355
385
  // Platform-specific path handling
@@ -359,11 +389,20 @@ const Updater = {
359
389
  // Use same sanitization as extractor: remove spaces and dots
360
390
  // Note: localInfo.name already includes the channel (e.g., "test1-canary")
361
391
  const appBundleName = localInfo.name.replace(/ /g, "").replace(/\./g, "-");
362
- newAppBundlePath = join(extractionFolder, appBundleName);
392
+ newAppBundlePath = join(extractionDir, appBundleName);
363
393
 
364
394
  // Verify the extracted app exists
365
395
  if (!statSync(newAppBundlePath, { throwIfNoEntry: false })) {
366
396
  console.error(`Extracted app not found at: ${newAppBundlePath}`);
397
+ console.log("Contents of extraction directory:");
398
+ try {
399
+ const files = readdirSync(extractionDir);
400
+ for (const file of files) {
401
+ console.log(` - ${file}`);
402
+ }
403
+ } catch (e) {
404
+ console.log("Could not list directory contents:", e);
405
+ }
367
406
  return;
368
407
  }
369
408
  } else {
@@ -458,8 +497,10 @@ const Updater = {
458
497
  }
459
498
  }
460
499
 
461
- // Remove the extracted app directory
462
- rmdirSync(newAppBundlePath, { recursive: true });
500
+ // Clean up the temporary extraction directory on Windows
501
+ if (currentOS === 'win') {
502
+ rmdirSync(extractionDir, { recursive: true });
503
+ }
463
504
 
464
505
  // Create/update the launcher batch file
465
506
  const launcherPath = join(parentDir, "run.bat");
@@ -507,6 +548,8 @@ start "" launcher.exe
507
548
  // On Windows, launch the run.bat file which handles versioning
508
549
  const parentDir = dirname(runningAppBundlePath);
509
550
  const runBatPath = join(parentDir, "run.bat");
551
+
552
+
510
553
  await Bun.spawn(["cmd", "/c", runBatPath], { detached: true });
511
554
  break;
512
555
  case 'linux':
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "electrobun",
3
- "version": "0.0.19-beta.90",
3
+ "version": "0.0.19-beta.91",
4
4
  "description": "Build ultra fast, tiny, and cross-platform desktop apps with Typescript.",
5
5
  "license": "MIT",
6
6
  "author": "Blackboard Technologies Inc.",