Compare commits

...

2 Commits

Author SHA1 Message Date
324a4a1e6f Enhance app version retrieval in appupdate.js
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.
2026-08-09 13:45:06 +01:00
df1228ffa6 Refactor Windows installer progress parsing to improve file name handling
- Updated the parsing logic in `parseWindowsInstallerProgress` to extract the file name from the copy file path, ensuring only the file name is displayed in progress messages.
- Enhanced readability by renaming the variable from `relativePath` to `fileName` and added logic to handle paths correctly.
2026-08-09 13:40:02 +01:00
2 changed files with 30 additions and 4 deletions

View File

@ -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)
})

View File

@ -45,7 +45,10 @@ const parseWindowsInstallerProgress = (output) => {
const copyFile = line.match(/^installer:COPY_FILE:(\d+):(.*)$/)
if (copyFile) {
const fileBytes = Number.parseInt(copyFile[1], 10)
const relativePath = copyFile[2].trim()
var fileName = copyFile[2].trim()
if (fileName.includes('\\')) {
fileName = fileName.split('\\').pop()
}
if (Number.isFinite(fileBytes)) {
copiedBytes += fileBytes
@ -57,8 +60,8 @@ const parseWindowsInstallerProgress = (output) => {
}
}
if (relativePath) {
message = `Copying ${relativePath} (${formatBytes(fileBytes)})`
if (fileName) {
message = `Copying ${fileName} (${formatBytes(fileBytes)})`
}
}
} else if (