diff --git a/package.json b/package.json index 9819ed3d..d32872b1 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "homepage", - "version": "1.36.0", + "version": "1.36.1", "private": true, "type": "module", "scripts": { diff --git a/scripts/hooks/pre-push b/scripts/hooks/pre-push new file mode 100755 index 00000000..2cace399 --- /dev/null +++ b/scripts/hooks/pre-push @@ -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" diff --git a/src/lib/server/liturgicalCalendar.ts b/src/lib/server/liturgicalCalendar.ts index f9b3f23e..b48ac34d 100644 --- a/src/lib/server/liturgicalCalendar.ts +++ b/src/lib/server/liturgicalCalendar.ts @@ -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> = { 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>(); function loadBundle1962(lang: CalendarLang): Promise { 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