feat: installer boots nvim once and restores the lazy-lock pins
A first nvim start cloned the later-round plugins (claudecode, mini.*, nvim-lint, friendly-snippets, ...) at branch tip and rewrote the seeded lazy-lock.json with the tips. The install pipeline now ends with a headless first boot, puts the seeded lockfile back, and runs `Lazy! restore`. It runs only where lazy has never installed a plugin, so a lockfile the user has moved on is never touched, and a second run does nothing.
This commit is contained in:
1 parent
4e2452e994
commit
e0c78a3ffa
5 files changed
+121
No files matched your search
@@ -157,6 +157,22 @@ herdr)
|
||||
integration:install) [ "$mode" = install ] && exit 1 ;;
|
||||
esac
|
||||
exit 0 ;;
|
||||
nvim)
|
||||
# Behaves like lazy.nvim's first start: a plain boot creates the plugin
|
||||
# directory and REWRITES lazy-lock.json with drifted commits, which is the
|
||||
# bug the installer's first-boot step exists to undo. `+Lazy! restore`
|
||||
# records the lockfile it was handed in ~/.nvim-restored-from. Injections:
|
||||
# FAKE_FAIL=nvim:boot and FAKE_FAIL=nvim:restore.
|
||||
_lock=${XDG_CONFIG_HOME:-$HOME/.config}/nvim/lazy-lock.json
|
||||
case "$*" in
|
||||
*'Lazy! restore'*)
|
||||
[ "$mode" = restore ] && exit 1
|
||||
cp "$_lock" "$HOME/.nvim-restored-from"; exit 0 ;;
|
||||
esac
|
||||
mkdir -p "${XDG_DATA_HOME:-$HOME/.local/share}/nvim/lazy/lazy.nvim"
|
||||
[ -f "$_lock" ] && printf '{ "drifted": "tip" }\n' > "$_lock"
|
||||
[ "$mode" = boot ] && exit 1
|
||||
exit 0 ;;
|
||||
fzf)
|
||||
# The picker's own fzf, and the only fake here whose ARGV is the thing
|
||||
# under test. `--bind` strings are built across a dozen continued lines, so
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
# what: nvim's first boot no longer puts the seeded lazy-lock.json back
|
||||
# why: restore then pins to the tips the boot just wrote, and the pins are lost
|
||||
# kills: …against the SEEDED lockfile, not the one the boot rewrote
|
||||
# run: unit
|
||||
<<<OLD
|
||||
run_sh "cp '$nb_seed' '$nb_lock'" || { warn "could not put the seeded lazy-lock.json back"; return 0; }
|
||||
<<<NEW
|
||||
<<<END
|
||||
@@ -0,0 +1,8 @@
|
||||
# what: the nvim first-boot step runs even where lazy already manages plugins
|
||||
# why: it would overwrite a lockfile the user moved on with :Lazy update
|
||||
# kills: …and nvim is not started
|
||||
# run: unit
|
||||
<<<OLD
|
||||
[ ! -e "$nb_lazy" ] || return 0
|
||||
<<<NEW
|
||||
<<<END
|
||||
@@ -814,6 +814,56 @@ else
|
||||
hasnt "with no herdr the step says nothing" "herdr" "$out"
|
||||
fi
|
||||
|
||||
printf '\n\033[1mnvim first boot keeps the lazy-lock.json pins\033[0m\n'
|
||||
# A real first boot clones some plugins at branch tip and rewrites the lockfile
|
||||
# with the tips; the fake nvim does the same rewrite. The step has to undo it:
|
||||
# boot, put the seed back, then restore against the seed. Once only, and never
|
||||
# over a lockfile lazy has already managed.
|
||||
seedlock() {
|
||||
mkdir -p "$SB/.config/nvim"
|
||||
printf '{ "plugin": "pinned" }\n' > "$SB/.config/nvim/lazy-lock.json"
|
||||
}
|
||||
newbox; sh ./seal.sh "$SB/seal" --with nvim >/dev/null; BOXPATH=$SB/seal
|
||||
seedlock; pick core/ripgrep
|
||||
out=$(box install 2>&1 | plain || true)
|
||||
is "a fresh box boots nvim, then restores" "boot restore" \
|
||||
"$(awk '$1=="nvim" {print (/Lazy! restore/ ? "restore" : "boot")}' "$LOG" | tr '\n' ' ' | sed 's/ $//')"
|
||||
is "…against the SEEDED lockfile, not the one the boot rewrote" '{ "plugin": "pinned" }' \
|
||||
"$(cat "$SB/.nvim-restored-from" 2>/dev/null)"
|
||||
is "…and leaves the seed in place" '{ "plugin": "pinned" }' \
|
||||
"$(cat "$SB/.config/nvim/lazy-lock.json")"
|
||||
: > "$LOG"; out=$(box install 2>&1 | plain || true)
|
||||
is "a second run starts no nvim" "0" "$(grep -c '^nvim ' "$LOG" || true)"
|
||||
hasnt "…and prints no nvim section" "pinned to lazy-lock.json" "$out"
|
||||
newbox; sh ./seal.sh "$SB/seal" --with nvim >/dev/null; BOXPATH=$SB/seal
|
||||
printf '{ "plugin": "updated-by-user" }\n' > "$SB/lock.user"
|
||||
seedlock; cp "$SB/lock.user" "$SB/.config/nvim/lazy-lock.json"
|
||||
mkdir -p "$SB/.local/share/nvim/lazy/lazy.nvim"; pick core/ripgrep
|
||||
box install >/dev/null 2>&1 || true
|
||||
is "a lockfile lazy already manages is left alone" "$(cat "$SB/lock.user")" \
|
||||
"$(cat "$SB/.config/nvim/lazy-lock.json")"
|
||||
is "…and nvim is not started" "0" "$(grep -c '^nvim ' "$LOG" || true)"
|
||||
newbox; sh ./seal.sh "$SB/seal" --with nvim >/dev/null; BOXPATH=$SB/seal; pick core/ripgrep
|
||||
box install >/dev/null 2>&1 || true
|
||||
is "with no nvim config there is nothing to pin" "0" "$(grep -c '^nvim ' "$LOG" || true)"
|
||||
newbox; sh ./seal.sh "$SB/seal" --with nvim >/dev/null; BOXPATH=$SB/seal
|
||||
seedlock; pick core/ripgrep; BOXENV='FAKE_FAIL=nvim:restore'
|
||||
rc=0; box install >"$SB/out" 2>&1 || rc=$?; out=$(plain < "$SB/out")
|
||||
has "a failed restore says how to retry" "nvim --headless '+Lazy! restore' +qa" "$out"
|
||||
is "…without failing the install" "0" "$rc"
|
||||
newbox; sh ./seal.sh "$SB/seal" --with nvim >/dev/null; BOXPATH=$SB/seal
|
||||
seedlock; pick core/ripgrep; BOXENV='FAKE_FAIL=nvim:boot'
|
||||
box install >/dev/null 2>&1 || true
|
||||
is "a failed first boot still restores the seed" '{ "plugin": "pinned" }' \
|
||||
"$(cat "$SB/.nvim-restored-from" 2>/dev/null)"
|
||||
newbox
|
||||
if holed nvim; then
|
||||
seedlock; pick core/ripgrep
|
||||
hasnt "with no nvim the step says nothing" "lazy-lock" "$(box install 2>&1 | plain || true)"
|
||||
else
|
||||
printf ' \033[33mskip\033[0m nvim sits at an absolute path find_tool probes\n'
|
||||
fi
|
||||
|
||||
printf '\n\033[1mclaude desktop trusts only Anthropic'"'"'s key\033[0m\n'
|
||||
# A vendor apt repository is a key apt will trust for root-installed packages,
|
||||
# so the key is checked against the published fingerprint before it is placed.
|
||||
|
||||
Reference in new issue
Block a user