Refactor Windows installer progress macros for improved clarity and functionality
- Introduced new macros for various installation progress stages, enhancing readability and maintainability of the installer script. - Updated the progress reporting in the `farmcontrol.nsi` file to utilize the new macros, ensuring consistent progress tracking during installation. - Adjusted the `winappupdate.js` file to align with the new progress constants, improving the accuracy of progress percentage calculations.
This commit is contained in:
parent
324a4a1e6f
commit
ba5856c248
@ -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 progressPercent 0
|
!insertmacro progressStart
|
||||||
|
|
||||||
; 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,6 +78,8 @@ Function .onInit
|
|||||||
StrCpy $FinalInstDir $INSTDIR
|
StrCpy $FinalInstDir $INSTDIR
|
||||||
!insertmacro uninstallPreviousFarmControl
|
!insertmacro uninstallPreviousFarmControl
|
||||||
${EndIf}
|
${EndIf}
|
||||||
|
|
||||||
|
!insertmacro progressPrepare
|
||||||
FunctionEnd
|
FunctionEnd
|
||||||
|
|
||||||
Function .onInstFailed
|
Function .onInstFailed
|
||||||
@ -93,17 +95,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 progressPercent 0
|
!insertmacro progressCopyStart
|
||||||
|
|
||||||
SetOverwrite try
|
SetOverwrite try
|
||||||
!insertmacro copyApplicationFilesWithProgress
|
!insertmacro copyApplicationFilesWithProgress
|
||||||
|
|
||||||
!insertmacro progressPercent 75
|
!insertmacro progressCopyComplete
|
||||||
!insertmacro customInstall
|
!insertmacro customInstall
|
||||||
|
|
||||||
|
!insertmacro progressFinalizeInstall
|
||||||
!insertmacro progressPhase "Finalizing installation"
|
!insertmacro progressPhase "Finalizing installation"
|
||||||
!insertmacro progressStatus "Writing uninstall information..."
|
!insertmacro progressStatus "Writing installation registry entries..."
|
||||||
!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" \
|
||||||
@ -119,8 +121,14 @@ 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.
|
||||||
|
|||||||
@ -95,10 +95,56 @@ 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
|
||||||
@ -302,6 +348,7 @@ 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"
|
||||||
@ -313,6 +360,7 @@ 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
|
||||||
|
|||||||
@ -4,7 +4,9 @@ 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_PERCENT = 75
|
const COPY_PROGRESS_START = 5
|
||||||
|
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))
|
||||||
|
|
||||||
@ -54,8 +56,11 @@ const parseWindowsInstallerProgress = (output) => {
|
|||||||
copiedBytes += fileBytes
|
copiedBytes += fileBytes
|
||||||
if (copyTotalBytes > 0) {
|
if (copyTotalBytes > 0) {
|
||||||
percent = Math.min(
|
percent = Math.min(
|
||||||
COPY_PROGRESS_PERCENT,
|
COPY_PROGRESS_END,
|
||||||
Math.round((copiedBytes / copyTotalBytes) * COPY_PROGRESS_PERCENT)
|
COPY_PROGRESS_START +
|
||||||
|
Math.round(
|
||||||
|
(copiedBytes / copyTotalBytes) * COPY_PROGRESS_RANGE
|
||||||
|
)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user