@prisma/composer-cli 0.39.0-dev.1 → 0.39.0-dev.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (74) hide show
  1. package/dist/app-converge-bS1l9jIf-B1FOgxBQ.mjs +88 -0
  2. package/dist/app-converge-bS1l9jIf-B1FOgxBQ.mjs.map +1 -0
  3. package/dist/composer-config-QKdY85G--CEXrb2Uc.mjs +254 -0
  4. package/dist/composer-config-QKdY85G--CEXrb2Uc.mjs.map +1 -0
  5. package/dist/{validate-environment-D1BTCkTs-C5m4rL6t.mjs → deploy-Br1yvLe3.mjs} +335 -1091
  6. package/dist/deploy-Br1yvLe3.mjs.map +1 -0
  7. package/dist/dev-converge-messages-DML4rTz7-B6uxtpZG.mjs +256 -0
  8. package/dist/dev-converge-messages-DML4rTz7-B6uxtpZG.mjs.map +1 -0
  9. package/dist/dev-converge-worker.d.mts +1 -0
  10. package/dist/dev-converge-worker.mjs +143 -0
  11. package/dist/dev-converge-worker.mjs.map +1 -0
  12. package/dist/{dev-current-wD5YDLjA-CFI8XTAK.mjs → dev-current-lAlj53eX-DvAHNZFo.mjs} +12 -18
  13. package/dist/dev-current-lAlj53eX-DvAHNZFo.mjs.map +1 -0
  14. package/dist/dev-environment-name-6eEr5PW8-CCY7WNWz.mjs +43 -0
  15. package/dist/dev-environment-name-6eEr5PW8-CCY7WNWz.mjs.map +1 -0
  16. package/dist/{dist-D0rWRHos.mjs → dist-C0OGaDnj.mjs} +4 -3
  17. package/dist/{dist-D0rWRHos.mjs.map → dist-C0OGaDnj.mjs.map} +1 -1
  18. package/dist/errors-CVYwN2km.mjs +93 -0
  19. package/dist/errors-CVYwN2km.mjs.map +1 -0
  20. package/dist/{execute-deploy-destroy-DOzo2Psp-2iWcFbD9.mjs → execute-deploy-destroy-DN16ETAk-CzORriUO.mjs} +374 -141
  21. package/dist/execute-deploy-destroy-DN16ETAk-CzORriUO.mjs.map +1 -0
  22. package/dist/{execute-dev-BIyOI3Ys-DGpTd9rP.mjs → execute-dev-DnVmNpc1-BzK9Qns_.mjs} +444 -128
  23. package/dist/execute-dev-DnVmNpc1-BzK9Qns_.mjs.map +1 -0
  24. package/dist/{execute-dev-current-CKOzjWuO-DTOVqZzZ.mjs → execute-dev-current-CZdmxVQ4-DxDflvNG.mjs} +9 -6
  25. package/dist/{execute-dev-current-CKOzjWuO-DTOVqZzZ.mjs.map → execute-dev-current-CZdmxVQ4-DxDflvNG.mjs.map} +1 -1
  26. package/dist/{redaction-Bf8FvTFH-XGchRgrK.d.mts → family-DfwviKFj-CS1L-EvS.d.mts} +439 -204
  27. package/dist/family-DfwviKFj-CS1L-EvS.d.mts.map +1 -0
  28. package/dist/family.d.mts +1 -1
  29. package/dist/family.mjs +259 -269
  30. package/dist/family.mjs.map +1 -1
  31. package/dist/internal-error-Dfur7Zqt-B8J8e7ac.mjs +58 -0
  32. package/dist/internal-error-Dfur7Zqt-B8J8e7ac.mjs.map +1 -0
  33. package/dist/{list-deployed-BFJJxt_W.mjs → list-deployed-D6vTzpWu.mjs} +6 -5
  34. package/dist/list-deployed-D6vTzpWu.mjs.map +1 -0
  35. package/dist/local-target-CZzICh5R.mjs +34 -0
  36. package/dist/local-target-CZzICh5R.mjs.map +1 -0
  37. package/dist/{preflight-transport-DmmtoFPH-CZ0o7QPf.mjs → preflight-transport-2d6iIchu-ArIJUY1L.mjs} +7 -28
  38. package/dist/preflight-transport-2d6iIchu-ArIJUY1L.mjs.map +1 -0
  39. package/dist/{redaction-DXung4ip-Co_fv4Zl.mjs → redaction-DY6eDC12-BrK1aSN5.mjs} +33 -267
  40. package/dist/redaction-DY6eDC12-BrK1aSN5.mjs.map +1 -0
  41. package/dist/result-CttmabB6.mjs +91 -0
  42. package/dist/result-CttmabB6.mjs.map +1 -0
  43. package/dist/rolldown-runtime-C7HZzL1F.mjs +26 -0
  44. package/dist/steps-BZXNqW6U-BM2Aa8Bp.mjs +287 -0
  45. package/dist/steps-BZXNqW6U-BM2Aa8Bp.mjs.map +1 -0
  46. package/dist/testing.d.mts +4 -49
  47. package/dist/testing.d.mts.map +1 -1
  48. package/dist/testing.mjs +2 -75
  49. package/dist/testing.mjs.map +1 -1
  50. package/dist/validate-environment-DCZiNSlR-idVge-kq.mjs +983 -0
  51. package/dist/validate-environment-DCZiNSlR-idVge-kq.mjs.map +1 -0
  52. package/dist/value-reads-change-text-DcRCv7Zy-Ca8m3bal.mjs +15 -0
  53. package/dist/value-reads-change-text-DcRCv7Zy-Ca8m3bal.mjs.map +1 -0
  54. package/package.json +9 -9
  55. package/src/exports/dev-converge-worker.ts +2 -0
  56. package/src/exports/testing.ts +1 -4
  57. package/dist/app-configuration-file-CeJvBAti-DA4EKwFq.mjs +0 -140
  58. package/dist/app-configuration-file-CeJvBAti-DA4EKwFq.mjs.map +0 -1
  59. package/dist/dev-current-wD5YDLjA-CFI8XTAK.mjs.map +0 -1
  60. package/dist/dev-environment-name-6eEr5PW8-Bs4Dl0vW.mjs +0 -71
  61. package/dist/dev-environment-name-6eEr5PW8-Bs4Dl0vW.mjs.map +0 -1
  62. package/dist/execute-deploy-destroy-DOzo2Psp-2iWcFbD9.mjs.map +0 -1
  63. package/dist/execute-dev-BIyOI3Ys-DGpTd9rP.mjs.map +0 -1
  64. package/dist/generate-dev-stack-BV_n-X9n-DM5faH3-.mjs +0 -100
  65. package/dist/generate-dev-stack-BV_n-X9n-DM5faH3-.mjs.map +0 -1
  66. package/dist/list-deployed-BFJJxt_W.mjs.map +0 -1
  67. package/dist/preflight-transport-DmmtoFPH-CZ0o7QPf.mjs.map +0 -1
  68. package/dist/redaction-Bf8FvTFH-XGchRgrK.d.mts.map +0 -1
  69. package/dist/redaction-DXung4ip-Co_fv4Zl.mjs.map +0 -1
  70. package/dist/result-sR7PBi61.mjs +0 -229
  71. package/dist/result-sR7PBi61.mjs.map +0 -1
  72. package/dist/run-alchemy-CRLAyOtt-CwFLe4Zg.mjs +0 -236
  73. package/dist/run-alchemy-CRLAyOtt-CwFLe4Zg.mjs.map +0 -1
  74. package/dist/validate-environment-D1BTCkTs-C5m4rL6t.mjs.map +0 -1
package/dist/family.mjs CHANGED
@@ -1,9 +1,11 @@
1
- import { d as checkComposerConfig, h as sectionMissing } from "./redaction-DXung4ip-Co_fv4Zl.mjs";
2
- import { n as platformVariableReaderText } from "./preflight-transport-DmmtoFPH-CZ0o7QPf.mjs";
3
- import { a as devWithDeps, i as devUrl, n as deployWithDeps, o as executionDiagnostics, r as devStop, t as DEFAULT_DEPLOY_ENVIRONMENT } from "./dev-current-wD5YDLjA-CFI8XTAK.mjs";
4
- import { t as alchemyCommandLine } from "./run-alchemy-CRLAyOtt-CwFLe4Zg.mjs";
1
+ import { a as sectionMissing, t as checkComposerConfig } from "./composer-config-QKdY85G--CEXrb2Uc.mjs";
2
+ import { t as SecretRedaction } from "./redaction-DY6eDC12-BrK1aSN5.mjs";
3
+ import { n as platformVariableReaderText } from "./preflight-transport-2d6iIchu-ArIJUY1L.mjs";
4
+ import { a as devUrl, i as devStop, o as devWithDeps, r as deployWithDeps, t as DEFAULT_DEPLOY_ENVIRONMENT } from "./dev-current-lAlj53eX-DvAHNZFo.mjs";
5
+ import { t as valueReadsChangeText } from "./value-reads-change-text-DcRCv7Zy-Ca8m3bal.mjs";
5
6
  import * as path from "node:path";
6
- import { defineCommand, defineCommandFamily, defineConfigSection, defineSessionCommand, exitWithChildStatus, flag, positional } from "@prisma/cli-engine";
7
+ import { format } from "node:util";
8
+ import { defineCommand, defineCommandFamily, defineConfigSection, defineSessionCommand, flag, positional } from "@prisma/cli-engine";
7
9
  import { CliStructuredError, notOk, ok } from "@prisma/cli-engine/protocol";
8
10
  //#region ../../0-framework/3-tooling/cli/dist/unset-platform-variables-B0aMhHaR.mjs
9
11
  const variableLines = (variable) => [variable.readers.length === 0 ? ` - ${variable.name}` : ` - ${variable.name} (${variable.readers.map(platformVariableReaderText).join("; ")})`, ...variable.commands.map((command) => ` ${command}`)];
@@ -31,137 +33,30 @@ function fieldText(field) {
31
33
  function dataLine(fields) {
32
34
  return fields.map(fieldText).join(" ");
33
35
  }
36
+ const METHODS = [
37
+ "log",
38
+ "info",
39
+ "debug",
40
+ "dir",
41
+ "table",
42
+ "warn",
43
+ "error"
44
+ ];
34
45
  /**
35
- * The family boundary's error translation.
36
- *
37
- * Composer and the engine each carry a class called `CliStructuredError`, both
38
- * descended from the same prisma/prisma foundation, and both recognize errors
39
- * by duck-typing on `name === 'CliStructuredError'`. That means a composer
40
- * error handed to the engine untranslated is ACCEPTED — it does not fail
41
- * loudly, it renders. What it loses is its `fix`: composer's foundation
42
- * carries remediation as one prose string on that field, the engine carries it
43
- * as a `nextActions` list and has no `fix` at all, so the fix text is dropped
44
- * silently and the user is told what broke with no word on what to do about
45
- * it. Nothing about that failure is visible without a test that looks for the
46
- * fix on the other side, which is why there is one.
47
- *
48
- * Everything else on the envelope survives as-is; only remediation changes
49
- * representation.
50
- */
51
- /**
52
- * Composer's `fix` is free prose — "add this overrides block and reinstall",
53
- * "run the build, then retry" — with no machine-readable command inside it.
54
- * `user-choice` is the engine's own kind for exactly that (it is what the
55
- * engine uses for its own config and prompt failures), so the text carries
56
- * over verbatim as one action rather than being parsed into a command the
57
- * author never wrote.
58
- */
59
- function fixAsNextActions(fix) {
60
- return fix === void 0 ? [] : [{
61
- kind: "user-choice",
62
- label: fix
63
- }];
64
- }
65
- /** Translates a composer failure into the engine's error type. Composer-side detail — `meta`, `where`, `docsUrl` — rides along untouched. */
66
- function toEngineError(error) {
67
- return new CliStructuredError(error.code, error.message, {
68
- severity: error.severity,
69
- nextActions: fixAsNextActions(error.fix),
70
- ...error.why === void 0 ? {} : { why: error.why },
71
- ...error.where === void 0 ? {} : { where: error.where },
72
- ...error.meta === void 0 ? {} : { meta: error.meta },
73
- ...error.docsUrl === void 0 ? {} : { docsUrl: error.docsUrl },
74
- cause: error
75
- });
76
- }
77
- /**
78
- * Node's `--import` of a module that sends the child's stdout to stderr when
79
- * stdout is not a terminal. In human format the engine hands a piped run's
80
- * stdout to the child, and that pipe carries only the parent's data lines.
81
- */
82
- const STDOUT_TO_STDERR = ["--import", `data:text/javascript,${encodeURIComponent("if (process.stdout.isTTY !== true) process.stdout.write = process.stderr.write.bind(process.stderr);")}`];
83
- /** The adapter the operations call, backed by the engine's `ctx.spawn` so the
84
- * terminal reaches alchemy natively and the engine owns signal policy. It
85
- * ignores `invocation.redactedValues`: the child writes to the terminal, so
86
- * its output is not redacted (ADR-0062). */
87
- function convergeSpawn(ctx) {
88
- return async (invocation) => {
89
- const commandLine = alchemyCommandLine(invocation);
90
- return {
91
- ...await ctx.spawn({
92
- command: commandLine.command,
93
- args: [...STDOUT_TO_STDERR, ...commandLine.args],
94
- cwd: commandLine.cwd,
95
- env: commandLine.env
96
- }),
97
- commandLine
98
- };
99
- };
100
- }
101
- /** The in-process leg's deps: composer's existing seam, carrying the engine's
102
- * own client and workspace id rather than anything read from the env. */
103
- function operationDeps(spec) {
104
- return {
105
- alchemy: spec.alchemy,
106
- credentials: {
107
- workspaceId: spec.workspaceId,
108
- client: spec.client
109
- }
110
- };
111
- }
112
- /**
113
- * The reproduce hint a failed converge carries. Deliberately absent for an
114
- * aborted one: the user stopped it, so there is nothing to reproduce.
115
- */
116
- function reproduceHint(failure) {
117
- const diagnostics = executionDiagnostics(failure);
118
- if (diagnostics === void 0) return [];
119
- return [{
120
- kind: "run-command",
121
- label: `Run the converge directly from ${diagnostics.cwd} to reproduce this`,
122
- command: diagnostics.reproduceCommand,
123
- reason: `Generated stack file: ${diagnostics.stackFilePath}`
124
- }];
125
- }
126
- /**
127
- * How a FAILED converge settles. `deploy` and `dev` both end this
128
- * way and must not drift apart, so the decision lives here once rather than
129
- * inline in each handler.
130
- *
131
- * A failure that reached the child exits with the child's status verbatim and
132
- * carries the reproduce hint; a failure that never reached the child is an
133
- * ordinary structured error and gets the normal envelope. Nothing here reads
134
- * `signal` — see settleConverge.
135
- */
136
- function settleConvergeFailure(failure, ctx) {
137
- const child = ctx.lastChild();
138
- if (child !== void 0 && child.exitCode !== 0) return ok(exitWithChildStatus({ nextActions: reproduceHint(failure) }));
139
- return notOk(toEngineError(failure));
140
- }
141
- /**
142
- * How a converge settles, now that the engine owns the child's status.
143
- *
144
- * Nothing here reads `signal`. `exitWithChildStatus` settles from the engine's
145
- * own record of the child, and a signal-killed one overrules whatever this
146
- * function asked for: 128 + the signal, no failure envelope, and the reproduce
147
- * hint dropped, because the user stopped the run and there is nothing to
148
- * reproduce.
149
- *
150
- * What is left is the operation's own verdict. A failure that reached the
151
- * child exits with the child's status verbatim and carries the reproduce hint;
152
- * a failure that never reached the child is an ordinary structured error and
153
- * gets the normal envelope.
154
- *
155
- * A SUCCESS presents its result even when the child was signal-killed. No
156
- * composer operation produces that pair today — each one reports a
157
- * signal-killed converge as a failure — and an operation that ever did would
158
- * have a real result worth showing. The run still exits 130, because the
159
- * engine settles a signal-terminated run from its own record of the signal
160
- * whatever the handler returns.
46
+ * Runs `run` with every `console` method writing to stderr through `redact`,
47
+ * and restores them after: stdout carries the command's data lines and JSON
48
+ * frames, so a provider's `console.log` during the apply must not land among
49
+ * them.
161
50
  */
162
- function settleConverge(result, ctx, present) {
163
- if (!result.ok) return settleConvergeFailure(result.failure, ctx);
164
- return ok(present(result.value));
51
+ async function withConsoleOnStderr(redact, run) {
52
+ const saved = METHODS.map((method) => [method, console[method]]);
53
+ const error = console.error;
54
+ try {
55
+ for (const method of METHODS) console[method] = (...args) => error.call(console, redact(format(...args)));
56
+ return await run();
57
+ } finally {
58
+ for (const [method, original] of saved) Object.assign(console, { [method]: original });
59
+ }
165
60
  }
166
61
  function diagnostic(finding, file) {
167
62
  const where = finding.where ?? file;
@@ -204,18 +99,47 @@ const composerSection = defineConfigSection({
204
99
  merge: (_parent, child) => child
205
100
  });
206
101
  /**
207
- * The workspace the in-process leg acts in, from the engine's credential
208
- * read. Handlers never decode a token and never read PRISMA_WORKSPACE_ID:
209
- * whether the credential came from a stored session or the environment, the
210
- * engine has already resolved it, and branching on where it came from is a
211
- * defect by the credential-manager design.
102
+ * The family boundary's error translation.
103
+ *
104
+ * Composer and the engine each carry a class called `CliStructuredError`, both
105
+ * descended from the same prisma/prisma foundation, and both recognize errors
106
+ * by duck-typing on `name === 'CliStructuredError'`. That means a composer
107
+ * error handed to the engine untranslated is ACCEPTED — it does not fail
108
+ * loudly, it renders. What it loses is its `fix`: composer's foundation
109
+ * carries remediation as one prose string on that field, the engine carries it
110
+ * as a `nextActions` list and has no `fix` at all, so the fix text is dropped
111
+ * silently and the user is told what broke with no word on what to do about
112
+ * it. Nothing about that failure is visible without a test that looks for the
113
+ * fix on the other side, which is why there is one.
212
114
  *
213
- * Undefined when the active credential names no workspace — an environment
214
- * token whose claims carry none. The container descriptors raise their own
215
- * "workspace required" error in that case, which is the error the user needs.
115
+ * Everything else on the envelope survives as-is; only remediation changes
116
+ * representation.
117
+ */
118
+ /**
119
+ * Composer's `fix` is free prose — "add this overrides block and reinstall",
120
+ * "run the build, then retry" — with no machine-readable command inside it.
121
+ * `user-choice` is the engine's own kind for exactly that (it is what the
122
+ * engine uses for its own config and prompt failures), so the text carries
123
+ * over verbatim as one action rather than being parsed into a command the
124
+ * author never wrote.
216
125
  */
217
- async function workspaceIdOf(ctx) {
218
- return (await ctx.activeCredential())?.workspaceId;
126
+ function fixAsNextActions(fix) {
127
+ return fix === void 0 ? [] : [{
128
+ kind: "user-choice",
129
+ label: fix
130
+ }];
131
+ }
132
+ /** Translates a composer failure into the engine's error type. Composer-side detail — `meta`, `where`, `docsUrl` — rides along untouched. */
133
+ function toEngineError(error) {
134
+ return new CliStructuredError(error.code, error.message, {
135
+ severity: error.severity,
136
+ nextActions: fixAsNextActions(error.fix),
137
+ ...error.why === void 0 ? {} : { why: error.why },
138
+ ...error.where === void 0 ? {} : { where: error.where },
139
+ ...error.meta === void 0 ? {} : { meta: error.meta },
140
+ ...error.docsUrl === void 0 ? {} : { docsUrl: error.docsUrl },
141
+ cause: error
142
+ });
219
143
  }
220
144
  const STEP_LABELS = {
221
145
  prepare: "load config and app",
@@ -226,10 +150,25 @@ const STEP_LABELS = {
226
150
  record: "record result"
227
151
  };
228
152
  function stepLabel(step) {
229
- return step.name === "assemble-service" ? `assemble ${step.address}` : STEP_LABELS[step.name];
153
+ switch (step.name) {
154
+ case "assemble-service": return `assemble ${step.address}`;
155
+ case "apply-resource": return `${step.status} ${step.resourceId}`;
156
+ default: return STEP_LABELS[step.name];
157
+ }
230
158
  }
231
159
  function stepId(step) {
232
- return step.name === "assemble-service" ? `deploy.assemble.${step.address}` : `deploy.${step.name}`;
160
+ switch (step.name) {
161
+ case "assemble-service": return `deploy.assemble.${step.address}`;
162
+ case "apply-resource": return `deploy.apply.${step.resourceId}`;
163
+ default: return `deploy.${step.name}`;
164
+ }
165
+ }
166
+ function parentId(step) {
167
+ switch (step.name) {
168
+ case "assemble-service": return "deploy.assemble";
169
+ case "apply-resource": return "deploy.apply";
170
+ default: return;
171
+ }
233
172
  }
234
173
  /** `850ms`, `12.3s`, `9m 35s`. */
235
174
  function formatDuration(ms) {
@@ -238,8 +177,13 @@ function formatDuration(ms) {
238
177
  const seconds = Math.round(ms / 1e3);
239
178
  return `${String(Math.floor(seconds / 60))}m ${String(seconds % 60)}s`;
240
179
  }
241
- /** The operation's events as engine events. */
180
+ /** The operation's events as engine events. The engine prints only `step`, so a finished step carries its duration in the text too. */
242
181
  function toEngineEvent(event) {
182
+ if (event.kind === "message") return {
183
+ kind: "message",
184
+ severity: event.severity,
185
+ text: event.text
186
+ };
243
187
  if (event.kind === "preflight-findings") {
244
188
  const text = unsetPlatformVariablesText(event.findings.unset);
245
189
  return text === void 0 ? void 0 : {
@@ -250,12 +194,16 @@ function toEngineEvent(event) {
250
194
  };
251
195
  }
252
196
  const id = stepId(event.step);
253
- if (event.kind === "step-started") return {
254
- kind: "step-started",
255
- step: stepLabel(event.step),
256
- id,
257
- ...event.step.name === "assemble-service" ? { parentId: "deploy.assemble" } : {}
258
- };
197
+ if (event.kind === "step-started") {
198
+ const parent = parentId(event.step);
199
+ return {
200
+ kind: "step-started",
201
+ step: stepLabel(event.step),
202
+ id,
203
+ ...parent === void 0 ? {} : { parentId: parent },
204
+ ...event.step.name === "apply-resource" ? { data: { resourceType: event.step.resourceType } } : {}
205
+ };
206
+ }
259
207
  return {
260
208
  kind: "step-finished",
261
209
  step: `${stepLabel(event.step)} (${formatDuration(event.durationMs)})`,
@@ -301,12 +249,12 @@ const createDeployCommand = (operations) => defineCommand({
301
249
  } },
302
250
  needs: {
303
251
  config: composerSection,
304
- credentials: "child"
252
+ credentials: true
305
253
  },
306
- maySpawn: true,
307
254
  handler: async (args, ctx) => {
308
- const alchemy = convergeSpawn(ctx);
309
- return settleConverge(await operations.deploy({
255
+ const credential = await ctx.activeCredential();
256
+ const redaction = new SecretRedaction(process.env);
257
+ const result = await withConsoleOnStderr((text) => redaction.redact(text), () => operations.deploy({
310
258
  entry: args.flags.entry,
311
259
  config: ctx.config,
312
260
  name: args.flags.name,
@@ -317,48 +265,73 @@ const createDeployCommand = (operations) => defineCommand({
317
265
  onEvent: (event) => {
318
266
  const engineEvent = toEngineEvent(event);
319
267
  if (engineEvent !== void 0) ctx.report(engineEvent);
268
+ },
269
+ signal: ctx.signal
270
+ }, {
271
+ credentials: {
272
+ workspaceId: credential?.workspaceId,
273
+ client: ctx.api
274
+ },
275
+ redaction
276
+ }));
277
+ if (!result.ok) {
278
+ if (result.failure.code === "DEPLOY.INTERRUPTED" && ctx.signal.aborted) {
279
+ const { code, message, why, fix } = result.failure;
280
+ ctx.report({
281
+ kind: "message",
282
+ severity: "warn",
283
+ text: `${message} ${fix ?? ""}`.trim(),
284
+ data: {
285
+ code,
286
+ message,
287
+ why,
288
+ fix
289
+ }
290
+ });
291
+ throw ctx.signal.reason;
320
292
  }
321
- }, operationDeps({
322
- alchemy,
323
- workspaceId: await workspaceIdOf(ctx),
324
- client: ctx.api
325
- })), ctx, ({ summary, durationMs }) => {
326
- const target = `to ${args.flags.environment ?? "production"} in ${formatDuration(durationMs)}`;
327
- for (const node of summary?.nodes ?? []) for (const entity of node.entities) if (entity.url !== void 0) ctx.report({
328
- kind: "endpoint",
329
- name: node.address,
330
- url: entity.url
331
- });
332
- return ctx.present({ data: {
293
+ return notOk(toEngineError(result.failure));
294
+ }
295
+ const { summary, durationMs } = result.value;
296
+ const unsetText = summary === void 0 ? void 0 : unsetPlatformVariablesText(summary.findings.unset);
297
+ const target = `to ${args.flags.environment ?? "production"} in ${formatDuration(durationMs)}`;
298
+ for (const node of summary?.nodes ?? []) for (const entity of node.entities) if (entity.url !== void 0) ctx.report({
299
+ kind: "endpoint",
300
+ name: node.address,
301
+ url: entity.url
302
+ });
303
+ return ok(ctx.present({ data: {
304
+ summary: summary ?? null,
305
+ durationMs
306
+ } }, {
307
+ human: (ui) => [...summary === void 0 ? [{
308
+ kind: "summary",
309
+ status: "ok",
310
+ text: `Deployed ${target}.`
311
+ }] : [{
312
+ kind: "summary",
313
+ status: "ok",
314
+ text: `Deployed ${ui.emphasize(summary.app)} ${target}.`
315
+ }, {
316
+ kind: "table",
317
+ columns: ["Address", "Deployed"],
318
+ rows: summary.nodes.map((node) => [node.address, node.entities.map((entity) => `${entity.kind} ${entity.id}`).join(", ")])
319
+ }], ...unsetText === void 0 ? [] : [{
320
+ kind: "drawing",
321
+ lines: unsetText.split("\n")
322
+ }]],
323
+ stdout: () => (summary?.nodes ?? []).flatMap((node) => node.entities.map((entity) => dataLine([
324
+ node.address,
325
+ entity.kind,
326
+ entity.id,
327
+ entity.url
328
+ ]))),
329
+ json: () => ({
333
330
  summary: summary ?? null,
334
331
  durationMs
335
- } }, {
336
- human: (ui) => summary === void 0 ? [{
337
- kind: "summary",
338
- status: "ok",
339
- text: `Deployed ${target}.`
340
- }] : [{
341
- kind: "summary",
342
- status: "ok",
343
- text: `Deployed ${ui.emphasize(summary.app)} ${target}.`
344
- }, {
345
- kind: "table",
346
- columns: ["Address", "Deployed"],
347
- rows: summary.nodes.map((node) => [node.address, node.entities.map((entity) => `${entity.kind} ${entity.id}`).join(", ")])
348
- }],
349
- stdout: () => (summary?.nodes ?? []).flatMap((node) => node.entities.map((entity) => dataLine([
350
- node.address,
351
- entity.kind,
352
- entity.id,
353
- entity.url
354
- ]))),
355
- json: () => ({
356
- summary: summary ?? null,
357
- durationMs
358
- }),
359
- next: () => []
360
- });
361
- });
332
+ }),
333
+ next: () => []
334
+ }));
362
335
  }
363
336
  });
364
337
  /**
@@ -366,10 +339,11 @@ const createDeployCommand = (operations) => defineCommand({
366
339
  * user interrupts it.
367
340
  *
368
341
  * The watch loop, the emulators and the live attachments stay the operation's
369
- * state. What the handler owns is the boundary: the converge child goes out
370
- * through `ctx.spawn`, so the terminal reaches alchemy natively and the engine
371
- * owns signal policy; the operation's events become engine events; and the
372
- * session settles on how it actually ended.
342
+ * state. What the handler owns is the boundary: the operation's events become
343
+ * engine events, Ctrl-C reaches a running converge through `ctx.signal`, and
344
+ * the session settles on how it actually ended. Every converge runs in this
345
+ * process, so `console`'s stdout methods write to stderr for the whole
346
+ * session, as they do for `deploy`.
373
347
  *
374
348
  * Windows is refused inside the operation itself (DEV.PLATFORM_UNSUPPORTED),
375
349
  * which is why nothing here reads the platform.
@@ -377,6 +351,9 @@ const createDeployCommand = (operations) => defineCommand({
377
351
  * `dev` is credential-free: everything it starts runs on this machine.
378
352
  */
379
353
  const STOP_STEP = "Stopping the app's services — emulators and data stay up";
354
+ function valueReadsChangedText(change) {
355
+ return `The platform variables the app reads changed since dev started: ${valueReadsChangeText(change)}. Restart dev to apply them; rebuilds are paused until then.`;
356
+ }
380
357
  /** Resolves when the run is asked to stop. */
381
358
  function stopRequested(signal) {
382
359
  if (signal.aborted) return Promise.resolve();
@@ -384,36 +361,12 @@ function stopRequested(signal) {
384
361
  signal.addEventListener("abort", () => resolve(), { once: true });
385
362
  });
386
363
  }
387
- /**
388
- * One converge at a time. `ctx.spawn` refuses a second live child, and the
389
- * watch loop can well fire a rebuild while the previous converge is still
390
- * running — so a request that arrives during a live converge joins the single
391
- * queued follow-up instead of starting its own. That extends the coalescing
392
- * the watcher already does across a burst of edits to cover the converge
393
- * itself, and it is sound because every dev converge is the SAME invocation:
394
- * one stack file at one fixed path, rewritten in place before each request.
395
- */
396
- function coalescedConverge(run) {
397
- let live;
398
- let queued;
399
- const start = (invocation) => {
400
- const outcome = run(invocation);
401
- const settled = outcome.then(() => void 0, () => void 0);
402
- live = settled;
403
- settled.then(() => {
404
- if (live === settled) live = void 0;
405
- });
406
- return outcome;
407
- };
408
- return (invocation) => {
409
- const running = live;
410
- if (running === void 0) return start(invocation);
411
- queued ??= running.then(() => {
412
- queued = void 0;
413
- return start(invocation);
414
- });
415
- return queued;
416
- };
364
+ function devStepId(step) {
365
+ return step.name === "converge" ? step.id : `${step.converge}.${step.resourceId}`;
366
+ }
367
+ function devStepLabel(step) {
368
+ if (step.name === "apply-resource") return `${step.status} ${step.resourceId}`;
369
+ return step.id === "dev.converge" ? "converge" : step.id.replace(/^dev\.rebuild\./, "rebuild ");
417
370
  }
418
371
  /** The front door, ordered by address depth (fewest dots first) then lexicographically. */
419
372
  function frontDoorOrder(endpoints) {
@@ -427,7 +380,7 @@ function frontDoorOrder(endpoints) {
427
380
  * The operation's events as engine events. The legacy `[dev]` console prefix
428
381
  * is gone: these are commentary the engine renders and frames.
429
382
  */
430
- function reportDevEvent(report, lastChild, cwd) {
383
+ function reportDevEvent(report, cwd) {
431
384
  let stopFailed = false;
432
385
  return (event) => {
433
386
  switch (event.kind) {
@@ -500,6 +453,13 @@ function reportDevEvent(report, lastChild, cwd) {
500
453
  text: "The values the config or secrets adapters return changed since dev started. Restart dev to apply them; rebuilds are paused until then."
501
454
  });
502
455
  return;
456
+ case "value-reads-changed":
457
+ report({
458
+ kind: "message",
459
+ severity: "warn",
460
+ text: valueReadsChangedText(event)
461
+ });
462
+ return;
503
463
  case "watch-error":
504
464
  report({
505
465
  kind: "message",
@@ -507,26 +467,44 @@ function reportDevEvent(report, lastChild, cwd) {
507
467
  text: `Watch error: ${event.message}`
508
468
  });
509
469
  return;
510
- case "converge-failed": {
511
- const child = lastChild();
512
- if (child !== void 0 && child.signal !== null) return;
470
+ case "step-started":
471
+ report({
472
+ kind: "step-started",
473
+ step: devStepLabel(event.step),
474
+ id: devStepId(event.step),
475
+ ...event.step.name === "apply-resource" ? {
476
+ parentId: event.step.converge,
477
+ data: { resourceType: event.step.resourceType }
478
+ } : {}
479
+ });
480
+ return;
481
+ case "step-finished":
482
+ report({
483
+ kind: "step-finished",
484
+ step: devStepLabel(event.step),
485
+ id: devStepId(event.step),
486
+ outcome: event.outcome,
487
+ data: { durationMs: event.durationMs }
488
+ });
489
+ return;
490
+ case "message":
513
491
  report({
514
492
  kind: "message",
515
- severity: "warn",
516
- text: `Converge failed — the running app is untouched; still watching.
517
- Generated stack file: ${event.stackFilePath}\nRun \`${event.reproduceCommand}\` from ${event.cwd} to reproduce this directly.`
493
+ severity: event.severity,
494
+ text: event.text
518
495
  });
496
+ return;
497
+ case "converge-failed":
519
498
  report({
520
- kind: "remediation",
521
- action: {
522
- kind: "run-command",
523
- label: `Run the converge directly from ${event.cwd} to reproduce this`,
524
- command: event.reproduceCommand,
525
- reason: `Generated stack file: ${event.stackFilePath}`
499
+ kind: "message",
500
+ severity: "warn",
501
+ text: `Converge failed; the running app is untouched and dev is still watching.\n${event.message}`,
502
+ data: {
503
+ code: event.code,
504
+ reasons: event.reasons
526
505
  }
527
506
  });
528
507
  return;
529
- }
530
508
  case "stopping":
531
509
  report({
532
510
  kind: "step-started",
@@ -570,7 +548,7 @@ async function stopDetachedApp(operations, app, ctx) {
570
548
  const createDevCommand = (operations) => defineSessionCommand({
571
549
  help: {
572
550
  summary: "Bring up the application whose root node is the entry module's default export, entirely on this machine.",
573
- description: "Runs credential-free and watches the app for changes, reconverging on every edit. A service whose build adapter declares a dev server (Next.js's `next dev`, or the `dev` command written on node()) runs that instead of its build, and its output is shown here, prefixed with its address. A node is one service, database or bucket in the app. Each node runs on a local emulator: a program on this machine that stands in for Prisma Cloud and runs services, databases or S3-compatible buckets. A node's address is its path from the app name, with dots between names (shop.catalog.database). Each environment is a complete local copy of the app, with its own services, databases, buckets and ports; the default is dev, and copies of other environments run alongside it. Where each node runs is recorded in this directory: `prisma dev url` works from here while `prisma dev` runs, and `prisma dev stop` also works after `prisma dev` was killed. Ending `prisma dev` stops its services and database servers; data and ports are kept. With --detach it returns once every service answers and leaves the app running without watching for changes, until `prisma dev stop`.",
551
+ description: "Runs credential-free and watches the app for changes, reconverging when a service's build output or an app definition file (the entry module, or any app file it loaded) changes. An edit that adds or removes a node, changes which platform variables the app reads, or makes the app's root pass on an input field it did not pass on at start, needs a restart of dev, which says so. A service whose build adapter declares a dev server (Next.js's `next dev`, or the `dev` command written on node()) runs that instead of its build, and its output is shown here, prefixed with its address. A node is one service, database or bucket in the app. Each node runs on a local emulator: a program on this machine that stands in for Prisma Cloud and runs services, databases or S3-compatible buckets. A node's address is its path from the app name, with dots between names (shop.catalog.database). Each environment is a complete local copy of the app, with its own services, databases, buckets and ports; the default is dev, and copies of other environments run alongside it. Where each node runs is recorded in this directory: `prisma dev url` works from here while `prisma dev` runs, and `prisma dev stop` also works after `prisma dev` was killed. Ending `prisma dev` stops its services and database servers; data and ports are kept. With --detach it returns once every service answers and leaves the app running without watching for changes, until `prisma dev stop`.",
574
552
  examples: [
575
553
  "{bin} dev",
576
554
  "{bin} dev --fresh",
@@ -597,31 +575,43 @@ const createDevCommand = (operations) => defineSessionCommand({
597
575
  detach: flag.boolean({ brief: "Return once every service answers and leave the app running without watching for changes. Use it in scripts, agents and CI. `prisma dev stop` stops the app." })
598
576
  } },
599
577
  needs: { config: composerSection },
600
- maySpawn: true,
601
- handler: async (args, ctx) => {
602
- const alchemy = convergeSpawn(ctx);
603
- const result = await operations.dev({
604
- entry: args.flags.entry,
605
- config: ctx.config,
606
- name: args.flags.name,
607
- environment: args.flags.environment,
608
- fresh: args.flags.fresh,
609
- detach: args.flags.detach,
610
- cwd: ctx.cwd,
611
- onEvent: reportDevEvent(ctx.report, ctx.lastChild, ctx.cwd)
612
- }, { alchemy: coalescedConverge(alchemy) });
613
- if (!result.ok) return settleConvergeFailure(result.failure, ctx);
614
- if (args.flags.detach) {
615
- if (ctx.signal.aborted) await stopDetachedApp(operations, {
578
+ handler: (args, ctx) => {
579
+ const redaction = new SecretRedaction(process.env);
580
+ return withConsoleOnStderr((text) => redaction.redact(text), async () => {
581
+ const result = await operations.dev({
616
582
  entry: args.flags.entry,
583
+ config: ctx.config,
617
584
  name: args.flags.name,
618
- environment: args.flags.environment
619
- }, ctx);
585
+ environment: args.flags.environment,
586
+ fresh: args.flags.fresh,
587
+ detach: args.flags.detach,
588
+ cwd: ctx.cwd,
589
+ onEvent: reportDevEvent(ctx.report, ctx.cwd),
590
+ signal: ctx.signal
591
+ }, { redaction });
592
+ if (!result.ok) {
593
+ if (result.failure.code === "DEV.INTERRUPTED" && ctx.signal.aborted) {
594
+ ctx.report({
595
+ kind: "message",
596
+ severity: "warn",
597
+ text: `${result.failure.message} ${result.failure.fix ?? ""}`.trim()
598
+ });
599
+ return ok(void 0);
600
+ }
601
+ return notOk(toEngineError(result.failure));
602
+ }
603
+ if (args.flags.detach) {
604
+ if (ctx.signal.aborted) await stopDetachedApp(operations, {
605
+ entry: args.flags.entry,
606
+ name: args.flags.name,
607
+ environment: args.flags.environment
608
+ }, ctx);
609
+ return ok(void 0);
610
+ }
611
+ await stopRequested(ctx.signal);
612
+ await result.value.stop();
620
613
  return ok(void 0);
621
- }
622
- await stopRequested(ctx.signal);
623
- await result.value.stop();
624
- return ok(void 0);
614
+ });
625
615
  }
626
616
  });
627
617
  /**
@@ -864,7 +854,7 @@ function createComposerFamily$1(options = {}) {
864
854
  * assembled into the family here, where both domains may be imported.
865
855
  */
866
856
  /** Loaded on first use, so nothing of the Management API reads loads with the family. */
867
- const listDeployed = async (input) => (await import("./list-deployed-BFJJxt_W.mjs")).listDeployed(input);
857
+ const listDeployed = async (input) => (await import("./list-deployed-D6vTzpWu.mjs")).listDeployed(input);
868
858
  const createDeployListCommand = (list) => defineCommand({
869
859
  help: {
870
860
  summary: "List every node the app has deployed in an environment, with its platform ID and URL.",
@@ -943,7 +933,7 @@ const createDeployListCommand = (list) => defineCommand({
943
933
  * family here, where both domains may be imported.
944
934
  */
945
935
  /** Loaded on first use, so nothing of the emulators' clients loads with the family. */
946
- const listEmulators = async () => (await import("./dist-D0rWRHos.mjs")).listEmulators();
936
+ const listEmulators = async () => (await import("./dist-C0OGaDnj.mjs")).listEmulators();
947
937
  const EMULATOR_NAMES = {
948
938
  service: "Service emulator",
949
939
  database: "Database emulator",