Fix installer state and launcher freshness checks

This commit is contained in:
Gabriel Brown
2026-08-27 17:31:46 -04:00
parent 99156442b5
commit b5832fc94a
6 changed files with 156 additions and 19 deletions
+62 -1
View File
@@ -123,7 +123,8 @@ grep -q '/etc/profile.d/nvm.sh' "$stage" \
|| note 'the extension build never sources nvm, so npm is missing on any machine without a system node'
# node_modules is a dependency tree, not configuration.
git -C "$repo_dir" check-ignore -q "$extension/node_modules" 2>/dev/null \
git -C "$repo_dir" check-ignore --no-index -q \
"$extension/node_modules/package.json" 2>/dev/null \
|| note 'the extension node_modules is not gitignored'
# npm must honour the committed dependency graph. This disposable fixture
@@ -167,6 +168,66 @@ stage_output="$(PATH="$fixture_root/bin:$PATH" PANAMA_PATH="$fixture_root" \
cmp -s -- "$lock_before" "$lockfile" \
|| note 'a rejected Vicinae lockfile mismatch changed package-lock.json'
# Editing an existing source file does not change its parent directory's
# timestamp, so freshness must inspect files rather than the src directory.
freshness_root="$fixture_root/freshness"
mkdir -p "$freshness_root/config/local/share/vicinae/scripts" \
"$freshness_root/config/local/share/vicinae/extensions/panama-search/src" \
"$freshness_root/bin"
freshness_extension="$freshness_root/config/local/share/vicinae/extensions/panama-search"
cp -- "$manifest" "$freshness_extension/package.json"
cp -- "$repo_dir/config/local/share/vicinae/extensions/panama-search/package-lock.json" \
"$freshness_extension/package-lock.json"
cp -- "$extension/src/search.tsx" "$freshness_extension/src/search.tsx"
cat >"$freshness_root/bin/npm" <<'EOF'
#!/usr/bin/env bash
printf '%s\n' "$*" >>"${NPM_LOG:?}"
if [[ "${1:-}" == ci ]]; then
exit 0
fi
if [[ "${1:-} ${2:-}" == 'run build' ]]; then
built="${VICINAE_DATA_DIR:?}/extensions/$(basename "$PWD")"
mkdir -p "$built"
touch "$built"
exit 0
fi
exit 64
EOF
chmod +x "$freshness_root/bin/npm"
: >"$freshness_root/npm.log"
run_freshness_stage() {
PATH="$freshness_root/bin:$PATH" PANAMA_PATH="$freshness_root" \
VICINAE_DATA_DIR="$freshness_root/vicinae-data" \
NPM_LOG="$freshness_root/npm.log" bash "$stage" >/dev/null 2>&1
}
run_freshness_stage || note 'the Vicinae freshness fixture did not build initially'
initial_builds="$(grep -c '^run build$' "$freshness_root/npm.log")"
run_freshness_stage || note 'the unchanged Vicinae freshness fixture failed'
unchanged_builds="$(grep -c '^run build$' "$freshness_root/npm.log")"
[[ "$unchanged_builds" == "$initial_builds" ]] \
|| note 'an unchanged Vicinae extension rebuilt unnecessarily'
touch -d '2030-01-01 UTC' "$freshness_extension/src/search.tsx"
run_freshness_stage || note 'the source-changed Vicinae freshness fixture failed'
source_changed_builds="$(grep -c '^run build$' "$freshness_root/npm.log")"
[[ "$source_changed_builds" -eq $(( initial_builds + 1 )) ]] \
|| note 'editing an existing Vicinae source file did not trigger a rebuild'
built_extension="$freshness_root/vicinae-data/extensions/panama-search"
touch -r "$built_extension" "$freshness_extension/src/search.tsx"
touch -d '2031-01-01 UTC' "$freshness_extension/package.json"
run_freshness_stage || note 'the manifest-changed Vicinae freshness fixture failed'
manifest_changed_builds="$(grep -c '^run build$' "$freshness_root/npm.log")"
[[ "$manifest_changed_builds" -eq $(( source_changed_builds + 1 )) ]] \
|| note 'changing a Vicinae package.json did not trigger a rebuild'
touch -r "$built_extension" "$freshness_extension/package.json" \
"$freshness_extension/src/search.tsx"
touch -d '2032-01-01 UTC' "$freshness_extension/package-lock.json"
run_freshness_stage || note 'the lockfile-changed Vicinae freshness fixture failed'
lockfile_changed_builds="$(grep -c '^run build$' "$freshness_root/npm.log")"
[[ "$lockfile_changed_builds" -eq $(( manifest_changed_builds + 1 )) ]] \
|| note 'changing a Vicinae package-lock.json did not trigger a rebuild'
# ── Report ───────────────────────────────────────────────────────────────────
if (( ${#findings[@]} > 0 )); then