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
|
|
@ -28,7 +28,10 @@ const POLL: Duration = Duration::from_millis(150);
|
|||
const PROBE: Duration = Duration::from_secs(2);
|
||||
|
||||
/// The desktop binary: `LUTRA_DESKTOP` if set, else `lutra-desktop` next to
|
||||
/// this executable, else the first `lutra-desktop` on `PATH`.
|
||||
/// this executable, else the first `lutra-desktop` on `PATH`. The executable
|
||||
/// is resolved through symbolic links first, so a `lutra` linked onto
|
||||
/// `PATH` from `Lutra.app/Contents/MacOS/` still finds the app next to its
|
||||
/// target; if that fails, the unresolved path is used.
|
||||
///
|
||||
/// # Errors
|
||||
/// A message naming the places that were tried.
|
||||
|
|
@ -38,6 +41,7 @@ pub fn find_desktop() -> Result<PathBuf, String> {
|
|||
}
|
||||
let sibling = std::env::current_exe()
|
||||
.ok()
|
||||
.map(resolve_link)
|
||||
.and_then(|exe| Some(exe.parent()?.join(DESKTOP_NAME)))
|
||||
.filter(|path| path.is_file());
|
||||
if let Some(path) = sibling {
|
||||
|
|
@ -56,6 +60,16 @@ pub fn find_desktop() -> Result<PathBuf, String> {
|
|||
})
|
||||
}
|
||||
|
||||
/// `path` resolved to its final target if it is a symbolic link, else
|
||||
/// `path` itself, also when resolving fails.
|
||||
fn resolve_link(path: PathBuf) -> PathBuf {
|
||||
let is_link = std::fs::symlink_metadata(&path).is_ok_and(|m| m.file_type().is_symlink());
|
||||
if !is_link {
|
||||
return path;
|
||||
}
|
||||
std::fs::canonicalize(&path).unwrap_or(path)
|
||||
}
|
||||
|
||||
/// Starts `desktop` detached from this terminal (Windows: a detached process
|
||||
/// in a new process group; Unix: a new process group, so a Ctrl-C or
|
||||
/// hangup aimed at the terminal's foreground group does not reach it) and
|
||||
|
|
@ -111,3 +125,33 @@ pub fn start(desktop: &Path, dir: &Path) -> Result<Client, String> {
|
|||
thread::sleep(POLL);
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn a_plain_file_stays_as_it_is() {
|
||||
let tmp = tempfile::tempdir().unwrap();
|
||||
let file = tmp.path().join("lutra");
|
||||
std::fs::write(&file, "").unwrap();
|
||||
assert_eq!(resolve_link(file.clone()), file);
|
||||
let missing = tmp.path().join("missing");
|
||||
assert_eq!(resolve_link(missing.clone()), missing);
|
||||
}
|
||||
|
||||
#[cfg(unix)]
|
||||
#[test]
|
||||
fn a_link_resolves_to_its_target() {
|
||||
let tmp = tempfile::tempdir().unwrap();
|
||||
let app = tmp.path().join("Lutra.app/Contents/MacOS");
|
||||
std::fs::create_dir_all(&app).unwrap();
|
||||
std::fs::write(app.join("lutra"), "").unwrap();
|
||||
let link = tmp.path().join("lutra");
|
||||
std::os::unix::fs::symlink(app.join("lutra"), &link).unwrap();
|
||||
assert_eq!(
|
||||
resolve_link(link),
|
||||
std::fs::canonicalize(app.join("lutra")).unwrap()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -394,6 +394,9 @@ FunctionEnd
|
|||
!define MUI_PAGE_CUSTOMFUNCTION_PRE SkipIfPassive
|
||||
!insertmacro MUI_PAGE_DIRECTORY
|
||||
|
||||
; Lutra: the "Add lutra to PATH" page (`LUTRA_PATH_PAGE` in `hooks.nsh`).
|
||||
!insertmacro LUTRA_PATH_PAGE
|
||||
|
||||
; 6. Start menu shortcut page
|
||||
Var AppStartMenuFolder
|
||||
!if "${STARTMENUFOLDER}" != ""
|
||||
|
|
@ -488,6 +491,26 @@ FunctionEnd
|
|||
!include "{{this}}"
|
||||
{{/each}}
|
||||
|
||||
; Lutra: the texts of the "Add lutra to PATH" page and its log lines. They
|
||||
; live here, not in `hooks.nsh`, because the bundler writes this file as
|
||||
; UTF-8 with a byte order mark, which the German umlauts need.
|
||||
LangString lutraPathTitle ${LANG_ENGLISH} "Command line"
|
||||
LangString lutraPathSubtitle ${LANG_ENGLISH} "Use Lutra from a terminal."
|
||||
LangString lutraPathText ${LANG_ENGLISH} "Setup installs the lutra command next to Lutra, so that lutra file.php opens the file in Lutra. To run it as lutra in every new terminal, add the install folder to your PATH.$\r$\n$\r$\nThis changes the PATH of your user account only. The uninstaller removes the entry again."
|
||||
LangString lutraPathCheckbox ${LANG_ENGLISH} "Add lutra to PATH"
|
||||
LangString lutraPathAdded ${LANG_ENGLISH} "Added $INSTDIR to the user PATH."
|
||||
LangString lutraPathRemoved ${LANG_ENGLISH} "Removed Lutra's entry from the user PATH."
|
||||
LangString lutraPathFailed ${LANG_ENGLISH} "Cannot change the user PATH: it cannot be read or is too long. Add $INSTDIR to it by hand to use lutra in a terminal."
|
||||
!ifdef LANG_GERMAN
|
||||
LangString lutraPathTitle ${LANG_GERMAN} "Kommandozeile"
|
||||
LangString lutraPathSubtitle ${LANG_GERMAN} "Lutra aus einem Terminal verwenden."
|
||||
LangString lutraPathText ${LANG_GERMAN} "Das Setup installiert den Befehl lutra neben Lutra, damit lutra datei.php die Datei in Lutra öffnet. Damit er in jedem neuen Terminal als lutra läuft, fügen Sie den Installationsordner zu Ihrem PATH hinzu.$\r$\n$\r$\nDas ändert nur den PATH Ihres Benutzerkontos. Die Deinstallation entfernt den Eintrag wieder."
|
||||
LangString lutraPathCheckbox ${LANG_GERMAN} "lutra zum PATH hinzufügen"
|
||||
LangString lutraPathAdded ${LANG_GERMAN} "$INSTDIR zum Benutzer-PATH hinzugefügt."
|
||||
LangString lutraPathRemoved ${LANG_GERMAN} "Lutras Eintrag aus dem Benutzer-PATH entfernt."
|
||||
LangString lutraPathFailed ${LANG_GERMAN} "Der Benutzer-PATH kann nicht geändert werden: Er ist nicht lesbar oder zu lang. Fügen Sie $INSTDIR von Hand hinzu, um lutra im Terminal zu verwenden."
|
||||
!endif
|
||||
|
||||
Function .onInit
|
||||
${GetOptions} $CMDLINE "/P" $PassiveMode
|
||||
${IfNot} ${Errors}
|
||||
|
|
@ -561,6 +584,9 @@ Function .onInit
|
|||
${EndIf}
|
||||
${EndIf}
|
||||
!endif
|
||||
|
||||
; Lutra: the initial "Add lutra to PATH" choice (`hooks.nsh`).
|
||||
!insertmacro LUTRA_PATH_INIT
|
||||
FunctionEnd
|
||||
|
||||
Section WebView2
|
||||
|
|
|
|||
|
|
@ -20,8 +20,13 @@
|
|||
//! `settings.json` goes straight into the new config directory, never
|
||||
//! replacing one that is already there.
|
||||
//!
|
||||
//! The webview's own data (recent projects, window layout) lives in a
|
||||
//! folder the webview manages and is not copied.
|
||||
//! The webview's own folder (WebView2's `EBWebView` under
|
||||
//! `%LOCALAPPDATA%\<identifier>`, WKWebView's under `~/Library/WebKit/`)
|
||||
//! is not copied: it holds only the webview's caches. The frontend keeps
|
||||
//! no state in `localStorage`, `sessionStorage` or IndexedDB (the UI lint
|
||||
//! forbids them), so nothing the user set lives there. State that has to
|
||||
//! survive a restart belongs in Lutra's own files above, which this
|
||||
//! migration carries over.
|
||||
|
||||
use std::fs;
|
||||
use std::io;
|
||||
|
|
@ -300,6 +305,36 @@ mod tests {
|
|||
assert!(new.data_dir.join("recovery/p1/e1.json").is_file());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn an_empty_settings_object_is_copied_too() {
|
||||
let tmp = tempfile::tempdir().unwrap();
|
||||
let old = shared(tmp.path(), rendezvous::LEGACY_APP_IDENTIFIER);
|
||||
let new = shared(tmp.path(), rendezvous::APP_IDENTIFIER);
|
||||
fs::create_dir_all(old.data_dir.join("recovery")).unwrap();
|
||||
fs::create_dir_all(old.data_dir.join("tools")).unwrap();
|
||||
fs::write(old.config_dir.join("settings.json"), "{}").unwrap();
|
||||
|
||||
let migrated = migrate(&old, &new).unwrap().unwrap();
|
||||
assert_eq!(migrated.entries, ["settings.json", "recovery", "tools"]);
|
||||
assert_eq!(
|
||||
fs::read_to_string(new.config_dir.join("settings.json")).unwrap(),
|
||||
"{}"
|
||||
);
|
||||
assert!(new.data_dir.join("recovery").is_dir());
|
||||
assert!(new.data_dir.join("tools").is_dir());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn the_ui_lint_keeps_state_out_of_the_webview_storage() {
|
||||
let lint = include_str!("../../../ui/eslint.config.js");
|
||||
for rule in ["no-restricted-globals", "no-restricted-properties"] {
|
||||
assert!(lint.contains(rule), "{rule} missing");
|
||||
}
|
||||
for name in ["\"localStorage\"", "\"sessionStorage\"", "\"indexedDB\""] {
|
||||
assert!(lint.contains(name), "{name} not banned");
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn the_tauri_config_uses_the_app_identifier() {
|
||||
let conf: serde_json::Value =
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
# Installing Lutra
|
||||
|
||||
> **Status:** draft, alpha installers · **Last updated:** 2026-10-31
|
||||
> **Status:** draft, alpha installers · **Last updated:** 2026-11-01
|
||||
|
||||
Lutra's alpha comes as an installer for Windows (a setup `.exe`) and macOS (a `.dmg`). Both are **not signed yet**, so Windows and macOS warn before the first start; the steps below get past that once. Linux has no installer yet: build it from source ([`development.md`](development.md)).
|
||||
|
||||
The installers contain the desktop app only. The `lutra` command-line tool (`lutra .`, `lutra mcp`) is not in them yet; build it with `cargo build --release -p lutra-cli` if you need it.
|
||||
Both installers contain the desktop app and the `lutra` command-line tool (`lutra file.php`, `lutra .`, `lutra mcp`). On Windows the setup can put `lutra` on your PATH; on macOS you link it once (see [Using `lutra` from a terminal](#using-lutra-from-a-terminal)).
|
||||
|
||||
## Building an installer
|
||||
|
||||
|
|
@ -14,7 +14,7 @@ On the platform you want the installer for:
|
|||
cargo xtask bundle
|
||||
```
|
||||
|
||||
It builds the release app with the bundled UI and prints the installer's path and size: `target/release/bundle/nsis/Lutra_<version>_x64-setup.exe` on Windows, `target/release/bundle/dmg/Lutra_<version>_aarch64.dmg` on macOS. It needs the Tauri CLI (`cargo install tauri-cli --locked`) and, on macOS, the Xcode Command Line Tools ([`macos.md`](macos.md)).
|
||||
It builds the `lutra` CLI and the release app with the bundled UI, packs both, and prints the installer's path, the version and the size, for example `bundle: Lutra 0.1.0-alpha: C:\…\target\release\bundle\nsis\Lutra_0.1.0-alpha_x64-setup.exe (5.4 MB)`. The installer is `target/release/bundle/nsis/Lutra_<version>_x64-setup.exe` on Windows and `target/release/bundle/dmg/Lutra_<version>_aarch64.dmg` on macOS. The version comes from `apps/lutra-desktop/tauri.conf.json`. It needs the Tauri CLI (`cargo install tauri-cli --locked`) and, on macOS, the Xcode Command Line Tools ([`macos.md`](macos.md)).
|
||||
|
||||
## Windows
|
||||
|
||||
|
|
@ -22,12 +22,26 @@ Lutra installs for your user only: no administrator rights, no UAC prompt. It ne
|
|||
|
||||
1. Start `Lutra_<version>_x64-setup.exe`.
|
||||
2. Windows SmartScreen says "Windows protected your PC", because the setup is not signed. Click **More info**, check that the app is `Lutra_<version>_x64-setup.exe` and the publisher is "Unknown publisher", then click **Run anyway**. If you downloaded the file with a browser, the browser may ask first whether to keep it.
|
||||
3. The setup runs in English or German, following Windows. Click **Next**, keep or change the folder (default `%LOCALAPPDATA%\Lutra`), click **Install**.
|
||||
4. On the last page, tick **Create desktop shortcut** if you want one, keep or clear **Run Lutra**, and click **Finish**. The setup closes at once; Lutra starts through Explorer a moment later.
|
||||
3. The setup runs in English or German, following Windows. Click **Next** and keep or change the folder (default `%LOCALAPPDATA%\Lutra`).
|
||||
4. On the **Command line** page, tick **Add lutra to PATH** if you want to run `lutra` in a terminal. It is off by default. Click **Next**, then **Install**.
|
||||
5. On the last page, tick **Create desktop shortcut** if you want one, keep or clear **Run Lutra**, and click **Finish**. The setup closes at once; Lutra starts through Explorer a moment later.
|
||||
|
||||
Lutra is now in the Start menu as **Lutra** and in Settings → Apps → Installed apps. Installing a newer setup over it updates it in place and keeps your settings.
|
||||
|
||||
For scripts: `Lutra_<version>_x64-setup.exe /S` installs silently with both shortcuts, `/P` shows only the progress bar, `/D=C:\path` (last argument) picks the folder, `/NS` skips the shortcuts, `/R` starts Lutra afterwards.
|
||||
For scripts: `Lutra_<version>_x64-setup.exe /S` installs silently with both shortcuts, `/P` shows only the progress bar, `/ADDTOPATH` adds `lutra` to the PATH, `/D=C:\path` (last argument) picks the folder, `/NS` skips the shortcuts, `/R` starts Lutra afterwards.
|
||||
|
||||
### Using `lutra` from a terminal
|
||||
|
||||
The setup installs `lutra.exe` next to `lutra-desktop.exe` in the install folder. With **Add lutra to PATH** ticked, the setup appends the install folder to your user PATH (`HKCU\Environment`, value `Path`; the system PATH is not touched) and tells Windows the environment changed. Terminals opened afterwards find it:
|
||||
|
||||
```bat
|
||||
lutra src\Controller\HomeController.php:42
|
||||
lutra .
|
||||
```
|
||||
|
||||
`lutra <file>` opens the file in the running Lutra, inside the project around it (see below); if Lutra is not running, it starts it first. Without the PATH entry, call it by its full path: `%LOCALAPPDATA%\Lutra\lutra.exe file.php`.
|
||||
|
||||
The setup notes the folder it added (value `PathEntry` under `HKCU\Software\Lutra\Lutra`). Running a newer setup keeps the entry; clearing the box there removes it. The uninstaller removes exactly that entry and leaves the rest of your PATH as it was. If the folder was on your PATH before the setup ran, the setup does not add it a second time and the uninstaller leaves it alone. A user PATH too long for the setup to edit safely (about 1000 characters) is not changed; the setup says so, and you can add the folder by hand.
|
||||
|
||||
### Opening PHP files from Explorer
|
||||
|
||||
|
|
@ -47,7 +61,7 @@ Since 0.1.0-alpha the finish page starts Lutra through Explorer (`explorer.exe "
|
|||
|
||||
### Uninstalling on Windows
|
||||
|
||||
Settings → Apps → Installed apps → **Lutra** → … → **Uninstall**, or run `uninstall.exe` in the install folder. The uninstaller removes the app, its shortcuts, its Installed-apps entry and the **Open with** entries. Your settings, recovery journal and Phpactor stay unless you tick **Delete the application data**.
|
||||
Settings → Apps → Installed apps → **Lutra** → … → **Uninstall**, or run `uninstall.exe` in the install folder. The uninstaller removes the app and `lutra.exe`, its shortcuts, its Installed-apps entry, the **Open with** entries and the PATH entry the setup added. Your settings, recovery journal and Phpactor stay unless you tick **Delete the application data**.
|
||||
|
||||
## macOS
|
||||
|
||||
|
|
@ -63,6 +77,17 @@ xattr -dr com.apple.quarantine /Applications/Lutra.app
|
|||
|
||||
You need to do this once per installed version.
|
||||
|
||||
### Using `lutra` from a terminal on macOS
|
||||
|
||||
The CLI is inside the app, at `/Applications/Lutra.app/Contents/MacOS/lutra`. Link it once into a folder on your PATH, for example:
|
||||
|
||||
```sh
|
||||
mkdir -p ~/.local/bin
|
||||
ln -sf /Applications/Lutra.app/Contents/MacOS/lutra ~/.local/bin/lutra
|
||||
```
|
||||
|
||||
`~/.local/bin` must be on your PATH (add `export PATH="$HOME/.local/bin:$PATH"` to `~/.zshrc` if it is not). `/usr/local/bin` works too, with `sudo`. The link follows updates, because a new version replaces the app at the same place. Remove the quarantine flag first (step 3 above), or macOS blocks the unsigned `lutra` binary as well. To remove it again: `rm ~/.local/bin/lutra`.
|
||||
|
||||
### Opening PHP files from Finder
|
||||
|
||||
Lutra registers as an alternate editor for `.php`, `.phtml`, `.phpt` and `.inc` files: it appears under **Open With** without becoming the default. A file opens as on Windows, in the project around it.
|
||||
|
|
@ -77,11 +102,11 @@ Quit Lutra and drag **Lutra** from **Applications** to the Trash. Your data stay
|
|||
|---|---|---|
|
||||
| The app | `%LOCALAPPDATA%\Lutra\` | `/Applications/Lutra.app` |
|
||||
| Settings (`settings.json`), recovery journal (`recovery\`), downloaded Phpactor (`tools\`) | `%APPDATA%\com.tyrveil.lutra\` | `~/Library/Application Support/com.tyrveil.lutra/` |
|
||||
| Window data of the web view (recent projects, layout) | `%LOCALAPPDATA%\com.tyrveil.lutra\` | `~/Library/WebKit/com.tyrveil.lutra/`, `~/Library/Caches/com.tyrveil.lutra/` |
|
||||
| The web view's caches (no settings or other state of yours) | `%LOCALAPPDATA%\com.tyrveil.lutra\` | `~/Library/WebKit/com.tyrveil.lutra/`, `~/Library/Caches/com.tyrveil.lutra/` |
|
||||
|
||||
On Linux, when built from source: settings in `~/.config/com.tyrveil.lutra/`, journal and tools in `~/.local/share/com.tyrveil.lutra/`.
|
||||
|
||||
**From a build before the installers.** Earlier builds used the identifier `dev.lutra.desktop`. The first start of a new build copies `settings.json`, the recovery journal and the downloaded Phpactor from the old `dev.lutra.desktop` folders once and shows a notification; the old folders stay untouched and can be deleted afterwards. Recent projects and the window layout are not copied.
|
||||
**From a build before the installers.** Earlier builds used the identifier `dev.lutra.desktop`. The first start of a new build copies `settings.json`, the recovery journal and the downloaded Phpactor from the old `dev.lutra.desktop` folders once and shows a notification; the old folders stay untouched and can be deleted afterwards. The web view's old folder (`%LOCALAPPDATA%\dev.lutra.desktop\`, `~/Library/WebKit/dev.lutra.desktop/`) holds only caches: Lutra keeps nothing in the web view's storage, so nothing is lost there, and it can be deleted too.
|
||||
|
||||
An instance started with `--control PORT` or `--data-dir DIR` keeps its files in its own folder (see [`development.md`](development.md#data-directories)).
|
||||
|
||||
|
|
@ -91,3 +116,4 @@ An instance started with `--control PORT` or `--data-dir DIR` keeps its files in
|
|||
|---|---|---|
|
||||
| 2026-10-31 | major | B1: initial version, NSIS setup and DMG, unsigned |
|
||||
| 2026-10-31 | minor | B2: finish-page hang found and fixed, Open with for PHP files, version 0.1.0-alpha |
|
||||
| 2026-11-01 | minor | C2: `lutra` CLI in both installers, optional per-user PATH entry on Windows, macOS link step, `xtask bundle` prints the version; the web view's folder holds no user state |
|
||||
|
|
|
|||
|
|
@ -8,6 +8,12 @@
|
|||
* Templates may not contain bare text: every interface string comes from the
|
||||
* message catalog (`src/i18n`). The rule's default punctuation allowlist is
|
||||
* extended by `;`, `…` and `×`.
|
||||
*
|
||||
* The webview's storage (`localStorage`, `sessionStorage`, IndexedDB) is
|
||||
* banned: it is tied to the app identifier and lives outside Lutra's own
|
||||
* files, so the desktop's data migration cannot carry it over (see
|
||||
* `apps/lutra-desktop/src/migrate.rs`). Remembered state goes through the
|
||||
* engine into Lutra's settings and data directories instead.
|
||||
*/
|
||||
import js from "@eslint/js";
|
||||
import { defineConfig } from "eslint/config";
|
||||
|
|
@ -37,6 +43,23 @@ export default defineConfig(
|
|||
"@typescript-eslint/no-misused-promises": "error",
|
||||
"@typescript-eslint/no-explicit-any": "error",
|
||||
"no-inline-comments": "error",
|
||||
"no-restricted-globals": [
|
||||
"error",
|
||||
...["localStorage", "sessionStorage", "indexedDB"].map((name) => ({
|
||||
name,
|
||||
message: "Keep state in Lutra's own files through the engine; the webview's storage is not migrated.",
|
||||
})),
|
||||
],
|
||||
"no-restricted-properties": [
|
||||
"error",
|
||||
...["window", "globalThis", "self"].flatMap((object) =>
|
||||
["localStorage", "sessionStorage", "indexedDB"].map((property) => ({
|
||||
object,
|
||||
property,
|
||||
message: "Keep state in Lutra's own files through the engine; the webview's storage is not migrated.",
|
||||
})),
|
||||
),
|
||||
],
|
||||
"vue/no-bare-strings-in-template": [
|
||||
"error",
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,37 +1,59 @@
|
|||
//! `cargo xtask bundle`: the platform's installer.
|
||||
//!
|
||||
//! Builds the desktop app in release mode with the bundled UI through the
|
||||
//! Tauri CLI and packs it: an NSIS setup (`.exe`, per-user install) on
|
||||
//! Windows, a DMG on macOS. The settings live in
|
||||
//! `apps/lutra-desktop/tauri.conf.json`; the installer images in
|
||||
//! `assets/installer/`. On macOS the 1x and 2x DMG backgrounds are joined
|
||||
//! into one HiDPI TIFF with `tiffutil` first, so Finder picks the sharp one
|
||||
//! on a Retina display; without `tiffutil` the 1x PNG from the config is
|
||||
//! used. Other platforms have no installer yet.
|
||||
//! Builds the `lutra` command-line tool and the desktop app in release mode
|
||||
//! with the bundled UI through the Tauri CLI and packs them: an NSIS setup
|
||||
//! (`.exe`, per-user install) on Windows, a DMG on macOS. The settings live
|
||||
//! in `apps/lutra-desktop/tauri.conf.json`; the installer images in
|
||||
//! `assets/installer/`.
|
||||
//!
|
||||
//! The CLI goes in as a Tauri external binary: it is copied to
|
||||
//! `<target>/sidecar/lutra-<host triple>[.exe]`, the name the bundler
|
||||
//! expects, and named in `bundle.externalBin` through a `--config` override,
|
||||
//! so plain `cargo build` and `cargo xtask ci` never need it. The bundler
|
||||
//! puts it next to the app binary: `lutra.exe` in the install folder on
|
||||
//! Windows, `Lutra.app/Contents/MacOS/lutra` on macOS.
|
||||
//!
|
||||
//! On macOS the 1x and 2x DMG backgrounds are joined into one HiDPI TIFF
|
||||
//! with `tiffutil` first, so Finder picks the sharp one on a Retina display;
|
||||
//! without `tiffutil` the 1x PNG from the config is used. Other platforms
|
||||
//! have no installer yet.
|
||||
//!
|
||||
//! At the end it prints the installer's path, the app version and the size.
|
||||
|
||||
use std::path::{Path, PathBuf};
|
||||
|
||||
use crate::util::{TaskResult, repo_root, run};
|
||||
use serde_json::{Value, json};
|
||||
|
||||
/// The Tauri bundle target and the output folder under `bundle/` for this
|
||||
/// platform, or `None` without an installer.
|
||||
fn target() -> Option<(&'static str, &'static str)> {
|
||||
use crate::util::{TaskResult, capture, repo_root, run};
|
||||
|
||||
/// Folder under the target directory for the external binaries.
|
||||
const SIDECAR_DIR: &str = "sidecar";
|
||||
|
||||
/// Name of the CLI binary, without the platform's extension.
|
||||
const CLI_NAME: &str = "lutra";
|
||||
|
||||
/// The Tauri bundle target, the output folder under `bundle/` and the
|
||||
/// installer's file extension for this platform, or `None` without an
|
||||
/// installer.
|
||||
fn target() -> Option<(&'static str, &'static str, &'static str)> {
|
||||
if cfg!(windows) {
|
||||
Some(("nsis", "nsis"))
|
||||
Some(("nsis", "nsis", "exe"))
|
||||
} else if cfg!(target_os = "macos") {
|
||||
Some(("dmg", "dmg"))
|
||||
Some(("dmg", "dmg", "dmg"))
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
/// Builds the platform's installer and prints where it is.
|
||||
/// Builds the platform's installer and prints where it is and which
|
||||
/// version it holds.
|
||||
///
|
||||
/// # Errors
|
||||
/// Fails on a platform without an installer, if the frontend dependencies
|
||||
/// cannot be installed, or if the Tauri CLI is missing or fails.
|
||||
/// cannot be installed, the CLI cannot be built, the Tauri CLI is missing
|
||||
/// or fails, or no installer was produced.
|
||||
pub fn bundle() -> TaskResult {
|
||||
let Some((bundles, folder)) = target() else {
|
||||
let Some((bundles, folder, extension)) = target() else {
|
||||
return Err("no installer for this platform yet (Windows: NSIS, macOS: DMG)".into());
|
||||
};
|
||||
let root = repo_root()?;
|
||||
|
|
@ -39,21 +61,25 @@ pub fn bundle() -> TaskResult {
|
|||
if !root.join("ui").join("node_modules").is_dir() {
|
||||
run(&root.join("ui"), "pnpm", &["install", "--frozen-lockfile"])?;
|
||||
}
|
||||
let mut args = vec![
|
||||
let target_dir = target_dir(&root);
|
||||
let version = app_version(&root)?;
|
||||
let sidecar = build_cli(&root, &cargo, &target_dir)?;
|
||||
let mut config = sidecar_override(&sidecar);
|
||||
if cfg!(target_os = "macos")
|
||||
&& let Some(tiff) = hidpi_background(&root, &target_dir)
|
||||
{
|
||||
merge(&mut config, dmg_background_override(&tiff));
|
||||
}
|
||||
let args = vec![
|
||||
"tauri".to_string(),
|
||||
"build".into(),
|
||||
"--bundles".into(),
|
||||
bundles.into(),
|
||||
"--features".into(),
|
||||
"bundled-ui".into(),
|
||||
"--config".into(),
|
||||
config.to_string(),
|
||||
];
|
||||
let target_dir = target_dir(&root);
|
||||
if cfg!(target_os = "macos")
|
||||
&& let Some(tiff) = hidpi_background(&root, &target_dir)
|
||||
{
|
||||
args.push("--config".into());
|
||||
args.push(dmg_background_override(&tiff));
|
||||
}
|
||||
let status = std::process::Command::new(&cargo)
|
||||
.args(&args)
|
||||
.current_dir(root.join("apps").join("lutra-desktop"))
|
||||
|
|
@ -69,22 +95,33 @@ pub fn bundle() -> TaskResult {
|
|||
let out = target_dir.join("release").join("bundle").join(folder);
|
||||
let listing = std::fs::read_dir(&out)
|
||||
.map_err(|e| format!("no installer folder {}: {e}", out.display()))?;
|
||||
let mut found = false;
|
||||
for entry in listing.flatten() {
|
||||
let path = entry.path();
|
||||
if !is_installer(&path, extension, &version) {
|
||||
continue;
|
||||
}
|
||||
found = true;
|
||||
let size = entry.metadata().map(|m| m.len()).unwrap_or(0);
|
||||
println!(
|
||||
"bundle: {} ({:.1} MB)",
|
||||
"bundle: Lutra {version}: {} ({:.1} MB)",
|
||||
path.display(),
|
||||
size as f64 / 1_000_000.0
|
||||
);
|
||||
}
|
||||
if !found {
|
||||
return Err(format!(
|
||||
"no Lutra {version} installer (*.{extension}) in {}",
|
||||
out.display()
|
||||
));
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// The Cargo target directory: `CARGO_TARGET_DIR` (relative to the
|
||||
/// repository root) or `<root>/target`. [`bundle`] hands it to the Tauri
|
||||
/// CLI as an absolute path: Cargo would read a relative one against
|
||||
/// `apps/lutra-desktop`, where the CLI runs.
|
||||
/// repository root) or `<root>/target`. [`bundle`] hands it to Cargo and
|
||||
/// the Tauri CLI as an absolute path: Cargo would read a relative one
|
||||
/// against `apps/lutra-desktop`, where the CLI runs.
|
||||
fn target_dir(root: &Path) -> PathBuf {
|
||||
match std::env::var_os("CARGO_TARGET_DIR").filter(|v| !v.is_empty()) {
|
||||
Some(dir) => root.join(dir),
|
||||
|
|
@ -92,6 +129,113 @@ fn target_dir(root: &Path) -> PathBuf {
|
|||
}
|
||||
}
|
||||
|
||||
/// The app version, `version` in `apps/lutra-desktop/tauri.conf.json`.
|
||||
///
|
||||
/// # Errors
|
||||
/// If the file cannot be read or has no version string.
|
||||
fn app_version(root: &Path) -> TaskResult<String> {
|
||||
let path = root
|
||||
.join("apps")
|
||||
.join("lutra-desktop")
|
||||
.join("tauri.conf.json");
|
||||
let text = std::fs::read_to_string(&path)
|
||||
.map_err(|e| format!("cannot read {}: {e}", path.display()))?;
|
||||
version_of(&text).ok_or_else(|| format!("{} has no version", path.display()))
|
||||
}
|
||||
|
||||
/// The `version` string of a Tauri config, or `None`.
|
||||
fn version_of(config: &str) -> Option<String> {
|
||||
let json: Value = serde_json::from_str(config).ok()?;
|
||||
json.get("version")?.as_str().map(str::to_string)
|
||||
}
|
||||
|
||||
/// Whether `path` is an installer of `version`: its extension is
|
||||
/// `extension` and its file name contains `_<version>_`, as the bundler
|
||||
/// names them (`Lutra_0.1.0-alpha_x64-setup.exe`). Older installers left in
|
||||
/// the folder are skipped.
|
||||
fn is_installer(path: &Path, extension: &str, version: &str) -> bool {
|
||||
let name = path
|
||||
.file_name()
|
||||
.map(|n| n.to_string_lossy())
|
||||
.unwrap_or_default();
|
||||
path.extension()
|
||||
.is_some_and(|e| e.eq_ignore_ascii_case(extension))
|
||||
&& name.contains(&format!("_{version}_"))
|
||||
}
|
||||
|
||||
/// Builds `lutra-cli` in release mode into `target_dir` and copies the
|
||||
/// binary to the name the bundler expects (see [`sidecar_file`]).
|
||||
///
|
||||
/// # Returns
|
||||
/// The external-binary path for the config: the copy without its triple
|
||||
/// and extension.
|
||||
///
|
||||
/// # Errors
|
||||
/// If the build fails, the host triple is unknown or the copy fails.
|
||||
fn build_cli(root: &Path, cargo: &str, target_dir: &Path) -> TaskResult<PathBuf> {
|
||||
let status = std::process::Command::new(cargo)
|
||||
.args(["build", "--release", "-p", "lutra-cli"])
|
||||
.current_dir(root)
|
||||
.env("CARGO_TARGET_DIR", target_dir)
|
||||
.status()
|
||||
.map_err(|e| format!("cannot start `{cargo}`: {e}"))?;
|
||||
if !status.success() {
|
||||
return Err(format!(
|
||||
"`{cargo} build --release -p lutra-cli` failed ({status})"
|
||||
));
|
||||
}
|
||||
let triple = host_triple(&capture(root, "rustc", &["-vV"])?)
|
||||
.ok_or("`rustc -vV` names no host triple")?;
|
||||
let exe = std::env::consts::EXE_SUFFIX;
|
||||
let built = target_dir.join("release").join(format!("{CLI_NAME}{exe}"));
|
||||
let base = target_dir.join(SIDECAR_DIR).join(CLI_NAME);
|
||||
let copy = sidecar_file(&base, &triple, exe);
|
||||
std::fs::create_dir_all(target_dir.join(SIDECAR_DIR)).map_err(|e| {
|
||||
format!(
|
||||
"cannot create {}: {e}",
|
||||
target_dir.join(SIDECAR_DIR).display()
|
||||
)
|
||||
})?;
|
||||
std::fs::copy(&built, ©)
|
||||
.map_err(|e| format!("cannot copy {} to {}: {e}", built.display(), copy.display()))?;
|
||||
Ok(base)
|
||||
}
|
||||
|
||||
/// The host triple from the output of `rustc -vV` (its `host:` line).
|
||||
fn host_triple(rustc_version: &str) -> Option<String> {
|
||||
rustc_version
|
||||
.lines()
|
||||
.find_map(|line| line.strip_prefix("host:"))
|
||||
.map(|triple| triple.trim().to_string())
|
||||
.filter(|triple| !triple.is_empty())
|
||||
}
|
||||
|
||||
/// The file the bundler looks for when the config names `base` as an
|
||||
/// external binary: `<base>-<triple><exe suffix>`.
|
||||
fn sidecar_file(base: &Path, triple: &str, exe_suffix: &str) -> PathBuf {
|
||||
let mut name = base.as_os_str().to_os_string();
|
||||
name.push(format!("-{triple}{exe_suffix}"));
|
||||
PathBuf::from(name)
|
||||
}
|
||||
|
||||
/// The `--config` JSON that adds `base` as an external binary.
|
||||
fn sidecar_override(base: &Path) -> Value {
|
||||
json!({ "bundle": { "externalBin": [base] } })
|
||||
}
|
||||
|
||||
/// Merges the JSON object `extra` into `into`, key by key and recursively;
|
||||
/// any other value of `extra` replaces the one in `into`.
|
||||
fn merge(into: &mut Value, extra: Value) {
|
||||
match (into, extra) {
|
||||
(Value::Object(into), Value::Object(extra)) => {
|
||||
for (key, value) in extra {
|
||||
merge(into.entry(key).or_insert(Value::Null), value);
|
||||
}
|
||||
}
|
||||
(into, extra) => *into = extra,
|
||||
}
|
||||
}
|
||||
|
||||
/// Joins `dmg-background.png` and `dmg-background@2x.png` into
|
||||
/// `<target>/dmg-background.tiff` with `tiffutil -cathidpicheck`. `None`
|
||||
/// (and a note) if that fails; the bundle then uses the 1x PNG.
|
||||
|
|
@ -117,11 +261,10 @@ fn hidpi_background(root: &Path, target_dir: &Path) -> Option<PathBuf> {
|
|||
|
||||
/// The `--config` JSON for the Tauri CLI that sets the DMG background to
|
||||
/// `tiff`.
|
||||
fn dmg_background_override(tiff: &Path) -> String {
|
||||
serde_json::json!({
|
||||
fn dmg_background_override(tiff: &Path) -> Value {
|
||||
json!({
|
||||
"bundle": { "macOS": { "dmg": { "background": tiff } } }
|
||||
})
|
||||
.to_string()
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
|
@ -130,8 +273,71 @@ mod tests {
|
|||
|
||||
#[test]
|
||||
fn the_override_names_the_tiff() {
|
||||
let json: serde_json::Value =
|
||||
serde_json::from_str(&dmg_background_override(Path::new("/t/bg.tiff"))).unwrap();
|
||||
let json = dmg_background_override(Path::new("/t/bg.tiff"));
|
||||
assert_eq!(json["bundle"]["macOS"]["dmg"]["background"], "/t/bg.tiff");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn the_overrides_merge_into_one_config() {
|
||||
let mut config = sidecar_override(Path::new("/t/sidecar/lutra"));
|
||||
merge(
|
||||
&mut config,
|
||||
dmg_background_override(Path::new("/t/bg.tiff")),
|
||||
);
|
||||
assert_eq!(config["bundle"]["externalBin"][0], "/t/sidecar/lutra");
|
||||
assert_eq!(config["bundle"]["macOS"]["dmg"]["background"], "/t/bg.tiff");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn the_sidecar_carries_the_triple() {
|
||||
let base = Path::new("/t/sidecar/lutra");
|
||||
assert_eq!(
|
||||
sidecar_file(base, "x86_64-pc-windows-msvc", ".exe"),
|
||||
Path::new("/t/sidecar/lutra-x86_64-pc-windows-msvc.exe")
|
||||
);
|
||||
assert_eq!(
|
||||
sidecar_file(base, "aarch64-apple-darwin", ""),
|
||||
Path::new("/t/sidecar/lutra-aarch64-apple-darwin")
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn the_host_triple_comes_from_rustc() {
|
||||
let out = "rustc 1.95.0 (abc 2026-09-01)\nbinary: rustc\nhost: x86_64-pc-windows-msvc\nrelease: 1.95.0\n";
|
||||
assert_eq!(host_triple(out).as_deref(), Some("x86_64-pc-windows-msvc"));
|
||||
assert_eq!(host_triple("rustc 1.95.0\n"), None);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn the_version_comes_from_the_tauri_config() {
|
||||
let conf = include_str!("../../apps/lutra-desktop/tauri.conf.json");
|
||||
let version = version_of(conf).unwrap();
|
||||
assert!(!version.is_empty());
|
||||
assert_eq!(version_of("{}"), None);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn only_installers_of_this_version_are_listed() {
|
||||
let v = "0.1.0-alpha";
|
||||
assert!(is_installer(
|
||||
Path::new("/b/Lutra_0.1.0-alpha_x64-setup.exe"),
|
||||
"exe",
|
||||
v
|
||||
));
|
||||
assert!(is_installer(
|
||||
Path::new("/b/Lutra_0.1.0-alpha_aarch64.dmg"),
|
||||
"dmg",
|
||||
v
|
||||
));
|
||||
assert!(!is_installer(
|
||||
Path::new("/b/Lutra_0.0.0_x64-setup.exe"),
|
||||
"exe",
|
||||
v
|
||||
));
|
||||
assert!(!is_installer(
|
||||
Path::new("/b/Lutra_0.1.0-alpha_x64.nsi"),
|
||||
"exe",
|
||||
v
|
||||
));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue