@prisma/cli 3.0.0-dev.62.1 → 3.0.0-dev.65.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/dist/adapters/local-state.js +1 -1
- package/dist/cli2.js +2 -3
- package/dist/controllers/app-env-file.js +4 -2
- package/dist/controllers/app-env.js +23 -17
- package/dist/controllers/app.js +30 -1
- package/dist/controllers/branch.js +5 -0
- package/dist/lib/diagnostics.js +15 -0
- package/dist/lib/git/local-status.js +57 -0
- package/dist/lib/project/resolution.js +49 -4
- package/dist/presenters/app-env.js +137 -43
- package/dist/presenters/app.js +140 -20
- package/dist/presenters/branch.js +10 -3
- package/dist/presenters/project.js +41 -17
- package/dist/presenters/verbose-context.js +64 -0
- package/dist/shell/command-runner.js +17 -1
- package/dist/shell/diagnostics-output.js +63 -0
- package/dist/shell/output.js +10 -1
- package/dist/shell/runtime.js +1 -1
- package/dist/shell/ui.js +20 -1
- package/package.json +3 -3
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
import { renderVerboseBlock } from "../shell/ui.js";
|
|
1
2
|
import { renderList, renderShow, serializeList } from "../output/patterns.js";
|
|
3
|
+
import { renderResolvedProjectContextBlock, stripVerboseContext } from "./verbose-context.js";
|
|
2
4
|
//#region src/presenters/app-env.ts
|
|
3
5
|
function scopeLabel(scope) {
|
|
4
6
|
if (scope.kind === "role") return scope.role ?? "unknown";
|
|
@@ -14,23 +16,102 @@ function listTargetLabel(result) {
|
|
|
14
16
|
}
|
|
15
17
|
return scopeLabel(result.scope);
|
|
16
18
|
}
|
|
17
|
-
function
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
19
|
+
function renderEnvVerboseBlocks(context, result) {
|
|
20
|
+
return [...renderEnvResolvedContextBlock(context, result.verboseContext), ...renderEnvTargetBlock(context, result)];
|
|
21
|
+
}
|
|
22
|
+
function renderEnvResolvedContextBlock(context, verboseContext) {
|
|
23
|
+
return renderResolvedProjectContextBlock(context.ui, verboseContext);
|
|
24
|
+
}
|
|
25
|
+
function renderEnvTargetBlock(context, result) {
|
|
26
|
+
return renderVerboseBlock(context.ui, envTargetRows(result), { title: "Env target" });
|
|
27
|
+
}
|
|
28
|
+
function envTargetRows(result) {
|
|
29
|
+
return [
|
|
30
|
+
{
|
|
31
|
+
key: "project id",
|
|
32
|
+
value: result.projectId,
|
|
33
|
+
tone: "dim"
|
|
24
34
|
},
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
35
|
+
{
|
|
36
|
+
key: "scope",
|
|
37
|
+
value: scopeLabel(result.scope)
|
|
38
|
+
},
|
|
39
|
+
...envListTargetRows(result),
|
|
40
|
+
...envFileRows(result),
|
|
41
|
+
{
|
|
42
|
+
key: "keys",
|
|
43
|
+
value: formatKeyNames(envResultKeys(result)),
|
|
44
|
+
tone: envResultKeys(result).length > 0 ? "default" : "dim"
|
|
45
|
+
}
|
|
46
|
+
];
|
|
47
|
+
}
|
|
48
|
+
function envListTargetRows(result) {
|
|
49
|
+
if (!("target" in result)) return [];
|
|
50
|
+
return [
|
|
51
|
+
{
|
|
52
|
+
key: "target source",
|
|
53
|
+
value: result.target.source
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
key: "env map",
|
|
57
|
+
value: result.target.envMap
|
|
58
|
+
},
|
|
59
|
+
...result.target.branchName ? [{
|
|
60
|
+
key: "branch",
|
|
61
|
+
value: result.target.branchName
|
|
62
|
+
}] : [],
|
|
63
|
+
...result.target.branchId ? [{
|
|
64
|
+
key: "branch id",
|
|
65
|
+
value: result.target.branchId,
|
|
66
|
+
tone: "dim"
|
|
67
|
+
}] : [],
|
|
68
|
+
...result.target.branchExists === false ? [{
|
|
69
|
+
key: "branch state",
|
|
70
|
+
value: "not created yet",
|
|
71
|
+
tone: "warning"
|
|
72
|
+
}] : []
|
|
73
|
+
];
|
|
74
|
+
}
|
|
75
|
+
function envFileRows(result) {
|
|
76
|
+
if (!("file" in result) || !result.file) return [];
|
|
77
|
+
return [{
|
|
78
|
+
key: "file",
|
|
79
|
+
value: result.file.path
|
|
80
|
+
}, {
|
|
81
|
+
key: "file count",
|
|
82
|
+
value: String(result.file.count)
|
|
83
|
+
}];
|
|
84
|
+
}
|
|
85
|
+
function envResultKeys(result) {
|
|
86
|
+
if ("variables" in result && result.variables) return result.variables.map((variable) => variable.key).sort((left, right) => left.localeCompare(right));
|
|
87
|
+
if ("variable" in result && result.variable) return [result.variable.key];
|
|
88
|
+
if ("key" in result) return [result.key];
|
|
89
|
+
return [];
|
|
90
|
+
}
|
|
91
|
+
function formatKeyNames(keys) {
|
|
92
|
+
return keys.length > 0 ? keys.join(", ") : "none";
|
|
93
|
+
}
|
|
94
|
+
function renderEnvAdd(context, descriptor, result) {
|
|
95
|
+
if (result.variables !== void 0) {
|
|
96
|
+
const lines = renderList({
|
|
97
|
+
title: "Setting new environment variables from file.",
|
|
98
|
+
descriptor,
|
|
99
|
+
parentContext: {
|
|
100
|
+
key: "target",
|
|
101
|
+
value: `${scopeLabel(result.scope)} from ${result.file.path}`
|
|
102
|
+
},
|
|
103
|
+
items: result.variables.map((variable) => ({
|
|
104
|
+
noun: "variable",
|
|
105
|
+
label: `${variable.key} (${variable.source})`,
|
|
106
|
+
id: variable.id,
|
|
107
|
+
status: variable.isManagedBySystem ? "default" : null
|
|
108
|
+
})),
|
|
109
|
+
emptyMessage: "No environment variables imported."
|
|
110
|
+
}, context.ui);
|
|
111
|
+
lines.push(...renderEnvVerboseBlocks(context, result));
|
|
112
|
+
return lines;
|
|
113
|
+
}
|
|
114
|
+
const lines = renderShow({
|
|
34
115
|
title: "Setting a new environment variable.",
|
|
35
116
|
descriptor,
|
|
36
117
|
fields: [
|
|
@@ -58,27 +139,33 @@ function renderEnvAdd(context, descriptor, result) {
|
|
|
58
139
|
}
|
|
59
140
|
]
|
|
60
141
|
}, context.ui);
|
|
142
|
+
lines.push(...renderEnvVerboseBlocks(context, result));
|
|
143
|
+
return lines;
|
|
61
144
|
}
|
|
62
145
|
function serializeEnvAdd(result) {
|
|
63
|
-
return result;
|
|
146
|
+
return stripVerboseContext(result);
|
|
64
147
|
}
|
|
65
148
|
function renderEnvUpdate(context, descriptor, result) {
|
|
66
|
-
if (result.variables !== void 0)
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
149
|
+
if (result.variables !== void 0) {
|
|
150
|
+
const lines = renderList({
|
|
151
|
+
title: "Replacing environment variable values from file.",
|
|
152
|
+
descriptor,
|
|
153
|
+
parentContext: {
|
|
154
|
+
key: "target",
|
|
155
|
+
value: `${scopeLabel(result.scope)} from ${result.file.path}`
|
|
156
|
+
},
|
|
157
|
+
items: result.variables.map((variable) => ({
|
|
158
|
+
noun: "variable",
|
|
159
|
+
label: `${variable.key} (${variable.source})`,
|
|
160
|
+
id: variable.id,
|
|
161
|
+
status: variable.isManagedBySystem ? "default" : null
|
|
162
|
+
})),
|
|
163
|
+
emptyMessage: "No environment variables updated."
|
|
164
|
+
}, context.ui);
|
|
165
|
+
lines.push(...renderEnvVerboseBlocks(context, result));
|
|
166
|
+
return lines;
|
|
167
|
+
}
|
|
168
|
+
const lines = renderShow({
|
|
82
169
|
title: "Replacing the environment variable's value.",
|
|
83
170
|
descriptor,
|
|
84
171
|
fields: [
|
|
@@ -106,12 +193,14 @@ function renderEnvUpdate(context, descriptor, result) {
|
|
|
106
193
|
}
|
|
107
194
|
]
|
|
108
195
|
}, context.ui);
|
|
196
|
+
lines.push(...renderEnvVerboseBlocks(context, result));
|
|
197
|
+
return lines;
|
|
109
198
|
}
|
|
110
199
|
function serializeEnvUpdate(result) {
|
|
111
|
-
return result;
|
|
200
|
+
return stripVerboseContext(result);
|
|
112
201
|
}
|
|
113
202
|
function renderEnvList(context, descriptor, result) {
|
|
114
|
-
|
|
203
|
+
const lines = renderList({
|
|
115
204
|
title: "Listing environment variables for the selected scope.",
|
|
116
205
|
descriptor,
|
|
117
206
|
parentContext: {
|
|
@@ -126,26 +215,29 @@ function renderEnvList(context, descriptor, result) {
|
|
|
126
215
|
})),
|
|
127
216
|
emptyMessage: "No environment variables defined in this scope."
|
|
128
217
|
}, context.ui);
|
|
218
|
+
lines.push(...renderEnvVerboseBlocks(context, result));
|
|
219
|
+
return lines;
|
|
129
220
|
}
|
|
130
221
|
function serializeEnvList(result) {
|
|
222
|
+
const serializable = stripVerboseContext(result);
|
|
131
223
|
return {
|
|
132
|
-
projectId:
|
|
133
|
-
scope:
|
|
134
|
-
target:
|
|
224
|
+
projectId: serializable.projectId,
|
|
225
|
+
scope: serializable.scope,
|
|
226
|
+
target: serializable.target,
|
|
135
227
|
...serializeList({
|
|
136
|
-
context: { target: listTargetLabel(
|
|
137
|
-
items:
|
|
228
|
+
context: { target: listTargetLabel(serializable) },
|
|
229
|
+
items: serializable.variables.map((variable) => ({
|
|
138
230
|
noun: "variable",
|
|
139
231
|
label: `${variable.key} (${variable.source})`,
|
|
140
232
|
id: variable.id,
|
|
141
233
|
status: variable.isManagedBySystem ? "default" : null
|
|
142
234
|
}))
|
|
143
235
|
}),
|
|
144
|
-
variables:
|
|
236
|
+
variables: serializable.variables
|
|
145
237
|
};
|
|
146
238
|
}
|
|
147
239
|
function renderEnvRm(context, descriptor, result) {
|
|
148
|
-
|
|
240
|
+
const lines = renderShow({
|
|
149
241
|
title: "Removing the environment variable from the scope.",
|
|
150
242
|
descriptor,
|
|
151
243
|
fields: [
|
|
@@ -163,9 +255,11 @@ function renderEnvRm(context, descriptor, result) {
|
|
|
163
255
|
}
|
|
164
256
|
]
|
|
165
257
|
}, context.ui);
|
|
258
|
+
lines.push(...renderEnvVerboseBlocks(context, result));
|
|
259
|
+
return lines;
|
|
166
260
|
}
|
|
167
261
|
function serializeEnvRm(result) {
|
|
168
|
-
return result;
|
|
262
|
+
return stripVerboseContext(result);
|
|
169
263
|
}
|
|
170
264
|
//#endregion
|
|
171
265
|
export { renderEnvAdd, renderEnvList, renderEnvRm, renderEnvUpdate, serializeEnvAdd, serializeEnvList, serializeEnvRm, serializeEnvUpdate };
|
package/dist/presenters/app.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
import { renderVerboseBlock } from "../shell/ui.js";
|
|
1
2
|
import { renderDeployOutputRows } from "../lib/app/deploy-output.js";
|
|
2
3
|
import { formatDomainFailureFix } from "../lib/app/domain-guidance.js";
|
|
3
4
|
import { renderList, renderShow, serializeList } from "../output/patterns.js";
|
|
5
|
+
import { renderResolvedProjectContextBlock, stripVerboseContext } from "./verbose-context.js";
|
|
4
6
|
//#region src/presenters/app.ts
|
|
5
7
|
function renderAppBuild(context, descriptor, result) {
|
|
6
8
|
return renderShow({
|
|
@@ -35,12 +37,18 @@ function renderAppDeploy(context, descriptor, result) {
|
|
|
35
37
|
...renderDeployOutputRows(context.ui, [{
|
|
36
38
|
label: "Logs",
|
|
37
39
|
value: "prisma-cli app logs"
|
|
38
|
-
}])
|
|
40
|
+
}]),
|
|
41
|
+
...renderDeployResolvedContextBlock(context, result),
|
|
42
|
+
...renderDeploySettingsBlock(context, result)
|
|
39
43
|
];
|
|
40
44
|
}
|
|
41
45
|
function serializeAppDeploy(result) {
|
|
42
|
-
const { localPin: _localPin, ...serialized } = result;
|
|
43
|
-
|
|
46
|
+
const { deploySettings: _deploySettings, localPin: _localPin, ...serialized } = result;
|
|
47
|
+
const { id: _branchId, ...branch } = serialized.branch;
|
|
48
|
+
return {
|
|
49
|
+
...serialized,
|
|
50
|
+
branch
|
|
51
|
+
};
|
|
44
52
|
}
|
|
45
53
|
function renderBranchDatabaseDeploySummary(context, result) {
|
|
46
54
|
if (!result.branchDatabase || result.branchDatabase.status !== "created") return [];
|
|
@@ -70,8 +78,107 @@ function formatDuration(durationMs) {
|
|
|
70
78
|
if (durationMs < 1e3) return `${durationMs}ms`;
|
|
71
79
|
return `${(durationMs / 1e3).toFixed(1)}s`;
|
|
72
80
|
}
|
|
81
|
+
function renderDeployResolvedContextBlock(context, result) {
|
|
82
|
+
return renderResolvedProjectContextBlock(context.ui, {
|
|
83
|
+
workspace: result.workspace,
|
|
84
|
+
project: result.project,
|
|
85
|
+
resolution: result.resolution,
|
|
86
|
+
branch: {
|
|
87
|
+
id: result.branch.id,
|
|
88
|
+
name: result.branch.name,
|
|
89
|
+
kind: result.branch.kind
|
|
90
|
+
}
|
|
91
|
+
}, { extraRows: [
|
|
92
|
+
{
|
|
93
|
+
key: "app",
|
|
94
|
+
value: result.app.name
|
|
95
|
+
},
|
|
96
|
+
{
|
|
97
|
+
key: "app id",
|
|
98
|
+
value: result.app.id,
|
|
99
|
+
tone: "dim"
|
|
100
|
+
},
|
|
101
|
+
{
|
|
102
|
+
key: "deployment id",
|
|
103
|
+
value: result.deployment.id,
|
|
104
|
+
tone: "dim"
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
key: "deployment status",
|
|
108
|
+
value: result.deployment.status
|
|
109
|
+
},
|
|
110
|
+
...result.localPin ? [{
|
|
111
|
+
key: "local pin",
|
|
112
|
+
value: result.localPin.path
|
|
113
|
+
}] : [],
|
|
114
|
+
{
|
|
115
|
+
key: "deploy duration",
|
|
116
|
+
value: formatDuration(result.durationMs)
|
|
117
|
+
}
|
|
118
|
+
] });
|
|
119
|
+
}
|
|
120
|
+
function renderDeploySettingsBlock(context, result) {
|
|
121
|
+
return renderVerboseBlock(context.ui, [...deploySettingsRows(result.deploySettings), ...branchDatabaseRows(result.branchDatabase)], { title: "Deploy settings" });
|
|
122
|
+
}
|
|
123
|
+
function deploySettingsRows(settings) {
|
|
124
|
+
return [
|
|
125
|
+
{
|
|
126
|
+
key: "framework",
|
|
127
|
+
value: `${settings.framework.name} (${settings.framework.buildType})`
|
|
128
|
+
},
|
|
129
|
+
{
|
|
130
|
+
key: "framework source",
|
|
131
|
+
value: settings.framework.source,
|
|
132
|
+
tone: "dim"
|
|
133
|
+
},
|
|
134
|
+
{
|
|
135
|
+
key: "entrypoint",
|
|
136
|
+
value: settings.entrypoint ?? "derived from build output",
|
|
137
|
+
tone: settings.entrypoint ? "default" : "dim"
|
|
138
|
+
},
|
|
139
|
+
{
|
|
140
|
+
key: "http port",
|
|
141
|
+
value: String(settings.httpPort)
|
|
142
|
+
},
|
|
143
|
+
{
|
|
144
|
+
key: "region",
|
|
145
|
+
value: settings.region ?? "existing app region",
|
|
146
|
+
tone: settings.region ? "default" : "dim"
|
|
147
|
+
},
|
|
148
|
+
{
|
|
149
|
+
key: "env vars",
|
|
150
|
+
value: formatEnvVarNames(settings.envVars),
|
|
151
|
+
tone: settings.envVars.length > 0 ? "default" : "dim"
|
|
152
|
+
}
|
|
153
|
+
];
|
|
154
|
+
}
|
|
155
|
+
function branchDatabaseRows(branchDatabase) {
|
|
156
|
+
if (!branchDatabase) return [{
|
|
157
|
+
key: "branch db",
|
|
158
|
+
value: "not configured",
|
|
159
|
+
tone: "dim"
|
|
160
|
+
}];
|
|
161
|
+
return [
|
|
162
|
+
{
|
|
163
|
+
key: "branch db",
|
|
164
|
+
value: branchDatabase.status === "created" ? `created${branchDatabase.database ? ` (${branchDatabase.database.name})` : ""}` : `skipped${branchDatabase.reason ? ` (${branchDatabase.reason})` : ""}`,
|
|
165
|
+
tone: branchDatabase.status === "created" ? "success" : "dim"
|
|
166
|
+
},
|
|
167
|
+
...branchDatabase.envVars.length > 0 ? [{
|
|
168
|
+
key: "branch db env",
|
|
169
|
+
value: branchDatabase.envVars.join(", ")
|
|
170
|
+
}] : [],
|
|
171
|
+
...branchDatabase.schema ? [{
|
|
172
|
+
key: "branch db schema",
|
|
173
|
+
value: `${formatBranchDatabaseSchemaCommand(branchDatabase.schema.command)} (${branchDatabase.schema.source}, ${branchDatabase.schema.path})`
|
|
174
|
+
}] : []
|
|
175
|
+
];
|
|
176
|
+
}
|
|
177
|
+
function formatEnvVarNames(envVars) {
|
|
178
|
+
return envVars.length > 0 ? envVars.join(", ") : "none";
|
|
179
|
+
}
|
|
73
180
|
function renderAppListDeploys(context, descriptor, result) {
|
|
74
|
-
|
|
181
|
+
const lines = renderList({
|
|
75
182
|
title: "Listing deployments for the selected app.",
|
|
76
183
|
descriptor,
|
|
77
184
|
parentContext: {
|
|
@@ -86,20 +193,23 @@ function renderAppListDeploys(context, descriptor, result) {
|
|
|
86
193
|
})),
|
|
87
194
|
emptyMessage: result.app ? "No deployments found." : "No apps found."
|
|
88
195
|
}, context.ui);
|
|
196
|
+
lines.push(...renderResolvedProjectContextBlock(context.ui, result.verboseContext));
|
|
197
|
+
return lines;
|
|
89
198
|
}
|
|
90
199
|
function serializeAppListDeploys(result) {
|
|
91
|
-
|
|
92
|
-
|
|
200
|
+
const { verboseContext: _verboseContext, ...serializable } = result;
|
|
201
|
+
if (!serializable.app) return {
|
|
202
|
+
projectId: serializable.projectId,
|
|
93
203
|
app: null,
|
|
94
204
|
items: [],
|
|
95
205
|
count: 0
|
|
96
206
|
};
|
|
97
207
|
return {
|
|
98
|
-
projectId:
|
|
99
|
-
app:
|
|
208
|
+
projectId: serializable.projectId,
|
|
209
|
+
app: serializable.app,
|
|
100
210
|
...serializeList({
|
|
101
|
-
context: { app:
|
|
102
|
-
items:
|
|
211
|
+
context: { app: serializable.app.name },
|
|
212
|
+
items: serializable.deployments.map((deployment) => ({
|
|
103
213
|
noun: "deployment",
|
|
104
214
|
label: deployment.id,
|
|
105
215
|
id: deployment.id,
|
|
@@ -109,7 +219,7 @@ function serializeAppListDeploys(result) {
|
|
|
109
219
|
};
|
|
110
220
|
}
|
|
111
221
|
function renderAppShow(context, descriptor, result) {
|
|
112
|
-
|
|
222
|
+
const lines = renderShow({
|
|
113
223
|
title: "Showing the selected app state.",
|
|
114
224
|
descriptor,
|
|
115
225
|
fields: [
|
|
@@ -139,9 +249,11 @@ function renderAppShow(context, descriptor, result) {
|
|
|
139
249
|
}
|
|
140
250
|
]
|
|
141
251
|
}, context.ui);
|
|
252
|
+
lines.push(...renderResolvedProjectContextBlock(context.ui, result.verboseContext));
|
|
253
|
+
return lines;
|
|
142
254
|
}
|
|
143
255
|
function serializeAppShow(result) {
|
|
144
|
-
return result;
|
|
256
|
+
return stripVerboseContext(result);
|
|
145
257
|
}
|
|
146
258
|
function renderAppShowDeploy(context, descriptor, result) {
|
|
147
259
|
return renderShow({
|
|
@@ -183,7 +295,7 @@ function serializeAppShowDeploy(result) {
|
|
|
183
295
|
return result;
|
|
184
296
|
}
|
|
185
297
|
function renderAppOpen(context, descriptor, result) {
|
|
186
|
-
|
|
298
|
+
const lines = renderShow({
|
|
187
299
|
title: result.opened ? "Opening the live URL for the selected app." : "Resolving the live URL for the selected app.",
|
|
188
300
|
descriptor,
|
|
189
301
|
fields: [
|
|
@@ -207,9 +319,11 @@ function renderAppOpen(context, descriptor, result) {
|
|
|
207
319
|
}
|
|
208
320
|
]
|
|
209
321
|
}, context.ui);
|
|
322
|
+
lines.push(...renderResolvedProjectContextBlock(context.ui, result.verboseContext));
|
|
323
|
+
return lines;
|
|
210
324
|
}
|
|
211
325
|
function serializeAppOpen(result) {
|
|
212
|
-
return result;
|
|
326
|
+
return stripVerboseContext(result);
|
|
213
327
|
}
|
|
214
328
|
function renderAppDomainAdd(context, descriptor, result) {
|
|
215
329
|
return renderShow({
|
|
@@ -311,7 +425,7 @@ function serializeAppDomainRetry(result) {
|
|
|
311
425
|
return result;
|
|
312
426
|
}
|
|
313
427
|
function renderAppPromote(context, descriptor, result) {
|
|
314
|
-
|
|
428
|
+
const lines = renderShow({
|
|
315
429
|
title: "Switching the live deployment for the selected app.",
|
|
316
430
|
descriptor,
|
|
317
431
|
fields: [
|
|
@@ -349,12 +463,14 @@ function renderAppPromote(context, descriptor, result) {
|
|
|
349
463
|
}
|
|
350
464
|
]
|
|
351
465
|
}, context.ui);
|
|
466
|
+
lines.push(...renderResolvedProjectContextBlock(context.ui, result.verboseContext));
|
|
467
|
+
return lines;
|
|
352
468
|
}
|
|
353
469
|
function serializeAppPromote(result) {
|
|
354
|
-
return result;
|
|
470
|
+
return stripVerboseContext(result);
|
|
355
471
|
}
|
|
356
472
|
function renderAppRollback(context, descriptor, result) {
|
|
357
|
-
|
|
473
|
+
const lines = renderShow({
|
|
358
474
|
title: "Restoring the selected app to an earlier deployment.",
|
|
359
475
|
descriptor,
|
|
360
476
|
fields: [
|
|
@@ -397,9 +513,11 @@ function renderAppRollback(context, descriptor, result) {
|
|
|
397
513
|
}] : []
|
|
398
514
|
]
|
|
399
515
|
}, context.ui);
|
|
516
|
+
lines.push(...renderResolvedProjectContextBlock(context.ui, result.verboseContext));
|
|
517
|
+
return lines;
|
|
400
518
|
}
|
|
401
519
|
function serializeAppRollback(result) {
|
|
402
|
-
return result;
|
|
520
|
+
return stripVerboseContext(result);
|
|
403
521
|
}
|
|
404
522
|
function renderAppRun(_context, _descriptor, _result) {
|
|
405
523
|
return [];
|
|
@@ -408,7 +526,7 @@ function serializeAppRun(result) {
|
|
|
408
526
|
return result;
|
|
409
527
|
}
|
|
410
528
|
function renderAppRemove(context, descriptor, result) {
|
|
411
|
-
|
|
529
|
+
const lines = renderShow({
|
|
412
530
|
title: "Removing the selected app.",
|
|
413
531
|
descriptor,
|
|
414
532
|
fields: [
|
|
@@ -427,9 +545,11 @@ function renderAppRemove(context, descriptor, result) {
|
|
|
427
545
|
}
|
|
428
546
|
]
|
|
429
547
|
}, context.ui);
|
|
548
|
+
lines.push(...renderResolvedProjectContextBlock(context.ui, result.verboseContext));
|
|
549
|
+
return lines;
|
|
430
550
|
}
|
|
431
551
|
function serializeAppRemove(result) {
|
|
432
|
-
return result;
|
|
552
|
+
return stripVerboseContext(result);
|
|
433
553
|
}
|
|
434
554
|
function toneForStatus(status) {
|
|
435
555
|
if (status === "running" || status === "ready" || status === "healthy") return "success";
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { formatColumns } from "../shell/ui.js";
|
|
2
2
|
import { formatDescriptorLabel } from "../shell/command-meta.js";
|
|
3
|
+
import { renderResolvedProjectContextBlock } from "./verbose-context.js";
|
|
3
4
|
//#region src/presenters/branch.ts
|
|
4
5
|
function renderBranchList(context, descriptor, result) {
|
|
5
6
|
const ui = context.ui;
|
|
@@ -9,6 +10,7 @@ function renderBranchList(context, descriptor, result) {
|
|
|
9
10
|
lines.push(rail);
|
|
10
11
|
if (result.branches.length === 0) {
|
|
11
12
|
lines.push(`${rail} ${ui.dim("No branches found.")}`);
|
|
13
|
+
lines.push(...renderBranchResolvedContextBlock(context, result));
|
|
12
14
|
return lines;
|
|
13
15
|
}
|
|
14
16
|
const widths = [
|
|
@@ -26,14 +28,19 @@ function renderBranchList(context, descriptor, result) {
|
|
|
26
28
|
branch.role,
|
|
27
29
|
branch.envMap
|
|
28
30
|
], widths)}`);
|
|
31
|
+
lines.push(...renderBranchResolvedContextBlock(context, result));
|
|
29
32
|
return lines;
|
|
30
33
|
}
|
|
31
34
|
function serializeBranchList(result) {
|
|
35
|
+
const { verboseContext: _verboseContext, ...serializable } = result;
|
|
32
36
|
return {
|
|
33
|
-
projectId:
|
|
34
|
-
projectName:
|
|
35
|
-
branches:
|
|
37
|
+
projectId: serializable.projectId,
|
|
38
|
+
projectName: serializable.projectName,
|
|
39
|
+
branches: serializable.branches
|
|
36
40
|
};
|
|
37
41
|
}
|
|
42
|
+
function renderBranchResolvedContextBlock(context, result) {
|
|
43
|
+
return renderResolvedProjectContextBlock(context.ui, result.verboseContext);
|
|
44
|
+
}
|
|
38
45
|
//#endregion
|
|
39
46
|
export { renderBranchList, serializeBranchList };
|
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
import { padDisplay, renderNextSteps, renderSummaryLine } from "../shell/ui.js";
|
|
1
|
+
import { padDisplay, renderNextSteps, renderSummaryLine, renderVerboseBlock } from "../shell/ui.js";
|
|
2
2
|
import { formatDescriptorLabel } from "../shell/command-meta.js";
|
|
3
3
|
import { formatCommandArgument } from "../shell/command-arguments.js";
|
|
4
|
-
import {
|
|
4
|
+
import { renderMutate, renderShow, serializeList } from "../output/patterns.js";
|
|
5
|
+
import { renderResolvedProjectContextBlock } from "./verbose-context.js";
|
|
5
6
|
import path from "node:path";
|
|
7
|
+
import stringWidth from "string-width";
|
|
6
8
|
//#region src/presenters/project.ts
|
|
7
9
|
function renderProjectList(context, descriptor, result) {
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
emptyMessage: "No projects found."
|
|
22
|
-
}, context.ui);
|
|
10
|
+
const ui = context.ui;
|
|
11
|
+
const rail = ui.dim("│");
|
|
12
|
+
const lines = [`${ui.strong(formatDescriptorLabel(descriptor))} ${ui.dim("→")} ${ui.dim("Listing projects for the authenticated workspace.")}`, ""];
|
|
13
|
+
lines.push(`${rail} ${ui.accent("workspace:")} ${result.workspace.name}`);
|
|
14
|
+
if (result.projects.length === 0) {
|
|
15
|
+
lines.push(`${rail} ${ui.dim("No projects found.")}`);
|
|
16
|
+
if (result.localBinding?.status === "not-linked" || result.localBinding?.status === "invalid") lines.push(...renderNextSteps(["Link an existing Project you choose: prisma-cli project link <id-or-name>", "Create a new Project: prisma-cli project create <name>"]));
|
|
17
|
+
return lines;
|
|
18
|
+
}
|
|
19
|
+
const nameWidth = Math.max(4, ...result.projects.map((project) => stringWidth(project.name)));
|
|
20
|
+
lines.push(rail);
|
|
21
|
+
lines.push(`${rail} ${ui.accent(padDisplay("name", nameWidth))} ${ui.accent("id")}`);
|
|
22
|
+
for (const project of result.projects) lines.push(`${rail} ${padDisplay(project.name, nameWidth)} ${project.id}`);
|
|
23
23
|
if (result.localBinding?.status === "not-linked" || result.localBinding?.status === "invalid") lines.push(...renderNextSteps(["Link an existing Project you choose: prisma-cli project link <id-or-name>", "Create a new Project: prisma-cli project create <name>"]));
|
|
24
24
|
return lines;
|
|
25
25
|
}
|
|
@@ -51,6 +51,25 @@ function renderProjectShow(context, descriptor, result) {
|
|
|
51
51
|
tone: "warning"
|
|
52
52
|
}]
|
|
53
53
|
}, context.ui);
|
|
54
|
+
lines.push(...renderVerboseBlock(context.ui, [
|
|
55
|
+
{
|
|
56
|
+
key: "workspace",
|
|
57
|
+
value: result.workspace.name
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
key: "workspace id",
|
|
61
|
+
value: result.workspace.id,
|
|
62
|
+
tone: "dim"
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
key: "project source",
|
|
66
|
+
value: "unbound"
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
key: "suggested name",
|
|
70
|
+
value: `${result.suggestedProjectName} (${result.suggestedProjectNameSource})`
|
|
71
|
+
}
|
|
72
|
+
], { title: "Resolved context" }));
|
|
54
73
|
lines.push(...renderNextSteps(["Link an existing Project you choose: prisma-cli project link <id-or-name>", `Create a new Project: prisma-cli project create ${formatCommandArgument(result.suggestedProjectName)}`]));
|
|
55
74
|
return lines;
|
|
56
75
|
}
|
|
@@ -133,6 +152,11 @@ function renderBoundProjectShow(context, descriptor, result) {
|
|
|
133
152
|
lines.push(rail);
|
|
134
153
|
lines.push(`${rail} ${ui.dim("→")} ${ui.link(result.project.url)}`);
|
|
135
154
|
}
|
|
155
|
+
lines.push(...renderResolvedProjectContextBlock(context.ui, {
|
|
156
|
+
workspace: result.workspace,
|
|
157
|
+
project: result.project,
|
|
158
|
+
resolution: result.resolution
|
|
159
|
+
}));
|
|
136
160
|
return lines;
|
|
137
161
|
}
|
|
138
162
|
function formatLocalRepoPath(cwd, env) {
|