Enhance app version retrieval in appupdate.js
All checks were successful
farmcontrol/farmcontrol-ui/pipeline/head This commit looks good
All checks were successful
farmcontrol/farmcontrol-ui/pipeline/head This commit looks good
- 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.
This commit is contained in:
parent
df1228ffa6
commit
324a4a1e6f
@ -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)
|
||||
})
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user