Compare commits

..

No commits in common. "3caae592f191b6aeea3b056d2e139f476c510588" and "324a4a1e6fd7021d0cba377a7653ca27fbb66bc9" have entirely different histories.

5 changed files with 22 additions and 168 deletions

View File

@ -67,7 +67,7 @@ Function .onInit
!insertmacro progressPhase "Starting installation" !insertmacro progressPhase "Starting installation"
!insertmacro progressStatus "Starting Farm Control installation..." !insertmacro progressStatus "Starting Farm Control installation..."
!insertmacro progressCopyTotal "${APP_COPY_TOTAL_BYTES}" !insertmacro progressCopyTotal "${APP_COPY_TOTAL_BYTES}"
!insertmacro progressStart !insertmacro progressPercent 0
; In-app updates install into Farm Control.new while the running process ; In-app updates install into Farm Control.new while the running process
; keeps using Farm Control; the folders are swapped after exit (/RESTARTFC). ; keeps using Farm Control; the folders are swapped after exit (/RESTARTFC).
@ -78,8 +78,6 @@ Function .onInit
StrCpy $FinalInstDir $INSTDIR StrCpy $FinalInstDir $INSTDIR
!insertmacro uninstallPreviousFarmControl !insertmacro uninstallPreviousFarmControl
${EndIf} ${EndIf}
!insertmacro progressPrepare
FunctionEnd FunctionEnd
Function .onInstFailed Function .onInstFailed
@ -95,17 +93,17 @@ Section "Farm Control" SecMain
!insertmacro progressPhase "Copying application files" !insertmacro progressPhase "Copying application files"
!insertmacro progressStatus "Copying application files..." !insertmacro progressStatus "Copying application files..."
!insertmacro progressCopyStart !insertmacro progressPercent 0
SetOverwrite try SetOverwrite try
!insertmacro copyApplicationFilesWithProgress !insertmacro copyApplicationFilesWithProgress
!insertmacro progressCopyComplete !insertmacro progressPercent 75
!insertmacro customInstall !insertmacro customInstall
!insertmacro progressFinalizeInstall
!insertmacro progressPhase "Finalizing installation" !insertmacro progressPhase "Finalizing installation"
!insertmacro progressStatus "Writing installation registry entries..." !insertmacro progressStatus "Writing uninstall information..."
!insertmacro progressPercent 90
WriteRegStr HKCU "Software\Tom Butcher\Farm Control" "InstallDir" $FinalInstDir WriteRegStr HKCU "Software\Tom Butcher\Farm Control" "InstallDir" $FinalInstDir
WriteRegStr HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\Farm Control" \ WriteRegStr HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\Farm Control" \
@ -121,14 +119,8 @@ Section "Farm Control" SecMain
WriteRegDWORD HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\Farm Control" \ WriteRegDWORD HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\Farm Control" \
"NoRepair" 1 "NoRepair" 1
!insertmacro progressWriteUninstaller
!insertmacro progressStatus "Writing uninstall information..."
WriteUninstaller "$INSTDIR\Uninstall.exe" WriteUninstaller "$INSTDIR\Uninstall.exe"
!insertmacro progressFinalize
; For in-app updates (/RESTARTFC) the success signal is emitted from ; For in-app updates (/RESTARTFC) the success signal is emitted from
; restartFarmControlAfterUpdate, right before the install directory swap, ; restartFarmControlAfterUpdate, right before the install directory swap,
; so the running app quits while this installer stays alive. ; so the running app quits while this installer stays alive.

View File

@ -95,56 +95,10 @@ Var UpdateParentPid
${EndIf} ${EndIf}
!macroend !macroend
!define PROGRESS_START 1
!define PREPARE_PROGRESS 3
!define COPY_PROGRESS_START 5
!define COPY_PROGRESS_END 90
!define CONFIGURE_PROGRESS 91
!define SHORTCUTS_PROGRESS 93
!define FINALIZE_PROGRESS 95
!define UNINSTALLER_PROGRESS 97
!define COMPLETE_PROGRESS 99
!macro progressPercent percent !macro progressPercent percent
!insertmacro progressLog "installer:%${percent}" !insertmacro progressLog "installer:%${percent}"
!macroend !macroend
!macro progressStart
!insertmacro progressPercent "${PROGRESS_START}"
!macroend
!macro progressPrepare
!insertmacro progressPercent "${PREPARE_PROGRESS}"
!macroend
!macro progressCopyStart
!insertmacro progressPercent "${COPY_PROGRESS_START}"
!macroend
!macro progressCopyComplete
!insertmacro progressPercent "${COPY_PROGRESS_END}"
!macroend
!macro progressConfigure
!insertmacro progressPercent "${CONFIGURE_PROGRESS}"
!macroend
!macro progressShortcuts
!insertmacro progressPercent "${SHORTCUTS_PROGRESS}"
!macroend
!macro progressFinalizeInstall
!insertmacro progressPercent "${FINALIZE_PROGRESS}"
!macroend
!macro progressWriteUninstaller
!insertmacro progressPercent "${UNINSTALLER_PROGRESS}"
!macroend
!macro progressFinalize
!insertmacro progressPercent "${COMPLETE_PROGRESS}"
!macroend
!macro progressPhase phase !macro progressPhase phase
!insertmacro progressLog "installer:PHASE:${phase}" !insertmacro progressLog "installer:PHASE:${phase}"
!macroend !macroend
@ -348,7 +302,6 @@ Var UpdateParentPid
!macroend !macroend
!macro customInstall !macro customInstall
!insertmacro progressConfigure
!insertmacro progressPhase "Configuring Farm Control" !insertmacro progressPhase "Configuring Farm Control"
!insertmacro progressStatus "Registering farmcontrol URI handler..." !insertmacro progressStatus "Registering farmcontrol URI handler..."
DetailPrint "Register farmcontrol URI Handler" DetailPrint "Register farmcontrol URI Handler"
@ -360,7 +313,6 @@ Var UpdateParentPid
WriteRegStr HKCU "Software\Classes\farmcontrol\shell\Open" "" "" WriteRegStr HKCU "Software\Classes\farmcontrol\shell\Open" "" ""
WriteRegStr HKCU "Software\Classes\farmcontrol\shell\Open\command" "" '"$FinalInstDir\bin\bun.exe" "$FinalInstDir\bin\deeplink.js" "%1"' WriteRegStr HKCU "Software\Classes\farmcontrol\shell\Open\command" "" '"$FinalInstDir\bin\bun.exe" "$FinalInstDir\bin\deeplink.js" "%1"'
!insertmacro progressShortcuts
!insertmacro progressStatus "Creating shortcuts..." !insertmacro progressStatus "Creating shortcuts..."
DetailPrint "Creating shortcuts" DetailPrint "Creating shortcuts"
!insertmacro createDesktopShortcut !insertmacro createDesktopShortcut

View File

@ -62,20 +62,6 @@ const isUpdateDismissed = (update) => {
) )
} }
const formatFullAppVersion = (version, buildNumber) => {
const normalizedVersion = String(version || '')
.trim()
.replace(/^v/i, '')
if (!normalizedVersion) return null
const build = String(buildNumber || '').trim()
const buildSuffix =
!build || build === 'dev' ? 'dev' : build.startsWith('b') ? build : `b${build}`
return `v${normalizedVersion}-${buildSuffix}`
}
const saveDismissedUpdate = (update) => { const saveDismissedUpdate = (update) => {
if (!update) return if (!update) return
@ -557,12 +543,13 @@ export const AppUpdateProvider = ({ children }) => {
]} ]}
> >
<Text> <Text>
{completedUpdate?.message || Farm Control was successfully updated to version{' '}
`Farm Control was successfully updated to version ${ {completedUpdate?.current?.version || appVersion}
completedUpdate?.current?.version || {completedUpdate?.previous?.version &&
formatFullAppVersion(appVersion, CURRENT_BUILD_NUMBER) || completedUpdate.previous.version !== completedUpdate?.current?.version
`v${appVersion}` ? ` (previously ${completedUpdate.previous.version})`
}.`} : ''}
.
</Text> </Text>
</Modal> </Modal>
<Modal <Modal

View File

@ -263,65 +263,6 @@ const persistCurrentAppState = async (mainWindow) => {
const stateValueChanged = (previous, next) => const stateValueChanged = (previous, next) =>
Boolean(previous) && Boolean(next) && previous !== next Boolean(previous) && Boolean(next) && previous !== next
const formatEngineLabel = (engine) => {
const normalized = normalizeEngine(engine)
if (normalized === 'chromium') return 'Chromium'
if (normalized === 'native') return 'Native'
return String(engine || 'Unknown')
}
export const getUpdateInstalledMessage = ({ changes, current } = {}) => {
if (!current) return 'Farm Control was successfully updated.'
const versionChanged = Boolean(changes?.version && current.version)
const branchChanged = Boolean(changes?.branch && current.branch)
const engineChanged = Boolean(changes?.engine && current.engine)
if (!versionChanged && !branchChanged && !engineChanged) {
const version = current.version || getRunningAppVersion()
return version
? `Farm Control was successfully updated to version ${version}.`
: 'Farm Control was successfully updated.'
}
const segments = []
if (versionChanged) {
segments.push({ type: 'version', text: `version ${current.version}` })
}
if (branchChanged) {
segments.push({ type: 'branch', text: `the ${current.branch} branch` })
}
if (engineChanged) {
segments.push({
type: 'engine',
text: `the ${formatEngineLabel(current.engine)} engine`
})
}
if (segments.length === 1) {
const [segment] = segments
if (segment.type === 'engine') {
return `Farm Control was successfully updated to use ${segment.text}.`
}
return `Farm Control was successfully updated to ${segment.text}.`
}
let message = `Farm Control was successfully updated to ${segments[0].text}`
for (const segment of segments.slice(1)) {
if (segment.type === 'branch') {
message += ` on ${segment.text}`
} else if (segment.type === 'engine') {
message += ` using ${segment.text}`
} else {
message += ` and ${segment.text}`
}
}
return `${message}.`
}
let completedUpdateResult = null let completedUpdateResult = null
export const checkForCompletedUpdate = async (mainWindow) => { export const checkForCompletedUpdate = async (mainWindow) => {
@ -339,31 +280,18 @@ export const checkForCompletedUpdate = async (mainWindow) => {
await setAppSettings({ ...settings, current }) await setAppSettings({ ...settings, current })
const changes = {
version: stateValueChanged(previous.version, current.version),
branch: stateValueChanged(previous.branch, current.branch),
engine: stateValueChanged(
normalizeEngine(previous.engine),
normalizeEngine(current.engine)
)
}
const updated = const updated =
Boolean(previous) && Boolean(previous) &&
(changes.version || changes.branch || changes.engine) (stateValueChanged(previous.version, current.version) ||
stateValueChanged(previous.branch, current.branch) ||
stateValueChanged(
normalizeEngine(previous.engine),
normalizeEngine(current.engine)
))
const duplicates = checkForDuplicateInstallations() const duplicates = checkForDuplicateInstallations()
completedUpdateResult = { completedUpdateResult = { updated, previous, current, duplicates }
updated,
previous,
current,
changes,
message: updated
? getUpdateInstalledMessage({ changes, current })
: null,
duplicates
}
} catch (error) { } catch (error) {
console.warn('[app-update] Failed to check for a completed update.', error) console.warn('[app-update] Failed to check for a completed update.', error)
completedUpdateResult = { completedUpdateResult = {

View File

@ -4,9 +4,7 @@ import os from 'os'
import path from 'path' import path from 'path'
const PE_MZ_HEADER = Buffer.from([0x4d, 0x5a]) // "MZ" const PE_MZ_HEADER = Buffer.from([0x4d, 0x5a]) // "MZ"
const COPY_PROGRESS_START = 5 const COPY_PROGRESS_PERCENT = 75
const COPY_PROGRESS_END = 90
const COPY_PROGRESS_RANGE = COPY_PROGRESS_END - COPY_PROGRESS_START
const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms)) const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms))
@ -56,11 +54,8 @@ const parseWindowsInstallerProgress = (output) => {
copiedBytes += fileBytes copiedBytes += fileBytes
if (copyTotalBytes > 0) { if (copyTotalBytes > 0) {
percent = Math.min( percent = Math.min(
COPY_PROGRESS_END, COPY_PROGRESS_PERCENT,
COPY_PROGRESS_START + Math.round((copiedBytes / copyTotalBytes) * COPY_PROGRESS_PERCENT)
Math.round(
(copiedBytes / copyTotalBytes) * COPY_PROGRESS_RANGE
)
) )
} }
} }