Fix: Lock installer input state

This commit is contained in:
Gabriel Brown
2026-08-27 09:48:28 -04:00
parent 1ffd05f0e1
commit ba4e5e6677
5 changed files with 3239 additions and 54 deletions
+21 -5
View File
@@ -55,6 +55,7 @@ fi
# ── The extension ────────────────────────────────────────────────────────────
manifest="$extension/package.json"
lockfile="$extension/package-lock.json"
if [[ ! -f "$manifest" ]]; then
note 'the panama-search extension has no manifest'
else
@@ -76,6 +77,15 @@ else
fi
fi
if [[ ! -f "$lockfile" ]]; then
note 'the panama-search extension has no package-lock.json, so npm ci cannot install a fresh clone'
elif git -C "$repo_dir" check-ignore -q "$lockfile" 2>/dev/null; then
note 'the panama-search package-lock.json is ignored, so a fresh clone cannot use npm ci'
elif ! git -C "$repo_dir" ls-files --error-unmatch -- \
'config/local/share/vicinae/extensions/panama-search/package-lock.json' >/dev/null 2>&1; then
note 'the panama-search package-lock.json is not tracked, so a fresh clone cannot use npm ci'
fi
# ── One engine, written twice ────────────────────────────────────────────────
#
# The script command and the extension both have to know where a search goes.
@@ -124,23 +134,29 @@ trap 'rm -rf -- "$fixture_root"' EXIT
mkdir -p "$fixture_root/config/local/share/vicinae/scripts" \
"$fixture_root/config/local/share/vicinae/extensions/panama-search/src" \
"$fixture_root/bin"
printf '{"name":"panama-search","dependencies":{"left-pad":"1.3.0"}}\n' \
>"$fixture_root/config/local/share/vicinae/extensions/panama-search/package.json"
printf '{"lockfileVersion":3,"packages":{}}\n' \
>"$fixture_root/config/local/share/vicinae/extensions/panama-search/package-lock.json"
lockfile="$fixture_root/config/local/share/vicinae/extensions/panama-search/package-lock.json"
fixture_extension="$fixture_root/config/local/share/vicinae/extensions/panama-search"
cp -- "$manifest" "$fixture_extension/package.json"
cp -- "$lockfile" "$fixture_extension/package-lock.json"
cmp -s -- "$lockfile" "$fixture_extension/package-lock.json" \
|| note 'the fresh-clone fixture did not consume the repository package-lock.json'
sed -i 's/"dependencies": {/"dependencies": {"fixture-mismatch": "1.0.0",/' \
"$fixture_extension/package.json"
lockfile="$fixture_extension/package-lock.json"
lock_before="$fixture_root/package-lock.before"
cp -- "$lockfile" "$lock_before"
repository_lock_sha256="$(sha256sum -- "$lock_before" | awk '{ print $1 }')"
cat >"$fixture_root/bin/npm" <<'EOF'
#!/usr/bin/env bash
printf '%s\n' "$*" >>"${NPM_LOG:?}"
[[ "${1:-}" == ci ]] || exit 64
[[ "$(sha256sum -- package-lock.json | awk '{ print $1 }')" == "${NPM_EXPECTED_LOCK_SHA256:?}" ]] || exit 65
exit 1
EOF
chmod +x "$fixture_root/bin/npm"
stage_status=0
stage_output="$(PATH="$fixture_root/bin:$PATH" PANAMA_PATH="$fixture_root" \
VICINAE_DATA_DIR="$fixture_root/vicinae-data" NPM_LOG="$fixture_root/npm.log" \
NPM_EXPECTED_LOCK_SHA256="$repository_lock_sha256" \
bash "$stage" 2>&1)" || stage_status=$?
[[ "$stage_status" -eq 0 ]] \
|| note "the Vicinae stage returned $stage_status for a lockfile mismatch instead of remaining nonfatal"