C2: lutra CLI in the setup with optional PATH entry, xtask bundle prints the version
- xtask bundle builds lutra-cli and adds it as a Tauri external binary through a --config override (lutra.exe next to the app on Windows, Lutra.app/Contents/MacOS/lutra on macOS); prints path, version, size. - NSIS: "Add lutra to PATH" page, unticked by default, /ADDTOPATH for silent installs. Changes HKCU\Environment Path only, keeps its type, broadcasts WM_SETTINGCHANGE, records the entry; the uninstaller removes exactly that entry. A PATH too long for NSIS strings is left alone. - lutra CLI resolves a symlinked executable before looking for the app. - localStorage: the UI never used webview storage, so there is nothing to migrate; docs corrected, ESLint now bans localStorage, sessionStorage and indexedDB, with tests. - docs/install.md: CLI, PATH, macOS link step, webview folder. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
d8e66a4652
commit
0a4b80adec
7 changed files with 628 additions and 46 deletions
|
|
@ -45,6 +45,13 @@
|
|||
WriteRegStr SHCTX "Software\Classes\Applications\${MAINBINARYNAME}.exe\shell\open\command" "" '"$INSTDIR\${MAINBINARYNAME}.exe" "%1"'
|
||||
!insertmacro LUTRA_FOR_EACH_EXT LUTRA_OPEN_WITH
|
||||
!insertmacro UPDATEFILEASSOC
|
||||
Call LutraPathApply
|
||||
!macroend
|
||||
|
||||
; Remembers the PATH entry an earlier setup added before the uninstaller
|
||||
; may delete `${MANUPRODUCTKEY}` with the application data.
|
||||
!macro NSIS_HOOK_PREUNINSTALL
|
||||
ReadRegStr $LutraPathEntry HKCU "${MANUPRODUCTKEY}" "${LUTRA_PATH_RECORD}"
|
||||
!macroend
|
||||
|
||||
!macro NSIS_HOOK_POSTUNINSTALL
|
||||
|
|
@ -52,4 +59,219 @@
|
|||
DeleteRegKey SHCTX "Software\Classes\${LUTRA_PROGID}"
|
||||
DeleteRegKey SHCTX "Software\Classes\Applications\${MAINBINARYNAME}.exe"
|
||||
!insertmacro UPDATEFILEASSOC
|
||||
${If} $UpdateMode <> 1
|
||||
${AndIf} $LutraPathEntry != ""
|
||||
StrCpy $R3 $LutraPathEntry
|
||||
Call un.LutraPathRemove
|
||||
DeleteRegValue HKCU "${MANUPRODUCTKEY}" "${LUTRA_PATH_RECORD}"
|
||||
${EndIf}
|
||||
!macroend
|
||||
|
||||
; lutra on PATH
|
||||
;
|
||||
; The setup installs the `lutra` command-line tool (`lutra.exe`, a Tauri
|
||||
; external binary that `cargo xtask bundle` adds) next to the app. The page
|
||||
; `LUTRA_PATH_PAGE` offers "Add lutra to PATH", unticked unless an earlier
|
||||
; setup added the entry; `/ADDTOPATH` ticks it for `/S` and `/P` installs.
|
||||
;
|
||||
; Only the user's PATH changes: the value `Path` under `HKCU\Environment`,
|
||||
; written back with its type (REG_EXPAND_SZ or REG_SZ), followed by a
|
||||
; WM_SETTINGCHANGE broadcast so new terminals see it. The folder that was
|
||||
; added is recorded as `${LUTRA_PATH_RECORD}` under `HKCU\${MANUPRODUCTKEY}`.
|
||||
; The uninstaller removes exactly that entry from PATH and leaves every
|
||||
; other entry, empty ones included, as it was. An entry the user had added
|
||||
; before is never recorded, so it stays on uninstall. A PATH longer than
|
||||
; NSIS strings can hold is not touched: the setup says so and goes on.
|
||||
|
||||
!define LUTRA_PATH_RECORD "PathEntry"
|
||||
|
||||
Var LutraAddToPath
|
||||
Var LutraPathCheckbox
|
||||
Var LutraPathEntry
|
||||
|
||||
; The PATH helpers, for the installer (`UN` empty) or the uninstaller
|
||||
; (`UN` = `un.`).
|
||||
!macro LUTRA_PATH_FUNCTIONS UN
|
||||
; Reads the user's PATH.
|
||||
; Out: $R0 the value, $R1 its type (0 missing, 1 REG_SZ, 2 REG_EXPAND_SZ).
|
||||
; Sets the error flag if it cannot be read, or if it plus `$INSTDIR` would
|
||||
; not fit in an NSIS string, so it is never written back cut short.
|
||||
Function ${UN}LutraPathRead
|
||||
Push $0
|
||||
ClearErrors
|
||||
StrCpy $R0 ""
|
||||
StrCpy $R1 0
|
||||
StrCpy $R2 0
|
||||
System::Call 'advapi32::RegGetValueW(p 0x80000001, w "Environment", w "Path", i 0x1000ffff, *i .R1, p 0, *i .R2) i .r0'
|
||||
${If} $0 = 2
|
||||
StrCpy $R1 0
|
||||
${ElseIf} $0 <> 0
|
||||
SetErrors
|
||||
${ElseIf} $R1 <> 1
|
||||
${AndIf} $R1 <> 2
|
||||
SetErrors
|
||||
${Else}
|
||||
IntOp $R2 $R2 / 2
|
||||
StrLen $0 $INSTDIR
|
||||
IntOp $R2 $R2 + $0
|
||||
${If} $R2 >= ${NSIS_MAX_STRLEN}
|
||||
SetErrors
|
||||
${Else}
|
||||
ReadRegStr $R0 HKCU "Environment" "Path"
|
||||
${EndIf}
|
||||
${EndIf}
|
||||
Pop $0
|
||||
FunctionEnd
|
||||
|
||||
; Writes $R0 back as the user's PATH with type $R1 and tells running
|
||||
; programs that the environment changed.
|
||||
Function ${UN}LutraPathWrite
|
||||
${If} $R1 = 1
|
||||
WriteRegStr HKCU "Environment" "Path" $R0
|
||||
${Else}
|
||||
WriteRegExpandStr HKCU "Environment" "Path" $R0
|
||||
${EndIf}
|
||||
SendMessage ${HWND_BROADCAST} ${WM_SETTINGCHANGE} 0 "STR:Environment" /TIMEOUT=5000
|
||||
FunctionEnd
|
||||
|
||||
; Splits $R0 at ";" and drops every entry equal to $R3 (ignoring case).
|
||||
; Out: $R4 the remaining entries joined by ";", $R5 1 if one was dropped.
|
||||
Function ${UN}LutraPathFilter
|
||||
Push $6
|
||||
Push $7
|
||||
Push $8
|
||||
Push $9
|
||||
StrCpy $R4 ""
|
||||
StrCpy $R5 0
|
||||
StrCpy $6 0
|
||||
StrCpy $8 ""
|
||||
StrCpy $9 0
|
||||
loop:
|
||||
StrCpy $7 $R0 1 $6
|
||||
${If} $7 == ";"
|
||||
${OrIf} $7 == ""
|
||||
${If} $8 == $R3
|
||||
StrCpy $R5 1
|
||||
${ElseIf} $9 = 0
|
||||
StrCpy $R4 $8
|
||||
StrCpy $9 1
|
||||
${Else}
|
||||
StrCpy $R4 "$R4;$8"
|
||||
${EndIf}
|
||||
StrCpy $8 ""
|
||||
StrCmp $7 "" done
|
||||
${Else}
|
||||
StrCpy $8 "$8$7"
|
||||
${EndIf}
|
||||
IntOp $6 $6 + 1
|
||||
Goto loop
|
||||
done:
|
||||
Pop $9
|
||||
Pop $8
|
||||
Pop $7
|
||||
Pop $6
|
||||
FunctionEnd
|
||||
|
||||
; Removes the entry $R3 from the user's PATH if it is there.
|
||||
Function ${UN}LutraPathRemove
|
||||
Call ${UN}LutraPathRead
|
||||
${If} ${Errors}
|
||||
DetailPrint "$(lutraPathFailed)"
|
||||
Return
|
||||
${EndIf}
|
||||
Call ${UN}LutraPathFilter
|
||||
${If} $R5 = 1
|
||||
StrCpy $R0 $R4
|
||||
Call ${UN}LutraPathWrite
|
||||
DetailPrint "$(lutraPathRemoved)"
|
||||
${EndIf}
|
||||
FunctionEnd
|
||||
!macroend
|
||||
|
||||
; The PATH page and the functions behind it; inserted after the directory
|
||||
; page, so `$INSTDIR` is final.
|
||||
!macro LUTRA_PATH_PAGE
|
||||
Page custom LutraPathPageShow LutraPathPageLeave
|
||||
|
||||
!insertmacro LUTRA_PATH_FUNCTIONS ""
|
||||
!insertmacro LUTRA_PATH_FUNCTIONS "un."
|
||||
|
||||
Function LutraPathPageShow
|
||||
${If} $PassiveMode = 1
|
||||
Abort
|
||||
${EndIf}
|
||||
!insertmacro MUI_HEADER_TEXT "$(lutraPathTitle)" "$(lutraPathSubtitle)"
|
||||
nsDialogs::Create 1018
|
||||
Pop $0
|
||||
${IfThen} $(^RTL) = 1 ${|} nsDialogs::SetRTL $(^RTL) ${|}
|
||||
${NSD_CreateLabel} 0 0 100% 48u "$(lutraPathText)"
|
||||
Pop $0
|
||||
${NSD_CreateCheckbox} 0 56u 100% 12u "$(lutraPathCheckbox)"
|
||||
Pop $LutraPathCheckbox
|
||||
${If} $LutraAddToPath = 1
|
||||
${NSD_Check} $LutraPathCheckbox
|
||||
${EndIf}
|
||||
nsDialogs::Show
|
||||
FunctionEnd
|
||||
|
||||
Function LutraPathPageLeave
|
||||
${NSD_GetState} $LutraPathCheckbox $0
|
||||
${If} $0 = ${BST_CHECKED}
|
||||
StrCpy $LutraAddToPath 1
|
||||
${Else}
|
||||
StrCpy $LutraAddToPath 0
|
||||
${EndIf}
|
||||
FunctionEnd
|
||||
|
||||
; Brings the user's PATH in line with the choice: drops an entry an
|
||||
; earlier setup added if it is no longer wanted or points elsewhere, and
|
||||
; adds `$INSTDIR` if wanted and missing, recording it.
|
||||
Function LutraPathApply
|
||||
ReadRegStr $R6 HKCU "${MANUPRODUCTKEY}" "${LUTRA_PATH_RECORD}"
|
||||
${If} $R6 != ""
|
||||
${If} $LutraAddToPath <> 1
|
||||
${OrIf} $R6 != $INSTDIR
|
||||
StrCpy $R3 $R6
|
||||
Call LutraPathRemove
|
||||
DeleteRegValue HKCU "${MANUPRODUCTKEY}" "${LUTRA_PATH_RECORD}"
|
||||
${EndIf}
|
||||
${EndIf}
|
||||
${If} $LutraAddToPath <> 1
|
||||
Return
|
||||
${EndIf}
|
||||
Call LutraPathRead
|
||||
${If} ${Errors}
|
||||
DetailPrint "$(lutraPathFailed)"
|
||||
MessageBox MB_ICONEXCLAMATION|MB_OK "$(lutraPathFailed)" /SD IDOK
|
||||
Return
|
||||
${EndIf}
|
||||
StrCpy $R3 $INSTDIR
|
||||
Call LutraPathFilter
|
||||
${If} $R5 = 1
|
||||
Return
|
||||
${EndIf}
|
||||
StrCpy $R7 $R0 1 -1
|
||||
${If} $R0 == ""
|
||||
${OrIf} $R7 == ";"
|
||||
StrCpy $R0 "$R0$INSTDIR"
|
||||
${Else}
|
||||
StrCpy $R0 "$R0;$INSTDIR"
|
||||
${EndIf}
|
||||
${IfThen} $R1 = 0 ${|} StrCpy $R1 2 ${|}
|
||||
Call LutraPathWrite
|
||||
WriteRegStr HKCU "${MANUPRODUCTKEY}" "${LUTRA_PATH_RECORD}" $INSTDIR
|
||||
DetailPrint "$(lutraPathAdded)"
|
||||
FunctionEnd
|
||||
!macroend
|
||||
|
||||
; The PATH choice at start: ticked if an earlier setup added the entry or
|
||||
; `/ADDTOPATH` is given. Inserted at the end of `.onInit`.
|
||||
!macro LUTRA_PATH_INIT
|
||||
StrCpy $LutraAddToPath 0
|
||||
ReadRegStr $0 HKCU "${MANUPRODUCTKEY}" "${LUTRA_PATH_RECORD}"
|
||||
${IfThen} $0 != "" ${|} StrCpy $LutraAddToPath 1 ${|}
|
||||
${GetOptions} $CMDLINE "/ADDTOPATH" $0
|
||||
${IfNot} ${Errors}
|
||||
StrCpy $LutraAddToPath 1
|
||||
${EndIf}
|
||||
!macroend
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue