Repository navigation
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·87 lines (78 loc) · 3.37 KB
/
Copy pathinstall.sh
File metadata and controls
executable file
·87 lines (78 loc) · 3.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
#!/usr/bin/env bash
# install.sh — build lector from source and install it to /Applications.
# Usage: bash install.sh
# or: curl -fsSL https://raw.githubusercontent.com/Lockyc/lector/main/install.sh | bash
#
# The curl URL and the git clone below require the GitHub repo to be public.
#
# Two modes, auto-detected:
# • IN_REPO — run from a lector checkout: builds from the current working
# tree (so local changes are picked up). No clone/pull.
# • NOT_IN_REPO — otherwise: manages a persistent source clone at ~/.lector
# (clone if absent, git pull if present) and builds from it.
#
# Never relaunches the app (the caller decides) and never depends on `just`.
set -euo pipefail
if [[ "$(uname)" != "Darwin" ]]; then
echo "lector is a macOS-only app; install.sh only runs on macOS." >&2
exit 1
fi
REPO_URL="https://github.com/Lockyc/lector"
INSTALL_DIR="$HOME/.lector"
# 1. Hard prerequisites. Refused with a hint, never installed (except the Tauri
# CLI, which is backstopped below).
missing=0
for c in git cargo; do
if ! command -v "$c" >/dev/null 2>&1; then
echo "lector: '$c' is required but not found on PATH" >&2
missing=1
fi
done
if [ "$missing" -ne 0 ]; then
echo "lector: install Rust (https://rustup.rs) and Xcode Command Line Tools" >&2
echo " (xcode-select --install), then re-run." >&2
exit 1
fi
# 2. Resolve the source dir (IN_REPO vs clone at ~/.lector).
if [ -f install.sh ] && [ -f src-tauri/tauri.conf.json ]; then
SRC="$(pwd)"
echo "→ building from the current lector checkout: $SRC"
else
if [ ! -e "$INSTALL_DIR" ]; then
echo "→ cloning lector into $INSTALL_DIR"
git clone "$REPO_URL" "$INSTALL_DIR"
elif [ -d "$INSTALL_DIR/.git" ]; then
echo "→ updating lector clone in $INSTALL_DIR"
git -C "$INSTALL_DIR" pull --ff-only
else
echo "lector: $INSTALL_DIR exists but is not a git clone — move it aside and re-run." >&2
exit 1
fi
SRC="$INSTALL_DIR"
fi
# 3. Tauri CLI backstop — a source build needs `cargo tauri`; ship it as a cargo global.
if ! command -v cargo-tauri >/dev/null 2>&1; then
echo "→ installing the Tauri CLI (cargo install tauri-cli — this takes a while)"
cargo install tauri-cli --version '^2' --locked
fi
# 4. Build the release bundle.
cd "$SRC"
echo "→ building release bundle (this takes a few minutes)"
( cd src-tauri && cargo tauri build )
# 5. Install the built app into /Applications. lector is a Cargo workspace, so the
# bundle lands under the workspace-root target/, not src-tauri/target/.
bash scripts/install-app.sh "target/release/bundle/macos/lector.app"
# 6. Seed the user config from the app's own starter (never overwrite an existing one).
# Not examples/config.toml: that is the `just run` fixture, whose `dir = "."` is only
# right with the repo as cwd — a Dock launch would render `/`.
mkdir -p "$HOME/.config/lector"
if [ ! -f "$HOME/.config/lector/config.toml" ]; then
cp src/default-config.toml "$HOME/.config/lector/config.toml"
echo "→ seeded ~/.config/lector/config.toml from the starter config"
else
echo "→ ~/.config/lector/config.toml already exists — left untouched"
fi
echo ""
echo "✓ lector installed to /Applications/lector.app"
echo " Edit ~/.config/lector/config.toml to curate your doc tabs, then launch lector."
echo " Update any time by re-running this installer (it git-pulls + rebuilds)."