@prisma/cli 8.0.0-rc.1 → 8.0.0-rc.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 (110) hide show
  1. package/dist/cli.js +15115 -16
  2. package/dist/deploy-framework-C7bQM00A.js +23 -0
  3. package/dist/{v8/sender.js → sender.js} +2 -2
  4. package/package.json +11 -15
  5. package/dist/adapters/git.js +0 -54
  6. package/dist/adapters/local-state.js +0 -155
  7. package/dist/auth/client.js +0 -30
  8. package/dist/auth/errors.js +0 -50
  9. package/dist/auth/guard.js +0 -39
  10. package/dist/auth/login.js +0 -471
  11. package/dist/auth/operations.js +0 -208
  12. package/dist/auth/recipient.js +0 -42
  13. package/dist/auth/token-storage.js +0 -439
  14. package/dist/auth/workspaces.js +0 -171
  15. package/dist/cli-command.js +0 -14
  16. package/dist/cli-name.js +0 -12
  17. package/dist/cli2.js +0 -136
  18. package/dist/command-arguments.js +0 -12
  19. package/dist/commands/agent/index.js +0 -60
  20. package/dist/commands/app/index.js +0 -350
  21. package/dist/commands/auth/index.js +0 -95
  22. package/dist/commands/branch/index.js +0 -27
  23. package/dist/commands/bucket/index.js +0 -123
  24. package/dist/commands/build/index.js +0 -29
  25. package/dist/commands/database/index.js +0 -249
  26. package/dist/commands/env.js +0 -99
  27. package/dist/commands/feedback/index.js +0 -20
  28. package/dist/commands/git/index.js +0 -36
  29. package/dist/commands/init/index.js +0 -33
  30. package/dist/commands/project/index.js +0 -118
  31. package/dist/commands/version/index.js +0 -18
  32. package/dist/controllers/agent-setup.js +0 -52
  33. package/dist/controllers/agent.js +0 -228
  34. package/dist/controllers/app-env-api.js +0 -55
  35. package/dist/controllers/app-env-file.js +0 -181
  36. package/dist/controllers/app-env.js +0 -502
  37. package/dist/controllers/app.js +0 -2508
  38. package/dist/controllers/auth.js +0 -124
  39. package/dist/controllers/branch.js +0 -92
  40. package/dist/controllers/bucket.js +0 -184
  41. package/dist/controllers/build.js +0 -88
  42. package/dist/controllers/database.js +0 -463
  43. package/dist/controllers/feedback.js +0 -90
  44. package/dist/controllers/init.js +0 -814
  45. package/dist/controllers/project.js +0 -892
  46. package/dist/controllers/select-prompt-port.js +0 -13
  47. package/dist/controllers/version.js +0 -12
  48. package/dist/errors.js +0 -102
  49. package/dist/lib/agent/cli-command.js +0 -20
  50. package/dist/lib/agent/constants.js +0 -12
  51. package/dist/lib/agent/package-manager.js +0 -99
  52. package/dist/lib/agent/setup-status.js +0 -83
  53. package/dist/lib/app/app-provider.js +0 -617
  54. package/dist/lib/app/branch-database-api.js +0 -102
  55. package/dist/lib/app/branch-database-deploy.js +0 -353
  56. package/dist/lib/app/branch-database.js +0 -234
  57. package/dist/lib/app/build-settings.js +0 -98
  58. package/dist/lib/app/build.js +0 -82
  59. package/dist/lib/app/bun-project.js +0 -45
  60. package/dist/lib/app/compute-config.js +0 -145
  61. package/dist/lib/app/deploy-output.js +0 -24
  62. package/dist/lib/app/deploy-plan.js +0 -59
  63. package/dist/lib/app/deploy-progress.js +0 -100
  64. package/dist/lib/app/domain-guidance.js +0 -14
  65. package/dist/lib/app/env-config.js +0 -67
  66. package/dist/lib/app/env-file.js +0 -82
  67. package/dist/lib/app/env-vars.js +0 -50
  68. package/dist/lib/app/local-dev.js +0 -109
  69. package/dist/lib/app/production-deploy-gate.js +0 -162
  70. package/dist/lib/app/read-branch.js +0 -30
  71. package/dist/lib/bucket/provider.js +0 -139
  72. package/dist/lib/database/provider.js +0 -385
  73. package/dist/lib/diagnostics.js +0 -16
  74. package/dist/lib/feedback.js +0 -15
  75. package/dist/lib/fs/home-path.js +0 -24
  76. package/dist/lib/git/local-branch.js +0 -53
  77. package/dist/lib/git/local-status.js +0 -57
  78. package/dist/lib/project/interactive-setup.js +0 -57
  79. package/dist/lib/project/local-pin.js +0 -200
  80. package/dist/lib/project/provider.js +0 -93
  81. package/dist/lib/project/resolution.js +0 -389
  82. package/dist/lib/project/setup.js +0 -138
  83. package/dist/lib/version.js +0 -56
  84. package/dist/lib/workspace-id.js +0 -18
  85. package/dist/output/patterns.js +0 -90
  86. package/dist/presenters/agent.js +0 -74
  87. package/dist/presenters/app-env.js +0 -265
  88. package/dist/presenters/app.js +0 -672
  89. package/dist/presenters/auth.js +0 -184
  90. package/dist/presenters/branch.js +0 -46
  91. package/dist/presenters/bucket.js +0 -174
  92. package/dist/presenters/database.js +0 -462
  93. package/dist/presenters/feedback.js +0 -26
  94. package/dist/presenters/init.js +0 -30
  95. package/dist/presenters/project.js +0 -268
  96. package/dist/presenters/verbose-context.js +0 -64
  97. package/dist/presenters/version.js +0 -29
  98. package/dist/shell/cli-command.js +0 -2
  99. package/dist/shell/command-meta.js +0 -923
  100. package/dist/shell/command-runner.js +0 -119
  101. package/dist/shell/diagnostics-output.js +0 -57
  102. package/dist/shell/global-flags.js +0 -37
  103. package/dist/shell/help.js +0 -90
  104. package/dist/shell/output.js +0 -144
  105. package/dist/shell/prompt.js +0 -48
  106. package/dist/shell/runtime.js +0 -38
  107. package/dist/shell/ui.js +0 -116
  108. package/dist/state-dir.js +0 -12
  109. package/dist/update-check.js +0 -248
  110. package/dist/v8/cli.js +0 -14699
@@ -1,672 +0,0 @@
1
- import { resolvePrismaCliPackageCommandSync } from "../lib/agent/cli-command.js";
2
- import { renderVerboseBlock } from "../shell/ui.js";
3
- import { renderDeployOutputRows } from "../lib/app/deploy-output.js";
4
- import { formatDomainFailureFix } from "../lib/app/domain-guidance.js";
5
- import { renderList, renderShow, serializeList } from "../output/patterns.js";
6
- import { renderResolvedProjectContextBlock, stripVerboseContext } from "./verbose-context.js";
7
- //#region src/presenters/app.ts
8
- function renderAppBuild(context, descriptor, result) {
9
- return renderShow({
10
- title: "Building the local app artifact.",
11
- descriptor,
12
- fields: [
13
- {
14
- key: "build type",
15
- value: result.buildType
16
- },
17
- {
18
- key: "entrypoint",
19
- value: result.entrypoint ?? "none",
20
- tone: result.entrypoint ? "default" : "dim"
21
- },
22
- {
23
- key: "directory",
24
- value: result.directory
25
- }
26
- ]
27
- }, context.ui);
28
- }
29
- function serializeAppBuild(result) {
30
- return result;
31
- }
32
- function renderAppDeploy(context, descriptor, result, options) {
33
- const logsCommand = options?.logsTarget ? `prisma-cli app logs ${options.logsTarget}` : "prisma-cli app logs";
34
- return [
35
- ...result.promoted ? [`Live in ${formatDuration(result.durationMs)}`, ...result.deployment.url ? [context.ui.link(result.deployment.url)] : []] : [
36
- `Built ${result.deployment.id} in ${formatDuration(result.durationMs)} (not promoted)`,
37
- ...result.deployment.url ? [context.ui.link(result.deployment.url)] : [],
38
- context.ui.dim("The live deployment is unchanged.")
39
- ],
40
- ...renderBranchDatabaseDeploySummary(context, result),
41
- "",
42
- ...renderDeployOutputRows(context.ui, [
43
- ...result.promoted ? [] : [{
44
- label: "Promote",
45
- value: `prisma-cli app promote ${result.deployment.id}`
46
- }],
47
- {
48
- label: "Logs",
49
- value: logsCommand
50
- },
51
- ...result.deploySettings.region && result.deploySettings.regionSource === null ? [{
52
- label: "Region",
53
- value: result.deploySettings.region,
54
- origin: result.project.defaultRegion != null ? "project default" : "platform default — pass --region to choose"
55
- }] : [],
56
- ...deployUsedComputeConfig(result) ? [] : [{
57
- label: "Config",
58
- value: resolvePrismaCliPackageCommandSync(context.runtime.cwd, ["init"])
59
- }]
60
- ]),
61
- ...renderDeployResolvedContextBlock(context, result),
62
- ...renderDeploySettingsBlock(context, result)
63
- ];
64
- }
65
- function deployUsedComputeConfig(result) {
66
- return result.deploySettings.config.path !== null || [
67
- result.deploySettings.framework.source,
68
- result.deploySettings.buildCommand.source,
69
- result.deploySettings.outputDirectory.source
70
- ].some((source) => source?.includes("prisma.compute"));
71
- }
72
- function isAppDeployAllResult(result) {
73
- return "deployments" in result;
74
- }
75
- function renderAppDeployAll(context, descriptor, result) {
76
- const lines = [];
77
- for (const deployment of result.deployments) {
78
- lines.push(deployment.target);
79
- lines.push(...renderAppDeploy(context, descriptor, deployment.result, { logsTarget: deployment.target }).map((line) => line ? ` ${line}` : line));
80
- lines.push("");
81
- }
82
- lines.push(...renderDeployOutputRows(context.ui, result.deployments.map((deployment) => ({
83
- label: deployment.target,
84
- value: deployment.result.deployment.url ?? deployment.result.deployment.id
85
- }))));
86
- return lines;
87
- }
88
- function serializeAppDeployAll(result) {
89
- return {
90
- count: result.deployments.length,
91
- deployments: result.deployments.map((deployment) => ({
92
- target: deployment.target,
93
- ...serializeAppDeploy(deployment.result)
94
- }))
95
- };
96
- }
97
- function serializeAppDeploy(result) {
98
- const { deploySettings, localPin: _localPin, ...serialized } = result;
99
- const { id: _branchId, ...branch } = serialized.branch;
100
- return {
101
- ...serialized,
102
- branch,
103
- deploySettings: {
104
- config: deploySettings.config,
105
- buildCommand: deploySettings.buildCommand,
106
- outputDirectory: deploySettings.outputDirectory
107
- }
108
- };
109
- }
110
- function renderBranchDatabaseDeploySummary(context, result) {
111
- if (result.branchDatabase?.status !== "created") return [];
112
- return ["", ...renderDeployOutputRows(context.ui, [{
113
- label: "Database",
114
- value: result.branchDatabase.database?.name ?? "created"
115
- }, {
116
- label: "Env",
117
- value: result.branchDatabase.envVars.join(", ")
118
- }])];
119
- }
120
- function formatDuration(durationMs) {
121
- if (durationMs < 1e3) return `${durationMs}ms`;
122
- return `${(durationMs / 1e3).toFixed(1)}s`;
123
- }
124
- function renderDeployResolvedContextBlock(context, result) {
125
- return renderResolvedProjectContextBlock(context.ui, {
126
- workspace: result.workspace,
127
- project: result.project,
128
- resolution: result.resolution,
129
- branch: {
130
- id: result.branch.id,
131
- name: result.branch.name,
132
- kind: result.branch.kind
133
- }
134
- }, { extraRows: [
135
- {
136
- key: "app",
137
- value: result.app.name
138
- },
139
- {
140
- key: "app id",
141
- value: result.app.id,
142
- tone: "dim"
143
- },
144
- {
145
- key: "deployment id",
146
- value: result.deployment.id,
147
- tone: "dim"
148
- },
149
- {
150
- key: "deployment status",
151
- value: result.deployment.status
152
- },
153
- ...result.localPin ? [{
154
- key: "local pin",
155
- value: result.localPin.path
156
- }] : [],
157
- {
158
- key: "deploy duration",
159
- value: formatDuration(result.durationMs)
160
- }
161
- ] });
162
- }
163
- function renderDeploySettingsBlock(context, result) {
164
- return renderVerboseBlock(context.ui, [...deploySettingsRows(result.deploySettings), ...branchDatabaseRows(result.branchDatabase)], { title: "Deploy settings" });
165
- }
166
- function deploySettingsRows(settings) {
167
- return [
168
- {
169
- key: "framework",
170
- value: `${settings.framework.name} (${settings.framework.buildType})`
171
- },
172
- {
173
- key: "framework source",
174
- value: settings.framework.source,
175
- tone: "dim"
176
- },
177
- {
178
- key: "entrypoint",
179
- value: settings.entrypoint ?? "derived from build output",
180
- tone: settings.entrypoint ? "default" : "dim"
181
- },
182
- {
183
- key: "http port",
184
- value: String(settings.httpPort)
185
- },
186
- {
187
- key: "region",
188
- value: settings.region ?? "existing app region",
189
- tone: settings.region ? "default" : "dim"
190
- },
191
- {
192
- key: "env vars",
193
- value: formatEnvVarNames(settings.envVars),
194
- tone: settings.envVars.length > 0 ? "default" : "dim"
195
- }
196
- ];
197
- }
198
- function branchDatabaseRows(branchDatabase) {
199
- if (!branchDatabase) return [{
200
- key: "branch db",
201
- value: "not configured",
202
- tone: "dim"
203
- }];
204
- return [{
205
- key: "branch db",
206
- value: branchDatabase.status === "created" ? `created${branchDatabase.database ? ` (${branchDatabase.database.name})` : ""}` : `skipped${branchDatabase.reason ? ` (${branchDatabase.reason})` : ""}`,
207
- tone: branchDatabase.status === "created" ? "success" : "dim"
208
- }, ...branchDatabase.envVars.length > 0 ? [{
209
- key: "branch db env",
210
- value: branchDatabase.envVars.join(", ")
211
- }] : []];
212
- }
213
- function formatEnvVarNames(envVars) {
214
- return envVars.length > 0 ? envVars.join(", ") : "none";
215
- }
216
- function renderAppListDeploys(context, descriptor, result) {
217
- const lines = renderList({
218
- title: "Listing deployments for the selected app.",
219
- descriptor,
220
- parentContext: {
221
- key: "app",
222
- value: result.app?.name ?? "not selected"
223
- },
224
- items: result.deployments.map((deployment) => ({
225
- noun: "deployment",
226
- label: deployment.id,
227
- id: deployment.id,
228
- status: deployment.live ? "active" : null
229
- })),
230
- emptyMessage: result.app ? "No deployments found." : "No apps found."
231
- }, context.ui);
232
- lines.push(...renderResolvedProjectContextBlock(context.ui, result.verboseContext));
233
- return lines;
234
- }
235
- function serializeAppListDeploys(result) {
236
- const { verboseContext: _verboseContext, ...serializable } = result;
237
- if (!serializable.app) return {
238
- projectId: serializable.projectId,
239
- app: null,
240
- items: [],
241
- count: 0
242
- };
243
- return {
244
- projectId: serializable.projectId,
245
- app: serializable.app,
246
- ...serializeList({
247
- context: { app: serializable.app.name },
248
- items: serializable.deployments.map((deployment) => ({
249
- noun: "deployment",
250
- label: deployment.id,
251
- id: deployment.id,
252
- status: deployment.live ? "active" : null
253
- }))
254
- })
255
- };
256
- }
257
- function renderAppShow(context, descriptor, result) {
258
- const lines = renderShow({
259
- title: "Showing the selected app state.",
260
- descriptor,
261
- fields: [
262
- {
263
- key: "project",
264
- value: result.projectId
265
- },
266
- {
267
- key: "app",
268
- value: result.app?.name ?? "not selected",
269
- tone: result.app ? "default" : "dim"
270
- },
271
- {
272
- key: "live deployment",
273
- value: result.liveDeployment?.id ?? "none",
274
- tone: result.liveDeployment ? toneForStatus(result.liveDeployment.status) : "dim"
275
- },
276
- {
277
- key: "live url",
278
- value: result.liveUrl ?? "unavailable",
279
- tone: result.liveUrl ? "link" : "dim"
280
- },
281
- {
282
- key: "recent deployments",
283
- value: formatRecentDeployments(result.recentDeployments),
284
- tone: result.recentDeployments.length > 0 ? "default" : "dim"
285
- }
286
- ]
287
- }, context.ui);
288
- lines.push(...renderResolvedProjectContextBlock(context.ui, result.verboseContext));
289
- return lines;
290
- }
291
- function serializeAppShow(result) {
292
- return stripVerboseContext(result);
293
- }
294
- function renderAppShowDeploy(context, descriptor, result) {
295
- return renderShow({
296
- title: "Showing deployment details.",
297
- descriptor,
298
- fields: [
299
- ...result.app ? [{
300
- key: "app",
301
- value: result.app.name
302
- }] : [],
303
- {
304
- key: "deployment",
305
- value: result.deployment.id
306
- },
307
- {
308
- key: "status",
309
- value: result.deployment.status,
310
- tone: toneForStatus(result.deployment.status)
311
- },
312
- ...result.deployment.url ? [{
313
- key: "url",
314
- value: result.deployment.url,
315
- tone: "link"
316
- }] : [],
317
- ...result.deployment.live === null ? [] : [{
318
- key: "live",
319
- value: result.deployment.live ? "yes" : "no",
320
- tone: result.deployment.live ? "success" : "dim"
321
- }],
322
- {
323
- key: "created",
324
- value: result.deployment.createdAt,
325
- tone: "dim"
326
- }
327
- ]
328
- }, context.ui);
329
- }
330
- function serializeAppShowDeploy(result) {
331
- return result;
332
- }
333
- function renderAppOpen(context, descriptor, result) {
334
- const lines = renderShow({
335
- title: result.opened ? "Opening the live URL for the selected app." : "Resolving the live URL for the selected app.",
336
- descriptor,
337
- fields: [
338
- {
339
- key: "project",
340
- value: result.projectId
341
- },
342
- {
343
- key: "app",
344
- value: result.app.name
345
- },
346
- {
347
- key: "url",
348
- value: result.url,
349
- tone: "link"
350
- },
351
- {
352
- key: "opened",
353
- value: result.opened ? "yes" : "no",
354
- tone: result.opened ? "success" : "dim"
355
- }
356
- ]
357
- }, context.ui);
358
- lines.push(...renderResolvedProjectContextBlock(context.ui, result.verboseContext));
359
- return lines;
360
- }
361
- function serializeAppOpen(result) {
362
- return stripVerboseContext(result);
363
- }
364
- function renderAppDomainAdd(context, descriptor, result) {
365
- return renderShow({
366
- title: result.existing ? "Showing the existing custom domain for the selected app." : "Adding a custom domain to the selected app.",
367
- descriptor,
368
- fields: [
369
- ...domainTargetFields(result),
370
- {
371
- key: "hostname",
372
- value: result.domain.hostname
373
- },
374
- {
375
- key: "status",
376
- value: result.domain.status,
377
- tone: toneForDomainStatus(result.domain.status)
378
- },
379
- ...domainDnsFields(result.domain)
380
- ]
381
- }, context.ui);
382
- }
383
- function serializeAppDomainAdd(result) {
384
- return result;
385
- }
386
- function renderAppDomainShow(context, descriptor, result) {
387
- return renderShow({
388
- title: "Showing custom domain status.",
389
- descriptor,
390
- fields: [
391
- ...domainTargetFields(result),
392
- {
393
- key: "hostname",
394
- value: result.domain.hostname
395
- },
396
- {
397
- key: "status",
398
- value: result.domain.status,
399
- tone: toneForDomainStatus(result.domain.status)
400
- },
401
- ...domainFailureFields(result.domain),
402
- {
403
- key: "cert expires",
404
- value: formatOptionalUtcDate(result.domain.certExpiresAt),
405
- tone: result.domain.certExpiresAt ? "default" : "dim"
406
- },
407
- {
408
- key: "created",
409
- value: formatUtcDate(result.domain.createdAt),
410
- tone: "dim"
411
- },
412
- ...domainDnsFields(result.domain)
413
- ]
414
- }, context.ui);
415
- }
416
- function serializeAppDomainShow(result) {
417
- return result;
418
- }
419
- function renderAppDomainRemove(context, descriptor, result) {
420
- return renderShow({
421
- title: "Removing a custom domain from the selected app.",
422
- descriptor,
423
- fields: [
424
- ...domainTargetFields(result),
425
- {
426
- key: "hostname",
427
- value: result.hostname
428
- },
429
- {
430
- key: "removed",
431
- value: result.removed ? "yes" : "no",
432
- tone: result.removed ? "success" : "dim"
433
- }
434
- ]
435
- }, context.ui);
436
- }
437
- function serializeAppDomainRemove(result) {
438
- return result;
439
- }
440
- function renderAppDomainRetry(context, descriptor, result) {
441
- return renderShow({
442
- title: "Retrying custom domain verification.",
443
- descriptor,
444
- fields: [
445
- ...domainTargetFields(result),
446
- {
447
- key: "hostname",
448
- value: result.domain.hostname
449
- },
450
- {
451
- key: "status",
452
- value: result.domain.status,
453
- tone: toneForDomainStatus(result.domain.status)
454
- },
455
- ...domainFailureFields(result.domain),
456
- ...domainDnsFields(result.domain)
457
- ]
458
- }, context.ui);
459
- }
460
- function serializeAppDomainRetry(result) {
461
- return result;
462
- }
463
- function renderAppPromote(context, descriptor, result) {
464
- const lines = renderShow({
465
- title: "Switching the live deployment for the selected app.",
466
- descriptor,
467
- fields: [
468
- {
469
- key: "project",
470
- value: result.projectId
471
- },
472
- {
473
- key: "app",
474
- value: result.app.name
475
- },
476
- {
477
- key: "deployment",
478
- value: result.deployment.id
479
- },
480
- {
481
- key: "status",
482
- value: result.deployment.status,
483
- tone: toneForStatus(result.deployment.status)
484
- },
485
- ...result.deployment.url ? [{
486
- key: "url",
487
- value: result.deployment.url,
488
- tone: "link"
489
- }] : [],
490
- {
491
- key: "live",
492
- value: result.deployment.live ? "yes" : "no",
493
- tone: result.deployment.live ? "success" : "dim"
494
- },
495
- {
496
- key: "created",
497
- value: result.deployment.createdAt,
498
- tone: "dim"
499
- }
500
- ]
501
- }, context.ui);
502
- lines.push(...renderResolvedProjectContextBlock(context.ui, result.verboseContext));
503
- return lines;
504
- }
505
- function serializeAppPromote(result) {
506
- return stripVerboseContext(result);
507
- }
508
- function renderAppRollback(context, descriptor, result) {
509
- const lines = renderShow({
510
- title: "Restoring the selected app to an earlier deployment.",
511
- descriptor,
512
- fields: [
513
- {
514
- key: "project",
515
- value: result.projectId
516
- },
517
- {
518
- key: "app",
519
- value: result.app.name
520
- },
521
- {
522
- key: "deployment",
523
- value: result.deployment.id
524
- },
525
- {
526
- key: "status",
527
- value: result.deployment.status,
528
- tone: toneForStatus(result.deployment.status)
529
- },
530
- ...result.deployment.url ? [{
531
- key: "url",
532
- value: result.deployment.url,
533
- tone: "link"
534
- }] : [],
535
- {
536
- key: "live",
537
- value: result.deployment.live ? "yes" : "no",
538
- tone: result.deployment.live ? "success" : "dim"
539
- },
540
- {
541
- key: "created",
542
- value: result.deployment.createdAt,
543
- tone: "dim"
544
- },
545
- ...result.previousLiveDeploymentId ? [{
546
- key: "replaced",
547
- value: result.previousLiveDeploymentId,
548
- tone: "dim"
549
- }] : []
550
- ]
551
- }, context.ui);
552
- lines.push(...renderResolvedProjectContextBlock(context.ui, result.verboseContext));
553
- return lines;
554
- }
555
- function serializeAppRollback(result) {
556
- return stripVerboseContext(result);
557
- }
558
- function renderAppRun(_context, _descriptor, _result) {
559
- return [];
560
- }
561
- function serializeAppRun(result) {
562
- return result;
563
- }
564
- function renderAppRemove(context, descriptor, result) {
565
- const lines = renderShow({
566
- title: "Removing the selected app.",
567
- descriptor,
568
- fields: [
569
- {
570
- key: "project",
571
- value: result.projectId
572
- },
573
- {
574
- key: "app",
575
- value: result.app.name
576
- },
577
- {
578
- key: "removed",
579
- value: result.removed ? "yes" : "no",
580
- tone: result.removed ? "success" : "dim"
581
- }
582
- ]
583
- }, context.ui);
584
- lines.push(...renderResolvedProjectContextBlock(context.ui, result.verboseContext));
585
- return lines;
586
- }
587
- function serializeAppRemove(result) {
588
- return stripVerboseContext(result);
589
- }
590
- function toneForStatus(status) {
591
- if (status === "running" || status === "ready" || status === "healthy") return "success";
592
- if (status === "provisioning" || status === "building" || status === "starting") return "warning";
593
- if (status === "failed" || status === "error") return "error";
594
- return "default";
595
- }
596
- function toneForDomainStatus(status) {
597
- if (status === "active") return "success";
598
- if (status === "failed") return "error";
599
- if (status === "pending_dns" || status === "verifying" || status === "provisioning_tls" || status === "verified_routing_blocked") return "warning";
600
- return "default";
601
- }
602
- function domainTargetFields(result) {
603
- return [
604
- {
605
- key: "workspace",
606
- value: result.workspace.name
607
- },
608
- {
609
- key: "project",
610
- value: result.project.name
611
- },
612
- {
613
- key: "branch",
614
- value: result.branch.name
615
- },
616
- {
617
- key: "app",
618
- value: result.app.name
619
- }
620
- ];
621
- }
622
- function domainDnsFields(domain) {
623
- const records = domain.dnsRecords;
624
- if (records.length === 0) return [{
625
- key: "dns record",
626
- value: "not provided by platform",
627
- tone: "dim"
628
- }];
629
- return [{
630
- key: "dns record",
631
- value: records.map((record) => {
632
- const ttl = record.ttl ? ` ttl ${record.ttl}` : "";
633
- return `${record.type} ${record.name} -> ${record.value}${ttl}`;
634
- }).join(", ")
635
- }];
636
- }
637
- function formatDomainFailure(domain) {
638
- if (!domain.failureReason) return domain.failureCategory ?? "none";
639
- return domain.failureCategory ? `${domain.failureCategory} - ${domain.failureReason}` : domain.failureReason;
640
- }
641
- function domainFailureFields(domain) {
642
- const tone = hasDomainFailure(domain) ? "error" : "dim";
643
- return [{
644
- key: "failure",
645
- value: formatDomainFailure(domain),
646
- tone
647
- }, ...domainFixFields(domain)];
648
- }
649
- function hasDomainFailure(domain) {
650
- return Boolean(domain.failureCategory || domain.failureReason);
651
- }
652
- function domainFixFields(domain) {
653
- const fix = formatDomainFailureFix(domain);
654
- return fix ? [{
655
- key: "fix",
656
- value: fix
657
- }] : [];
658
- }
659
- function formatOptionalUtcDate(value) {
660
- return value ? formatUtcDate(value) : "-";
661
- }
662
- function formatUtcDate(value) {
663
- const date = new Date(value);
664
- if (Number.isNaN(date.getTime())) return value;
665
- return `${date.getUTCFullYear()}-${String(date.getUTCMonth() + 1).padStart(2, "0")}-${String(date.getUTCDate()).padStart(2, "0")} ${String(date.getUTCHours()).padStart(2, "0")}:${String(date.getUTCMinutes()).padStart(2, "0")} UTC`;
666
- }
667
- function formatRecentDeployments(deployments) {
668
- if (deployments.length === 0) return "none";
669
- return deployments.map((deployment) => `${deployment.id}${deployment.live ? " (live)" : ""}`).join(", ");
670
- }
671
- //#endregion
672
- export { isAppDeployAllResult, renderAppBuild, renderAppDeploy, renderAppDeployAll, renderAppDomainAdd, renderAppDomainRemove, renderAppDomainRetry, renderAppDomainShow, renderAppListDeploys, renderAppOpen, renderAppPromote, renderAppRemove, renderAppRollback, renderAppRun, renderAppShow, renderAppShowDeploy, serializeAppBuild, serializeAppDeploy, serializeAppDeployAll, serializeAppDomainAdd, serializeAppDomainRemove, serializeAppDomainRetry, serializeAppDomainShow, serializeAppListDeploys, serializeAppOpen, serializeAppPromote, serializeAppRemove, serializeAppRollback, serializeAppRun, serializeAppShow, serializeAppShowDeploy };