Seeds: guardSeedExit() — a run that ends early exits 1 with the reason, never a silent 0

payload run starts the CLI with `void start()` and imports the script; when the script's top-level await
is left without live handles, Node exits with code 0 and no output — a success in Coolify's Terminal.
guardSeedExit() (@intecion/ipal-kit/seed, dependency-free) listens for beforeExit: until summary() runs it
prints "[seed] ended before Payload initialized" / "… before the seed finished" and exits 1. createSeeder
marks the run initialized, summary() finished; process.exit paths (normal, errors, the production
refusals) are untouched. Wired into the ipal-site and ipal-form seed templates and the reference seed, so
ipal-kit create sites get it. Tests include a real child process started like payload run.
Docs: seeding.md, deployment.md §4.7, AGENT.md, ipal-reference (+ api.md), CHANGELOG Unreleased.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
Radosław Smoliński
2026-10-29 19:19:14 +01:00
co-authored by Claude Opus 5.5
parent 55dc69b69f
commit f789e36636
14 changed files with 277 additions and 9 deletions
+3 -1
View File
@@ -13,7 +13,7 @@
* only with the owner's explicit OK). Pages are create-only; an edited record is skipped.
*/
import config from '@payload-config'
import { createSeeder } from '@intecion/ipal-kit/seed'
import { createSeeder, guardSeedExit } from '@intecion/ipal-kit/seed'
import { getPayload } from 'payload'
import { seedBaseGlobals, seedBaseNavigation, seedBasePages, seedBaseTexts } from './base'
@@ -33,6 +33,8 @@ const withBase = layer === 'all' || layer === 'base'
//: const withBase = true // a new site has only the base layer (the reference site's demo is not copied)
// @starter:endif
// An early exit (Payload never up, the run cut short) fails with exit 1 instead of a silent 0 (seeding.md).
guardSeedExit()
const payload = await getPayload({ config })
const seed = createSeeder(payload)