@prisma/composer-cli 0.38.0 → 0.39.0-dev.10

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-C_YkTIBF-RmqGOR45.mjs +88 -0
  2. package/dist/app-converge-C_YkTIBF-RmqGOR45.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-CpQLC3CA-Ct-PXoKN.mjs → deploy-Br1yvLe3.mjs} +341 -1082
  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-D-Qb6Yem-CvaY4xsk.mjs → dev-current-DANgmcle-RwunETUJ.mjs} +12 -18
  13. package/dist/dev-current-DANgmcle-RwunETUJ.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-BH6HQ6zZ.mjs → dist-C0OGaDnj.mjs} +4 -3
  17. package/dist/{dist-BH6HQ6zZ.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-C6EsdmLz-DqdToZ_i.mjs → execute-deploy-destroy-DIR9uvA_-Bk0HBMTz.mjs} +385 -141
  21. package/dist/execute-deploy-destroy-DIR9uvA_-Bk0HBMTz.mjs.map +1 -0
  22. package/dist/{execute-dev-gjIKYybU-hRndPEgC.mjs → execute-dev-Cu9_LsQi-CsyIqphZ.mjs} +450 -127
  23. package/dist/execute-dev-Cu9_LsQi-CsyIqphZ.mjs.map +1 -0
  24. package/dist/{execute-dev-current-tBKmDAjV-DOOMGrl5.mjs → execute-dev-current-Bs0lE_5--BU3A2hsC.mjs} +9 -6
  25. package/dist/{execute-dev-current-tBKmDAjV-DOOMGrl5.mjs.map → execute-dev-current-Bs0lE_5--BU3A2hsC.mjs.map} +1 -1
  26. package/dist/{redaction-Bf8FvTFH-D0dXGsO8.d.mts → family-DfwviKFj-CS1L-EvS.d.mts} +484 -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 +350 -270
  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-IL0MgmTX.mjs → list-deployed-slo4P7dl.mjs} +6 -5
  34. package/dist/list-deployed-slo4P7dl.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/{config-DiZaanS3.mjs → preflight-transport-2d6iIchu-ArIJUY1L.mjs} +11 -19
  38. package/dist/preflight-transport-2d6iIchu-ArIJUY1L.mjs.map +1 -0
  39. package/dist/{redaction-HnbkSFrK-CCKJNRwi.mjs → redaction-DY6eDC12-BrK1aSN5.mjs} +55 -262
  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 +11 -11
  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-Dk65W3Az.mjs +0 -140
  58. package/dist/app-configuration-file-CeJvBAti-Dk65W3Az.mjs.map +0 -1
  59. package/dist/config-DiZaanS3.mjs.map +0 -1
  60. package/dist/dev-current-D-Qb6Yem-CvaY4xsk.mjs.map +0 -1
  61. package/dist/dev-environment-name-6eEr5PW8-DpdGjmTb.mjs +0 -71
  62. package/dist/dev-environment-name-6eEr5PW8-DpdGjmTb.mjs.map +0 -1
  63. package/dist/execute-deploy-destroy-C6EsdmLz-DqdToZ_i.mjs.map +0 -1
  64. package/dist/execute-dev-gjIKYybU-hRndPEgC.mjs.map +0 -1
  65. package/dist/generate-dev-stack-BV_n-X9n-BDBjgphH.mjs +0 -100
  66. package/dist/generate-dev-stack-BV_n-X9n-BDBjgphH.mjs.map +0 -1
  67. package/dist/list-deployed-IL0MgmTX.mjs.map +0 -1
  68. package/dist/redaction-Bf8FvTFH-D0dXGsO8.d.mts.map +0 -1
  69. package/dist/redaction-HnbkSFrK-CCKJNRwi.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-OS_ix5g0-DSlHsv2p.mjs +0 -236
  73. package/dist/run-alchemy-OS_ix5g0-DSlHsv2p.mjs.map +0 -1
  74. package/dist/validate-environment-CpQLC3CA-Ct-PXoKN.mjs.map +0 -1
package/dist/family.mjs CHANGED
@@ -1,9 +1,19 @@
1
- import { m as sectionMissing, u as checkComposerConfig } from "./redaction-HnbkSFrK-CCKJNRwi.mjs";
2
- import { a as devWithDeps, i as devUrl, n as deployWithDeps, o as executionDiagnostics, r as devStop, t as DEFAULT_DEPLOY_ENVIRONMENT } from "./dev-current-D-Qb6Yem-CvaY4xsk.mjs";
3
- import { t as alchemyCommandLine } from "./run-alchemy-OS_ix5g0-DSlHsv2p.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-DANgmcle-RwunETUJ.mjs";
5
+ import { t as valueReadsChangeText } from "./value-reads-change-text-DcRCv7Zy-Ca8m3bal.mjs";
4
6
  import * as path from "node:path";
5
- 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";
6
9
  import { CliStructuredError, notOk, ok } from "@prisma/cli-engine/protocol";
10
+ //#region ../../0-framework/3-tooling/cli/dist/unset-platform-variables-B0aMhHaR.mjs
11
+ const variableLines = (variable) => [variable.readers.length === 0 ? ` - ${variable.name}` : ` - ${variable.name} (${variable.readers.map(platformVariableReaderText).join("; ")})`, ...variable.commands.map((command) => ` ${command}`)];
12
+ function unsetPlatformVariablesText(unset) {
13
+ if (unset.length === 0) return void 0;
14
+ return ["Platform variables with no value:", ...unset.flatMap(variableLines)].join("\n");
15
+ }
16
+ //#endregion
7
17
  //#region ../../0-framework/3-tooling/cli/dist/family.mjs
8
18
  const ESCAPES = {
9
19
  "\\": "\\\\",
@@ -23,137 +33,30 @@ function fieldText(field) {
23
33
  function dataLine(fields) {
24
34
  return fields.map(fieldText).join(" ");
25
35
  }
36
+ const METHODS = [
37
+ "log",
38
+ "info",
39
+ "debug",
40
+ "dir",
41
+ "table",
42
+ "warn",
43
+ "error"
44
+ ];
26
45
  /**
27
- * The family boundary's error translation.
28
- *
29
- * Composer and the engine each carry a class called `CliStructuredError`, both
30
- * descended from the same prisma/prisma foundation, and both recognize errors
31
- * by duck-typing on `name === 'CliStructuredError'`. That means a composer
32
- * error handed to the engine untranslated is ACCEPTED — it does not fail
33
- * loudly, it renders. What it loses is its `fix`: composer's foundation
34
- * carries remediation as one prose string on that field, the engine carries it
35
- * as a `nextActions` list and has no `fix` at all, so the fix text is dropped
36
- * silently and the user is told what broke with no word on what to do about
37
- * it. Nothing about that failure is visible without a test that looks for the
38
- * fix on the other side, which is why there is one.
39
- *
40
- * Everything else on the envelope survives as-is; only remediation changes
41
- * representation.
42
- */
43
- /**
44
- * Composer's `fix` is free prose — "add this overrides block and reinstall",
45
- * "run the build, then retry" — with no machine-readable command inside it.
46
- * `user-choice` is the engine's own kind for exactly that (it is what the
47
- * engine uses for its own config and prompt failures), so the text carries
48
- * over verbatim as one action rather than being parsed into a command the
49
- * author never wrote.
50
- */
51
- function fixAsNextActions(fix) {
52
- return fix === void 0 ? [] : [{
53
- kind: "user-choice",
54
- label: fix
55
- }];
56
- }
57
- /** Translates a composer failure into the engine's error type. Composer-side detail — `meta`, `where`, `docsUrl` — rides along untouched. */
58
- function toEngineError(error) {
59
- return new CliStructuredError(error.code, error.message, {
60
- severity: error.severity,
61
- nextActions: fixAsNextActions(error.fix),
62
- ...error.why === void 0 ? {} : { why: error.why },
63
- ...error.where === void 0 ? {} : { where: error.where },
64
- ...error.meta === void 0 ? {} : { meta: error.meta },
65
- ...error.docsUrl === void 0 ? {} : { docsUrl: error.docsUrl },
66
- cause: error
67
- });
68
- }
69
- /**
70
- * Node's `--import` of a module that sends the child's stdout to stderr when
71
- * stdout is not a terminal. In human format the engine hands a piped run's
72
- * stdout to the child, and that pipe carries only the parent's data lines.
73
- */
74
- const STDOUT_TO_STDERR = ["--import", `data:text/javascript,${encodeURIComponent("if (process.stdout.isTTY !== true) process.stdout.write = process.stderr.write.bind(process.stderr);")}`];
75
- /** The adapter the operations call, backed by the engine's `ctx.spawn` so the
76
- * terminal reaches alchemy natively and the engine owns signal policy. It
77
- * ignores `invocation.redactedValues`: the child writes to the terminal, so
78
- * its output is not redacted (ADR-0062). */
79
- function convergeSpawn(ctx) {
80
- return async (invocation) => {
81
- const commandLine = alchemyCommandLine(invocation);
82
- return {
83
- ...await ctx.spawn({
84
- command: commandLine.command,
85
- args: [...STDOUT_TO_STDERR, ...commandLine.args],
86
- cwd: commandLine.cwd,
87
- env: commandLine.env
88
- }),
89
- commandLine
90
- };
91
- };
92
- }
93
- /** The in-process leg's deps: composer's existing seam, carrying the engine's
94
- * own client and workspace id rather than anything read from the env. */
95
- function operationDeps(spec) {
96
- return {
97
- alchemy: spec.alchemy,
98
- credentials: {
99
- workspaceId: spec.workspaceId,
100
- client: spec.client
101
- }
102
- };
103
- }
104
- /**
105
- * The reproduce hint a failed converge carries. Deliberately absent for an
106
- * aborted one: the user stopped it, so there is nothing to reproduce.
107
- */
108
- function reproduceHint(failure) {
109
- const diagnostics = executionDiagnostics(failure);
110
- if (diagnostics === void 0) return [];
111
- return [{
112
- kind: "run-command",
113
- label: `Run the converge directly from ${diagnostics.cwd} to reproduce this`,
114
- command: diagnostics.reproduceCommand,
115
- reason: `Generated stack file: ${diagnostics.stackFilePath}`
116
- }];
117
- }
118
- /**
119
- * How a FAILED converge settles. `deploy` and `dev` both end this
120
- * way and must not drift apart, so the decision lives here once rather than
121
- * inline in each handler.
122
- *
123
- * A failure that reached the child exits with the child's status verbatim and
124
- * carries the reproduce hint; a failure that never reached the child is an
125
- * ordinary structured error and gets the normal envelope. Nothing here reads
126
- * `signal` — see settleConverge.
127
- */
128
- function settleConvergeFailure(failure, ctx) {
129
- const child = ctx.lastChild();
130
- if (child !== void 0 && child.exitCode !== 0) return ok(exitWithChildStatus({ nextActions: reproduceHint(failure) }));
131
- return notOk(toEngineError(failure));
132
- }
133
- /**
134
- * How a converge settles, now that the engine owns the child's status.
135
- *
136
- * Nothing here reads `signal`. `exitWithChildStatus` settles from the engine's
137
- * own record of the child, and a signal-killed one overrules whatever this
138
- * function asked for: 128 + the signal, no failure envelope, and the reproduce
139
- * hint dropped, because the user stopped the run and there is nothing to
140
- * reproduce.
141
- *
142
- * What is left is the operation's own verdict. A failure that reached the
143
- * child exits with the child's status verbatim and carries the reproduce hint;
144
- * a failure that never reached the child is an ordinary structured error and
145
- * gets the normal envelope.
146
- *
147
- * A SUCCESS presents its result even when the child was signal-killed. No
148
- * composer operation produces that pair today — each one reports a
149
- * signal-killed converge as a failure — and an operation that ever did would
150
- * have a real result worth showing. The run still exits 130, because the
151
- * engine settles a signal-terminated run from its own record of the signal
152
- * 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.
153
50
  */
154
- function settleConverge(result, ctx, present) {
155
- if (!result.ok) return settleConvergeFailure(result.failure, ctx);
156
- 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
+ }
157
60
  }
158
61
  function diagnostic(finding, file) {
159
62
  const where = finding.where ?? file;
@@ -196,18 +99,47 @@ const composerSection = defineConfigSection({
196
99
  merge: (_parent, child) => child
197
100
  });
198
101
  /**
199
- * The workspace the in-process leg acts in, from the engine's credential
200
- * read. Handlers never decode a token and never read PRISMA_WORKSPACE_ID:
201
- * whether the credential came from a stored session or the environment, the
202
- * engine has already resolved it, and branching on where it came from is a
203
- * 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.
204
114
  *
205
- * Undefined when the active credential names no workspace — an environment
206
- * token whose claims carry none. The container descriptors raise their own
207
- * "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.
208
125
  */
209
- async function workspaceIdOf(ctx) {
210
- 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
+ });
211
143
  }
212
144
  const STEP_LABELS = {
213
145
  prepare: "load config and app",
@@ -218,10 +150,25 @@ const STEP_LABELS = {
218
150
  record: "record result"
219
151
  };
220
152
  function stepLabel(step) {
221
- 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
+ }
222
158
  }
223
159
  function stepId(step) {
224
- 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
+ }
225
172
  }
226
173
  /** `850ms`, `12.3s`, `9m 35s`. */
227
174
  function formatDuration(ms) {
@@ -230,15 +177,33 @@ function formatDuration(ms) {
230
177
  const seconds = Math.round(ms / 1e3);
231
178
  return `${String(Math.floor(seconds / 60))}m ${String(seconds % 60)}s`;
232
179
  }
233
- /** The operation's step events as engine events. The engine prints only `step`, so a finished step carries its duration in the text too. */
180
+ /** The operation's events as engine events. The engine prints only `step`, so a finished step carries its duration in the text too. */
234
181
  function toEngineEvent(event) {
235
- const id = stepId(event.step);
236
- if (event.kind === "step-started") return {
237
- kind: "step-started",
238
- step: stepLabel(event.step),
239
- id,
240
- ...event.step.name === "assemble-service" ? { parentId: "deploy.assemble" } : {}
182
+ if (event.kind === "message") return {
183
+ kind: "message",
184
+ severity: event.severity,
185
+ text: event.text
241
186
  };
187
+ if (event.kind === "preflight-findings") {
188
+ const text = unsetPlatformVariablesText(event.findings.unset);
189
+ return text === void 0 ? void 0 : {
190
+ kind: "message",
191
+ severity: "warn",
192
+ text,
193
+ data: event.findings
194
+ };
195
+ }
196
+ const id = stepId(event.step);
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
+ }
242
207
  return {
243
208
  kind: "step-finished",
244
209
  step: `${stepLabel(event.step)} (${formatDuration(event.durationMs)})`,
@@ -284,12 +249,12 @@ const createDeployCommand = (operations) => defineCommand({
284
249
  } },
285
250
  needs: {
286
251
  config: composerSection,
287
- credentials: "child"
252
+ credentials: true
288
253
  },
289
- maySpawn: true,
290
254
  handler: async (args, ctx) => {
291
- const alchemy = convergeSpawn(ctx);
292
- 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({
293
258
  entry: args.flags.entry,
294
259
  config: ctx.config,
295
260
  name: args.flags.name,
@@ -297,48 +262,76 @@ const createDeployCommand = (operations) => defineCommand({
297
262
  cwd: ctx.cwd,
298
263
  reportPath: args.flags.report,
299
264
  reportId: args.flags.buildId,
300
- onEvent: (event) => ctx.report(toEngineEvent(event))
301
- }, operationDeps({
302
- alchemy,
303
- workspaceId: await workspaceIdOf(ctx),
304
- client: ctx.api
305
- })), ctx, ({ summary, durationMs }) => {
306
- const target = `to ${args.flags.environment ?? "production"} in ${formatDuration(durationMs)}`;
307
- for (const node of summary?.nodes ?? []) for (const entity of node.entities) if (entity.url !== void 0) ctx.report({
308
- kind: "endpoint",
309
- name: node.address,
310
- url: entity.url
311
- });
312
- return ctx.present({ data: {
265
+ onEvent: (event) => {
266
+ const engineEvent = toEngineEvent(event);
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;
292
+ }
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: () => ({
313
330
  summary: summary ?? null,
314
331
  durationMs
315
- } }, {
316
- human: (ui) => summary === void 0 ? [{
317
- kind: "summary",
318
- status: "ok",
319
- text: `Deployed ${target}.`
320
- }] : [{
321
- kind: "summary",
322
- status: "ok",
323
- text: `Deployed ${ui.emphasize(summary.app)} ${target}.`
324
- }, {
325
- kind: "table",
326
- columns: ["Address", "Deployed"],
327
- rows: summary.nodes.map((node) => [node.address, node.entities.map((entity) => `${entity.kind} ${entity.id}`).join(", ")])
328
- }],
329
- stdout: () => (summary?.nodes ?? []).flatMap((node) => node.entities.map((entity) => dataLine([
330
- node.address,
331
- entity.kind,
332
- entity.id,
333
- entity.url
334
- ]))),
335
- json: () => ({
336
- summary: summary ?? null,
337
- durationMs
338
- }),
339
- next: () => []
340
- });
341
- });
332
+ }),
333
+ next: () => []
334
+ }));
342
335
  }
343
336
  });
344
337
  /**
@@ -346,10 +339,11 @@ const createDeployCommand = (operations) => defineCommand({
346
339
  * user interrupts it.
347
340
  *
348
341
  * The watch loop, the emulators and the live attachments stay the operation's
349
- * state. What the handler owns is the boundary: the converge child goes out
350
- * through `ctx.spawn`, so the terminal reaches alchemy natively and the engine
351
- * owns signal policy; the operation's events become engine events; and the
352
- * 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`.
353
347
  *
354
348
  * Windows is refused inside the operation itself (DEV.PLATFORM_UNSUPPORTED),
355
349
  * which is why nothing here reads the platform.
@@ -357,6 +351,9 @@ const createDeployCommand = (operations) => defineCommand({
357
351
  * `dev` is credential-free: everything it starts runs on this machine.
358
352
  */
359
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
+ }
360
357
  /** Resolves when the run is asked to stop. */
361
358
  function stopRequested(signal) {
362
359
  if (signal.aborted) return Promise.resolve();
@@ -364,36 +361,12 @@ function stopRequested(signal) {
364
361
  signal.addEventListener("abort", () => resolve(), { once: true });
365
362
  });
366
363
  }
367
- /**
368
- * One converge at a time. `ctx.spawn` refuses a second live child, and the
369
- * watch loop can well fire a rebuild while the previous converge is still
370
- * running — so a request that arrives during a live converge joins the single
371
- * queued follow-up instead of starting its own. That extends the coalescing
372
- * the watcher already does across a burst of edits to cover the converge
373
- * itself, and it is sound because every dev converge is the SAME invocation:
374
- * one stack file at one fixed path, rewritten in place before each request.
375
- */
376
- function coalescedConverge(run) {
377
- let live;
378
- let queued;
379
- const start = (invocation) => {
380
- const outcome = run(invocation);
381
- const settled = outcome.then(() => void 0, () => void 0);
382
- live = settled;
383
- settled.then(() => {
384
- if (live === settled) live = void 0;
385
- });
386
- return outcome;
387
- };
388
- return (invocation) => {
389
- const running = live;
390
- if (running === void 0) return start(invocation);
391
- queued ??= running.then(() => {
392
- queued = void 0;
393
- return start(invocation);
394
- });
395
- return queued;
396
- };
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 ");
397
370
  }
398
371
  /** The front door, ordered by address depth (fewest dots first) then lexicographically. */
399
372
  function frontDoorOrder(endpoints) {
@@ -407,7 +380,7 @@ function frontDoorOrder(endpoints) {
407
380
  * The operation's events as engine events. The legacy `[dev]` console prefix
408
381
  * is gone: these are commentary the engine renders and frames.
409
382
  */
410
- function reportDevEvent(report, lastChild, cwd) {
383
+ function reportDevEvent(report, cwd) {
411
384
  let stopFailed = false;
412
385
  return (event) => {
413
386
  switch (event.kind) {
@@ -480,6 +453,13 @@ function reportDevEvent(report, lastChild, cwd) {
480
453
  text: "The values the config or secrets adapters return changed since dev started. Restart dev to apply them; rebuilds are paused until then."
481
454
  });
482
455
  return;
456
+ case "value-reads-changed":
457
+ report({
458
+ kind: "message",
459
+ severity: "warn",
460
+ text: valueReadsChangedText(event)
461
+ });
462
+ return;
483
463
  case "watch-error":
484
464
  report({
485
465
  kind: "message",
@@ -487,26 +467,44 @@ function reportDevEvent(report, lastChild, cwd) {
487
467
  text: `Watch error: ${event.message}`
488
468
  });
489
469
  return;
490
- case "converge-failed": {
491
- const child = lastChild();
492
- 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":
493
491
  report({
494
492
  kind: "message",
495
- severity: "warn",
496
- text: `Converge failed — the running app is untouched; still watching.
497
- Generated stack file: ${event.stackFilePath}\nRun \`${event.reproduceCommand}\` from ${event.cwd} to reproduce this directly.`
493
+ severity: event.severity,
494
+ text: event.text
498
495
  });
496
+ return;
497
+ case "converge-failed":
499
498
  report({
500
- kind: "remediation",
501
- action: {
502
- kind: "run-command",
503
- label: `Run the converge directly from ${event.cwd} to reproduce this`,
504
- command: event.reproduceCommand,
505
- 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
506
505
  }
507
506
  });
508
507
  return;
509
- }
510
508
  case "stopping":
511
509
  report({
512
510
  kind: "step-started",
@@ -550,7 +548,7 @@ async function stopDetachedApp(operations, app, ctx) {
550
548
  const createDevCommand = (operations) => defineSessionCommand({
551
549
  help: {
552
550
  summary: "Bring up the application whose root node is the entry module's default export, entirely on this machine.",
553
- 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`.",
554
552
  examples: [
555
553
  "{bin} dev",
556
554
  "{bin} dev --fresh",
@@ -577,31 +575,43 @@ const createDevCommand = (operations) => defineSessionCommand({
577
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." })
578
576
  } },
579
577
  needs: { config: composerSection },
580
- maySpawn: true,
581
- handler: async (args, ctx) => {
582
- const alchemy = convergeSpawn(ctx);
583
- const result = await operations.dev({
584
- entry: args.flags.entry,
585
- config: ctx.config,
586
- name: args.flags.name,
587
- environment: args.flags.environment,
588
- fresh: args.flags.fresh,
589
- detach: args.flags.detach,
590
- cwd: ctx.cwd,
591
- onEvent: reportDevEvent(ctx.report, ctx.lastChild, ctx.cwd)
592
- }, { alchemy: coalescedConverge(alchemy) });
593
- if (!result.ok) return settleConvergeFailure(result.failure, ctx);
594
- if (args.flags.detach) {
595
- 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({
596
582
  entry: args.flags.entry,
583
+ config: ctx.config,
597
584
  name: args.flags.name,
598
- environment: args.flags.environment
599
- }, 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();
600
613
  return ok(void 0);
601
- }
602
- await stopRequested(ctx.signal);
603
- await result.value.stop();
604
- return ok(void 0);
614
+ });
605
615
  }
606
616
  });
607
617
  /**
@@ -750,6 +760,72 @@ function retiredStageFlagRedirect(command) {
750
760
  reason: "A place the app runs is now called an environment."
751
761
  };
752
762
  }
763
+ function withPrisma7Cli(reason, invocation) {
764
+ return `${reason} To keep using Prisma 7, install its CLI with \`npm install --save-dev @prisma/prisma7@7\` and run \`prisma7 ${invocation}\`.`;
765
+ }
766
+ function kebabCase(flag) {
767
+ return flag.replace(/[A-Z]/g, (letter) => `-${letter.toLowerCase()}`);
768
+ }
769
+ function v7Command(from, entry) {
770
+ const { prisma7 = from, ...rest } = entry;
771
+ return {
772
+ from,
773
+ code: "CLI.V7_COMMAND",
774
+ summary: `\`{bin} ${from}\` is a Prisma 7 command and is not available in Prisma 8`,
775
+ ...rest,
776
+ reason: withPrisma7Cli(entry.reason, prisma7)
777
+ };
778
+ }
779
+ function v7Flag(command, flag, entry) {
780
+ const { prisma7 = `${command} --${kebabCase(flag)}`, ...rest } = entry;
781
+ return {
782
+ from: command,
783
+ flag,
784
+ code: "CLI.V7_FLAG",
785
+ summary: `\`--${kebabCase(flag)}\` on \`{bin} ${command}\` is a Prisma 7 flag and is not available in Prisma 8`,
786
+ ...rest,
787
+ reason: withPrisma7Cli(entry.reason, prisma7)
788
+ };
789
+ }
790
+ const ENVIRONMENT = "environment (a separate local copy of the app: the one named dev unless `--environment` names another)";
791
+ const DEV_PORTS_REASON = `\`dev\` takes no port options. Each ${ENVIRONMENT} gets its own ports for its services, databases and buckets and keeps them between runs. While \`dev\` runs, \`dev url <address>\` prints where one service, database or bucket answers; its address is its path from the app name, with dots between names, such as \`shop.catalog.database\`.`;
792
+ const V7_REDIRECTS = [
793
+ v7Command("dev ls", {
794
+ replacement: "{bin} emulator list",
795
+ help: "emulator list",
796
+ reason: "`emulator list` lists the local emulators on this machine, the programs `dev` starts to run the app's services, databases and buckets, with every instance each one holds."
797
+ }),
798
+ v7Command("dev rm", {
799
+ prisma7: "dev rm <name>",
800
+ replacement: "{bin} dev --fresh",
801
+ help: "dev",
802
+ reason: `\`dev --fresh\` deletes this app's local services, databases and buckets, and their data, in one ${ENVIRONMENT}, then starts the app again. \`dev stop\` only stops the app's service processes and local database servers, and keeps their data.`
803
+ }),
804
+ v7Command("dev start", {
805
+ prisma7: "dev start <name>",
806
+ replacement: "{bin} dev --detach",
807
+ help: "dev",
808
+ reason: "`dev --detach` runs the app locally in the background: it returns once every service answers and leaves the app running, without watching for changes, until `dev stop`."
809
+ }),
810
+ ...[
811
+ "port",
812
+ "dbPort",
813
+ "shadowDbPort"
814
+ ].map((flag) => v7Flag("dev", flag, {
815
+ prisma7: `dev --${kebabCase(flag)} <port>`,
816
+ help: "dev",
817
+ reason: DEV_PORTS_REASON
818
+ })),
819
+ v7Flag("dev", "debug", {
820
+ help: "dev",
821
+ reason: "`dev` has no debug output option. It shows the output of each service that runs a dev server, such as `next dev`, prefixed with the service's address."
822
+ }),
823
+ v7Flag("dev stop", "debug", {
824
+ prisma7: "dev stop <name> --debug",
825
+ help: "dev stop",
826
+ reason: "`dev stop` has no debug output option."
827
+ })
828
+ ];
753
829
  function createComposerFamily$1(options = {}) {
754
830
  const operations = options.operations ?? realOperations;
755
831
  return defineCommandFamily({
@@ -762,7 +838,11 @@ function createComposerFamily$1(options = {}) {
762
838
  ...options.commands
763
839
  },
764
840
  docsBaseUrl: CLI_DOCS_BASE,
765
- redirects: [retiredStageFlagRedirect("deploy"), ...options.redirects ?? []]
841
+ redirects: [
842
+ retiredStageFlagRedirect("deploy"),
843
+ ...V7_REDIRECTS,
844
+ ...options.redirects ?? []
845
+ ]
766
846
  });
767
847
  }
768
848
  //#endregion
@@ -774,7 +854,7 @@ function createComposerFamily$1(options = {}) {
774
854
  * assembled into the family here, where both domains may be imported.
775
855
  */
776
856
  /** Loaded on first use, so nothing of the Management API reads loads with the family. */
777
- const listDeployed = async (input) => (await import("./list-deployed-IL0MgmTX.mjs")).listDeployed(input);
857
+ const listDeployed = async (input) => (await import("./list-deployed-slo4P7dl.mjs")).listDeployed(input);
778
858
  const createDeployListCommand = (list) => defineCommand({
779
859
  help: {
780
860
  summary: "List every node the app has deployed in an environment, with its platform ID and URL.",
@@ -853,7 +933,7 @@ const createDeployListCommand = (list) => defineCommand({
853
933
  * family here, where both domains may be imported.
854
934
  */
855
935
  /** Loaded on first use, so nothing of the emulators' clients loads with the family. */
856
- const listEmulators = async () => (await import("./dist-BH6HQ6zZ.mjs")).listEmulators();
936
+ const listEmulators = async () => (await import("./dist-C0OGaDnj.mjs")).listEmulators();
857
937
  const EMULATOR_NAMES = {
858
938
  service: "Service emulator",
859
939
  database: "Database emulator",