You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Browse filesBrowse the repository at this point in the historyBrowse files
authored
feat(engine): support structured delegated output (#184)
## What
`maySpawn` currently forces human mode and rejects `--json`. That means
`create-prisma` has to capture Composer's decorated output and regex a
`.prisma.build` URL out of it.
This change lets delegated commands use the engine's normal
structured-output contract:
- human/TTY mode is unchanged: the child inherits the terminal
- JSON or non-TTY mode keeps stdin inherited but pipes both child output
streams to diagnostic stderr
- stdout remains framed NDJSON with exactly one terminal result
- a non-zero child status keeps its verbatim process exit code and emits
`CLI.CHILD_PROCESS_FAILED` with `{ exitCode, signal }` in `error.meta`
- signal-killed children still drop reproduce guidance
The pinned Composer family already presents deploy success as:
```json
{
"summary": {
"app": "...",
"nodes": [
{ "address": "https://....prisma.build", "entities": [] }
]
}
}
```
With this change that result reaches a piped caller directly. A
follow-up in `create-prisma` can parse the terminal frame and stop
regexing human logs; it can also keep captured diagnostic logs hidden
behind its deployment spinner and reveal them only on failure.
## Verification
- `pnpm lint`
- `pnpm -r --if-present typecheck`
- `pnpm --filter @prisma/cli-engine exec vitest run --exclude
tests/clack-prompts.test.ts` — 795 passed
- `pnpm --filter @prisma/cli test` — 942 passed, 1 skipped
- focused fake-child, real-child, shipped spawn-adapter, telemetry, and
bin tests — 93 passed, 1 skipped
- built CLI smoke test: `prisma composer deploy module.ts --json`
accepts structured mode and emits a `composer.deploy` result frame
`packages/cli-engine/tests/clack-prompts.test.ts` has one unrelated
interactive prompt test that times out locally on current main as well;
none of the changed code is in that path.
---------
Signed-off-by: Aman Varshney <amanvarshney.work@gmail.com>
Signed-off-by: willbot <w.a.madden+machine@gmail.com>
Signed-off-by: Will Madden <madden@prisma.io>
Co-authored-by: willbot <w.a.madden+machine@gmail.com>
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
Copy file name to clipboardExpand all lines: packages/cli-engine/src/execution/settlement.ts
+52-5Lines changed: 52 additions & 5 deletions
Original file line number
Diff line number
Diff line change
@@ -211,9 +211,8 @@ export function settleVerbatimExitCode(
211
211
* The status comes from the engine's own record of the child, never
212
212
* from the handler, so there is nothing here for a handler to state.
213
213
* Two conditions fence it, both construction errors: the command must
214
-
* hand the terminal to another program — reachable from a
215
-
* non-declaring handler this would also end a json stream without its
216
-
* terminal result frame — and a child must actually have run.
214
+
* declare that it can hand execution to another program, and a child must
215
+
* actually have run.
217
216
*
218
217
* A signal-killed child overrules whatever the handler asked for. The
219
218
* user stopped the run: it settles 128 + the signal number, with no
@@ -235,15 +234,63 @@ export function settleChildStatus(
235
234
`@prisma/cli-engine: command '${invocation.state.commandId}' returned exitWithChildStatus without a child having run — that settlement reports the status of a child ctx.spawn started, and this run started none`,
236
235
);
237
236
}
238
-
// Only human format is reachable here: maySpawn forces it.
0 commit comments