Files
ipal-kit/test/exports.test.ts
T
radoslaw.smolinskiandClaude Opus 5.5 c9a50abc33 SEO/GEO tools and project requests: site index, IndexNow, page JSON-LD, fixes
GEO / SEO
- collectSiteIndex: one list of public docs per locale (pages + archive
  entries) on sitemap rules; llms.txt/llms-full and MCP list_pages now include
  blog/content entries and every language. Fixes hard-coded "## Strony" heading
  and homepage not collapsing to the locale root in llms.txt.
- Markdown frontmatter: canonical url + updated date.
- Metadata: X/Twitter card, OG image width/height/alt, og:type article with
  published/modified times for entries.
- Fix: Site Settings "defaultShareImage" was never used — now the OG fallback.
- getPageJsonLd (createContentHelpers): WebPage/CollectionPage/BlogPosting,
  BreadcrumbList from the real route, FAQPage via a project mapper.
- IndexNow (opt-in ipalKit({ indexNow: true })): submit published URLs in all
  languages, key generated in Site Integrations or INDEXNOW_KEY, key route.
- sameAs profiles in Site Settings + sameAsUrls(); sitemap <image:image>.

From project reports
- Fix: package exports were missing ./env and ./fluid.css although the docs
  import them (TS2307); regression test checks every documented subpath.
- Fix: plugins run before Payload adds its default users collection, so roles
  and 2FA had nothing to attach to — ipalKit injects an auth collection when
  the project has none (project's own one wins). Audit no longer errors on it.
- createMarkdownRoute, createSubmitAction (/server, headers injected).
- formatOpeningHours (PL/EN/DE text → schema.org), used by
  buildLocalBusinessJsonLd, which also takes a schema.org `type`.
- buildNavigationJsonLd straight from the header global.
- buildCsp googleMaps: full Maps JS API domain set; values de-duplicated.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-16 02:19:08 +02:00

38 lines
1.8 KiB
TypeScript

import { existsSync, readdirSync, readFileSync, statSync } from 'node:fs'
import path from 'node:path'
import { describe, expect, test } from 'vitest'
const root = path.resolve(import.meta.dirname, '..')
const pkg = JSON.parse(readFileSync(path.join(root, 'package.json'), 'utf8')) as { exports: Record<string, unknown> }
function files(dir: string): string[] {
return readdirSync(dir).flatMap((name) => {
const p = path.join(dir, name)
return statSync(p).isDirectory() ? files(p) : /\.(?:md|ts|tsx|mjs)$/.test(name) ? [p] : []
})
}
describe('package exports', () => {
test('every @intecion/ipal-kit/<subpath> used in docs and src is exported', () => {
const used = new Map<string, string>()
for (const file of [...files(path.join(root, 'docs')), ...files(path.join(root, 'src'))]) {
for (const m of readFileSync(file, 'utf8').matchAll(/@intecion\/ipal-kit(?<sub>\/[a-z0-9./-]+)?(?=['"#\s`)])/g)) {
const sub = m.groups?.sub ? `.${m.groups.sub}` : '.'
// node_modules/@intecion/ipal-kit/dist|docs|package.json — filesystem paths in prose, not imports
if (/^\.\/(?:dist|docs|package\.json)(?:\/|$)/.test(sub)) {continue}
if (!used.has(sub)) {used.set(sub, path.relative(root, file))}
}
}
const missing = [...used].filter(([sub]) => !(sub in pkg.exports)).map(([sub, file]) => `${sub} (e.g. ${file})`)
expect(missing).toEqual([])
})
test('every export points at a file the build produces from src', () => {
for (const [sub, target] of Object.entries(pkg.exports)) {
const out = typeof target === 'string' ? target : (target as { import: string }).import
const src = out.replace('./dist/', 'src/').replace(/\.js$/, '.ts')
expect(existsSync(path.join(root, src)) || existsSync(path.join(root, src.replace(/\.ts$/, '.tsx'))), `${sub} → ${src}`).toBe(true)
}
})
})