fix(faith): resolve 1962 bundles via createRequire and add deploy pre-push hook
CI / update (push) Successful in 1m27s

romcal's 1962 bundle files live outside the package's exports map and were
being loaded via a cwd-relative path. Under systemd the server runs with
cwd /usr/share/webapps/homepage/dist/, so node_modules/romcal/... resolved
against dist/ and hit ERR_MODULE_NOT_FOUND. Switch to createRequire +
require.resolve('romcal/package.json') so the bundle path is anchored to
the actual package root regardless of cwd.

Also track scripts/hooks/pre-push which runs scripts/deploy.sh after a
master push to origin. Git has no native post-push hook; pre-push is the
closest client-side equivalent — if deploy fails the push is aborted.
Install with: ln -sf ../../scripts/hooks/pre-push .git/hooks/pre-push
This commit is contained in:
2026-04-20 16:44:03 +02:00
parent 9c119b8df2
commit f447520aaa
3 changed files with 41 additions and 4 deletions
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "homepage",
"version": "1.36.0",
"version": "1.36.1",
"private": true,
"type": "module",
"scripts": {
+30
View File
@@ -0,0 +1,30 @@
#!/usr/bin/env bash
# Run scripts/deploy.sh after a push to origin/master.
# Git has no native post-push hook; pre-push runs before the push completes.
# If deploy fails the push is aborted, which is safer than deploying after a
# push that might have been rejected anyway.
#
# Install: ln -sf ../../scripts/hooks/pre-push .git/hooks/pre-push
set -e
remote_name="$1"
# Only deploy when pushing to the Gitea origin.
if [ "$remote_name" != "origin" ]; then
exit 0
fi
should_deploy=0
while read -r _local_ref _local_sha remote_ref _remote_sha; do
if [ "$remote_ref" = "refs/heads/master" ]; then
should_deploy=1
fi
done
if [ "$should_deploy" -ne 1 ]; then
exit 0
fi
repo_root="$(git rev-parse --show-toplevel)"
exec "$repo_root/scripts/deploy.sh"
+10 -3
View File
@@ -23,7 +23,8 @@ import {
} from 'romcal/1962';
import type { LiturgicalDay1962, RomcalBundle1962 } from 'romcal/1962';
import { pathToFileURL } from 'node:url';
import { resolve as resolvePath } from 'node:path';
import { dirname, join as joinPath } from 'node:path';
import { createRequire } from 'node:module';
import {
colorLabel1962,
rank1962Label,
@@ -39,6 +40,9 @@ import type {
Rite1962Detail
} from '../calendarTypes';
const requireFromHere = createRequire(import.meta.url);
const romcalRoot = dirname(requireFromHere.resolve('romcal/package.json'));
const bundles1969: Record<Diocese1969, Record<CalendarLang, RomcalBundleObject>> = {
general: { en: GeneralRoman_En, de: GeneralRoman_De, la: GeneralRoman_La },
switzerland: { en: Switzerland_En, de: Switzerland_De, la: Switzerland_La }
@@ -110,8 +114,11 @@ const bundle1962Cache = new Map<CalendarLang, Promise<RomcalBundle1962>>();
function loadBundle1962(lang: CalendarLang): Promise<RomcalBundle1962> {
let p = bundle1962Cache.get(lang);
if (p) return p;
const abs = resolvePath(
`node_modules/romcal/rites/roman1962/dist/bundles/${lang}/esm/index.js`
const abs = joinPath(
romcalRoot,
'rites/roman1962/dist/bundles',
lang,
'esm/index.js'
);
p = import(/* @vite-ignore */ pathToFileURL(abs).href).then(
(m) => m.default as RomcalBundle1962