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]>
46 lines
1.4 KiB
TypeScript
46 lines
1.4 KiB
TypeScript
/**
|
|
* Entry point: @intecion/ipal-kit/seed
|
|
*
|
|
* Seed helper for the project's seed scripts (docs/seeding.md):
|
|
*
|
|
* // scripts/seed-content.ts — pnpm payload run scripts/seed-content.ts
|
|
* import config from '@payload-config'
|
|
* import { getPayload } from 'payload'
|
|
* import { createSeeder, guardSeedExit } from '@intecion/ipal-kit/seed'
|
|
*
|
|
* guardSeedExit() // first: an early exit (no Payload, unfinished run) becomes exit 1, not a silent 0
|
|
* const seed = createSeeder(await getPayload({ config }))
|
|
* await seed.upsertBySlug('pages', [{ title: { pl: 'Kontakt', en: 'Contact' }, slug: { pl: 'kontakt', en: 'contact' } }])
|
|
* await seed.fillGlobal('header', { links: [] })
|
|
* process.exit(seed.summary().errors ? 1 : 0)
|
|
*
|
|
* Server only: Node built-ins and the Local API. Never import it from client
|
|
* code, the Payload config or a route. It does not import 'server-only' — that
|
|
* package throws in plain Node, and `payload run` is plain Node.
|
|
*/
|
|
export {
|
|
activeSeedExitGuard,
|
|
createSeeder,
|
|
editedSinceSeed,
|
|
guardSeedExit,
|
|
isLocalDatabase,
|
|
projectOnto,
|
|
seedHash,
|
|
writeLocales,
|
|
} from '../modules/seed/index.js'
|
|
export type {
|
|
EditedSinceSeedArgs,
|
|
Seeder,
|
|
SeederOptions,
|
|
SeedExitGuard,
|
|
SeedExitGuardOptions,
|
|
SeedExitProcess,
|
|
SeedResult,
|
|
SeedStatus,
|
|
SeedSummary,
|
|
SeedTarget,
|
|
SeedValue,
|
|
UpsertOptions,
|
|
WriteLocalesOptions,
|
|
} from '../modules/seed/index.js'
|