Merge claude/starter-gate-refusal: the production full-seed check needs the guard's message
starter:gate passes the production full-seed check only when the output says "full seed refused" and the exit is non-zero; a payload run that ends before Payload initializes (exit 0, no output) is inconclusive and retried, up to 3 times. Fixes the flaky check found in the 1.15.0 gate.
This commit is contained in:
@@ -178,7 +178,8 @@ compiled code with source maps, docs — is ~340 KB unpacked (~4 % of 7.96 MB) a
|
|||||||
`pnpm starter:gate` (the last step of `prepublishOnly`) blocks the publish unless a site created from the
|
`pnpm starter:gate` (the last step of `prepublishOnly`) blocks the publish unless a site created from the
|
||||||
**packed tarball** works the way it will in Coolify: `dlx` create → frozen install → first seed of a fresh
|
**packed tarball** works the way it will in Coolify: `dlx` create → frozen install → first seed of a fresh
|
||||||
`_dev` database (MongoDB in its own Docker container) → `pnpm generate:types && pnpm build` →
|
`_dev` database (MongoDB in its own Docker container) → `pnpm generate:types && pnpm build` →
|
||||||
`SEED_ONLY="pages:kontakt" [SEED_DRY_RUN=1] pnpm seed` in production mode → a full seed in production refused →
|
`SEED_ONLY="pages:kontakt" [SEED_DRY_RUN=1] pnpm seed` in production mode → a full seed in production refused (the guard's
|
||||||
|
"full seed refused" message is required; a run where Payload never initialized is inconclusive and retried, up to 3) →
|
||||||
`pnpm start` with `/api/health`, `/pl`, report-only CSP, no `X-Powered-By`, `/llms.txt` → `ipal-doctor --strict`
|
`pnpm start` with `/api/health`, `/pl`, report-only CSP, no `X-Powered-By`, `/llms.txt` → `ipal-doctor --strict`
|
||||||
(when shipped) → with the `nixpacks` CLI on PATH, the same seed inside the Nixpacks image. Each run packs to a new
|
(when shipped) → with the `nixpacks` CLI on PATH, the same seed inside the Nixpacks image. Each run packs to a new
|
||||||
file name and calls `dlx` with `--config.dlx-cache-max-age=0` (pnpm's dlx cache is keyed by the spec, so a reused path
|
file name and calls `dlx` with `--config.dlx-cache-max-age=0` (pnpm's dlx cache is keyed by the spec, so a reused path
|
||||||
|
|||||||
@@ -47,6 +47,28 @@ function check(name, ok, detail = '') {
|
|||||||
if (!ok) {throw new Error(`gate failed: ${name}`)}
|
if (!ok) {throw new Error(`gate failed: ${name}`)}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Runs the production full seed and decides whether the guard refused it. Only the guard's own message counts:
|
||||||
|
* an exit code alone does not, because `payload run` can end with exit 0 and no output before Payload initializes
|
||||||
|
* (its bin does `void start()`; when the script's top-level `await getPayload()` is left with nothing that keeps the
|
||||||
|
* event loop alive, Node simply exits). Such a run says nothing — it is retried, up to `tries` times.
|
||||||
|
*/
|
||||||
|
function fullSeedRefused(site, env, tries = 3) {
|
||||||
|
for (let attempt = 1; attempt <= tries; attempt++) {
|
||||||
|
log(`$ pnpm seed (production, no SEED_ONLY) — attempt ${attempt}/${tries}`)
|
||||||
|
const run = spawnSync('pnpm', ['seed'], { cwd: site, encoding: 'utf8', env: { ...process.env, ...env } })
|
||||||
|
const output = `${run.stdout ?? ''}${run.stderr ?? ''}`
|
||||||
|
process.stdout.write(output)
|
||||||
|
if (/full seed refused/.test(output)) {return run.status !== 0}
|
||||||
|
if (/\[ipal\] Plugin initialized/.test(output)) {
|
||||||
|
log(`Payload initialized but the seed was not refused (exit ${run.status})`)
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
log(`inconclusive: Payload never initialized (exit ${run.status}, ${output.trim() ? 'no guard message' : 'no output'})${attempt < tries ? ' — retrying' : ''}`)
|
||||||
|
}
|
||||||
|
throw new Error(`gate failed: the production full seed was inconclusive in all ${tries} runs — Payload never initialized, so the guard was never reached`)
|
||||||
|
}
|
||||||
|
|
||||||
async function waitFor(url, seconds) {
|
async function waitFor(url, seconds) {
|
||||||
for (let i = 0; i < seconds; i++) {
|
for (let i = 0; i < seconds; i++) {
|
||||||
try {
|
try {
|
||||||
@@ -138,8 +160,7 @@ async function main() {
|
|||||||
sh(site, 'pnpm', ['seed'], { ...prod, SEED_ONLY: 'pages:kontakt' })
|
sh(site, 'pnpm', ['seed'], { ...prod, SEED_ONLY: 'pages:kontakt' })
|
||||||
check('targeted seed in production mode: SEED_ONLY="pages:kontakt" [SEED_DRY_RUN=1] pnpm seed', true)
|
check('targeted seed in production mode: SEED_ONLY="pages:kontakt" [SEED_DRY_RUN=1] pnpm seed', true)
|
||||||
// after launch: a run without SEED_ONLY on production must be refused by the plugin's guard
|
// after launch: a run without SEED_ONLY on production must be refused by the plugin's guard
|
||||||
const refused = sh(site, 'pnpm', ['seed'], prod, { allowFail: true })
|
check('full seed on production (no SEED_ONLY) is refused', fullSeedRefused(site, prod), 'exit 1 with "full seed refused"')
|
||||||
check('full seed on production (no SEED_ONLY) is refused', refused !== 0)
|
|
||||||
|
|
||||||
// 6. the production server
|
// 6. the production server
|
||||||
log(`$ pnpm start (PORT=${PORT})`)
|
log(`$ pnpm start (PORT=${PORT})`)
|
||||||
|
|||||||
Reference in New Issue
Block a user