test(int-suite): auto-accept drizzle push prompts in tests/push-schema.ts
payload's pushDevSchema() awaits prompts() whenever drizzle push reports warnings (incl. DATA LOSS); under non-TTY stdin that await hangs forever (2026-10-19 bootstrap hang). Inject confirmations through the single hoisted prompts copy before getPayload boots; stdio stays inherit so all other push output remains visible.
This commit is contained in:
parent
c64d56b830
commit
859f6d4310
1 changed files with 19 additions and 0 deletions
|
|
@ -1,3 +1,5 @@
|
|||
// @ts-expect-error - the `prompts` package ships no bundled types; only `.inject()` is used here.
|
||||
import prompts from "prompts";
|
||||
import { getPayload } from "payload";
|
||||
import config from "@payload-config";
|
||||
|
||||
|
|
@ -6,7 +8,24 @@ import config from "@payload-config";
|
|||
* DATABASE_URI pointing at the test database (tests/test-db.ts does this);
|
||||
* initializing the Payload adapter with push: true makes drizzle create or
|
||||
* diff the full schema. Exits immediately after initialization.
|
||||
*
|
||||
* Non-interactive by construction: when drizzle push reports warnings
|
||||
* (including DATA LOSS ones), @payloadcms/drizzle's pushDevSchema asks via
|
||||
* `prompts()`. Under a non-TTY stdin that await hangs forever, so we pre-load
|
||||
* the SAME hoisted `prompts` module Payload imports and inject confirmations
|
||||
* for it. The injected queue never empties in practice (one confirm per run,
|
||||
* ten prepared); if it ever did, prompts would fall back to stdin, which is
|
||||
* exactly why the queue is generous rather than exactly one.
|
||||
*
|
||||
* This relies on module identity: bun's loader resolves every `import
|
||||
* prompts from "prompts"` to the single hoisted copy in node_modules (verified
|
||||
* no nested copies under payload's own node_modules subtree). If a future
|
||||
* dependency bump nests a second copy, the injection silently stops applying
|
||||
* and pushes with warnings hang again - watch for that when touching deps.
|
||||
*/
|
||||
prompts.inject(Array(10).fill(true));
|
||||
console.log("[push-schema] non-interactive mode: any drizzle push warnings/data-loss confirmations are auto-accepted");
|
||||
|
||||
const payload = await getPayload({ config });
|
||||
void payload;
|
||||
process.exit(0);
|
||||
|
|
|
|||
Loading…
Reference in a new issue