From 324a4a1e6fd7021d0cba377a7653ca27fbb66bc9 Mon Sep 17 00:00:00 2001 From: Tom Butcher Date: Sun, 9 Aug 2026 13:45:06 +0100 Subject: [PATCH] Enhance app version retrieval in appupdate.js - Introduced a new function `formatFullAppVersion` to format the application version and build number, improving version representation. - Updated `getRunningAppVersion` to utilize the new formatting function, ensuring accurate version information is displayed. - Refactored the `getRunningAppState` function to call `getRunningAppVersion`, enhancing clarity and maintainability of the code. --- src/desktop/appupdate.js | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/src/desktop/appupdate.js b/src/desktop/appupdate.js index 6edfd8a..0ed9faa 100644 --- a/src/desktop/appupdate.js +++ b/src/desktop/appupdate.js @@ -9,6 +9,7 @@ import { launchMacInstaller } from './macappupdate.js' import { launchWindowsInstaller } from './winappupdate.js' import { checkForDuplicateInstallations } from './check-duplicate-installations.js' import { scheduleAppRestart } from './updater-runner.js' +import buildInfo from '../buildInfo.json' import { getAppSettings, setAppSettings } from './store.js' const SUPPORTED_TARGETS = { @@ -215,8 +216,30 @@ const downloadArtifact = async (artifact, destinationPath, sendProgress) => { const getRunningEngine = (mainWindow) => mainWindow?.renderer === 'cef' ? 'chromium' : 'native' +const formatFullAppVersion = (version, buildNumber) => { + const normalizedVersion = String(version || '') + .trim() + .replace(/^v/i, '') + + if (!normalizedVersion) return null + + const build = String( + buildNumber || process.env.BUILD_NUMBER || process.env.VITE_BUILD_NUMBER || '' + ).trim() + const buildSuffix = + !build || build === 'dev' ? 'dev' : build.startsWith('b') ? build : `b${build}` + + return `v${normalizedVersion}-${buildSuffix}` +} + +const getRunningAppVersion = () => + formatFullAppVersion( + process.env.ELECTROBUN_VERSION, + buildInfo?.buildNumber + ) + const getRunningAppState = (mainWindow, settings) => ({ - version: process.env.ELECTROBUN_VERSION || null, + version: getRunningAppVersion(), branch: settings?.appUpdateRunningBranch || null, engine: getRunningEngine(mainWindow) })