Refactor app version handling in appupdate.js and rpc.js
All checks were successful
farmcontrol/farmcontrol-ui/pipeline/head This commit looks good

- Updated `getRunningAppVersion` to retrieve the version from `package.json`, ensuring accurate version representation.
- Modified `getAppVersion` in `rpc.js` to utilize the refactored `getRunningAppVersion`, improving consistency in version reporting.
This commit is contained in:
Tom Butcher 2026-08-09 15:25:43 +01:00
parent 578caaffc2
commit f52f0e35a9
2 changed files with 9 additions and 7 deletions

View File

@ -10,6 +10,7 @@ import { launchWindowsInstaller } from './winappupdate.js'
import { checkForDuplicateInstallations } from './check-duplicate-installations.js'
import { scheduleAppRestart } from './updater-runner.js'
import buildInfo from '../buildInfo.json'
import { version as packageVersion } from '../../package.json'
import { getAppSettings, setAppSettings } from './store.js'
const SUPPORTED_TARGETS = {
@ -232,11 +233,8 @@ const formatFullAppVersion = (version, buildNumber) => {
return `v${normalizedVersion}-${buildSuffix}`
}
const getRunningAppVersion = () =>
formatFullAppVersion(
process.env.ELECTROBUN_VERSION,
buildInfo?.buildNumber
)
export const getRunningAppVersion = () =>
formatFullAppVersion(packageVersion, buildInfo?.buildNumber)
const getRunningAppState = (mainWindow, settings) => ({
version: getRunningAppVersion(),

View File

@ -1,5 +1,9 @@
import { BrowserView } from 'electrobun/bun'
import { checkForCompletedUpdate, startAppUpdate } from './appupdate.js'
import {
checkForCompletedUpdate,
getRunningAppVersion,
startAppUpdate
} from './appupdate.js'
import {
checkForDuplicateInstallations,
removeDuplicateInstallations
@ -89,7 +93,7 @@ export function createAppRpc() {
})
return { ok: true }
},
getAppVersion: async () => process.env.ELECTROBUN_VERSION || 'desktop',
getAppVersion: async () => getRunningAppVersion() || 'desktop',
getAppEngine: async () => {
const mainWindow = getMainWindow()
const renderer = mainWindow?.renderer || 'native'