diff --git a/package.json b/package.json index d32872b1..276c7232 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "homepage", - "version": "1.36.1", + "version": "1.36.2", "private": true, "type": "module", "scripts": { diff --git a/src/lib/server/liturgicalCalendar.ts b/src/lib/server/liturgicalCalendar.ts index b48ac34d..4e205ce4 100644 --- a/src/lib/server/liturgicalCalendar.ts +++ b/src/lib/server/liturgicalCalendar.ts @@ -25,6 +25,7 @@ import type { LiturgicalDay1962, RomcalBundle1962 } from 'romcal/1962'; import { pathToFileURL } from 'node:url'; import { dirname, join as joinPath } from 'node:path'; import { createRequire } from 'node:module'; +import { existsSync, readFileSync } from 'node:fs'; import { colorLabel1962, rank1962Label, @@ -40,8 +41,27 @@ import type { Rite1962Detail } from '../calendarTypes'; +// romcal's package.json isn't exposed via its exports map, so resolve the +// main entry instead and walk up until we hit the package root. const requireFromHere = createRequire(import.meta.url); -const romcalRoot = dirname(requireFromHere.resolve('romcal/package.json')); +function findRomcalRoot(): string { + let dir = dirname(requireFromHere.resolve('romcal')); + while (true) { + const pkgPath = joinPath(dir, 'package.json'); + if (existsSync(pkgPath)) { + try { + const pkg = JSON.parse(readFileSync(pkgPath, 'utf8')) as { name?: string }; + if (pkg.name === 'romcal') return dir; + } catch { + // fall through and keep walking + } + } + const parent = dirname(dir); + if (parent === dir) throw new Error('Could not locate romcal package root'); + dir = parent; + } +} +const romcalRoot = findRomcalRoot(); const bundles1969: Record> = { general: { en: GeneralRoman_En, de: GeneralRoman_De, la: GeneralRoman_La },