@prisma-next/cli 0.3.0-pr.94.3 → 0.3.0-pr.95.2

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 (115) hide show
  1. package/dist/chunk-AGOTG4L3.js +965 -0
  2. package/dist/chunk-AGOTG4L3.js.map +1 -0
  3. package/dist/chunk-HLLI4YL7.js +180 -0
  4. package/dist/chunk-HLLI4YL7.js.map +1 -0
  5. package/dist/chunk-HWYQOCAJ.js +47 -0
  6. package/dist/chunk-HWYQOCAJ.js.map +1 -0
  7. package/dist/chunk-VG2R7DGF.js +735 -0
  8. package/dist/chunk-VG2R7DGF.js.map +1 -0
  9. package/dist/cli.d.ts +2 -2
  10. package/dist/cli.d.ts.map +1 -0
  11. package/dist/cli.js +2764 -2522
  12. package/dist/cli.js.map +1 -1
  13. package/dist/commands/contract-emit.d.ts +3 -0
  14. package/dist/commands/contract-emit.d.ts.map +1 -0
  15. package/dist/commands/contract-emit.js +10 -0
  16. package/dist/commands/contract-emit.js.map +1 -0
  17. package/dist/commands/db-init.d.ts +3 -0
  18. package/dist/commands/db-init.d.ts.map +1 -0
  19. package/dist/commands/db-init.js +257 -0
  20. package/dist/commands/db-init.js.map +1 -0
  21. package/dist/commands/db-introspect.d.ts +3 -0
  22. package/dist/commands/db-introspect.d.ts.map +1 -0
  23. package/dist/commands/db-introspect.js +155 -0
  24. package/dist/commands/db-introspect.js.map +1 -0
  25. package/dist/commands/db-schema-verify.d.ts +3 -0
  26. package/dist/commands/db-schema-verify.d.ts.map +1 -0
  27. package/dist/commands/db-schema-verify.js +171 -0
  28. package/dist/commands/db-schema-verify.js.map +1 -0
  29. package/dist/commands/db-sign.d.ts +3 -0
  30. package/dist/commands/db-sign.d.ts.map +1 -0
  31. package/dist/commands/db-sign.js +195 -0
  32. package/dist/commands/db-sign.js.map +1 -0
  33. package/dist/commands/db-verify.d.ts +3 -0
  34. package/dist/commands/db-verify.d.ts.map +1 -0
  35. package/dist/commands/db-verify.js +193 -0
  36. package/dist/commands/db-verify.js.map +1 -0
  37. package/dist/{config-loader.d.mts → config-loader.d.ts} +3 -8
  38. package/dist/config-loader.d.ts.map +1 -0
  39. package/dist/config-loader.js +7 -0
  40. package/dist/config-loader.js.map +1 -0
  41. package/dist/control-api/client.d.ts +13 -0
  42. package/dist/control-api/client.d.ts.map +1 -0
  43. package/dist/control-api/operations/db-init.d.ts +29 -0
  44. package/dist/control-api/operations/db-init.d.ts.map +1 -0
  45. package/dist/control-api/types.d.ts +387 -0
  46. package/dist/control-api/types.d.ts.map +1 -0
  47. package/dist/exports/config-types.d.ts +3 -0
  48. package/dist/exports/config-types.d.ts.map +1 -0
  49. package/dist/exports/config-types.js +6 -0
  50. package/dist/exports/config-types.js.map +1 -0
  51. package/dist/exports/control-api.d.ts +13 -0
  52. package/dist/exports/control-api.d.ts.map +1 -0
  53. package/dist/exports/control-api.js +7 -0
  54. package/dist/exports/control-api.js.map +1 -0
  55. package/dist/exports/index.d.ts +4 -0
  56. package/dist/exports/index.d.ts.map +1 -0
  57. package/dist/exports/index.js +176 -0
  58. package/dist/exports/index.js.map +1 -0
  59. package/dist/{exports/index.d.mts → load-ts-contract.d.ts} +5 -10
  60. package/dist/load-ts-contract.d.ts.map +1 -0
  61. package/dist/utils/cli-errors.d.ts +7 -0
  62. package/dist/utils/cli-errors.d.ts.map +1 -0
  63. package/dist/utils/command-helpers.d.ts +12 -0
  64. package/dist/utils/command-helpers.d.ts.map +1 -0
  65. package/dist/utils/framework-components.d.ts +70 -0
  66. package/dist/utils/framework-components.d.ts.map +1 -0
  67. package/dist/utils/global-flags.d.ts +25 -0
  68. package/dist/utils/global-flags.d.ts.map +1 -0
  69. package/dist/utils/output.d.ts +142 -0
  70. package/dist/utils/output.d.ts.map +1 -0
  71. package/dist/utils/progress-adapter.d.ts +26 -0
  72. package/dist/utils/progress-adapter.d.ts.map +1 -0
  73. package/dist/utils/result-handler.d.ts +15 -0
  74. package/dist/utils/result-handler.d.ts.map +1 -0
  75. package/package.json +54 -29
  76. package/dist/client-CoxxGz_7.mjs +0 -692
  77. package/dist/client-CoxxGz_7.mjs.map +0 -1
  78. package/dist/commands/contract-emit.d.mts +0 -7
  79. package/dist/commands/contract-emit.d.mts.map +0 -1
  80. package/dist/commands/contract-emit.mjs +0 -139
  81. package/dist/commands/contract-emit.mjs.map +0 -1
  82. package/dist/commands/db-init.d.mts +0 -7
  83. package/dist/commands/db-init.d.mts.map +0 -1
  84. package/dist/commands/db-init.mjs +0 -178
  85. package/dist/commands/db-init.mjs.map +0 -1
  86. package/dist/commands/db-introspect.d.mts +0 -7
  87. package/dist/commands/db-introspect.d.mts.map +0 -1
  88. package/dist/commands/db-introspect.mjs +0 -120
  89. package/dist/commands/db-introspect.mjs.map +0 -1
  90. package/dist/commands/db-schema-verify.d.mts +0 -7
  91. package/dist/commands/db-schema-verify.d.mts.map +0 -1
  92. package/dist/commands/db-schema-verify.mjs +0 -116
  93. package/dist/commands/db-schema-verify.mjs.map +0 -1
  94. package/dist/commands/db-sign.d.mts +0 -7
  95. package/dist/commands/db-sign.d.mts.map +0 -1
  96. package/dist/commands/db-sign.mjs +0 -138
  97. package/dist/commands/db-sign.mjs.map +0 -1
  98. package/dist/commands/db-verify.d.mts +0 -7
  99. package/dist/commands/db-verify.d.mts.map +0 -1
  100. package/dist/commands/db-verify.mjs +0 -128
  101. package/dist/commands/db-verify.mjs.map +0 -1
  102. package/dist/config-loader-B-pobG0R.mjs +0 -42
  103. package/dist/config-loader-B-pobG0R.mjs.map +0 -1
  104. package/dist/config-loader.d.mts.map +0 -1
  105. package/dist/config-loader.mjs +0 -3
  106. package/dist/exports/config-types.d.mts +0 -2
  107. package/dist/exports/config-types.mjs +0 -3
  108. package/dist/exports/control-api.d.mts +0 -405
  109. package/dist/exports/control-api.d.mts.map +0 -1
  110. package/dist/exports/control-api.mjs +0 -3
  111. package/dist/exports/index.d.mts.map +0 -1
  112. package/dist/exports/index.mjs +0 -128
  113. package/dist/exports/index.mjs.map +0 -1
  114. package/dist/result-handler-Do_4Fi4U.mjs +0 -959
  115. package/dist/result-handler-Do_4Fi4U.mjs.map +0 -1
@@ -0,0 +1,965 @@
1
+ // src/utils/command-helpers.ts
2
+ function setCommandDescriptions(command, shortDescription, longDescription) {
3
+ command.description(shortDescription);
4
+ if (longDescription) {
5
+ command._longDescription = longDescription;
6
+ }
7
+ return command;
8
+ }
9
+ function getLongDescription(command) {
10
+ return command._longDescription;
11
+ }
12
+
13
+ // src/utils/global-flags.ts
14
+ function parseGlobalFlags(options) {
15
+ const flags = {};
16
+ if (options.json === true || options.json === "object") {
17
+ flags.json = "object";
18
+ } else if (options.json === "ndjson") {
19
+ flags.json = "ndjson";
20
+ }
21
+ if (options.quiet || options.q) {
22
+ flags.quiet = true;
23
+ }
24
+ if (options.vv || options.trace) {
25
+ flags.verbose = 2;
26
+ } else if (options.verbose || options.v) {
27
+ flags.verbose = 1;
28
+ } else {
29
+ flags.verbose = 0;
30
+ }
31
+ if (options.timestamps) {
32
+ flags.timestamps = true;
33
+ }
34
+ if (process.env["NO_COLOR"] || flags.json) {
35
+ flags.color = false;
36
+ } else if (options["no-color"]) {
37
+ flags.color = false;
38
+ } else if (options.color !== void 0) {
39
+ flags.color = options.color;
40
+ } else {
41
+ flags.color = process.stdout.isTTY && !process.env["CI"];
42
+ }
43
+ return flags;
44
+ }
45
+
46
+ // src/utils/output.ts
47
+ import { relative } from "path";
48
+ import { bgGreen, blue, bold, cyan, dim, green, magenta, red, yellow } from "colorette";
49
+ import stringWidth from "string-width";
50
+ import stripAnsi from "strip-ansi";
51
+ import wrapAnsi from "wrap-ansi";
52
+ function formatTimestamp() {
53
+ return (/* @__PURE__ */ new Date()).toISOString();
54
+ }
55
+ function createPrefix(flags) {
56
+ return flags.timestamps ? `[${formatTimestamp()}] ` : "";
57
+ }
58
+ function isVerbose(flags, level) {
59
+ return (flags.verbose ?? 0) >= level;
60
+ }
61
+ function createColorFormatter(useColor, colorFn) {
62
+ return useColor ? colorFn : (text) => text;
63
+ }
64
+ function formatDim(useColor, text) {
65
+ return useColor ? dim(text) : text;
66
+ }
67
+ function formatEmitOutput(result, flags) {
68
+ if (flags.quiet) {
69
+ return "";
70
+ }
71
+ const lines = [];
72
+ const prefix = createPrefix(flags);
73
+ const jsonPath = relative(process.cwd(), result.files.json);
74
+ const dtsPath = relative(process.cwd(), result.files.dts);
75
+ lines.push(`${prefix}\u2714 Emitted contract.json \u2192 ${jsonPath}`);
76
+ lines.push(`${prefix}\u2714 Emitted contract.d.ts \u2192 ${dtsPath}`);
77
+ lines.push(`${prefix} coreHash: ${result.coreHash}`);
78
+ if (result.profileHash) {
79
+ lines.push(`${prefix} profileHash: ${result.profileHash}`);
80
+ }
81
+ if (isVerbose(flags, 1)) {
82
+ lines.push(`${prefix} Total time: ${result.timings.total}ms`);
83
+ }
84
+ return lines.join("\n");
85
+ }
86
+ function formatEmitJson(result) {
87
+ const output = {
88
+ ok: true,
89
+ coreHash: result.coreHash,
90
+ ...result.profileHash ? { profileHash: result.profileHash } : {},
91
+ outDir: result.outDir,
92
+ files: result.files,
93
+ timings: result.timings
94
+ };
95
+ return JSON.stringify(output, null, 2);
96
+ }
97
+ function formatErrorOutput(error, flags) {
98
+ const lines = [];
99
+ const prefix = createPrefix(flags);
100
+ const useColor = flags.color !== false;
101
+ const formatRed = createColorFormatter(useColor, red);
102
+ const formatDimText = (text) => formatDim(useColor, text);
103
+ lines.push(`${prefix}${formatRed("\u2716")} ${error.summary} (${error.code})`);
104
+ if (error.why) {
105
+ lines.push(`${prefix}${formatDimText(` Why: ${error.why}`)}`);
106
+ }
107
+ if (error.fix) {
108
+ lines.push(`${prefix}${formatDimText(` Fix: ${error.fix}`)}`);
109
+ }
110
+ if (error.where?.path) {
111
+ const whereLine = error.where.line ? `${error.where.path}:${error.where.line}` : error.where.path;
112
+ lines.push(`${prefix}${formatDimText(` Where: ${whereLine}`)}`);
113
+ }
114
+ if (error.meta?.["conflicts"]) {
115
+ const conflicts = error.meta["conflicts"];
116
+ if (conflicts.length > 0) {
117
+ const maxToShow = isVerbose(flags, 1) ? conflicts.length : Math.min(3, conflicts.length);
118
+ const header = isVerbose(flags, 1) ? " Conflicts:" : ` Conflicts (showing ${maxToShow} of ${conflicts.length}):`;
119
+ lines.push(`${prefix}${formatDimText(header)}`);
120
+ for (const conflict of conflicts.slice(0, maxToShow)) {
121
+ lines.push(`${prefix}${formatDimText(` - [${conflict.kind}] ${conflict.summary}`)}`);
122
+ }
123
+ if (!isVerbose(flags, 1) && conflicts.length > maxToShow) {
124
+ lines.push(`${prefix}${formatDimText(" Re-run with -v/--verbose to see all conflicts")}`);
125
+ }
126
+ }
127
+ }
128
+ if (error.meta?.["issues"]) {
129
+ const issues = error.meta["issues"];
130
+ if (issues.length > 0) {
131
+ const maxToShow = isVerbose(flags, 1) ? issues.length : Math.min(3, issues.length);
132
+ const header = isVerbose(flags, 1) ? " Issues:" : ` Issues (showing ${maxToShow} of ${issues.length}):`;
133
+ lines.push(`${prefix}${formatDimText(header)}`);
134
+ for (const issue of issues.slice(0, maxToShow)) {
135
+ const kind = issue.kind ?? "issue";
136
+ const message = issue.message ?? "";
137
+ lines.push(`${prefix}${formatDimText(` - [${kind}] ${message}`)}`);
138
+ }
139
+ if (!isVerbose(flags, 1) && issues.length > maxToShow) {
140
+ lines.push(`${prefix}${formatDimText(" Re-run with -v/--verbose to see all issues")}`);
141
+ }
142
+ }
143
+ }
144
+ if (error.docsUrl && isVerbose(flags, 1)) {
145
+ lines.push(formatDimText(error.docsUrl));
146
+ }
147
+ if (isVerbose(flags, 2) && error.meta) {
148
+ lines.push(`${prefix}${formatDimText(` Meta: ${JSON.stringify(error.meta, null, 2)}`)}`);
149
+ }
150
+ return lines.join("\n");
151
+ }
152
+ function formatErrorJson(error) {
153
+ return JSON.stringify(error, null, 2);
154
+ }
155
+ function formatVerifyOutput(result, flags) {
156
+ if (flags.quiet) {
157
+ return "";
158
+ }
159
+ const lines = [];
160
+ const prefix = createPrefix(flags);
161
+ const useColor = flags.color !== false;
162
+ const formatGreen = createColorFormatter(useColor, green);
163
+ const formatRed = createColorFormatter(useColor, red);
164
+ const formatDimText = (text) => formatDim(useColor, text);
165
+ if (result.ok) {
166
+ lines.push(`${prefix}${formatGreen("\u2714")} ${result.summary}`);
167
+ lines.push(`${prefix}${formatDimText(` coreHash: ${result.contract.coreHash}`)}`);
168
+ if (result.contract.profileHash) {
169
+ lines.push(`${prefix}${formatDimText(` profileHash: ${result.contract.profileHash}`)}`);
170
+ }
171
+ } else {
172
+ lines.push(`${prefix}${formatRed("\u2716")} ${result.summary} (${result.code})`);
173
+ }
174
+ if (isVerbose(flags, 1)) {
175
+ if (result.codecCoverageSkipped) {
176
+ lines.push(
177
+ `${prefix}${formatDimText(" Codec coverage check skipped (helper returned no supported types)")}`
178
+ );
179
+ }
180
+ lines.push(`${prefix}${formatDimText(` Total time: ${result.timings.total}ms`)}`);
181
+ }
182
+ return lines.join("\n");
183
+ }
184
+ function formatVerifyJson(result) {
185
+ const output = {
186
+ ok: result.ok,
187
+ ...result.code ? { code: result.code } : {},
188
+ summary: result.summary,
189
+ contract: result.contract,
190
+ ...result.marker ? { marker: result.marker } : {},
191
+ target: result.target,
192
+ ...result.missingCodecs ? { missingCodecs: result.missingCodecs } : {},
193
+ ...result.meta ? { meta: result.meta } : {},
194
+ timings: result.timings
195
+ };
196
+ return JSON.stringify(output, null, 2);
197
+ }
198
+ function formatIntrospectJson(result) {
199
+ return JSON.stringify(result, null, 2);
200
+ }
201
+ function renderSchemaTree(node, flags, options) {
202
+ const { isLast, prefix, useColor, formatDimText, isRoot = false } = options;
203
+ const lines = [];
204
+ let formattedLabel = node.label;
205
+ if (useColor) {
206
+ switch (node.kind) {
207
+ case "root":
208
+ formattedLabel = bold(node.label);
209
+ break;
210
+ case "entity": {
211
+ const tableMatch = node.label.match(/^table\s+(.+)$/);
212
+ if (tableMatch?.[1]) {
213
+ const tableName = tableMatch[1];
214
+ formattedLabel = `${dim("table")} ${cyan(tableName)}`;
215
+ } else {
216
+ formattedLabel = cyan(node.label);
217
+ }
218
+ break;
219
+ }
220
+ case "collection": {
221
+ formattedLabel = dim(node.label);
222
+ break;
223
+ }
224
+ case "field": {
225
+ const columnMatch = node.label.match(/^([^:]+):\s*(.+)$/);
226
+ if (columnMatch?.[1] && columnMatch[2]) {
227
+ const columnName = columnMatch[1];
228
+ const rest = columnMatch[2];
229
+ const typeMatch = rest.match(/^([^\s(]+)\s*(\([^)]+\))$/);
230
+ if (typeMatch?.[1] && typeMatch[2]) {
231
+ const typeDisplay = typeMatch[1];
232
+ const nullability = typeMatch[2];
233
+ formattedLabel = `${cyan(columnName)}: ${typeDisplay} ${dim(nullability)}`;
234
+ } else {
235
+ formattedLabel = `${cyan(columnName)}: ${rest}`;
236
+ }
237
+ } else {
238
+ formattedLabel = node.label;
239
+ }
240
+ break;
241
+ }
242
+ case "index": {
243
+ const pkMatch = node.label.match(/^primary key:\s*(.+)$/);
244
+ if (pkMatch?.[1]) {
245
+ const columnNames = pkMatch[1];
246
+ formattedLabel = `${dim("primary key")}: ${cyan(columnNames)}`;
247
+ } else {
248
+ const uniqueMatch = node.label.match(/^unique\s+(.+)$/);
249
+ if (uniqueMatch?.[1]) {
250
+ const name = uniqueMatch[1];
251
+ formattedLabel = `${dim("unique")} ${cyan(name)}`;
252
+ } else {
253
+ const indexMatch = node.label.match(/^(unique\s+)?index\s+(.+)$/);
254
+ if (indexMatch?.[2]) {
255
+ const prefix2 = indexMatch[1] ? `${dim("unique")} ` : "";
256
+ const name = indexMatch[2];
257
+ formattedLabel = `${prefix2}${dim("index")} ${cyan(name)}`;
258
+ } else {
259
+ formattedLabel = dim(node.label);
260
+ }
261
+ }
262
+ }
263
+ break;
264
+ }
265
+ case "extension": {
266
+ const extMatch = node.label.match(/^([^\s]+)\s+(extension is enabled)$/);
267
+ if (extMatch?.[1] && extMatch[2]) {
268
+ const extName = extMatch[1];
269
+ const rest = extMatch[2];
270
+ formattedLabel = `${cyan(extName)} ${dim(rest)}`;
271
+ } else {
272
+ formattedLabel = magenta(node.label);
273
+ }
274
+ break;
275
+ }
276
+ default:
277
+ formattedLabel = node.label;
278
+ break;
279
+ }
280
+ }
281
+ if (isRoot) {
282
+ lines.push(formattedLabel);
283
+ } else {
284
+ const treeChar = isLast ? "\u2514" : "\u251C";
285
+ const treePrefix = `${prefix}${formatDimText(treeChar)}\u2500 `;
286
+ const isRootChild = prefix === "";
287
+ const prefixWithoutAnsi = stripAnsi(prefix);
288
+ const prefixHasVerticalBar = prefixWithoutAnsi.includes("\u2502");
289
+ if (isRootChild) {
290
+ lines.push(`${treePrefix}${formattedLabel}`);
291
+ } else if (prefixHasVerticalBar) {
292
+ lines.push(`${treePrefix}${formattedLabel}`);
293
+ } else {
294
+ lines.push(`${formatDimText("\u2502")} ${treePrefix}${formattedLabel}`);
295
+ }
296
+ }
297
+ if (node.children && node.children.length > 0) {
298
+ const childPrefix = isRoot ? "" : isLast ? `${prefix} ` : `${prefix}${formatDimText("\u2502")} `;
299
+ for (let i = 0; i < node.children.length; i++) {
300
+ const child = node.children[i];
301
+ if (!child) continue;
302
+ const isLastChild = i === node.children.length - 1;
303
+ const childLines = renderSchemaTree(child, flags, {
304
+ isLast: isLastChild,
305
+ prefix: childPrefix,
306
+ useColor,
307
+ formatDimText,
308
+ isRoot: false
309
+ });
310
+ lines.push(...childLines);
311
+ }
312
+ }
313
+ return lines;
314
+ }
315
+ function formatIntrospectOutput(result, schemaView, flags) {
316
+ if (flags.quiet) {
317
+ return "";
318
+ }
319
+ const lines = [];
320
+ const prefix = createPrefix(flags);
321
+ const useColor = flags.color !== false;
322
+ const formatDimText = (text) => formatDim(useColor, text);
323
+ if (schemaView) {
324
+ const treeLines = renderSchemaTree(schemaView.root, flags, {
325
+ isLast: true,
326
+ prefix: "",
327
+ useColor,
328
+ formatDimText,
329
+ isRoot: true
330
+ });
331
+ const prefixedTreeLines = treeLines.map((line) => `${prefix}${line}`);
332
+ lines.push(...prefixedTreeLines);
333
+ } else {
334
+ lines.push(`${prefix}\u2714 ${result.summary}`);
335
+ if (isVerbose(flags, 1)) {
336
+ lines.push(`${prefix} Target: ${result.target.familyId}/${result.target.id}`);
337
+ if (result.meta?.dbUrl) {
338
+ lines.push(`${prefix} Database: ${result.meta.dbUrl}`);
339
+ }
340
+ }
341
+ }
342
+ if (isVerbose(flags, 1)) {
343
+ lines.push(`${prefix}${formatDimText(` Total time: ${result.timings.total}ms`)}`);
344
+ }
345
+ return lines.join("\n");
346
+ }
347
+ function renderSchemaVerificationTree(node, flags, options) {
348
+ const { isLast, prefix, useColor, formatDimText, isRoot = false } = options;
349
+ const lines = [];
350
+ let statusGlyph = "";
351
+ let statusColor = (text) => text;
352
+ if (useColor) {
353
+ switch (node.status) {
354
+ case "pass":
355
+ statusGlyph = "\u2714";
356
+ statusColor = green;
357
+ break;
358
+ case "warn":
359
+ statusGlyph = "\u26A0";
360
+ statusColor = (text) => useColor ? yellow(text) : text;
361
+ break;
362
+ case "fail":
363
+ statusGlyph = "\u2716";
364
+ statusColor = red;
365
+ break;
366
+ }
367
+ } else {
368
+ switch (node.status) {
369
+ case "pass":
370
+ statusGlyph = "\u2714";
371
+ break;
372
+ case "warn":
373
+ statusGlyph = "\u26A0";
374
+ break;
375
+ case "fail":
376
+ statusGlyph = "\u2716";
377
+ break;
378
+ }
379
+ }
380
+ let labelColor = (text) => text;
381
+ let formattedLabel = node.name;
382
+ if (useColor) {
383
+ switch (node.kind) {
384
+ case "contract":
385
+ case "schema":
386
+ labelColor = bold;
387
+ formattedLabel = labelColor(node.name);
388
+ break;
389
+ case "table": {
390
+ const tableMatch = node.name.match(/^table\s+(.+)$/);
391
+ if (tableMatch?.[1]) {
392
+ const tableName = tableMatch[1];
393
+ formattedLabel = `${dim("table")} ${cyan(tableName)}`;
394
+ } else {
395
+ formattedLabel = dim(node.name);
396
+ }
397
+ break;
398
+ }
399
+ case "columns":
400
+ labelColor = dim;
401
+ formattedLabel = labelColor(node.name);
402
+ break;
403
+ case "column": {
404
+ const columnMatch = node.name.match(/^([^:]+):\s*(.+)$/);
405
+ if (columnMatch?.[1] && columnMatch[2]) {
406
+ const columnName = columnMatch[1];
407
+ const rest = columnMatch[2];
408
+ const typeMatch = rest.match(/^([^\s→]+)\s*→\s*([^\s(]+)\s*(\([^)]+\))$/);
409
+ if (typeMatch?.[1] && typeMatch[2] && typeMatch[3]) {
410
+ const contractType = typeMatch[1];
411
+ const nativeType = typeMatch[2];
412
+ const nullability = typeMatch[3];
413
+ formattedLabel = `${cyan(columnName)}: ${contractType} \u2192 ${dim(nativeType)} ${dim(nullability)}`;
414
+ } else {
415
+ formattedLabel = `${cyan(columnName)}: ${rest}`;
416
+ }
417
+ } else {
418
+ formattedLabel = node.name;
419
+ }
420
+ break;
421
+ }
422
+ case "type":
423
+ case "nullability":
424
+ labelColor = (text) => text;
425
+ formattedLabel = labelColor(node.name);
426
+ break;
427
+ case "primaryKey": {
428
+ const pkMatch = node.name.match(/^primary key:\s*(.+)$/);
429
+ if (pkMatch?.[1]) {
430
+ const columnNames = pkMatch[1];
431
+ formattedLabel = `${dim("primary key")}: ${cyan(columnNames)}`;
432
+ } else {
433
+ formattedLabel = dim(node.name);
434
+ }
435
+ break;
436
+ }
437
+ case "foreignKey":
438
+ case "unique":
439
+ case "index":
440
+ labelColor = dim;
441
+ formattedLabel = labelColor(node.name);
442
+ break;
443
+ case "extension": {
444
+ const dbMatch = node.name.match(/^database is\s+(.+)$/);
445
+ if (dbMatch?.[1]) {
446
+ const dbName = dbMatch[1];
447
+ formattedLabel = `${dim("database is")} ${cyan(dbName)}`;
448
+ } else {
449
+ const extMatch = node.name.match(/^([^\s]+)\s+(extension is enabled)$/);
450
+ if (extMatch?.[1] && extMatch[2]) {
451
+ const extName = extMatch[1];
452
+ const rest = extMatch[2];
453
+ formattedLabel = `${cyan(extName)} ${dim(rest)}`;
454
+ } else {
455
+ labelColor = magenta;
456
+ formattedLabel = labelColor(node.name);
457
+ }
458
+ }
459
+ break;
460
+ }
461
+ default:
462
+ formattedLabel = node.name;
463
+ break;
464
+ }
465
+ } else {
466
+ formattedLabel = node.name;
467
+ }
468
+ const statusGlyphColored = statusColor(statusGlyph);
469
+ let nodeLabel = formattedLabel;
470
+ if ((node.status === "fail" || node.status === "warn") && node.message && node.message.length > 0) {
471
+ const messageText = formatDimText(`(${node.message})`);
472
+ nodeLabel = `${formattedLabel} ${messageText}`;
473
+ }
474
+ if (isRoot) {
475
+ lines.push(`${statusGlyphColored} ${nodeLabel}`);
476
+ } else {
477
+ const treeChar = isLast ? "\u2514" : "\u251C";
478
+ const treePrefix = `${prefix}${formatDimText(treeChar)}\u2500 `;
479
+ const isRootChild = prefix === "";
480
+ const prefixWithoutAnsi = stripAnsi(prefix);
481
+ const prefixHasVerticalBar = prefixWithoutAnsi.includes("\u2502");
482
+ if (isRootChild) {
483
+ lines.push(`${treePrefix}${statusGlyphColored} ${nodeLabel}`);
484
+ } else if (prefixHasVerticalBar) {
485
+ lines.push(`${treePrefix}${statusGlyphColored} ${nodeLabel}`);
486
+ } else {
487
+ lines.push(`${formatDimText("\u2502")} ${treePrefix}${statusGlyphColored} ${nodeLabel}`);
488
+ }
489
+ }
490
+ if (node.children && node.children.length > 0) {
491
+ const childPrefix = isRoot ? "" : isLast ? `${prefix} ` : `${prefix}${formatDimText("\u2502")} `;
492
+ for (let i = 0; i < node.children.length; i++) {
493
+ const child = node.children[i];
494
+ if (!child) continue;
495
+ const isLastChild = i === node.children.length - 1;
496
+ const childLines = renderSchemaVerificationTree(child, flags, {
497
+ isLast: isLastChild,
498
+ prefix: childPrefix,
499
+ useColor,
500
+ formatDimText,
501
+ isRoot: false
502
+ });
503
+ lines.push(...childLines);
504
+ }
505
+ }
506
+ return lines;
507
+ }
508
+ function formatSchemaVerifyOutput(result, flags) {
509
+ if (flags.quiet) {
510
+ return "";
511
+ }
512
+ const lines = [];
513
+ const prefix = createPrefix(flags);
514
+ const useColor = flags.color !== false;
515
+ const formatGreen = createColorFormatter(useColor, green);
516
+ const formatRed = createColorFormatter(useColor, red);
517
+ const formatDimText = (text) => formatDim(useColor, text);
518
+ const treeLines = renderSchemaVerificationTree(result.schema.root, flags, {
519
+ isLast: true,
520
+ prefix: "",
521
+ useColor,
522
+ formatDimText,
523
+ isRoot: true
524
+ });
525
+ const prefixedTreeLines = treeLines.map((line) => `${prefix}${line}`);
526
+ lines.push(...prefixedTreeLines);
527
+ if (isVerbose(flags, 1)) {
528
+ lines.push(`${prefix}${formatDimText(` Total time: ${result.timings.total}ms`)}`);
529
+ lines.push(
530
+ `${prefix}${formatDimText(` pass=${result.schema.counts.pass} warn=${result.schema.counts.warn} fail=${result.schema.counts.fail}`)}`
531
+ );
532
+ }
533
+ lines.push("");
534
+ if (result.ok) {
535
+ lines.push(`${prefix}${formatGreen("\u2714")} ${result.summary}`);
536
+ } else {
537
+ const codeText = result.code ? ` (${result.code})` : "";
538
+ lines.push(`${prefix}${formatRed("\u2716")} ${result.summary}${codeText}`);
539
+ }
540
+ return lines.join("\n");
541
+ }
542
+ function formatSchemaVerifyJson(result) {
543
+ return JSON.stringify(result, null, 2);
544
+ }
545
+ function formatSignOutput(result, flags) {
546
+ if (flags.quiet) {
547
+ return "";
548
+ }
549
+ const lines = [];
550
+ const prefix = createPrefix(flags);
551
+ const useColor = flags.color !== false;
552
+ const formatGreen = createColorFormatter(useColor, green);
553
+ const formatDimText = (text) => formatDim(useColor, text);
554
+ if (result.ok) {
555
+ lines.push(`${prefix}${formatGreen("\u2714")} Database signed`);
556
+ const previousHash = result.marker.previous?.coreHash ?? "none";
557
+ const currentHash = result.contract.coreHash;
558
+ lines.push(`${prefix}${formatDimText(` from: ${previousHash}`)}`);
559
+ lines.push(`${prefix}${formatDimText(` to: ${currentHash}`)}`);
560
+ if (isVerbose(flags, 1)) {
561
+ if (result.contract.profileHash) {
562
+ lines.push(`${prefix}${formatDimText(` profileHash: ${result.contract.profileHash}`)}`);
563
+ }
564
+ if (result.marker.previous?.profileHash) {
565
+ lines.push(
566
+ `${prefix}${formatDimText(` previous profileHash: ${result.marker.previous.profileHash}`)}`
567
+ );
568
+ }
569
+ lines.push(`${prefix}${formatDimText(` Total time: ${result.timings.total}ms`)}`);
570
+ }
571
+ }
572
+ return lines.join("\n");
573
+ }
574
+ function formatSignJson(result) {
575
+ return JSON.stringify(result, null, 2);
576
+ }
577
+ function formatDbInitPlanOutput(result, flags) {
578
+ if (flags.quiet) {
579
+ return "";
580
+ }
581
+ const lines = [];
582
+ const prefix = createPrefix(flags);
583
+ const useColor = flags.color !== false;
584
+ const formatGreen = createColorFormatter(useColor, green);
585
+ const formatDimText = (text) => formatDim(useColor, text);
586
+ const operationCount = result.plan?.operations.length ?? 0;
587
+ lines.push(`${prefix}${formatGreen("\u2714")} Planned ${operationCount} operation(s)`);
588
+ if (result.plan?.operations && result.plan.operations.length > 0) {
589
+ lines.push(`${prefix}${formatDimText("\u2502")}`);
590
+ for (let i = 0; i < result.plan.operations.length; i++) {
591
+ const op = result.plan.operations[i];
592
+ if (!op) continue;
593
+ const isLast = i === result.plan.operations.length - 1;
594
+ const treeChar = isLast ? "\u2514" : "\u251C";
595
+ const opClass = formatDimText(`[${op.operationClass}]`);
596
+ lines.push(`${prefix}${formatDimText(treeChar)}\u2500 ${op.label} ${opClass}`);
597
+ }
598
+ }
599
+ if (result.plan?.destination) {
600
+ lines.push(`${prefix}`);
601
+ lines.push(
602
+ `${prefix}${formatDimText(`Destination hash: ${result.plan.destination.coreHash}`)}`
603
+ );
604
+ }
605
+ if (isVerbose(flags, 1)) {
606
+ lines.push(`${prefix}${formatDimText(`Total time: ${result.timings.total}ms`)}`);
607
+ }
608
+ lines.push(`${prefix}`);
609
+ lines.push(`${prefix}${formatDimText("This is a dry run. No changes were applied.")}`);
610
+ lines.push(`${prefix}${formatDimText("Run without --plan to apply changes.")}`);
611
+ return lines.join("\n");
612
+ }
613
+ function formatDbInitApplyOutput(result, flags) {
614
+ if (flags.quiet) {
615
+ return "";
616
+ }
617
+ const lines = [];
618
+ const prefix = createPrefix(flags);
619
+ const useColor = flags.color !== false;
620
+ const formatGreen = createColorFormatter(useColor, green);
621
+ const formatDimText = (text) => formatDim(useColor, text);
622
+ if (result.ok) {
623
+ const executed = result.execution?.operationsExecuted ?? 0;
624
+ lines.push(`${prefix}${formatGreen("\u2714")} Applied ${executed} operation(s)`);
625
+ if (result.marker) {
626
+ lines.push(`${prefix}${formatDimText(` Marker written: ${result.marker.coreHash}`)}`);
627
+ if (result.marker.profileHash) {
628
+ lines.push(`${prefix}${formatDimText(` Profile hash: ${result.marker.profileHash}`)}`);
629
+ }
630
+ }
631
+ if (isVerbose(flags, 1)) {
632
+ lines.push(`${prefix}${formatDimText(` Total time: ${result.timings.total}ms`)}`);
633
+ }
634
+ }
635
+ return lines.join("\n");
636
+ }
637
+ function formatDbInitJson(result) {
638
+ return JSON.stringify(result, null, 2);
639
+ }
640
+ var LEFT_COLUMN_WIDTH = 20;
641
+ var RIGHT_COLUMN_MIN_WIDTH = 40;
642
+ var RIGHT_COLUMN_MAX_WIDTH = 90;
643
+ function getTerminalWidth() {
644
+ const terminalWidth = process.stdout.columns;
645
+ const defaultWidth = Number.parseInt(process.env["CLI_WIDTH"] || "80", 10);
646
+ return terminalWidth || defaultWidth;
647
+ }
648
+ function calculateRightColumnWidth() {
649
+ const terminalWidth = getTerminalWidth();
650
+ const availableWidth = terminalWidth - 2 - LEFT_COLUMN_WIDTH - 2;
651
+ return Math.max(RIGHT_COLUMN_MIN_WIDTH, Math.min(availableWidth, RIGHT_COLUMN_MAX_WIDTH));
652
+ }
653
+ function createPrismaNextBadge(useColor) {
654
+ if (!useColor) {
655
+ return "prisma-next";
656
+ }
657
+ const text = " prisma-next ";
658
+ const body = bgGreen(bold(text));
659
+ const separator = "\uE0B0";
660
+ const tip = green(separator);
661
+ return `${body}${tip}`;
662
+ }
663
+ function createPadFunction() {
664
+ return (s, w) => s + " ".repeat(Math.max(0, w - s.length));
665
+ }
666
+ function formatHeaderLine(options) {
667
+ if (options.operation) {
668
+ return `${options.brand} ${options.operation} \u2192 ${options.intent}`;
669
+ }
670
+ return `${options.brand} ${options.intent}`;
671
+ }
672
+ function formatReadMoreLine(options) {
673
+ const pad = createPadFunction();
674
+ const labelPadded = pad("Read more", options.maxLabelWidth);
675
+ const valueColored = options.useColor ? blue(options.url) : options.url;
676
+ return `${options.formatDimText("\u2502")} ${labelPadded} ${valueColored}`;
677
+ }
678
+ function padToFixedWidth(text, width) {
679
+ const actualWidth = stringWidth(text);
680
+ const padding = Math.max(0, width - actualWidth);
681
+ return text + " ".repeat(padding);
682
+ }
683
+ function wrapTextAnsi(text, width) {
684
+ const wrapped = wrapAnsi(text, width, { hard: false, trim: true });
685
+ return wrapped.split("\n");
686
+ }
687
+ function formatDefaultValue(value, useColor) {
688
+ const valueStr = String(value);
689
+ const defaultText = `default: ${valueStr}`;
690
+ return useColor ? dim(defaultText) : defaultText;
691
+ }
692
+ function renderCommandTree(options) {
693
+ const { commands, useColor, formatDimText, hasItemsAfter, continuationPrefix } = options;
694
+ const lines = [];
695
+ if (commands.length === 0) {
696
+ return lines;
697
+ }
698
+ for (let i = 0; i < commands.length; i++) {
699
+ const cmd = commands[i];
700
+ if (!cmd) continue;
701
+ const subcommands = cmd.commands.filter((subcmd) => !subcmd.name().startsWith("_"));
702
+ const isLastCommand = i === commands.length - 1;
703
+ if (subcommands.length > 0) {
704
+ const prefix = isLastCommand && !hasItemsAfter ? formatDimText("\u2514") : formatDimText("\u251C");
705
+ const treePrefix = `${prefix}\u2500 `;
706
+ const treePrefixWidth = stringWidth(stripAnsi(treePrefix));
707
+ const remainingWidth = LEFT_COLUMN_WIDTH - treePrefixWidth;
708
+ const commandNamePadded = padToFixedWidth(cmd.name(), remainingWidth);
709
+ const commandNameColored = useColor ? cyan(commandNamePadded) : commandNamePadded;
710
+ lines.push(`${formatDimText("\u2502")} ${treePrefix}${commandNameColored}`);
711
+ for (let j = 0; j < subcommands.length; j++) {
712
+ const subcmd = subcommands[j];
713
+ if (!subcmd) continue;
714
+ const isLastSubcommand = j === subcommands.length - 1;
715
+ const shortDescription = subcmd.description() || "";
716
+ const treeChar = isLastSubcommand ? "\u2514" : "\u251C";
717
+ const continuation = continuationPrefix ?? (isLastCommand && isLastSubcommand && !hasItemsAfter ? " " : formatDimText("\u2502"));
718
+ const continuationStr = continuation === " " ? " " : continuation;
719
+ const subTreePrefix = `${continuationStr} ${formatDimText(treeChar)}\u2500 `;
720
+ const subTreePrefixWidth = stringWidth(stripAnsi(subTreePrefix));
721
+ const subRemainingWidth = LEFT_COLUMN_WIDTH - subTreePrefixWidth;
722
+ const subcommandNamePadded = padToFixedWidth(subcmd.name(), subRemainingWidth);
723
+ const subcommandNameColored = useColor ? cyan(subcommandNamePadded) : subcommandNamePadded;
724
+ lines.push(
725
+ `${formatDimText("\u2502")} ${subTreePrefix}${subcommandNameColored} ${shortDescription}`
726
+ );
727
+ }
728
+ } else {
729
+ const prefix = isLastCommand && !hasItemsAfter ? formatDimText("\u2514") : formatDimText("\u251C");
730
+ const treePrefix = `${prefix}\u2500 `;
731
+ const treePrefixWidth = stringWidth(stripAnsi(treePrefix));
732
+ const remainingWidth = LEFT_COLUMN_WIDTH - treePrefixWidth;
733
+ const commandNamePadded = padToFixedWidth(cmd.name(), remainingWidth);
734
+ const commandNameColored = useColor ? cyan(commandNamePadded) : commandNamePadded;
735
+ const shortDescription = cmd.description() || "";
736
+ lines.push(`${formatDimText("\u2502")} ${treePrefix}${commandNameColored} ${shortDescription}`);
737
+ }
738
+ }
739
+ return lines;
740
+ }
741
+ function formatMultilineDescription(options) {
742
+ const lines = [];
743
+ const formatGreen = (text) => options.useColor ? green(text) : text;
744
+ const rightColumnWidth = calculateRightColumnWidth();
745
+ const totalWidth = 2 + LEFT_COLUMN_WIDTH + 2 + rightColumnWidth;
746
+ const wrapWidth = totalWidth - 2;
747
+ for (const descLine of options.descriptionLines) {
748
+ const formattedLine = descLine.replace(/Prisma Next/g, (match) => formatGreen(match));
749
+ const wrappedLines = wrapTextAnsi(formattedLine, wrapWidth);
750
+ for (const wrappedLine of wrappedLines) {
751
+ lines.push(`${options.formatDimText("\u2502")} ${wrappedLine}`);
752
+ }
753
+ }
754
+ return lines;
755
+ }
756
+ function formatStyledHeader(options) {
757
+ const lines = [];
758
+ const useColor = options.flags.color !== false;
759
+ const formatDimText = (text) => formatDim(useColor, text);
760
+ const brand = createPrismaNextBadge(useColor);
761
+ const operation = useColor ? bold(options.command) : options.command;
762
+ const intent = formatDimText(options.description);
763
+ lines.push(formatHeaderLine({ brand, operation, intent }));
764
+ lines.push(formatDimText("\u2502"));
765
+ for (const detail of options.details) {
766
+ const labelWithColon = `${detail.label}:`;
767
+ const labelPadded = padToFixedWidth(labelWithColon, LEFT_COLUMN_WIDTH);
768
+ const labelColored = useColor ? cyan(labelPadded) : labelPadded;
769
+ lines.push(`${formatDimText("\u2502")} ${labelColored} ${detail.value}`);
770
+ }
771
+ if (options.url) {
772
+ lines.push(formatDimText("\u2502"));
773
+ lines.push(
774
+ formatReadMoreLine({
775
+ url: options.url,
776
+ maxLabelWidth: LEFT_COLUMN_WIDTH,
777
+ useColor,
778
+ formatDimText
779
+ })
780
+ );
781
+ }
782
+ lines.push(formatDimText("\u2514"));
783
+ return `${lines.join("\n")}
784
+ `;
785
+ }
786
+ function formatSuccessMessage(flags) {
787
+ const useColor = flags.color !== false;
788
+ const formatGreen = createColorFormatter(useColor, green);
789
+ return `${formatGreen("\u2714")} Success`;
790
+ }
791
+ function getCommandDocsUrl(commandPath) {
792
+ const docsMap = {
793
+ "contract emit": "https://pris.ly/contract-emit",
794
+ "db verify": "https://pris.ly/db-verify"
795
+ };
796
+ return docsMap[commandPath];
797
+ }
798
+ function buildCommandPath(command) {
799
+ const parts = [];
800
+ let current = command;
801
+ while (current && current.name() !== "prisma-next") {
802
+ parts.unshift(current.name());
803
+ current = current.parent ?? void 0;
804
+ }
805
+ return parts.join(" ");
806
+ }
807
+ function formatCommandHelp(options) {
808
+ const { command, flags } = options;
809
+ const lines = [];
810
+ const useColor = flags.color !== false;
811
+ const formatDimText = (text) => formatDim(useColor, text);
812
+ const commandPath = buildCommandPath(command);
813
+ const shortDescription = command.description() || "";
814
+ const longDescription = getLongDescription(command);
815
+ const brand = createPrismaNextBadge(useColor);
816
+ const operation = useColor ? bold(commandPath) : commandPath;
817
+ const intent = formatDimText(shortDescription);
818
+ lines.push(formatHeaderLine({ brand, operation, intent }));
819
+ lines.push(formatDimText("\u2502"));
820
+ const optionsList = command.options.map((opt) => {
821
+ const flags2 = opt.flags;
822
+ const description = opt.description || "";
823
+ const defaultValue = opt.defaultValue;
824
+ return { flags: flags2, description, defaultValue };
825
+ });
826
+ const subcommands = command.commands.filter((cmd) => !cmd.name().startsWith("_"));
827
+ if (subcommands.length > 0) {
828
+ const hasItemsAfter = optionsList.length > 0;
829
+ const treeLines = renderCommandTree({
830
+ commands: subcommands,
831
+ useColor,
832
+ formatDimText,
833
+ hasItemsAfter
834
+ });
835
+ lines.push(...treeLines);
836
+ }
837
+ if (subcommands.length > 0 && optionsList.length > 0) {
838
+ lines.push(formatDimText("\u2502"));
839
+ }
840
+ if (optionsList.length > 0) {
841
+ for (const opt of optionsList) {
842
+ const flagsPadded = padToFixedWidth(opt.flags, LEFT_COLUMN_WIDTH);
843
+ let flagsColored = flagsPadded;
844
+ if (useColor) {
845
+ flagsColored = flagsPadded.replace(/(<[^>]+>)/g, (match) => magenta(match));
846
+ flagsColored = cyan(flagsColored);
847
+ }
848
+ const rightColumnWidth = calculateRightColumnWidth();
849
+ const wrappedDescription = wrapTextAnsi(opt.description, rightColumnWidth);
850
+ lines.push(`${formatDimText("\u2502")} ${flagsColored} ${wrappedDescription[0] || ""}`);
851
+ for (let i = 1; i < wrappedDescription.length; i++) {
852
+ const emptyLabel = " ".repeat(LEFT_COLUMN_WIDTH);
853
+ lines.push(`${formatDimText("\u2502")} ${emptyLabel} ${wrappedDescription[i] || ""}`);
854
+ }
855
+ if (opt.defaultValue !== void 0) {
856
+ const emptyLabel = " ".repeat(LEFT_COLUMN_WIDTH);
857
+ const defaultText = formatDefaultValue(opt.defaultValue, useColor);
858
+ lines.push(`${formatDimText("\u2502")} ${emptyLabel} ${defaultText}`);
859
+ }
860
+ }
861
+ }
862
+ const docsUrl = getCommandDocsUrl(commandPath);
863
+ if (docsUrl) {
864
+ lines.push(formatDimText("\u2502"));
865
+ lines.push(
866
+ formatReadMoreLine({
867
+ url: docsUrl,
868
+ maxLabelWidth: LEFT_COLUMN_WIDTH,
869
+ useColor,
870
+ formatDimText
871
+ })
872
+ );
873
+ }
874
+ if (longDescription) {
875
+ lines.push(formatDimText("\u2502"));
876
+ const descriptionLines = longDescription.split("\n").filter((line) => line.trim().length > 0);
877
+ lines.push(...formatMultilineDescription({ descriptionLines, useColor, formatDimText }));
878
+ }
879
+ lines.push(formatDimText("\u2514"));
880
+ return `${lines.join("\n")}
881
+ `;
882
+ }
883
+
884
+ // src/utils/progress-adapter.ts
885
+ import ora from "ora";
886
+ function createProgressAdapter(options) {
887
+ const { flags } = options;
888
+ const shouldShowProgress = !flags.quiet && flags.json !== "object" && process.stdout.isTTY;
889
+ if (!shouldShowProgress) {
890
+ return () => {
891
+ };
892
+ }
893
+ const activeSpans = /* @__PURE__ */ new Map();
894
+ return (event) => {
895
+ if (event.kind === "spanStart") {
896
+ if (event.parentSpanId) {
897
+ console.log(` \u2192 ${event.label}...`);
898
+ return;
899
+ }
900
+ const spinner = ora({
901
+ text: event.label,
902
+ color: flags.color !== false ? "cyan" : false
903
+ }).start();
904
+ activeSpans.set(event.spanId, {
905
+ spinner,
906
+ startTime: Date.now()
907
+ });
908
+ } else if (event.kind === "spanEnd") {
909
+ const spanState = activeSpans.get(event.spanId);
910
+ if (spanState) {
911
+ const elapsed = Date.now() - spanState.startTime;
912
+ if (event.outcome === "error") {
913
+ spanState.spinner.fail(`${spanState.spinner.text} (failed)`);
914
+ } else if (event.outcome === "skipped") {
915
+ spanState.spinner.info(`${spanState.spinner.text} (skipped)`);
916
+ } else {
917
+ spanState.spinner.succeed(`${spanState.spinner.text} (${elapsed}ms)`);
918
+ }
919
+ activeSpans.delete(event.spanId);
920
+ }
921
+ }
922
+ };
923
+ }
924
+
925
+ // src/utils/result-handler.ts
926
+ function handleResult(result, flags, onSuccess) {
927
+ if (result.ok) {
928
+ if (onSuccess) {
929
+ onSuccess(result.value);
930
+ }
931
+ return 0;
932
+ }
933
+ const envelope = result.failure.toEnvelope();
934
+ if (flags.json) {
935
+ console.error(formatErrorJson(envelope));
936
+ } else {
937
+ console.error(formatErrorOutput(envelope, flags));
938
+ }
939
+ const exitCode = result.failure.domain === "CLI" ? 2 : 1;
940
+ return exitCode;
941
+ }
942
+
943
+ export {
944
+ setCommandDescriptions,
945
+ parseGlobalFlags,
946
+ formatEmitOutput,
947
+ formatEmitJson,
948
+ formatVerifyOutput,
949
+ formatVerifyJson,
950
+ formatIntrospectJson,
951
+ formatIntrospectOutput,
952
+ formatSchemaVerifyOutput,
953
+ formatSchemaVerifyJson,
954
+ formatSignOutput,
955
+ formatSignJson,
956
+ formatDbInitPlanOutput,
957
+ formatDbInitApplyOutput,
958
+ formatDbInitJson,
959
+ formatStyledHeader,
960
+ formatSuccessMessage,
961
+ formatCommandHelp,
962
+ createProgressAdapter,
963
+ handleResult
964
+ };
965
+ //# sourceMappingURL=chunk-AGOTG4L3.js.map