@prisma/cli 3.0.0-beta.8 → 3.0.0-dev.101.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.
- package/README.md +0 -13
- package/dist/adapters/mock-api.js +75 -0
- package/dist/adapters/token-storage.js +311 -33
- package/dist/cli.js +7 -7
- package/dist/cli2.js +5 -3
- package/dist/commands/app/index.js +65 -52
- package/dist/commands/auth/index.js +55 -2
- package/dist/commands/database/index.js +159 -0
- package/dist/controllers/app-env.js +10 -7
- package/dist/controllers/app.js +550 -208
- package/dist/controllers/auth.js +211 -2
- package/dist/controllers/branch.js +5 -6
- package/dist/controllers/database.js +318 -0
- package/dist/controllers/project.js +49 -20
- package/dist/lib/app/app-interaction.js +5 -0
- package/dist/lib/app/{preview-provider.js → app-provider.js} +32 -28
- package/dist/lib/app/{preview-branch-database.js → branch-database-api.js} +1 -1
- package/dist/lib/app/branch-database-deploy.js +13 -60
- package/dist/lib/app/branch-database.js +1 -102
- package/dist/lib/app/build-settings.js +93 -0
- package/dist/lib/app/build.js +82 -0
- package/dist/lib/app/bun-project.js +2 -3
- package/dist/lib/app/compute-config.js +147 -0
- package/dist/lib/app/deploy-plan.js +58 -0
- package/dist/lib/app/{preview-progress.js → deploy-progress.js} +5 -5
- package/dist/lib/app/local-dev.js +3 -60
- package/dist/lib/app/production-deploy-gate.js +3 -3
- package/dist/lib/app/read-branch.js +30 -0
- package/dist/lib/auth/auth-ops.js +10 -4
- package/dist/lib/auth/guard.js +4 -1
- package/dist/lib/auth/login.js +32 -25
- package/dist/lib/database/provider.js +167 -0
- package/dist/lib/diagnostics.js +1 -1
- package/dist/lib/fs/home-path.js +24 -0
- package/dist/lib/git/local-branch.js +15 -3
- package/dist/lib/project/local-pin.js +170 -40
- package/dist/lib/project/resolution.js +166 -61
- package/dist/lib/project/setup.js +65 -19
- package/dist/output/patterns.js +1 -1
- package/dist/presenters/app.js +44 -39
- package/dist/presenters/auth.js +98 -1
- package/dist/presenters/branch.js +1 -1
- package/dist/presenters/database.js +274 -0
- package/dist/presenters/project.js +3 -9
- package/dist/shell/command-meta.js +153 -2
- package/dist/shell/command-runner.js +39 -21
- package/dist/shell/diagnostics-output.js +2 -8
- package/dist/shell/errors.js +50 -1
- package/dist/shell/help.js +30 -20
- package/dist/shell/runtime.js +8 -4
- package/dist/shell/ui.js +19 -2
- package/dist/use-cases/auth.js +68 -1
- package/package.json +18 -3
- package/dist/lib/app/preview-build-settings.js +0 -385
- package/dist/lib/app/preview-build.js +0 -475
- package/dist/lib/app/preview-interaction.js +0 -5
package/dist/presenters/auth.js
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
|
+
import { formatDescriptorLabel } from "../shell/command-meta.js";
|
|
2
|
+
import { padDisplay } from "../shell/ui.js";
|
|
1
3
|
import { renderMutate, renderShow } from "../output/patterns.js";
|
|
4
|
+
import stringWidth from "string-width";
|
|
2
5
|
//#region src/presenters/auth.ts
|
|
3
6
|
function renderAuthSuccess(context, descriptor, command, result) {
|
|
4
7
|
if (command === "auth.login") {
|
|
@@ -62,11 +65,105 @@ function renderAuthSuccess(context, descriptor, command, result) {
|
|
|
62
65
|
}]
|
|
63
66
|
}, context.ui);
|
|
64
67
|
}
|
|
68
|
+
function renderAuthWorkspaceList(context, descriptor, result) {
|
|
69
|
+
const ui = context.ui;
|
|
70
|
+
const rail = ui.dim("│");
|
|
71
|
+
const lines = [
|
|
72
|
+
`${ui.strong(formatDescriptorLabel(descriptor))} ${ui.dim("→")} ${ui.dim("Listing authenticated workspaces on this machine.")}`,
|
|
73
|
+
"",
|
|
74
|
+
`${rail} ${ui.accent("auth source:")} ${authSourceLabel(result.authSource)}`
|
|
75
|
+
];
|
|
76
|
+
const hasMixedSources = new Set(result.workspaces.map((workspace) => workspace.source)).size > 1;
|
|
77
|
+
if (result.workspaces.length === 0) {
|
|
78
|
+
lines.push(`${rail} ${ui.dim("No local OAuth workspaces found.")}`);
|
|
79
|
+
return lines;
|
|
80
|
+
}
|
|
81
|
+
const nameWidth = Math.max(4, ...result.workspaces.map((workspace) => stringWidth(workspace.name)));
|
|
82
|
+
const idWidth = Math.max(2, ...result.workspaces.map((workspace) => stringWidth(workspace.id)));
|
|
83
|
+
const sourceWidth = hasMixedSources ? Math.max(6, ...result.workspaces.map((workspace) => stringWidth(workspaceSourceLabel(workspace.source)))) : 0;
|
|
84
|
+
lines.push(rail);
|
|
85
|
+
lines.push(hasMixedSources ? `${rail} ${ui.accent(padDisplay("name", nameWidth))} ${ui.accent(padDisplay("id", idWidth))} ${ui.accent(padDisplay("source", sourceWidth))} ${ui.accent("status")}` : `${rail} ${ui.accent(padDisplay("name", nameWidth))} ${ui.accent(padDisplay("id", idWidth))} ${ui.accent("status")}`);
|
|
86
|
+
for (const workspace of result.workspaces) {
|
|
87
|
+
const status = workspace.active ? "active" : "";
|
|
88
|
+
const source = workspaceSourceLabel(workspace.source);
|
|
89
|
+
lines.push(hasMixedSources ? `${rail} ${padDisplay(workspace.name, nameWidth)} ${padDisplay(workspace.id, idWidth)} ${padDisplay(source, sourceWidth)} ${status}` : `${rail} ${padDisplay(workspace.name, nameWidth)} ${padDisplay(workspace.id, idWidth)} ${status}`);
|
|
90
|
+
}
|
|
91
|
+
return lines;
|
|
92
|
+
}
|
|
93
|
+
function serializeAuthWorkspaceList(result) {
|
|
94
|
+
return {
|
|
95
|
+
context: {
|
|
96
|
+
authSource: result.authSource,
|
|
97
|
+
activeWorkspaceId: result.activeWorkspace?.id ?? null,
|
|
98
|
+
activeWorkspaceName: result.activeWorkspace?.name ?? null
|
|
99
|
+
},
|
|
100
|
+
items: result.workspaces.map((workspace) => ({
|
|
101
|
+
id: workspace.id,
|
|
102
|
+
name: workspace.name,
|
|
103
|
+
status: workspace.active ? "active" : null,
|
|
104
|
+
source: workspace.source,
|
|
105
|
+
switchable: workspace.switchable,
|
|
106
|
+
credentialWorkspaceId: workspace.credentialWorkspaceId,
|
|
107
|
+
lastSeenAt: workspace.lastSeenAt
|
|
108
|
+
})),
|
|
109
|
+
count: result.workspaces.length
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
function renderAuthWorkspaceUse(context, descriptor, result) {
|
|
113
|
+
return renderMutate({
|
|
114
|
+
title: "Switching the local CLI workspace.",
|
|
115
|
+
descriptor,
|
|
116
|
+
context: [...result.previousWorkspace ? [{
|
|
117
|
+
key: "previous",
|
|
118
|
+
value: result.previousWorkspace.name
|
|
119
|
+
}] : [], {
|
|
120
|
+
key: "workspace",
|
|
121
|
+
value: result.workspace.name
|
|
122
|
+
}],
|
|
123
|
+
operationDescription: "Applying workspace selection",
|
|
124
|
+
operationCount: 1,
|
|
125
|
+
details: ["Local OAuth workspace selection updated."]
|
|
126
|
+
}, context.ui);
|
|
127
|
+
}
|
|
128
|
+
function serializeAuthWorkspaceUse(result) {
|
|
129
|
+
return result;
|
|
130
|
+
}
|
|
131
|
+
function renderAuthWorkspaceLogout(context, descriptor, result) {
|
|
132
|
+
return renderMutate({
|
|
133
|
+
title: "Removing a local OAuth workspace session.",
|
|
134
|
+
descriptor,
|
|
135
|
+
context: [{
|
|
136
|
+
key: "workspace",
|
|
137
|
+
value: result.workspace.name
|
|
138
|
+
}, ...result.activeWorkspace ? [{
|
|
139
|
+
key: "active",
|
|
140
|
+
value: result.activeWorkspace.name
|
|
141
|
+
}] : [{
|
|
142
|
+
key: "active",
|
|
143
|
+
value: "none",
|
|
144
|
+
tone: "dim"
|
|
145
|
+
}]],
|
|
146
|
+
operationDescription: "Removing workspace session",
|
|
147
|
+
operationCount: 1,
|
|
148
|
+
details: [result.wasActive ? "Removed active workspace session; no replacement workspace was selected." : "Removed workspace session."]
|
|
149
|
+
}, context.ui);
|
|
150
|
+
}
|
|
151
|
+
function serializeAuthWorkspaceLogout(result) {
|
|
152
|
+
return result;
|
|
153
|
+
}
|
|
65
154
|
function providerLabel(provider) {
|
|
66
155
|
if (provider === "github") return "GitHub";
|
|
67
156
|
if (provider === "google") return "Google";
|
|
68
157
|
return "";
|
|
69
158
|
}
|
|
159
|
+
function authSourceLabel(source) {
|
|
160
|
+
if (source === "oauth") return "local OAuth";
|
|
161
|
+
if (source === "service_token") return "PRISMA_SERVICE_TOKEN";
|
|
162
|
+
return "none";
|
|
163
|
+
}
|
|
164
|
+
function workspaceSourceLabel(source) {
|
|
165
|
+
return source === "service_token" ? "service token" : "OAuth";
|
|
166
|
+
}
|
|
70
167
|
function authUserLabel(result) {
|
|
71
168
|
return result.user?.email ?? credentialUserLabel(result);
|
|
72
169
|
}
|
|
@@ -83,4 +180,4 @@ function credentialUserLabel(result) {
|
|
|
83
180
|
return null;
|
|
84
181
|
}
|
|
85
182
|
//#endregion
|
|
86
|
-
export { renderAuthSuccess };
|
|
183
|
+
export { renderAuthSuccess, renderAuthWorkspaceList, renderAuthWorkspaceLogout, renderAuthWorkspaceUse, serializeAuthWorkspaceList, serializeAuthWorkspaceLogout, serializeAuthWorkspaceUse };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { formatColumns } from "../shell/ui.js";
|
|
2
1
|
import { formatDescriptorLabel } from "../shell/command-meta.js";
|
|
2
|
+
import { formatColumns } from "../shell/ui.js";
|
|
3
3
|
import { renderResolvedProjectContextBlock } from "./verbose-context.js";
|
|
4
4
|
//#region src/presenters/branch.ts
|
|
5
5
|
function renderBranchList(context, descriptor, result) {
|
|
@@ -0,0 +1,274 @@
|
|
|
1
|
+
import { formatDescriptorLabel } from "../shell/command-meta.js";
|
|
2
|
+
import { formatColumns, renderSummaryLine } from "../shell/ui.js";
|
|
3
|
+
import { renderMutate, renderShow, serializeList } from "../output/patterns.js";
|
|
4
|
+
import { renderResolvedProjectContextBlock, stripVerboseContext } from "./verbose-context.js";
|
|
5
|
+
//#region src/presenters/database.ts
|
|
6
|
+
function renderDatabaseList(context, descriptor, result) {
|
|
7
|
+
const ui = context.ui;
|
|
8
|
+
const lines = [`${ui.strong(formatDescriptorLabel(descriptor))} ${ui.dim("→")} ${ui.dim("Listing databases for the resolved project.")}`, ""];
|
|
9
|
+
const rail = ui.dim("│");
|
|
10
|
+
lines.push(`${rail} ${ui.accent("project:")} ${result.projectName}`);
|
|
11
|
+
if (result.branchName) lines.push(`${rail} ${ui.accent("branch:")} ${result.branchName}`);
|
|
12
|
+
lines.push(rail);
|
|
13
|
+
if (result.databases.length === 0) {
|
|
14
|
+
lines.push(`${rail} ${ui.dim("No databases found.")}`);
|
|
15
|
+
lines.push(...renderResolvedProjectContextBlock(context.ui, result.verboseContext));
|
|
16
|
+
return lines;
|
|
17
|
+
}
|
|
18
|
+
const rows = result.databases.map((database) => [
|
|
19
|
+
database.name,
|
|
20
|
+
database.branchName ?? "unscoped",
|
|
21
|
+
database.region ?? "unknown",
|
|
22
|
+
formatStatus(database),
|
|
23
|
+
database.id
|
|
24
|
+
]);
|
|
25
|
+
const widths = [
|
|
26
|
+
Math.max(4, ...rows.map((row) => row[0].length)),
|
|
27
|
+
Math.max(6, ...rows.map((row) => row[1].length)),
|
|
28
|
+
Math.max(6, ...rows.map((row) => row[2].length)),
|
|
29
|
+
Math.max(6, ...rows.map((row) => row[3].length)),
|
|
30
|
+
Math.max(2, ...rows.map((row) => row[4].length))
|
|
31
|
+
];
|
|
32
|
+
lines.push(`${rail} ${ui.accent(formatColumns([
|
|
33
|
+
"Name",
|
|
34
|
+
"Branch",
|
|
35
|
+
"Region",
|
|
36
|
+
"Status",
|
|
37
|
+
"Id"
|
|
38
|
+
], widths))}`);
|
|
39
|
+
for (const row of rows) lines.push(`${rail} ${formatColumns(row, widths)}`);
|
|
40
|
+
lines.push(...renderResolvedProjectContextBlock(context.ui, result.verboseContext));
|
|
41
|
+
return lines;
|
|
42
|
+
}
|
|
43
|
+
function serializeDatabaseList(result) {
|
|
44
|
+
return {
|
|
45
|
+
...serializeList({
|
|
46
|
+
context: {
|
|
47
|
+
project: result.projectName,
|
|
48
|
+
...result.branchName ? { branch: result.branchName } : {}
|
|
49
|
+
},
|
|
50
|
+
items: result.databases.map((database) => ({
|
|
51
|
+
noun: "database",
|
|
52
|
+
label: database.name,
|
|
53
|
+
id: database.id,
|
|
54
|
+
status: database.isDefault ? "default" : null
|
|
55
|
+
}))
|
|
56
|
+
}),
|
|
57
|
+
projectId: result.projectId,
|
|
58
|
+
branchName: result.branchName,
|
|
59
|
+
databases: result.databases
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
function renderDatabaseShow(context, descriptor, result) {
|
|
63
|
+
const lines = renderShow({
|
|
64
|
+
title: "Showing database metadata.",
|
|
65
|
+
descriptor,
|
|
66
|
+
fields: [
|
|
67
|
+
{
|
|
68
|
+
key: "project",
|
|
69
|
+
value: result.projectName
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
key: "database",
|
|
73
|
+
value: result.database.name
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
key: "id",
|
|
77
|
+
value: result.database.id,
|
|
78
|
+
tone: "dim"
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
key: "branch",
|
|
82
|
+
value: result.database.branchName ?? "unscoped",
|
|
83
|
+
tone: result.database.branchName ? "default" : "dim"
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
key: "region",
|
|
87
|
+
value: result.database.region ?? "unknown",
|
|
88
|
+
tone: result.database.region ? "default" : "dim"
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
key: "status",
|
|
92
|
+
value: formatStatus(result.database)
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
key: "connections",
|
|
96
|
+
value: String(result.connections.length)
|
|
97
|
+
}
|
|
98
|
+
]
|
|
99
|
+
}, context.ui);
|
|
100
|
+
lines.push(...renderResolvedProjectContextBlock(context.ui, result.verboseContext));
|
|
101
|
+
return lines;
|
|
102
|
+
}
|
|
103
|
+
function serializeDatabaseShow(result) {
|
|
104
|
+
return stripVerboseContext(result);
|
|
105
|
+
}
|
|
106
|
+
function renderDatabaseCreateStdout(_context, _descriptor, result) {
|
|
107
|
+
return [result.connectionString];
|
|
108
|
+
}
|
|
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;
|
|
121
|
+
}
|
|
122
|
+
function serializeDatabaseCreate(result) {
|
|
123
|
+
return stripVerboseContext(result);
|
|
124
|
+
}
|
|
125
|
+
function renderDatabaseRemove(context, descriptor, result) {
|
|
126
|
+
const lines = renderMutate({
|
|
127
|
+
title: "Removing database.",
|
|
128
|
+
descriptor,
|
|
129
|
+
context: [
|
|
130
|
+
{
|
|
131
|
+
key: "project",
|
|
132
|
+
value: result.projectName
|
|
133
|
+
},
|
|
134
|
+
{
|
|
135
|
+
key: "database",
|
|
136
|
+
value: result.database.name
|
|
137
|
+
},
|
|
138
|
+
{
|
|
139
|
+
key: "id",
|
|
140
|
+
value: result.database.id,
|
|
141
|
+
tone: "dim"
|
|
142
|
+
}
|
|
143
|
+
],
|
|
144
|
+
operationDescription: "Removing database",
|
|
145
|
+
operationCount: 1,
|
|
146
|
+
details: ["Database and its connection metadata were removed."]
|
|
147
|
+
}, context.ui);
|
|
148
|
+
lines.push(...renderResolvedProjectContextBlock(context.ui, result.verboseContext));
|
|
149
|
+
return lines;
|
|
150
|
+
}
|
|
151
|
+
function serializeDatabaseRemove(result) {
|
|
152
|
+
return stripVerboseContext(result);
|
|
153
|
+
}
|
|
154
|
+
function renderDatabaseConnectionList(context, descriptor, result) {
|
|
155
|
+
const ui = context.ui;
|
|
156
|
+
const lines = [`${ui.strong(formatDescriptorLabel(descriptor))} ${ui.dim("→")} ${ui.dim("Listing database connection metadata.")}`, ""];
|
|
157
|
+
const rail = ui.dim("│");
|
|
158
|
+
lines.push(`${rail} ${ui.accent("database:")} ${result.database.name}`);
|
|
159
|
+
lines.push(rail);
|
|
160
|
+
if (result.connections.length === 0) {
|
|
161
|
+
lines.push(`${rail} ${ui.dim("No database connections found.")}`);
|
|
162
|
+
lines.push(...renderResolvedProjectContextBlock(context.ui, result.verboseContext));
|
|
163
|
+
return lines;
|
|
164
|
+
}
|
|
165
|
+
const rows = result.connections.map((connection) => [
|
|
166
|
+
connection.name,
|
|
167
|
+
connection.id,
|
|
168
|
+
connection.createdAt ?? "unknown"
|
|
169
|
+
]);
|
|
170
|
+
const widths = [
|
|
171
|
+
Math.max(4, ...rows.map((row) => row[0].length)),
|
|
172
|
+
Math.max(2, ...rows.map((row) => row[1].length)),
|
|
173
|
+
Math.max(7, ...rows.map((row) => row[2].length))
|
|
174
|
+
];
|
|
175
|
+
lines.push(`${rail} ${ui.accent(formatColumns([
|
|
176
|
+
"Name",
|
|
177
|
+
"Id",
|
|
178
|
+
"Created"
|
|
179
|
+
], widths))}`);
|
|
180
|
+
for (const row of rows) lines.push(`${rail} ${formatColumns(row, widths)}`);
|
|
181
|
+
lines.push(...renderResolvedProjectContextBlock(context.ui, result.verboseContext));
|
|
182
|
+
return lines;
|
|
183
|
+
}
|
|
184
|
+
function serializeDatabaseConnectionList(result) {
|
|
185
|
+
return {
|
|
186
|
+
...serializeList({
|
|
187
|
+
context: {
|
|
188
|
+
project: result.projectName,
|
|
189
|
+
database: result.database.name
|
|
190
|
+
},
|
|
191
|
+
items: result.connections.map((connection) => ({
|
|
192
|
+
noun: "connection",
|
|
193
|
+
label: connection.name,
|
|
194
|
+
id: connection.id,
|
|
195
|
+
status: null
|
|
196
|
+
}))
|
|
197
|
+
}),
|
|
198
|
+
projectId: result.projectId,
|
|
199
|
+
database: result.database,
|
|
200
|
+
connections: result.connections
|
|
201
|
+
};
|
|
202
|
+
}
|
|
203
|
+
function renderDatabaseConnectionCreateStdout(_context, _descriptor, result) {
|
|
204
|
+
return [result.connectionString];
|
|
205
|
+
}
|
|
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;
|
|
218
|
+
}
|
|
219
|
+
function serializeDatabaseConnectionCreate(result) {
|
|
220
|
+
return stripVerboseContext(result);
|
|
221
|
+
}
|
|
222
|
+
function renderDatabaseConnectionRemove(context, descriptor, result) {
|
|
223
|
+
return renderMutate({
|
|
224
|
+
title: "Removing database connection.",
|
|
225
|
+
descriptor,
|
|
226
|
+
context: [{
|
|
227
|
+
key: "connection",
|
|
228
|
+
value: result.connection.id,
|
|
229
|
+
tone: "dim"
|
|
230
|
+
}],
|
|
231
|
+
operationDescription: "Removing database connection",
|
|
232
|
+
operationCount: 1,
|
|
233
|
+
details: ["The connection metadata was removed. Existing one-time secrets were not shown."]
|
|
234
|
+
}, context.ui);
|
|
235
|
+
}
|
|
236
|
+
function serializeDatabaseConnectionRemove(result) {
|
|
237
|
+
return { connection: result.connection };
|
|
238
|
+
}
|
|
239
|
+
function formatStatus(database) {
|
|
240
|
+
return database.status ?? (database.isDefault ? "default" : "unknown");
|
|
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
|
+
}
|
|
273
|
+
//#endregion
|
|
274
|
+
export { renderDatabaseConnectionCreate, renderDatabaseConnectionCreateStdout, renderDatabaseConnectionList, renderDatabaseConnectionRemove, renderDatabaseCreate, renderDatabaseCreateStdout, renderDatabaseList, renderDatabaseRemove, renderDatabaseShow, serializeDatabaseConnectionCreate, serializeDatabaseConnectionList, serializeDatabaseConnectionRemove, serializeDatabaseCreate, serializeDatabaseList, serializeDatabaseRemove, serializeDatabaseShow };
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { padDisplay, renderNextSteps, renderSummaryLine, renderVerboseBlock } from "../shell/ui.js";
|
|
2
1
|
import { formatDescriptorLabel } from "../shell/command-meta.js";
|
|
2
|
+
import { padDisplay, renderNextSteps, renderSummaryLine, renderVerboseBlock } from "../shell/ui.js";
|
|
3
|
+
import { shortenHomePath } from "../lib/fs/home-path.js";
|
|
3
4
|
import { formatCommandArgument } from "../shell/command-arguments.js";
|
|
4
5
|
import { renderMutate, renderShow, serializeList } from "../output/patterns.js";
|
|
5
6
|
import { renderResolvedProjectContextBlock } from "./verbose-context.js";
|
|
6
|
-
import path from "node:path";
|
|
7
7
|
import stringWidth from "string-width";
|
|
8
8
|
//#region src/presenters/project.ts
|
|
9
9
|
function renderProjectList(context, descriptor, result) {
|
|
@@ -160,13 +160,7 @@ function renderBoundProjectShow(context, descriptor, result) {
|
|
|
160
160
|
return lines;
|
|
161
161
|
}
|
|
162
162
|
function formatLocalRepoPath(cwd, env) {
|
|
163
|
-
|
|
164
|
-
const home = env.HOME ? path.resolve(env.HOME) : null;
|
|
165
|
-
if (home && (resolved === home || resolved.startsWith(`${home}${path.sep}`))) {
|
|
166
|
-
const relative = path.relative(home, resolved);
|
|
167
|
-
return relative ? `~/${relative}` : "~";
|
|
168
|
-
}
|
|
169
|
-
return resolved;
|
|
163
|
+
return shortenHomePath(cwd, env);
|
|
170
164
|
}
|
|
171
165
|
function formatGitConnectionDetail(status) {
|
|
172
166
|
switch (status) {
|
|
@@ -50,6 +50,58 @@ const DESCRIPTORS = [
|
|
|
50
50
|
description: "Show the authenticated user and accessible workspace",
|
|
51
51
|
examples: ["prisma-cli auth whoami", "prisma-cli auth whoami --json"]
|
|
52
52
|
},
|
|
53
|
+
{
|
|
54
|
+
id: "auth.workspace",
|
|
55
|
+
path: [
|
|
56
|
+
"prisma",
|
|
57
|
+
"auth",
|
|
58
|
+
"workspace"
|
|
59
|
+
],
|
|
60
|
+
description: "Manage local authenticated workspaces",
|
|
61
|
+
examples: [
|
|
62
|
+
"prisma-cli auth workspace list",
|
|
63
|
+
"prisma-cli auth workspace use",
|
|
64
|
+
"prisma-cli auth workspace use wksp_123",
|
|
65
|
+
"prisma-cli auth workspace logout wksp_123"
|
|
66
|
+
]
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
id: "auth.workspace.list",
|
|
70
|
+
path: [
|
|
71
|
+
"prisma",
|
|
72
|
+
"auth",
|
|
73
|
+
"workspace",
|
|
74
|
+
"list"
|
|
75
|
+
],
|
|
76
|
+
description: "List locally authenticated workspaces",
|
|
77
|
+
examples: ["prisma-cli auth workspace list", "prisma-cli auth workspace list --json"]
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
id: "auth.workspace.use",
|
|
81
|
+
path: [
|
|
82
|
+
"prisma",
|
|
83
|
+
"auth",
|
|
84
|
+
"workspace",
|
|
85
|
+
"use"
|
|
86
|
+
],
|
|
87
|
+
description: "Switch the local CLI workspace",
|
|
88
|
+
examples: [
|
|
89
|
+
"prisma-cli auth workspace use",
|
|
90
|
+
"prisma-cli auth workspace use wksp_123",
|
|
91
|
+
"prisma-cli auth workspace use \"Acme Inc\""
|
|
92
|
+
]
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
id: "auth.workspace.logout",
|
|
96
|
+
path: [
|
|
97
|
+
"prisma",
|
|
98
|
+
"auth",
|
|
99
|
+
"workspace",
|
|
100
|
+
"logout"
|
|
101
|
+
],
|
|
102
|
+
description: "Remove one local OAuth workspace session",
|
|
103
|
+
examples: ["prisma-cli auth workspace logout wksp_123", "prisma-cli auth workspace logout \"Acme Inc\""]
|
|
104
|
+
},
|
|
53
105
|
{
|
|
54
106
|
id: "project",
|
|
55
107
|
path: ["prisma", "project"],
|
|
@@ -72,6 +124,16 @@ const DESCRIPTORS = [
|
|
|
72
124
|
description: "View your Platform branches",
|
|
73
125
|
examples: ["prisma-cli branch list"]
|
|
74
126
|
},
|
|
127
|
+
{
|
|
128
|
+
id: "database",
|
|
129
|
+
path: ["prisma", "database"],
|
|
130
|
+
description: "Manage Prisma Postgres databases for a project",
|
|
131
|
+
examples: [
|
|
132
|
+
"prisma-cli database list",
|
|
133
|
+
"prisma-cli database create my-db",
|
|
134
|
+
"prisma-cli database connection create db_123"
|
|
135
|
+
]
|
|
136
|
+
},
|
|
75
137
|
{
|
|
76
138
|
id: "git",
|
|
77
139
|
path: ["prisma", "git"],
|
|
@@ -156,6 +218,97 @@ const DESCRIPTORS = [
|
|
|
156
218
|
description: "List Platform branches for the resolved project",
|
|
157
219
|
examples: ["prisma-cli branch list", "prisma-cli branch list --json"]
|
|
158
220
|
},
|
|
221
|
+
{
|
|
222
|
+
id: "database.list",
|
|
223
|
+
path: [
|
|
224
|
+
"prisma",
|
|
225
|
+
"database",
|
|
226
|
+
"list"
|
|
227
|
+
],
|
|
228
|
+
description: "List Prisma Postgres databases for the resolved project",
|
|
229
|
+
examples: [
|
|
230
|
+
"prisma-cli database list",
|
|
231
|
+
"prisma-cli database list --branch feature/foo",
|
|
232
|
+
"prisma-cli database list --json"
|
|
233
|
+
]
|
|
234
|
+
},
|
|
235
|
+
{
|
|
236
|
+
id: "database.show",
|
|
237
|
+
path: [
|
|
238
|
+
"prisma",
|
|
239
|
+
"database",
|
|
240
|
+
"show"
|
|
241
|
+
],
|
|
242
|
+
description: "Show database metadata without secret values",
|
|
243
|
+
examples: ["prisma-cli database show db_123", "prisma-cli database show acme-preview --branch preview --json"]
|
|
244
|
+
},
|
|
245
|
+
{
|
|
246
|
+
id: "database.create",
|
|
247
|
+
path: [
|
|
248
|
+
"prisma",
|
|
249
|
+
"database",
|
|
250
|
+
"create"
|
|
251
|
+
],
|
|
252
|
+
description: "Create a Prisma Postgres database and print its one-time connection URL",
|
|
253
|
+
examples: ["prisma-cli database create my-db", "prisma-cli database create my-db --branch feature/foo --region eu-central-1"]
|
|
254
|
+
},
|
|
255
|
+
{
|
|
256
|
+
id: "database.remove",
|
|
257
|
+
path: [
|
|
258
|
+
"prisma",
|
|
259
|
+
"database",
|
|
260
|
+
"remove"
|
|
261
|
+
],
|
|
262
|
+
description: "Remove a database after exact id confirmation",
|
|
263
|
+
examples: ["prisma-cli database remove db_123 --confirm db_123"]
|
|
264
|
+
},
|
|
265
|
+
{
|
|
266
|
+
id: "database.connection",
|
|
267
|
+
path: [
|
|
268
|
+
"prisma",
|
|
269
|
+
"database",
|
|
270
|
+
"connection"
|
|
271
|
+
],
|
|
272
|
+
description: "Manage one-time-view database connection strings",
|
|
273
|
+
examples: [
|
|
274
|
+
"prisma-cli database connection list db_123",
|
|
275
|
+
"prisma-cli database connection create db_123",
|
|
276
|
+
"prisma-cli database connection remove conn_123 --confirm conn_123"
|
|
277
|
+
]
|
|
278
|
+
},
|
|
279
|
+
{
|
|
280
|
+
id: "database.connection.list",
|
|
281
|
+
path: [
|
|
282
|
+
"prisma",
|
|
283
|
+
"database",
|
|
284
|
+
"connection",
|
|
285
|
+
"list"
|
|
286
|
+
],
|
|
287
|
+
description: "List database connection metadata without secret values",
|
|
288
|
+
examples: ["prisma-cli database connection list db_123", "prisma-cli database connection list acme-preview --branch preview --json"]
|
|
289
|
+
},
|
|
290
|
+
{
|
|
291
|
+
id: "database.connection.create",
|
|
292
|
+
path: [
|
|
293
|
+
"prisma",
|
|
294
|
+
"database",
|
|
295
|
+
"connection",
|
|
296
|
+
"create"
|
|
297
|
+
],
|
|
298
|
+
description: "Create a database connection and print its one-time connection URL",
|
|
299
|
+
examples: ["prisma-cli database connection create db_123", "prisma-cli database connection create db_123 --name readonly"]
|
|
300
|
+
},
|
|
301
|
+
{
|
|
302
|
+
id: "database.connection.remove",
|
|
303
|
+
path: [
|
|
304
|
+
"prisma",
|
|
305
|
+
"database",
|
|
306
|
+
"connection",
|
|
307
|
+
"remove"
|
|
308
|
+
],
|
|
309
|
+
description: "Remove a database connection after exact id confirmation",
|
|
310
|
+
examples: ["prisma-cli database connection remove conn_123 --confirm conn_123"]
|
|
311
|
+
},
|
|
159
312
|
{
|
|
160
313
|
id: "app.build",
|
|
161
314
|
path: [
|
|
@@ -188,7 +341,6 @@ const DESCRIPTORS = [
|
|
|
188
341
|
"deploy"
|
|
189
342
|
],
|
|
190
343
|
description: "Creates a new deployment for the app",
|
|
191
|
-
longDescription: "Agent skills for guided Next.js deploys are available from the Prisma CLI skill cluster.",
|
|
192
344
|
examples: [
|
|
193
345
|
"prisma-cli app deploy",
|
|
194
346
|
"prisma-cli app deploy --project proj_123",
|
|
@@ -200,7 +352,6 @@ const DESCRIPTORS = [
|
|
|
200
352
|
"prisma-cli app deploy --app my-app --framework nextjs --http-port 3000",
|
|
201
353
|
"prisma-cli app deploy --branch feat-login --framework hono",
|
|
202
354
|
"prisma-cli app deploy --prod --yes",
|
|
203
|
-
"pnpm dlx skills@latest add prisma/prisma-cli/skills#cli-v<cli-version> --all",
|
|
204
355
|
"prisma-cli app deploy --framework bun --entry src/server.ts"
|
|
205
356
|
]
|
|
206
357
|
},
|