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()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue