@prisma/cli 3.0.0-dev.74.1 → 3.0.0-dev.75.1
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.
|
@@ -69,7 +69,7 @@ function createDatabaseCreateCommand(runtime) {
|
|
|
69
69
|
region
|
|
70
70
|
}), {
|
|
71
71
|
renderStdout: (context, descriptor, result) => renderDatabaseCreateStdout(context, descriptor, result),
|
|
72
|
-
renderHuman: () => renderDatabaseCreate(),
|
|
72
|
+
renderHuman: (context, descriptor, result) => renderDatabaseCreate(context, descriptor, result),
|
|
73
73
|
renderJson: (result) => serializeDatabaseCreate(result)
|
|
74
74
|
});
|
|
75
75
|
});
|
|
@@ -136,7 +136,7 @@ function createDatabaseConnectionCreateCommand(runtime) {
|
|
|
136
136
|
name
|
|
137
137
|
}), {
|
|
138
138
|
renderStdout: (context, descriptor, result) => renderDatabaseConnectionCreateStdout(context, descriptor, result),
|
|
139
|
-
renderHuman: () => renderDatabaseConnectionCreate(),
|
|
139
|
+
renderHuman: (context, descriptor, result) => renderDatabaseConnectionCreate(context, descriptor, result),
|
|
140
140
|
renderJson: (result) => serializeDatabaseConnectionCreate(result)
|
|
141
141
|
});
|
|
142
142
|
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { formatColumns } from "../shell/ui.js";
|
|
1
|
+
import { formatColumns, renderSummaryLine } from "../shell/ui.js";
|
|
2
2
|
import { formatDescriptorLabel } from "../shell/command-meta.js";
|
|
3
3
|
import { renderMutate, renderShow, serializeList } from "../output/patterns.js";
|
|
4
4
|
import { renderResolvedProjectContextBlock, stripVerboseContext } from "./verbose-context.js";
|
|
@@ -106,8 +106,18 @@ function serializeDatabaseShow(result) {
|
|
|
106
106
|
function renderDatabaseCreateStdout(_context, _descriptor, result) {
|
|
107
107
|
return [result.connectionString];
|
|
108
108
|
}
|
|
109
|
-
function renderDatabaseCreate() {
|
|
110
|
-
|
|
109
|
+
function renderDatabaseCreate(context, _descriptor, result) {
|
|
110
|
+
const ui = context.ui;
|
|
111
|
+
const lines = [
|
|
112
|
+
"Creating database...",
|
|
113
|
+
renderSummaryLine(ui, "success", `Created database "${result.database.name}" in ${formatDatabaseTarget(result.projectName, result.database.branchName)}.`),
|
|
114
|
+
" The connection URL below is shown once, so save it now."
|
|
115
|
+
];
|
|
116
|
+
if (ui.verbose) {
|
|
117
|
+
lines.push("");
|
|
118
|
+
lines.push(...renderDatabaseCreateVerboseRows(context, result));
|
|
119
|
+
}
|
|
120
|
+
return lines;
|
|
111
121
|
}
|
|
112
122
|
function serializeDatabaseCreate(result) {
|
|
113
123
|
return stripVerboseContext(result);
|
|
@@ -193,8 +203,18 @@ function serializeDatabaseConnectionList(result) {
|
|
|
193
203
|
function renderDatabaseConnectionCreateStdout(_context, _descriptor, result) {
|
|
194
204
|
return [result.connectionString];
|
|
195
205
|
}
|
|
196
|
-
function renderDatabaseConnectionCreate() {
|
|
197
|
-
|
|
206
|
+
function renderDatabaseConnectionCreate(context, _descriptor, result) {
|
|
207
|
+
const ui = context.ui;
|
|
208
|
+
const lines = [
|
|
209
|
+
"Creating connection...",
|
|
210
|
+
renderSummaryLine(ui, "success", `Added a connection to "${result.database.name}" in ${formatDatabaseTarget(result.projectName, result.database.branchName)}.`),
|
|
211
|
+
" The connection URL below is shown once, so save it now."
|
|
212
|
+
];
|
|
213
|
+
if (ui.verbose) {
|
|
214
|
+
lines.push("");
|
|
215
|
+
lines.push(...renderDatabaseConnectionCreateVerboseRows(context, result));
|
|
216
|
+
}
|
|
217
|
+
return lines;
|
|
198
218
|
}
|
|
199
219
|
function serializeDatabaseConnectionCreate(result) {
|
|
200
220
|
return stripVerboseContext(result);
|
|
@@ -219,5 +239,36 @@ function serializeDatabaseConnectionRemove(result) {
|
|
|
219
239
|
function formatStatus(database) {
|
|
220
240
|
return database.status ?? (database.isDefault ? "default" : "unknown");
|
|
221
241
|
}
|
|
242
|
+
function formatDatabaseTarget(projectName, branchName) {
|
|
243
|
+
return branchName ? `${projectName} / ${branchName}` : projectName;
|
|
244
|
+
}
|
|
245
|
+
function renderDatabaseCreateVerboseRows(context, result) {
|
|
246
|
+
return renderMetadataRows([
|
|
247
|
+
...renderWorkspaceProjectRows(result),
|
|
248
|
+
["branch", result.database.branchName ?? "unscoped"],
|
|
249
|
+
["database", formatResourceWithId(context, result.database.name, result.database.id)],
|
|
250
|
+
["region", result.database.region ?? "unknown"],
|
|
251
|
+
["status", formatStatus(result.database)],
|
|
252
|
+
["connection", formatResourceWithId(context, result.connection.name, result.connection.id)]
|
|
253
|
+
]);
|
|
254
|
+
}
|
|
255
|
+
function renderDatabaseConnectionCreateVerboseRows(context, result) {
|
|
256
|
+
return renderMetadataRows([
|
|
257
|
+
...renderWorkspaceProjectRows(result),
|
|
258
|
+
["branch", result.database.branchName ?? "unscoped"],
|
|
259
|
+
["database", formatResourceWithId(context, result.database.name, result.database.id)],
|
|
260
|
+
["connection", formatResourceWithId(context, result.connection.name, result.connection.id)]
|
|
261
|
+
]);
|
|
262
|
+
}
|
|
263
|
+
function renderWorkspaceProjectRows(result) {
|
|
264
|
+
return [...result.verboseContext ? [["workspace", result.verboseContext.workspace.name]] : [], ["project", result.projectName]];
|
|
265
|
+
}
|
|
266
|
+
function formatResourceWithId(context, name, id) {
|
|
267
|
+
return `${name} ${context.ui.dim(`(${id})`)}`;
|
|
268
|
+
}
|
|
269
|
+
function renderMetadataRows(rows) {
|
|
270
|
+
const widths = [Math.max(...rows.map((row) => row[0].length)), 0];
|
|
271
|
+
return rows.map(([key, value]) => ` ${formatColumns([key, value], widths)}`);
|
|
272
|
+
}
|
|
222
273
|
//#endregion
|
|
223
274
|
export { renderDatabaseConnectionCreate, renderDatabaseConnectionCreateStdout, renderDatabaseConnectionList, renderDatabaseConnectionRemove, renderDatabaseCreate, renderDatabaseCreateStdout, renderDatabaseList, renderDatabaseRemove, renderDatabaseShow, serializeDatabaseConnectionCreate, serializeDatabaseConnectionList, serializeDatabaseConnectionRemove, serializeDatabaseCreate, serializeDatabaseList, serializeDatabaseRemove, serializeDatabaseShow };
|
|
@@ -32,14 +32,19 @@ async function runCommand(runtime, commandName, options, handler, presenter) {
|
|
|
32
32
|
return;
|
|
33
33
|
}
|
|
34
34
|
const stdout = presenter.renderStdout?.(context, descriptor, success.result) ?? [];
|
|
35
|
-
if (
|
|
36
|
-
|
|
35
|
+
if (flags.quiet) {
|
|
36
|
+
if (stdout.length > 0) context.output.stdout.write(`${stdout.join("\n")}\n`);
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
37
39
|
const rendered = presenter.renderHuman(context, descriptor, success.result);
|
|
38
40
|
const diagnostics = await renderBestEffortCommandDiagnostics(context, {
|
|
39
41
|
enabled: flags.verbose && rendered.length > 0,
|
|
40
42
|
durationMs: Date.now() - startedAt
|
|
41
43
|
});
|
|
42
|
-
|
|
44
|
+
const humanLines = [...rendered, ...diagnostics];
|
|
45
|
+
if (stdout.length > 0 && humanLines.length > 0) humanLines.push("");
|
|
46
|
+
writeHumanLines(context.output, humanLines);
|
|
47
|
+
if (stdout.length > 0) context.output.stdout.write(`${stdout.join("\n")}\n`);
|
|
43
48
|
} catch (error) {
|
|
44
49
|
const cliError = toCliError(error, runtime);
|
|
45
50
|
if (cliError) {
|