electrobun 0.0.19-beta.88 → 0.0.19-beta.90
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 +32 -11
- package/package.json +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { join, dirname, resolve, basename } from "path";
|
|
2
2
|
import { homedir } from "os";
|
|
3
|
-
import { renameSync, unlinkSync, mkdirSync, rmdirSync, statSync, readdirSync } from "fs";
|
|
3
|
+
import { renameSync, unlinkSync, mkdirSync, rmdirSync, statSync, readdirSync, cpSync } 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';
|
|
@@ -439,26 +439,47 @@ const Updater = {
|
|
|
439
439
|
const parentDir = dirname(runningAppBundlePath);
|
|
440
440
|
const newVersionDir = join(parentDir, `app-${latestHash}`);
|
|
441
441
|
|
|
442
|
-
//
|
|
443
|
-
|
|
442
|
+
// Create the versioned directory
|
|
443
|
+
mkdirSync(newVersionDir, { recursive: true });
|
|
444
|
+
|
|
445
|
+
// Copy all contents from the extracted app to the versioned directory
|
|
446
|
+
const files = readdirSync(newAppBundlePath);
|
|
447
|
+
for (const file of files) {
|
|
448
|
+
const srcPath = join(newAppBundlePath, file);
|
|
449
|
+
const destPath = join(newVersionDir, file);
|
|
450
|
+
const stats = statSync(srcPath);
|
|
451
|
+
|
|
452
|
+
if (stats.isDirectory()) {
|
|
453
|
+
// Recursively copy directories
|
|
454
|
+
cpSync(srcPath, destPath, { recursive: true });
|
|
455
|
+
} else {
|
|
456
|
+
// Copy files
|
|
457
|
+
cpSync(srcPath, destPath);
|
|
458
|
+
}
|
|
459
|
+
}
|
|
460
|
+
|
|
461
|
+
// Remove the extracted app directory
|
|
462
|
+
rmdirSync(newAppBundlePath, { recursive: true });
|
|
444
463
|
|
|
445
464
|
// Create/update the launcher batch file
|
|
446
465
|
const launcherPath = join(parentDir, "run.bat");
|
|
447
466
|
const launcherContent = `@echo off
|
|
448
467
|
:: Electrobun App Launcher
|
|
449
|
-
:: This file launches the current version
|
|
468
|
+
:: This file launches the current version
|
|
450
469
|
|
|
451
470
|
:: Set current version
|
|
452
471
|
set CURRENT_HASH=${latestHash}
|
|
453
472
|
set APP_DIR=%~dp0app-%CURRENT_HASH%
|
|
454
473
|
|
|
455
|
-
::
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
474
|
+
:: TODO: Implement proper cleanup mechanism that checks for running processes
|
|
475
|
+
:: For now, old versions are kept to avoid race conditions during updates
|
|
476
|
+
:: :: Clean up old app versions (keep current and one backup)
|
|
477
|
+
:: for /d %%D in ("%~dp0app-*") do (
|
|
478
|
+
:: if not "%%~nxD"=="app-%CURRENT_HASH%" (
|
|
479
|
+
:: echo Removing old version: %%~nxD
|
|
480
|
+
:: rmdir /s /q "%%D" 2>nul
|
|
481
|
+
:: )
|
|
482
|
+
:: )
|
|
462
483
|
|
|
463
484
|
:: Launch the app
|
|
464
485
|
cd /d "%APP_DIR%\\bin"
|
package/package.json
CHANGED