@prisma/cli 2.20.1 → 3.0.0-alpha.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.
Files changed (217) hide show
  1. package/LICENSE +158 -0
  2. package/README.md +29 -28
  3. package/dist/adapters/config.js +74 -0
  4. package/dist/adapters/local-state.js +98 -0
  5. package/dist/adapters/mock-api.js +57 -0
  6. package/dist/adapters/token-storage.js +43 -0
  7. package/dist/cli.js +9 -0
  8. package/dist/cli2.js +59 -0
  9. package/dist/commands/app/index.js +216 -0
  10. package/dist/commands/auth/index.js +42 -0
  11. package/dist/commands/branch/index.js +51 -0
  12. package/dist/commands/project/index.js +45 -0
  13. package/dist/controllers/app.js +834 -0
  14. package/dist/controllers/auth.js +107 -0
  15. package/dist/controllers/branch.js +73 -0
  16. package/dist/controllers/project.js +214 -0
  17. package/dist/controllers/select-prompt-port.js +12 -0
  18. package/dist/lib/app/bun-project.js +39 -0
  19. package/dist/lib/app/env-vars.js +24 -0
  20. package/dist/lib/app/local-dev.js +150 -0
  21. package/dist/lib/app/preview-build.js +142 -0
  22. package/dist/lib/app/preview-interaction.js +38 -0
  23. package/dist/lib/app/preview-progress.js +139 -0
  24. package/dist/lib/app/preview-provider.js +232 -0
  25. package/dist/lib/auth/auth-ops.js +57 -0
  26. package/dist/lib/auth/client.js +22 -0
  27. package/dist/lib/auth/guard.js +34 -0
  28. package/dist/lib/auth/login.js +117 -0
  29. package/dist/output/patterns.js +93 -0
  30. package/dist/presenters/app.js +405 -0
  31. package/dist/presenters/auth.js +73 -0
  32. package/dist/presenters/branch.js +111 -0
  33. package/dist/presenters/project.js +84 -0
  34. package/dist/shell/command-meta.js +329 -0
  35. package/dist/shell/command-runner.js +33 -0
  36. package/dist/shell/errors.js +66 -0
  37. package/dist/shell/global-flags.js +25 -0
  38. package/dist/shell/help.js +78 -0
  39. package/dist/shell/output.js +54 -0
  40. package/dist/shell/prompt.js +31 -0
  41. package/dist/shell/runtime.js +51 -0
  42. package/dist/shell/ui.js +59 -0
  43. package/dist/use-cases/auth.js +70 -0
  44. package/dist/use-cases/branch.js +95 -0
  45. package/dist/use-cases/create-cli-gateways.js +93 -0
  46. package/dist/use-cases/project.js +75 -0
  47. package/package.json +49 -137
  48. package/build/child.js +0 -4110
  49. package/build/index.js +0 -104447
  50. package/build/public/.DS_Store +0 -0
  51. package/build/public/assets/alert.60ea9f84.svg +0 -5
  52. package/build/public/assets/array.1a36c222.svg +0 -4
  53. package/build/public/assets/boolean.9188b434.svg +0 -4
  54. package/build/public/assets/browser.21a575be.js +0 -1
  55. package/build/public/assets/browser.38b7fdb1.js +0 -1
  56. package/build/public/assets/browser.cdd2249a.js +0 -1
  57. package/build/public/assets/chevron-down.24f76e3c.svg +0 -3
  58. package/build/public/assets/cross.c2610cf5.svg +0 -11
  59. package/build/public/assets/datetime.a3bf710a.svg +0 -4
  60. package/build/public/assets/download.8d34b65a.svg +0 -4
  61. package/build/public/assets/ellipsis.a8c5a34a.svg +0 -10
  62. package/build/public/assets/enum.7ec0b64c.svg +0 -6
  63. package/build/public/assets/folder.d77b8eaf.svg +0 -6
  64. package/build/public/assets/hamburger.5fdadeac.svg +0 -4
  65. package/build/public/assets/logotype.a960b169.svg +0 -4
  66. package/build/public/assets/number.85ddf96b.svg +0 -7
  67. package/build/public/assets/object.0ba944a6.svg +0 -5
  68. package/build/public/assets/play.8811691e.svg +0 -6
  69. package/build/public/assets/plus.8fbf7ad3.svg +0 -4
  70. package/build/public/assets/read.79154521.svg +0 -1
  71. package/build/public/assets/refresh.d5448ccc.svg +0 -4
  72. package/build/public/assets/search.2ed766ce.svg +0 -7
  73. package/build/public/assets/settings.5ad25af2.svg +0 -8
  74. package/build/public/assets/string.ea615a24.svg +0 -4
  75. package/build/public/assets/tick-indeterminate.aec8a44d.svg +0 -3
  76. package/build/public/assets/tick.8cbb6a93.svg +0 -4
  77. package/build/public/assets/vendor.c4d0f081.js +0 -354
  78. package/build/public/demo.html +0 -17
  79. package/build/public/demoChunk.js +0 -2
  80. package/build/public/electron-darwin.html +0 -19
  81. package/build/public/electron-linux.html +0 -18
  82. package/build/public/electron-mac.html +0 -18
  83. package/build/public/electron-win.html +0 -17
  84. package/build/public/electron-win32.html +0 -18
  85. package/build/public/electron.html +0 -17
  86. package/build/public/electronBus.js +0 -2
  87. package/build/public/electronChunk.js +0 -2
  88. package/build/public/favicon/apple-touch-icon.png +0 -0
  89. package/build/public/favicon/favicon-16x16.png +0 -0
  90. package/build/public/favicon/favicon-32x32.png +0 -0
  91. package/build/public/favicon/prisma.png +0 -0
  92. package/build/public/favicon.svg +0 -5
  93. package/build/public/fonts/.DS_Store +0 -0
  94. package/build/public/fonts/Inter.ttf +0 -0
  95. package/build/public/fonts/RobotoMono.ttf +0 -0
  96. package/build/public/icons/.DS_Store +0 -0
  97. package/build/public/icons/alert.svg +0 -5
  98. package/build/public/icons/array.svg +0 -4
  99. package/build/public/icons/bin.svg +0 -37
  100. package/build/public/icons/boolean.svg +0 -4
  101. package/build/public/icons/check.svg +0 -3
  102. package/build/public/icons/chevron-down.svg +0 -3
  103. package/build/public/icons/code.svg +0 -4
  104. package/build/public/icons/cross.svg +0 -11
  105. package/build/public/icons/data-tool.svg +0 -5
  106. package/build/public/icons/database.svg +0 -4
  107. package/build/public/icons/datetime.svg +0 -4
  108. package/build/public/icons/double-arrow-right.svg +0 -4
  109. package/build/public/icons/download.svg +0 -4
  110. package/build/public/icons/ellipsis.svg +0 -10
  111. package/build/public/icons/enum.svg +0 -6
  112. package/build/public/icons/expand.svg +0 -4
  113. package/build/public/icons/eye.svg +0 -20
  114. package/build/public/icons/filters.svg +0 -5
  115. package/build/public/icons/folder.svg +0 -6
  116. package/build/public/icons/hamburger.svg +0 -4
  117. package/build/public/icons/icon.svg +0 -199
  118. package/build/public/icons/logo.svg +0 -199
  119. package/build/public/icons/logotype.svg +0 -4
  120. package/build/public/icons/number.svg +0 -7
  121. package/build/public/icons/object.svg +0 -5
  122. package/build/public/icons/play.svg +0 -6
  123. package/build/public/icons/plus.svg +0 -4
  124. package/build/public/icons/refresh.svg +0 -4
  125. package/build/public/icons/search.svg +0 -7
  126. package/build/public/icons/settings.svg +0 -8
  127. package/build/public/icons/string.svg +0 -4
  128. package/build/public/icons/tick-indeterminate.svg +0 -3
  129. package/build/public/icons/tick.svg +0 -4
  130. package/build/public/illustrations/.DS_Store +0 -0
  131. package/build/public/illustrations/empty.svg +0 -1
  132. package/build/public/illustrations/read.svg +0 -1
  133. package/build/public/illustrations/searching.svg +0 -1
  134. package/build/public/images/.DS_Store +0 -0
  135. package/build/public/images/icon-1024.png +0 -0
  136. package/build/public/index.css +0 -1
  137. package/build/public/index.html +0 -49
  138. package/build/public/index.js +0 -1
  139. package/build/public/main.31f688a6254e294d9128.css +0 -118
  140. package/build/public/main.31f688a6254e294d9128.css.map +0 -1
  141. package/build/public/main.364c712f32662ff0e43d.css +0 -116
  142. package/build/public/main.364c712f32662ff0e43d.css.map +0 -1
  143. package/build/public/main.42ef3fe7e97347765c91.css +0 -118
  144. package/build/public/main.42ef3fe7e97347765c91.css.map +0 -1
  145. package/build/public/main.503446defafe7aeca2f3.css +0 -116
  146. package/build/public/main.503446defafe7aeca2f3.css.map +0 -1
  147. package/build/public/main.c50a3b5980fe26f78b65.css +0 -118
  148. package/build/public/main.c50a3b5980fe26f78b65.css.map +0 -1
  149. package/build/public/main.cda25e5813776c2af295.css +0 -116
  150. package/build/public/main.cda25e5813776c2af295.css.map +0 -1
  151. package/build/public/main.dbac3b290f78404ff579.css +0 -116
  152. package/build/public/main.dbac3b290f78404ff579.css.map +0 -1
  153. package/build/public/main.f8ce44e122e5e2b8f778.css +0 -118
  154. package/build/public/main.f8ce44e122e5e2b8f778.css.map +0 -1
  155. package/build/public/main.fc9ea7521a4aecce1a77.css +0 -118
  156. package/build/public/main.fc9ea7521a4aecce1a77.css.map +0 -1
  157. package/build/public/main.js +0 -403
  158. package/build/public/main.js.map +0 -1
  159. package/build/public/mainChunk.0a84f3ba4d2ab481e877.css +0 -116
  160. package/build/public/mainChunk.1b327d58afbddc917bce.css +0 -118
  161. package/build/public/mainChunk.2cdf583b2bd51aa67587.css +0 -118
  162. package/build/public/mainChunk.544af00f7e9ffcbe782c.css +0 -118
  163. package/build/public/mainChunk.56f96a13868b2b4a53be.css +0 -118
  164. package/build/public/mainChunk.5cee429bfbf06e7ecb39.css +0 -118
  165. package/build/public/mainChunk.a862474ed4cdb421ffa2.css +0 -118
  166. package/build/public/mainChunk.ada34153c4911b5ac22b.css +0 -118
  167. package/build/public/mainChunk.c16a8d01b2c49b2f2751.css +0 -118
  168. package/build/public/mainChunk.ca4a878d5478b9320be8.css +0 -116
  169. package/build/public/mainChunk.e3adc8758b4395546cef.css +0 -116
  170. package/build/public/mainChunk.f2c59fcbfc455d8b9de5.css +0 -118
  171. package/build/public/mainChunk.js +0 -396
  172. package/build/public/manifest.json +0 -34
  173. package/build/public/preview.html +0 -16
  174. package/build/public/previewBus.js +0 -2
  175. package/build/public/previewChunk.js +0 -2
  176. package/build/public/projects.html +0 -86
  177. package/build/public/server.html +0 -16
  178. package/build/public/serverBus.js +0 -2
  179. package/build/public/serverChunk.js +0 -2
  180. package/build/public/splash.html +0 -17
  181. package/build/public/studioBundle.828f34b1781061528841.css +0 -118
  182. package/build/public/studioBundle.bfe9138b2e0293fcb7da.css +0 -118
  183. package/build/public/studioBundle.c5b256eede880e502aac.css +0 -118
  184. package/build/public/studioBundle.e43df511c8e2e368900a.css +0 -118
  185. package/build/public/studioBundle.e69382554c2a2942ae32.css +0 -118
  186. package/build/public/studioBundle.ee21aa56a3999a2b380b.css +0 -118
  187. package/build/public/studioBundle.js +0 -396
  188. package/build/public/vercel.html +0 -16
  189. package/build/public/vercelChunk.js +0 -2
  190. package/build/public/views/index.pug +0 -89
  191. package/build/xdg-open +0 -1066
  192. package/install/index.js +0 -5
  193. package/preinstall/index.js +0 -46
  194. package/prisma-client/README.md +0 -27
  195. package/prisma-client/generator-build/.DS_Store +0 -0
  196. package/prisma-client/generator-build/index.js +0 -79697
  197. package/prisma-client/index-browser.js +0 -3
  198. package/prisma-client/index.d.ts +0 -1
  199. package/prisma-client/index.js +0 -11
  200. package/prisma-client/package.json +0 -138
  201. package/prisma-client/runtime/index-browser.d.ts +0 -267
  202. package/prisma-client/runtime/index-browser.js +0 -2273
  203. package/prisma-client/runtime/index.d.ts +0 -1018
  204. package/prisma-client/runtime/index.js +0 -35028
  205. package/prisma-client/scripts/backup-index-browser.js +0 -3
  206. package/prisma-client/scripts/backup-index.d.ts +0 -1
  207. package/prisma-client/scripts/backup-index.js +0 -11
  208. package/prisma-client/scripts/colors.js +0 -180
  209. package/prisma-client/scripts/default-index-browser.js +0 -12
  210. package/prisma-client/scripts/default-index.d.ts +0 -47
  211. package/prisma-client/scripts/default-index.js +0 -12
  212. package/prisma-client/scripts/get-packed-client.js +0 -12
  213. package/prisma-client/scripts/mock-fs.js +0 -14
  214. package/prisma-client/scripts/postinstall.d.ts +0 -5
  215. package/prisma-client/scripts/postinstall.js +0 -398
  216. package/scripts/install-entry.js +0 -8
  217. package/scripts/preinstall-entry.js +0 -9
@@ -0,0 +1,117 @@
1
+ import { getApiBaseUrl } from "./client.js";
2
+ import { FileTokenStorage } from "../../adapters/token-storage.js";
3
+ import open from "open";
4
+ import { AuthError, createManagementApiSdk } from "@prisma/management-api-sdk";
5
+ import events from "node:events";
6
+ import http from "node:http";
7
+ //#region src/lib/auth/login.ts
8
+ var AuthError$1 = class extends Error {
9
+ constructor(message) {
10
+ super(message);
11
+ this.name = "AuthError";
12
+ }
13
+ };
14
+ async function login(options = {}) {
15
+ const hostname = options.hostname ?? "localhost";
16
+ const port = options.port ?? 0;
17
+ const server = http.createServer();
18
+ server.listen({
19
+ host: hostname,
20
+ port
21
+ });
22
+ try {
23
+ const state = new LoginState({
24
+ hostname,
25
+ port: (await events.once(server, "listening").then(() => server.address())).port,
26
+ tokenStorage: options.tokenStorage,
27
+ clientId: options.clientId,
28
+ apiBaseUrl: options.apiBaseUrl,
29
+ authBaseUrl: options.authBaseUrl,
30
+ openUrl: options.openUrl,
31
+ env: options.env
32
+ });
33
+ const authResult = new Promise((resolve, reject) => {
34
+ server.on("request", async (req, res) => {
35
+ const url = new URL(`http://${state.host}${req.url}`);
36
+ if (url.pathname !== "/auth/callback") {
37
+ res.statusCode = 404;
38
+ res.end("Not found");
39
+ return;
40
+ }
41
+ try {
42
+ await state.handleCallback(url);
43
+ } catch (error) {
44
+ res.statusCode = 400;
45
+ const message = error instanceof Error ? error.message : String(error);
46
+ res.end(message);
47
+ reject(error);
48
+ return;
49
+ }
50
+ res.setHeader("Content-Type", "text/html");
51
+ res.end(`<html><body style="font-family:system-ui;max-width:400px;margin:80px auto;text-align:center"><h2>✓ Signed in</h2><p>You may now close this tab and return to the terminal.</p></body></html>`);
52
+ resolve();
53
+ });
54
+ });
55
+ await state.openLoginPage();
56
+ await authResult;
57
+ } finally {
58
+ if (server.listening) await new Promise((resolve) => server.close(() => resolve()));
59
+ }
60
+ }
61
+ var LoginState = class {
62
+ latestVerifier;
63
+ latestState;
64
+ sdk;
65
+ openUrl;
66
+ constructor(options) {
67
+ this.options = options;
68
+ const tokenStorage = options.tokenStorage ?? new FileTokenStorage(options.env);
69
+ this.sdk = createManagementApiSdk({
70
+ clientId: options.clientId ?? "cmm3lndn701oo0uefvxzo0ivw",
71
+ redirectUri: `http://${options.hostname}:${options.port}/auth/callback`,
72
+ tokenStorage,
73
+ apiBaseUrl: options.apiBaseUrl ?? getApiBaseUrl(options.env),
74
+ authBaseUrl: options.authBaseUrl
75
+ });
76
+ this.openUrl = options.openUrl ?? open;
77
+ }
78
+ async openLoginPage() {
79
+ const { url, state, verifier } = await this.sdk.getLoginUrl({
80
+ scope: "workspace:admin offline_access",
81
+ additionalParams: {
82
+ utm_source: "prisma-cli",
83
+ utm_medium: "command-login",
84
+ utm_campaign: "prisma-cli"
85
+ }
86
+ });
87
+ this.latestState = state;
88
+ this.latestVerifier = verifier;
89
+ await this.openUrl(url);
90
+ }
91
+ async handleCallback(url) {
92
+ if (url.pathname !== "/auth/callback") throw new AuthError$1("Not a callback URL");
93
+ const params = url.searchParams;
94
+ const error = params.get("error");
95
+ if (error) {
96
+ const desc = params.get("error_description");
97
+ throw new AuthError$1(desc ? `${error}: ${desc}` : error);
98
+ }
99
+ if (!this.latestVerifier) throw new AuthError$1("No verifier found");
100
+ if (!this.latestState) throw new AuthError$1("No state found");
101
+ try {
102
+ await this.sdk.handleCallback({
103
+ callbackUrl: url,
104
+ verifier: this.latestVerifier,
105
+ expectedState: this.latestState
106
+ });
107
+ } catch (error) {
108
+ if (error instanceof AuthError) throw new AuthError$1(error.message);
109
+ throw new AuthError$1(error instanceof Error ? error.message : "Unknown error during login");
110
+ }
111
+ }
112
+ get host() {
113
+ return `${this.options.hostname}:${this.options.port}`;
114
+ }
115
+ };
116
+ //#endregion
117
+ export { login };
@@ -0,0 +1,93 @@
1
+ import { formatDescriptorLabel } from "../shell/command-meta.js";
2
+ import { maskValue, padDisplay, renderSummaryLine } from "../shell/ui.js";
3
+ import stringWidth from "string-width";
4
+ //#region src/output/patterns.ts
5
+ function renderList(input, ui) {
6
+ const keyWidth = Math.max(stringWidth(`${input.parentContext.key}:`), ...input.items.map((item) => stringWidth(`⚬ ${item.noun}:`)), stringWidth("Read more"));
7
+ const lines = renderCardTitle(input.descriptor, input.title, ui);
8
+ lines.push(renderCardRow(ui, keyWidth, input.parentContext.key, input.parentContext.value));
9
+ if (input.items.length === 0) lines.push(renderPlainCardLine(ui, ui.dim(input.emptyMessage)));
10
+ else for (const item of input.items) lines.push(renderCardRow(ui, keyWidth, `⚬ ${item.noun}`, formatListItemValue(ui, item)));
11
+ lines.push(renderCardDivider(ui));
12
+ lines.push(renderReadMore(ui, keyWidth, input.descriptor));
13
+ return lines;
14
+ }
15
+ function serializeList(input) {
16
+ return {
17
+ context: input.context,
18
+ items: input.items.map((item) => ({
19
+ name: item.label,
20
+ id: item.id,
21
+ status: item.status
22
+ })),
23
+ count: input.items.length
24
+ };
25
+ }
26
+ function renderShow(input, ui) {
27
+ const keyWidth = Math.max(...input.fields.map((field) => stringWidth(`${field.key}:`)), stringWidth("Read more"));
28
+ const lines = renderCardTitle(input.descriptor, input.title, ui);
29
+ for (const field of input.fields) lines.push(renderCardRow(ui, keyWidth, field.key, formatValue(ui, field.value, field.tone, field.sensitive)));
30
+ lines.push(renderCardDivider(ui));
31
+ lines.push(renderReadMore(ui, keyWidth, input.descriptor));
32
+ return lines;
33
+ }
34
+ function renderMutate(input, ui) {
35
+ const rows = [...input.context, {
36
+ key: "mode",
37
+ value: "apply",
38
+ tone: "dim"
39
+ }];
40
+ const keyWidth = Math.max(...rows.map((row) => stringWidth(`${row.key}:`)), stringWidth("Read more"));
41
+ const lines = renderCardTitle(input.descriptor, input.title, ui);
42
+ for (const row of rows) lines.push(renderCardRow(ui, keyWidth, row.key, formatValue(ui, row.value, row.tone, row.sensitive)));
43
+ lines.push(renderCardDivider(ui));
44
+ lines.push(renderReadMore(ui, keyWidth, input.descriptor));
45
+ lines.push("");
46
+ lines.push(`${ui.warning("◇")} ${input.operationDescription}...`);
47
+ lines.push(renderSummaryLine(ui, "success", `Applied ${input.operationCount} operation(s)`));
48
+ for (const detail of input.details) lines.push(` ${detail}`);
49
+ for (const alert of input.alerts ?? []) {
50
+ lines.push("");
51
+ lines.push(renderSummaryLine(ui, alert.tone, alert.text));
52
+ }
53
+ return lines;
54
+ }
55
+ function renderCardTitle(descriptor, title, ui) {
56
+ return [`${ui.strong(formatDescriptorLabel(descriptor))} ${ui.dim("→")} ${ui.dim(title)}`, ""];
57
+ }
58
+ function renderCardRow(ui, keyWidth, key, value) {
59
+ return `${renderCardRail(ui)} ${ui.accent(padDisplay(`${key}:`, keyWidth))} ${value}`;
60
+ }
61
+ function renderPlainCardLine(ui, text) {
62
+ return `${renderCardRail(ui)} ${text}`;
63
+ }
64
+ function renderCardDivider(ui) {
65
+ return renderCardRail(ui);
66
+ }
67
+ function renderReadMore(ui, keyWidth, descriptor) {
68
+ return `${renderCardRail(ui)} ${ui.accent(padDisplay("Read more", keyWidth))} ${ui.link(descriptor.docsPath ?? "")}`;
69
+ }
70
+ function renderCardRail(ui) {
71
+ return ui.dim("│");
72
+ }
73
+ function formatListItemValue(ui, item) {
74
+ const annotation = renderAnnotation(ui, item.status);
75
+ return annotation ? `${item.label} ${annotation}` : item.label;
76
+ }
77
+ function renderAnnotation(ui, status) {
78
+ if (status === "active") return ui.success("(active)");
79
+ if (status === "linked") return ui.accent("(linked)");
80
+ if (status === "default") return ui.dim("(default)");
81
+ return "";
82
+ }
83
+ function formatValue(ui, value, tone = "default", sensitive = false) {
84
+ const resolvedValue = sensitive ? maskValue(value) : value;
85
+ if (tone === "success") return ui.success(resolvedValue);
86
+ if (tone === "warning") return ui.warning(resolvedValue);
87
+ if (tone === "error") return ui.error(resolvedValue);
88
+ if (tone === "link") return ui.link(resolvedValue);
89
+ if (tone === "dim") return ui.dim(resolvedValue);
90
+ return resolvedValue;
91
+ }
92
+ //#endregion
93
+ export { renderList, renderMutate, renderShow, serializeList };
@@ -0,0 +1,405 @@
1
+ import { renderList, renderShow, serializeList } from "../output/patterns.js";
2
+ //#region src/presenters/app.ts
3
+ function renderAppBuild(context, descriptor, result) {
4
+ return renderShow({
5
+ title: "Building the local app artifact.",
6
+ descriptor,
7
+ fields: [
8
+ {
9
+ key: "build type",
10
+ value: result.buildType
11
+ },
12
+ {
13
+ key: "entrypoint",
14
+ value: result.entrypoint ?? "none",
15
+ tone: result.entrypoint ? "default" : "dim"
16
+ },
17
+ {
18
+ key: "directory",
19
+ value: result.directory
20
+ }
21
+ ]
22
+ }, context.ui);
23
+ }
24
+ function serializeAppBuild(result) {
25
+ return result;
26
+ }
27
+ function renderAppDeploy(context, descriptor, result) {
28
+ return renderShow({
29
+ title: "Deploying the selected app.",
30
+ descriptor,
31
+ fields: [
32
+ {
33
+ key: "project",
34
+ value: result.projectId
35
+ },
36
+ {
37
+ key: "app",
38
+ value: result.app.name
39
+ },
40
+ {
41
+ key: "deployment",
42
+ value: result.deployment.id
43
+ },
44
+ {
45
+ key: "status",
46
+ value: result.deployment.status,
47
+ tone: toneForStatus(result.deployment.status)
48
+ },
49
+ ...result.deployment.url ? [{
50
+ key: "url",
51
+ value: result.deployment.url,
52
+ tone: "link"
53
+ }] : []
54
+ ]
55
+ }, context.ui);
56
+ }
57
+ function serializeAppDeploy(result) {
58
+ return result;
59
+ }
60
+ function renderAppUpdateEnv(context, descriptor, result) {
61
+ return renderShow({
62
+ title: "Updating environment variables for the selected app.",
63
+ descriptor,
64
+ fields: [
65
+ {
66
+ key: "project",
67
+ value: result.projectId
68
+ },
69
+ {
70
+ key: "app",
71
+ value: result.app.name
72
+ },
73
+ {
74
+ key: "deployment",
75
+ value: result.deployment.id
76
+ },
77
+ {
78
+ key: "status",
79
+ value: result.deployment.status,
80
+ tone: toneForStatus(result.deployment.status)
81
+ },
82
+ ...result.deployment.url ? [{
83
+ key: "url",
84
+ value: result.deployment.url,
85
+ tone: "link"
86
+ }] : [],
87
+ {
88
+ key: "variables",
89
+ value: formatVariableNames(result.variables),
90
+ tone: result.variables.length > 0 ? "default" : "dim"
91
+ }
92
+ ]
93
+ }, context.ui);
94
+ }
95
+ function serializeAppUpdateEnv(result) {
96
+ return result;
97
+ }
98
+ function renderAppListEnv(context, descriptor, result) {
99
+ return renderShow({
100
+ title: "Listing environment variables for the selected app.",
101
+ descriptor,
102
+ fields: [
103
+ {
104
+ key: "project",
105
+ value: result.projectId
106
+ },
107
+ {
108
+ key: "app",
109
+ value: result.app?.name ?? "not selected",
110
+ tone: result.app ? "default" : "dim"
111
+ },
112
+ {
113
+ key: "deployment",
114
+ value: result.deployment?.id ?? "none",
115
+ tone: result.deployment ? toneForStatus(result.deployment.status) : "dim"
116
+ },
117
+ {
118
+ key: "variables",
119
+ value: formatVariableNames(result.variables),
120
+ tone: result.variables.length > 0 ? "default" : "dim"
121
+ }
122
+ ]
123
+ }, context.ui);
124
+ }
125
+ function serializeAppListEnv(result) {
126
+ return result;
127
+ }
128
+ function renderAppListDeploys(context, descriptor, result) {
129
+ return renderList({
130
+ title: "Listing deployments for the selected app.",
131
+ descriptor,
132
+ parentContext: {
133
+ key: "app",
134
+ value: result.app?.name ?? "not selected"
135
+ },
136
+ items: result.deployments.map((deployment) => ({
137
+ noun: "deployment",
138
+ label: deployment.id,
139
+ id: deployment.id,
140
+ status: deployment.live ? "active" : null
141
+ })),
142
+ emptyMessage: result.app ? "No deployments found." : "No apps found."
143
+ }, context.ui);
144
+ }
145
+ function serializeAppListDeploys(result) {
146
+ if (!result.app) return {
147
+ projectId: result.projectId,
148
+ app: null,
149
+ items: [],
150
+ count: 0
151
+ };
152
+ return {
153
+ projectId: result.projectId,
154
+ app: result.app,
155
+ ...serializeList({
156
+ context: { app: result.app.name },
157
+ items: result.deployments.map((deployment) => ({
158
+ noun: "deployment",
159
+ label: deployment.id,
160
+ id: deployment.id,
161
+ status: deployment.live ? "active" : null
162
+ }))
163
+ })
164
+ };
165
+ }
166
+ function renderAppShow(context, descriptor, result) {
167
+ return renderShow({
168
+ title: "Showing the selected app state.",
169
+ descriptor,
170
+ fields: [
171
+ {
172
+ key: "project",
173
+ value: result.projectId
174
+ },
175
+ {
176
+ key: "app",
177
+ value: result.app?.name ?? "not selected",
178
+ tone: result.app ? "default" : "dim"
179
+ },
180
+ {
181
+ key: "live deployment",
182
+ value: result.liveDeployment?.id ?? "none",
183
+ tone: result.liveDeployment ? toneForStatus(result.liveDeployment.status) : "dim"
184
+ },
185
+ {
186
+ key: "live url",
187
+ value: result.liveUrl ?? "unavailable",
188
+ tone: result.liveUrl ? "link" : "dim"
189
+ },
190
+ {
191
+ key: "recent deployments",
192
+ value: formatRecentDeployments(result.recentDeployments),
193
+ tone: result.recentDeployments.length > 0 ? "default" : "dim"
194
+ }
195
+ ]
196
+ }, context.ui);
197
+ }
198
+ function serializeAppShow(result) {
199
+ return result;
200
+ }
201
+ function renderAppShowDeploy(context, descriptor, result) {
202
+ return renderShow({
203
+ title: "Showing deployment details.",
204
+ descriptor,
205
+ fields: [
206
+ ...result.app ? [{
207
+ key: "app",
208
+ value: result.app.name
209
+ }] : [],
210
+ {
211
+ key: "deployment",
212
+ value: result.deployment.id
213
+ },
214
+ {
215
+ key: "status",
216
+ value: result.deployment.status,
217
+ tone: toneForStatus(result.deployment.status)
218
+ },
219
+ ...result.deployment.url ? [{
220
+ key: "url",
221
+ value: result.deployment.url,
222
+ tone: "link"
223
+ }] : [],
224
+ ...result.deployment.live === null ? [] : [{
225
+ key: "live",
226
+ value: result.deployment.live ? "yes" : "no",
227
+ tone: result.deployment.live ? "success" : "dim"
228
+ }],
229
+ {
230
+ key: "created",
231
+ value: result.deployment.createdAt,
232
+ tone: "dim"
233
+ }
234
+ ]
235
+ }, context.ui);
236
+ }
237
+ function serializeAppShowDeploy(result) {
238
+ return result;
239
+ }
240
+ function renderAppOpen(context, descriptor, result) {
241
+ return renderShow({
242
+ title: result.opened ? "Opening the live URL for the selected app." : "Resolving the live URL for the selected app.",
243
+ descriptor,
244
+ fields: [
245
+ {
246
+ key: "project",
247
+ value: result.projectId
248
+ },
249
+ {
250
+ key: "app",
251
+ value: result.app.name
252
+ },
253
+ {
254
+ key: "url",
255
+ value: result.url,
256
+ tone: "link"
257
+ },
258
+ {
259
+ key: "opened",
260
+ value: result.opened ? "yes" : "no",
261
+ tone: result.opened ? "success" : "dim"
262
+ }
263
+ ]
264
+ }, context.ui);
265
+ }
266
+ function serializeAppOpen(result) {
267
+ return result;
268
+ }
269
+ function renderAppPromote(context, descriptor, result) {
270
+ return renderShow({
271
+ title: "Switching the live deployment for the selected app.",
272
+ descriptor,
273
+ fields: [
274
+ {
275
+ key: "project",
276
+ value: result.projectId
277
+ },
278
+ {
279
+ key: "app",
280
+ value: result.app.name
281
+ },
282
+ {
283
+ key: "deployment",
284
+ value: result.deployment.id
285
+ },
286
+ {
287
+ key: "status",
288
+ value: result.deployment.status,
289
+ tone: toneForStatus(result.deployment.status)
290
+ },
291
+ ...result.deployment.url ? [{
292
+ key: "url",
293
+ value: result.deployment.url,
294
+ tone: "link"
295
+ }] : [],
296
+ {
297
+ key: "live",
298
+ value: result.deployment.live ? "yes" : "no",
299
+ tone: result.deployment.live ? "success" : "dim"
300
+ },
301
+ {
302
+ key: "created",
303
+ value: result.deployment.createdAt,
304
+ tone: "dim"
305
+ }
306
+ ]
307
+ }, context.ui);
308
+ }
309
+ function serializeAppPromote(result) {
310
+ return result;
311
+ }
312
+ function renderAppRollback(context, descriptor, result) {
313
+ return renderShow({
314
+ title: "Restoring the selected app to an earlier deployment.",
315
+ descriptor,
316
+ fields: [
317
+ {
318
+ key: "project",
319
+ value: result.projectId
320
+ },
321
+ {
322
+ key: "app",
323
+ value: result.app.name
324
+ },
325
+ {
326
+ key: "deployment",
327
+ value: result.deployment.id
328
+ },
329
+ {
330
+ key: "status",
331
+ value: result.deployment.status,
332
+ tone: toneForStatus(result.deployment.status)
333
+ },
334
+ ...result.deployment.url ? [{
335
+ key: "url",
336
+ value: result.deployment.url,
337
+ tone: "link"
338
+ }] : [],
339
+ {
340
+ key: "live",
341
+ value: result.deployment.live ? "yes" : "no",
342
+ tone: result.deployment.live ? "success" : "dim"
343
+ },
344
+ {
345
+ key: "created",
346
+ value: result.deployment.createdAt,
347
+ tone: "dim"
348
+ },
349
+ ...result.previousLiveDeploymentId ? [{
350
+ key: "replaced",
351
+ value: result.previousLiveDeploymentId,
352
+ tone: "dim"
353
+ }] : []
354
+ ]
355
+ }, context.ui);
356
+ }
357
+ function serializeAppRollback(result) {
358
+ return result;
359
+ }
360
+ function renderAppRun(_context, _descriptor, _result) {
361
+ return [];
362
+ }
363
+ function serializeAppRun(result) {
364
+ return result;
365
+ }
366
+ function renderAppRemove(context, descriptor, result) {
367
+ return renderShow({
368
+ title: "Removing the selected app.",
369
+ descriptor,
370
+ fields: [
371
+ {
372
+ key: "project",
373
+ value: result.projectId
374
+ },
375
+ {
376
+ key: "app",
377
+ value: result.app.name
378
+ },
379
+ {
380
+ key: "removed",
381
+ value: result.removed ? "yes" : "no",
382
+ tone: result.removed ? "success" : "dim"
383
+ }
384
+ ]
385
+ }, context.ui);
386
+ }
387
+ function serializeAppRemove(result) {
388
+ return result;
389
+ }
390
+ function toneForStatus(status) {
391
+ if (status === "running" || status === "ready" || status === "healthy") return "success";
392
+ if (status === "provisioning" || status === "building" || status === "starting") return "warning";
393
+ if (status === "failed" || status === "error") return "error";
394
+ return "default";
395
+ }
396
+ function formatRecentDeployments(deployments) {
397
+ if (deployments.length === 0) return "none";
398
+ return deployments.map((deployment) => `${deployment.id}${deployment.live ? " (live)" : ""}`).join(", ");
399
+ }
400
+ function formatVariableNames(variables) {
401
+ if (variables.length === 0) return "none";
402
+ return variables.join(", ");
403
+ }
404
+ //#endregion
405
+ export { renderAppBuild, renderAppDeploy, renderAppListDeploys, renderAppListEnv, renderAppOpen, renderAppPromote, renderAppRemove, renderAppRollback, renderAppRun, renderAppShow, renderAppShowDeploy, renderAppUpdateEnv, serializeAppBuild, serializeAppDeploy, serializeAppListDeploys, serializeAppListEnv, serializeAppOpen, serializeAppPromote, serializeAppRemove, serializeAppRollback, serializeAppRun, serializeAppShow, serializeAppShowDeploy, serializeAppUpdateEnv };
@@ -0,0 +1,73 @@
1
+ import { renderMutate, renderShow } from "../output/patterns.js";
2
+ //#region src/presenters/auth.ts
3
+ function renderAuthSuccess(context, descriptor, command, result) {
4
+ if (command === "auth.login") {
5
+ const rows = [];
6
+ if (result.provider) rows.push({
7
+ key: "provider",
8
+ value: providerLabel(result.provider)
9
+ });
10
+ if (result.user) rows.push({
11
+ key: "user",
12
+ value: `${result.user.name} <${result.user.email}>`
13
+ });
14
+ if (result.workspace?.name) rows.push({
15
+ key: "workspace",
16
+ value: result.workspace.name
17
+ });
18
+ return renderMutate({
19
+ title: "Starting an authenticated CLI session.",
20
+ descriptor,
21
+ context: rows,
22
+ operationDescription: "Applying authentication session changes",
23
+ operationCount: 1,
24
+ details: ["Session stored in local CLI state."]
25
+ }, context.ui);
26
+ }
27
+ if (command === "auth.logout") return renderMutate({
28
+ title: "Clearing the current CLI session.",
29
+ descriptor,
30
+ context: [{
31
+ key: "session",
32
+ value: "local CLI state",
33
+ tone: "dim"
34
+ }],
35
+ operationDescription: "Applying authentication session changes",
36
+ operationCount: 1,
37
+ details: ["Session removed from local CLI state."]
38
+ }, context.ui);
39
+ return renderShow({
40
+ title: "Showing the current authenticated identity.",
41
+ descriptor,
42
+ fields: result.authenticated ? [
43
+ {
44
+ key: "status",
45
+ value: "signed in",
46
+ tone: "success"
47
+ },
48
+ ...result.user ? [{
49
+ key: "user",
50
+ value: `${result.user.name} <${result.user.email}>`
51
+ }] : [],
52
+ ...result.provider ? [{
53
+ key: "provider",
54
+ value: providerLabel(result.provider)
55
+ }] : [],
56
+ ...result.workspace?.name ? [{
57
+ key: "workspace",
58
+ value: result.workspace.name
59
+ }] : []
60
+ ] : [{
61
+ key: "status",
62
+ value: "signed out",
63
+ tone: "dim"
64
+ }]
65
+ }, context.ui);
66
+ }
67
+ function providerLabel(provider) {
68
+ if (provider === "github") return "GitHub";
69
+ if (provider === "google") return "Google";
70
+ return "";
71
+ }
72
+ //#endregion
73
+ export { renderAuthSuccess };