@prisma/cli 2.20.1 → 3.0.0-alpha.0

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 +223 -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 +813 -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 +149 -0
  21. package/dist/lib/app/preview-build.js +283 -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 +320 -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,320 @@
1
+ //#region src/shell/command-meta.ts
2
+ const COMMAND_DESCRIPTOR_ID = Symbol("prisma.commandDescriptorId");
3
+ const DESCRIPTORS = [
4
+ {
5
+ id: "root",
6
+ path: ["prisma"],
7
+ description: "Unified Prisma CLI.",
8
+ docsPath: "docs/product/command-principles.md",
9
+ examples: ["prisma auth login", "prisma project list"],
10
+ longDescription: "The Prisma CLI groups commands by developer workflow and keeps human and agent behavior aligned."
11
+ },
12
+ {
13
+ id: "auth",
14
+ path: ["prisma", "auth"],
15
+ description: "Authentication and identity commands.",
16
+ docsPath: "docs/product/command-spec.md#prisma-auth-login",
17
+ examples: ["prisma auth login", "prisma auth whoami"]
18
+ },
19
+ {
20
+ id: "auth.login",
21
+ path: [
22
+ "prisma",
23
+ "auth",
24
+ "login"
25
+ ],
26
+ description: "Start an authenticated CLI session.",
27
+ docsPath: "docs/product/command-spec.md#prisma-auth-login",
28
+ examples: ["prisma auth login"]
29
+ },
30
+ {
31
+ id: "auth.logout",
32
+ path: [
33
+ "prisma",
34
+ "auth",
35
+ "logout"
36
+ ],
37
+ description: "Clear the current CLI session.",
38
+ docsPath: "docs/product/command-spec.md#prisma-auth-logout",
39
+ examples: ["prisma auth logout"]
40
+ },
41
+ {
42
+ id: "auth.whoami",
43
+ path: [
44
+ "prisma",
45
+ "auth",
46
+ "whoami"
47
+ ],
48
+ description: "Show the current authenticated identity.",
49
+ docsPath: "docs/product/command-spec.md#prisma-auth-whoami",
50
+ examples: ["prisma auth whoami", "prisma auth whoami --json"]
51
+ },
52
+ {
53
+ id: "project",
54
+ path: ["prisma", "project"],
55
+ description: "Project discovery and repo linking commands.",
56
+ docsPath: "docs/product/command-spec.md#prisma-project-list",
57
+ examples: ["prisma project list", "prisma project show"]
58
+ },
59
+ {
60
+ id: "app",
61
+ path: ["prisma", "app"],
62
+ description: "App deployment and release commands.",
63
+ docsPath: "docs/product/command-spec.md#prisma-app-deploy---app-name---entry-path---build-type-autobunnextjs---http-port-port---env-namevalue",
64
+ examples: ["prisma app build --build-type nextjs", "prisma app deploy --app hello-world --build-type nextjs --http-port 3000"]
65
+ },
66
+ {
67
+ id: "branch",
68
+ path: ["prisma", "branch"],
69
+ description: "Branch context and safety commands.",
70
+ docsPath: "docs/product/command-spec.md#prisma-branch-list",
71
+ examples: ["prisma branch list", "prisma branch use production"]
72
+ },
73
+ {
74
+ id: "project.list",
75
+ path: [
76
+ "prisma",
77
+ "project",
78
+ "list"
79
+ ],
80
+ description: "List projects for the authenticated workspace.",
81
+ docsPath: "docs/product/command-spec.md#prisma-project-list",
82
+ examples: ["prisma project list", "prisma project list --json"]
83
+ },
84
+ {
85
+ id: "project.show",
86
+ path: [
87
+ "prisma",
88
+ "project",
89
+ "show"
90
+ ],
91
+ description: "Show the linked project for the current repo.",
92
+ docsPath: "docs/product/command-spec.md#prisma-project-show",
93
+ examples: ["prisma project show", "prisma project show --json"]
94
+ },
95
+ {
96
+ id: "project.link",
97
+ path: [
98
+ "prisma",
99
+ "project",
100
+ "link"
101
+ ],
102
+ description: "Link the current repo to an existing project.",
103
+ docsPath: "docs/product/command-spec.md#prisma-project-link-project",
104
+ examples: ["prisma project link", "prisma project link proj_123"]
105
+ },
106
+ {
107
+ id: "branch.list",
108
+ path: [
109
+ "prisma",
110
+ "branch",
111
+ "list"
112
+ ],
113
+ description: "List branches for the linked project.",
114
+ docsPath: "docs/product/command-spec.md#prisma-branch-list",
115
+ examples: ["prisma branch list", "prisma branch list --json"]
116
+ },
117
+ {
118
+ id: "branch.show",
119
+ path: [
120
+ "prisma",
121
+ "branch",
122
+ "show"
123
+ ],
124
+ description: "Show the current active branch context.",
125
+ docsPath: "docs/product/command-spec.md#prisma-branch-show",
126
+ examples: ["prisma branch show", "prisma branch show --json"]
127
+ },
128
+ {
129
+ id: "branch.use",
130
+ path: [
131
+ "prisma",
132
+ "branch",
133
+ "use"
134
+ ],
135
+ description: "Change the local default branch context.",
136
+ docsPath: "docs/product/command-spec.md#prisma-branch-use-name",
137
+ examples: ["prisma branch use", "prisma branch use production"]
138
+ },
139
+ {
140
+ id: "app.build",
141
+ path: [
142
+ "prisma",
143
+ "app",
144
+ "build"
145
+ ],
146
+ description: "Build the local app into a deployable artifact.",
147
+ docsPath: "docs/product/command-spec.md#prisma-app-build---entry-path---build-type-autobunnextjs",
148
+ examples: ["prisma app build --build-type nextjs", "prisma app build --build-type bun --entry server.ts"]
149
+ },
150
+ {
151
+ id: "app.run",
152
+ path: [
153
+ "prisma",
154
+ "app",
155
+ "run"
156
+ ],
157
+ description: "Start a local framework dev server.",
158
+ docsPath: "docs/product/command-spec.md#prisma-app-run---entry-path---build-type-autobunnextjs---port-port",
159
+ examples: ["prisma app run --build-type nextjs", "prisma app run --build-type bun --entry server.ts --port 3000"]
160
+ },
161
+ {
162
+ id: "app.deploy",
163
+ path: [
164
+ "prisma",
165
+ "app",
166
+ "deploy"
167
+ ],
168
+ description: "Build and release the selected app.",
169
+ docsPath: "docs/product/command-spec.md#prisma-app-deploy---app-name---entry-path---build-type-autobunnextjs---http-port-port---env-namevalue",
170
+ examples: [
171
+ "prisma app deploy",
172
+ "prisma app deploy --app hello-world --env DATABASE_URL=postgresql://example",
173
+ "prisma app deploy --app hello-world --build-type nextjs --http-port 3000"
174
+ ]
175
+ },
176
+ {
177
+ id: "app.update-env",
178
+ path: [
179
+ "prisma",
180
+ "app",
181
+ "update-env"
182
+ ],
183
+ description: "Create a new deployment with updated environment variables.",
184
+ docsPath: "docs/product/command-spec.md#prisma-app-update-env---app-name---env-namevalue",
185
+ examples: ["prisma app update-env --env DATABASE_URL=postgresql://example", "prisma app update-env --app hello-world --env DATABASE_URL=postgresql://another"]
186
+ },
187
+ {
188
+ id: "app.list-env",
189
+ path: [
190
+ "prisma",
191
+ "app",
192
+ "list-env"
193
+ ],
194
+ description: "List environment variable names for the selected app.",
195
+ docsPath: "docs/product/command-spec.md#prisma-app-list-env---app-name",
196
+ examples: ["prisma app list-env", "prisma app list-env --app hello-world"]
197
+ },
198
+ {
199
+ id: "app.show",
200
+ path: [
201
+ "prisma",
202
+ "app",
203
+ "show"
204
+ ],
205
+ description: "Show the current state of the selected app.",
206
+ docsPath: "docs/product/command-spec.md#prisma-app-show---app-name",
207
+ examples: ["prisma app show", "prisma app show --app hello-world"]
208
+ },
209
+ {
210
+ id: "app.open",
211
+ path: [
212
+ "prisma",
213
+ "app",
214
+ "open"
215
+ ],
216
+ description: "Open the live URL for the selected app.",
217
+ docsPath: "docs/product/command-spec.md#prisma-app-open---app-name",
218
+ examples: ["prisma app open", "prisma app open --app hello-world"]
219
+ },
220
+ {
221
+ id: "app.logs",
222
+ path: [
223
+ "prisma",
224
+ "app",
225
+ "logs"
226
+ ],
227
+ description: "Show or stream logs for a deployment.",
228
+ docsPath: "docs/product/command-spec.md#prisma-app-logs---app-name---deployment-id",
229
+ examples: ["prisma app logs", "prisma app logs --deployment dep_123"]
230
+ },
231
+ {
232
+ id: "app.list-deploys",
233
+ path: [
234
+ "prisma",
235
+ "app",
236
+ "list-deploys"
237
+ ],
238
+ description: "List deployments for the selected app.",
239
+ docsPath: "docs/product/command-spec.md#prisma-app-list-deploys---app-name",
240
+ examples: ["prisma app list-deploys", "prisma app list-deploys --app hello-world"]
241
+ },
242
+ {
243
+ id: "app.show-deploy",
244
+ path: [
245
+ "prisma",
246
+ "app",
247
+ "show-deploy"
248
+ ],
249
+ description: "Show one deployment in detail.",
250
+ docsPath: "docs/product/command-spec.md#prisma-app-show-deploy-deployment",
251
+ examples: ["prisma app show-deploy dep_123"]
252
+ },
253
+ {
254
+ id: "app.promote",
255
+ path: [
256
+ "prisma",
257
+ "app",
258
+ "promote"
259
+ ],
260
+ description: "Switch the live deployment for the selected app.",
261
+ docsPath: "docs/product/command-spec.md#prisma-app-promote-deployment---app-name",
262
+ examples: ["prisma app promote dep_123", "prisma app promote dep_123 --app hello-world"]
263
+ },
264
+ {
265
+ id: "app.rollback",
266
+ path: [
267
+ "prisma",
268
+ "app",
269
+ "rollback"
270
+ ],
271
+ description: "Restore the selected app to an earlier deployment.",
272
+ docsPath: "docs/product/command-spec.md#prisma-app-rollback---app-name---to-deployment",
273
+ examples: ["prisma app rollback", "prisma app rollback --app hello-world --to dep_123"]
274
+ },
275
+ {
276
+ id: "app.remove",
277
+ path: [
278
+ "prisma",
279
+ "app",
280
+ "remove"
281
+ ],
282
+ description: "Remove the selected app from the linked project.",
283
+ docsPath: "docs/product/command-spec.md#prisma-app-remove---app-name--y---yes",
284
+ examples: ["prisma app remove --app hello-world", "prisma app remove --app hello-world --yes"]
285
+ }
286
+ ];
287
+ const DESCRIPTORS_BY_ID = new Map(DESCRIPTORS.map((descriptor) => [descriptor.id, descriptor]));
288
+ function attachCommandDescriptor(command, descriptorId) {
289
+ const descriptor = getCommandDescriptor(descriptorId);
290
+ command[COMMAND_DESCRIPTOR_ID] = descriptor.id;
291
+ command.description(descriptor.description);
292
+ return command;
293
+ }
294
+ function getCommandDescriptor(id) {
295
+ const descriptor = DESCRIPTORS_BY_ID.get(id);
296
+ if (!descriptor) throw new Error(`Unknown command descriptor "${id}".`);
297
+ return descriptor;
298
+ }
299
+ function getDescriptorForCommand(command) {
300
+ const descriptorId = command[COMMAND_DESCRIPTOR_ID];
301
+ if (descriptorId) return getCommandDescriptor(descriptorId);
302
+ const path = getCommandPath(command);
303
+ const descriptor = DESCRIPTORS.find((candidate) => candidate.path.join(" ") === path.join(" "));
304
+ if (!descriptor) throw new Error(`No command descriptor registered for "${path.join(" ")}".`);
305
+ return descriptor;
306
+ }
307
+ function getCommandPath(command) {
308
+ const names = [];
309
+ let current = command;
310
+ while (current) {
311
+ if (current.name()) names.unshift(current.name());
312
+ current = current.parent ?? null;
313
+ }
314
+ return names;
315
+ }
316
+ function formatDescriptorLabel(descriptor) {
317
+ return descriptor.path.length === 1 ? descriptor.path[0] : descriptor.path.slice(1).join(" ");
318
+ }
319
+ //#endregion
320
+ export { attachCommandDescriptor, formatDescriptorLabel, getCommandDescriptor, getDescriptorForCommand };
@@ -0,0 +1,33 @@
1
+ import { CliError } from "./errors.js";
2
+ import { getCommandDescriptor } from "./command-meta.js";
3
+ import { resolveGlobalFlags } from "./global-flags.js";
4
+ import { createCommandContext } from "./runtime.js";
5
+ import { writeHumanError, writeHumanLines, writeJsonError, writeJsonSuccess } from "./output.js";
6
+ //#region src/shell/command-runner.ts
7
+ async function runCommand(runtime, commandName, options, handler, presenter) {
8
+ const flags = resolveGlobalFlags(runtime.argv, options);
9
+ const context = await createCommandContext(runtime, flags);
10
+ const descriptor = getCommandDescriptor(commandName);
11
+ try {
12
+ const success = await handler(context);
13
+ if (flags.json) {
14
+ writeJsonSuccess(context.output, {
15
+ ...success,
16
+ result: presenter.renderJson ? presenter.renderJson(success.result) : success.result
17
+ });
18
+ return;
19
+ }
20
+ if (flags.quiet) return;
21
+ writeHumanLines(context.output, presenter.renderHuman(context, descriptor, success.result));
22
+ } catch (error) {
23
+ if (error instanceof CliError) {
24
+ if (flags.json) writeJsonError(context.output, commandName, error);
25
+ else writeHumanError(context.output, context.ui, error, { trace: flags.trace });
26
+ process.exitCode = error.exitCode;
27
+ return;
28
+ }
29
+ throw error;
30
+ }
31
+ }
32
+ //#endregion
33
+ export { runCommand };
@@ -0,0 +1,66 @@
1
+ //#region src/shell/errors.ts
2
+ var CliError = class extends Error {
3
+ code;
4
+ domain;
5
+ severity;
6
+ summary;
7
+ why;
8
+ fix;
9
+ debug;
10
+ where;
11
+ meta;
12
+ docsUrl;
13
+ exitCode;
14
+ nextSteps;
15
+ constructor(options) {
16
+ super(options.summary);
17
+ this.name = "CliError";
18
+ this.code = options.code;
19
+ this.domain = options.domain;
20
+ this.severity = "error";
21
+ this.summary = options.summary;
22
+ this.why = options.why;
23
+ this.fix = options.fix;
24
+ this.debug = options.debug ?? null;
25
+ this.where = options.where ?? null;
26
+ this.meta = options.meta ?? {};
27
+ this.docsUrl = options.docsUrl ?? null;
28
+ this.exitCode = options.exitCode ?? 1;
29
+ this.nextSteps = options.nextSteps ?? [];
30
+ }
31
+ };
32
+ function usageError(summary, why, fix, nextSteps = [], domain = "cli") {
33
+ return new CliError({
34
+ code: "USAGE_ERROR",
35
+ domain,
36
+ summary,
37
+ why,
38
+ fix,
39
+ exitCode: 2,
40
+ nextSteps
41
+ });
42
+ }
43
+ function authRequiredError(nextSteps = ["prisma auth login"]) {
44
+ return new CliError({
45
+ code: "AUTH_REQUIRED",
46
+ domain: "auth",
47
+ summary: "Authentication required",
48
+ why: "This command needs an authenticated session.",
49
+ fix: "Run prisma auth login, or rerun the command in a TTY to sign in interactively.",
50
+ exitCode: 1,
51
+ nextSteps
52
+ });
53
+ }
54
+ function featureUnavailableError(summary, why, fix, nextSteps = [], domain = "cli") {
55
+ return new CliError({
56
+ code: "FEATURE_UNAVAILABLE",
57
+ domain,
58
+ summary,
59
+ why,
60
+ fix,
61
+ exitCode: 1,
62
+ nextSteps
63
+ });
64
+ }
65
+ //#endregion
66
+ export { CliError, authRequiredError, featureUnavailableError, usageError };
@@ -0,0 +1,25 @@
1
+ import { Option } from "commander";
2
+ //#region src/shell/global-flags.ts
3
+ function addGlobalFlags(command) {
4
+ return command.option("--json", "Emit structured JSON output.").option("-q, --quiet", "Reduce human-oriented output.").option("-v, --verbose", "Increase human-oriented output detail.").option("--trace", "Show deeper diagnostics for failures.").option("-y, --yes", "Accept supported confirmation prompts.").addOption(new Option("--interactive", "Force interactive behavior when prompts are supported.")).addOption(new Option("--no-interactive", "Disable interactive behavior and prompts.")).addOption(new Option("--color", "Force color output in supported terminals.")).addOption(new Option("--no-color", "Disable color output."));
5
+ }
6
+ function getExplicitBoolean(argv, positive, negative) {
7
+ for (let index = argv.length - 1; index >= 0; index -= 1) {
8
+ const value = argv[index];
9
+ if (value === positive) return true;
10
+ if (value === negative) return false;
11
+ }
12
+ }
13
+ function resolveGlobalFlags(argv, options) {
14
+ return {
15
+ json: options.json === true || argv.includes("--json"),
16
+ quiet: options.quiet === true || argv.includes("--quiet") || argv.includes("-q"),
17
+ verbose: options.verbose === true || argv.includes("--verbose") || argv.includes("-v"),
18
+ trace: options.trace === true || argv.includes("--trace"),
19
+ yes: options.yes === true || argv.includes("--yes") || argv.includes("-y"),
20
+ interactive: getExplicitBoolean(argv, "--interactive", "--no-interactive"),
21
+ color: getExplicitBoolean(argv, "--color", "--no-color")
22
+ };
23
+ }
24
+ //#endregion
25
+ export { addGlobalFlags, resolveGlobalFlags };
@@ -0,0 +1,78 @@
1
+ import { formatDescriptorLabel, getDescriptorForCommand } from "./command-meta.js";
2
+ import { resolveGlobalFlags } from "./global-flags.js";
3
+ import { createShellUi, padDisplay, wrapText } from "./ui.js";
4
+ //#region src/shell/help.ts
5
+ function renderHelp(command, runtime) {
6
+ const descriptor = getDescriptorForCommand(command);
7
+ const ui = createShellUi(runtime, resolveGlobalFlags(runtime.argv, {}));
8
+ const rail = ui.isTTY ? ui.dim("│") : "│";
9
+ const lines = [`${formatDescriptorLabel(descriptor)} ${ui.dim("→")} ${ui.dim(descriptor.description)}`, ""];
10
+ const visibleCommands = command.commands.filter((candidate) => candidate.name() !== "help" && !candidate.hidden);
11
+ const visibleOptions = command.options.filter((candidate) => !candidate.hidden);
12
+ if (visibleCommands.length > 0) lines.push(...renderCommandRows(rail, ui, visibleCommands));
13
+ if (visibleOptions.length > 0) {
14
+ if (visibleCommands.length > 0) lines.push(`${rail}`);
15
+ lines.push(...renderOptionRows(rail, ui, visibleOptions));
16
+ }
17
+ if (descriptor.examples && descriptor.examples.length > 0) {
18
+ lines.push(`${rail}`);
19
+ lines.push(`${rail} Examples:`);
20
+ for (const example of descriptor.examples) lines.push(`${rail} $ ${example}`);
21
+ }
22
+ if (descriptor.longDescription) {
23
+ lines.push(`${rail}`);
24
+ const wrapped = wrapText(descriptor.longDescription, Math.max(ui.width - 3, 40));
25
+ for (const line of wrapped) lines.push(`${rail} ${line}`);
26
+ }
27
+ if (descriptor.docsPath) {
28
+ lines.push(`${rail}`);
29
+ lines.push(`${rail} ${ui.accent(padDisplay("Read more", 16))} ${ui.link(descriptor.docsPath)}`);
30
+ }
31
+ lines.push("");
32
+ return `${lines.join("\n")}`;
33
+ }
34
+ function renderCommandRows(rail, ui, commands) {
35
+ return renderAlignedRows(rail, ui, commands.map((command) => {
36
+ const descriptor = getDescriptorForCommand(command);
37
+ return {
38
+ term: renderCommandTerm(command),
39
+ description: descriptor.description
40
+ };
41
+ }));
42
+ }
43
+ function renderOptionRows(rail, ui, options) {
44
+ return renderAlignedRows(rail, ui, options.map((option) => ({
45
+ term: option.flags,
46
+ description: option.description || "",
47
+ defaultValue: option.defaultValueDescription ?? formatDefaultValue(option.defaultValue)
48
+ })));
49
+ }
50
+ function renderAlignedRows(rail, ui, rows) {
51
+ const termWidth = rows.reduce((width, row) => Math.max(width, row.term.length), 0);
52
+ const descriptionWidth = Math.max(ui.width - 3 - termWidth - 4, 30);
53
+ const lines = [];
54
+ for (const row of rows) {
55
+ const [firstLine, ...rest] = wrapText(row.description, descriptionWidth, " ".repeat(termWidth + 2));
56
+ lines.push(`${rail} ${ui.accent(padDisplay(row.term, termWidth))} ${firstLine}`);
57
+ for (const line of rest) lines.push(`${rail} ${" ".repeat(termWidth)} ${line.trimStart()}`);
58
+ if (row.defaultValue) lines.push(`${rail} ${" ".repeat(termWidth)} ${ui.dim(`default: ${row.defaultValue}`)}`);
59
+ }
60
+ return lines;
61
+ }
62
+ function renderCommandTerm(command) {
63
+ const argumentsList = command.registeredArguments.map(renderArgumentLabel).join(" ");
64
+ return `${command.name()}${argumentsList ? ` ${argumentsList}` : ""}`;
65
+ }
66
+ function renderArgumentLabel(argument) {
67
+ const name = argument.name();
68
+ return argument.required ? `<${name}>` : `[${name}]`;
69
+ }
70
+ function formatDefaultValue(value) {
71
+ if (value === void 0) return null;
72
+ if (Array.isArray(value)) return value.join(", ");
73
+ if (typeof value === "boolean" || typeof value === "number") return String(value);
74
+ if (typeof value === "string" && value.length > 0) return value;
75
+ return null;
76
+ }
77
+ //#endregion
78
+ export { renderHelp };
@@ -0,0 +1,54 @@
1
+ import { renderNextSteps, renderSummaryLine } from "./ui.js";
2
+ //#region src/shell/output.ts
3
+ function writeJsonSuccess(output, success) {
4
+ output.stdout.write(`${JSON.stringify({
5
+ ok: true,
6
+ ...success
7
+ }, null, 2)}\n`);
8
+ }
9
+ function writeJsonError(output, command, error) {
10
+ output.stdout.write(`${JSON.stringify({
11
+ ok: false,
12
+ command,
13
+ error: {
14
+ code: error.code,
15
+ domain: error.domain,
16
+ severity: error.severity,
17
+ summary: error.summary,
18
+ why: error.why,
19
+ fix: error.fix,
20
+ where: error.where,
21
+ meta: error.meta,
22
+ docsUrl: error.docsUrl
23
+ },
24
+ warnings: [],
25
+ nextSteps: error.nextSteps
26
+ }, null, 2)}\n`);
27
+ }
28
+ function writeHumanLines(output, lines) {
29
+ if (lines.length === 0) return;
30
+ output.stderr.write(`${lines.join("\n")}\n`);
31
+ }
32
+ function writeHumanError(output, ui, error, options) {
33
+ const lines = [renderSummaryLine(ui, "error", `${error.summary} [${error.code}]`)];
34
+ if (error.where) lines.push(...["", `Where: ${error.where}`]);
35
+ if (error.why) {
36
+ if (!error.where) lines.push("");
37
+ lines.push(`Why: ${error.why}`);
38
+ }
39
+ if (error.fix) lines.push(`Fix: ${error.fix}`);
40
+ if (options.trace) {
41
+ if (error.debug) {
42
+ lines.push("");
43
+ lines.push("Trace:");
44
+ lines.push(...error.debug.trimEnd().split("\n"));
45
+ }
46
+ } else {
47
+ lines.push("");
48
+ lines.push("More: Re-run with --trace for deeper diagnostics");
49
+ }
50
+ lines.push(...renderNextSteps(error.nextSteps));
51
+ writeHumanLines(output, lines);
52
+ }
53
+ //#endregion
54
+ export { writeHumanError, writeHumanLines, writeJsonError, writeJsonSuccess };
@@ -0,0 +1,31 @@
1
+ import { usageError } from "./errors.js";
2
+ import { isCancel, select, text } from "@clack/prompts";
3
+ //#region src/shell/prompt.ts
4
+ async function selectPrompt(options) {
5
+ const promptOptions = options.choices.map((choice) => ({
6
+ label: choice.label,
7
+ value: choice.value
8
+ }));
9
+ const response = await select({
10
+ input: options.input,
11
+ output: options.output,
12
+ message: options.message,
13
+ options: promptOptions
14
+ });
15
+ if (isCancel(response)) throw usageError("Interactive prompt canceled", "The command was canceled before a selection was made.", "Re-run the command and choose an option to continue.");
16
+ return response;
17
+ }
18
+ async function textPrompt(options) {
19
+ const response = await text({
20
+ input: options.input,
21
+ output: options.output,
22
+ message: options.message,
23
+ placeholder: options.placeholder,
24
+ validate: options.validate
25
+ });
26
+ if (isCancel(response)) throw usageError("Interactive prompt canceled", "The command was canceled before a value was entered.", "Re-run the command and provide a value to continue.");
27
+ return response;
28
+ }
29
+ function disposePromptState(_input) {}
30
+ //#endregion
31
+ export { disposePromptState, selectPrompt, textPrompt };
@@ -0,0 +1,51 @@
1
+ import { LocalStateStore } from "../adapters/local-state.js";
2
+ import { MockApi } from "../adapters/mock-api.js";
3
+ import { createShellUi } from "./ui.js";
4
+ import { renderHelp } from "./help.js";
5
+ import path from "node:path";
6
+ //#region src/shell/runtime.ts
7
+ const DEFAULT_STATE_DIR_NAME = path.join(".prisma", "cli");
8
+ function configureRuntimeCommand(command, runtime) {
9
+ return command.helpCommand(false).configureHelp({ formatHelp: (configuredCommand) => renderHelp(configuredCommand, runtime) }).configureOutput({
10
+ writeOut: (text) => {
11
+ runtime.stderr.write(text);
12
+ },
13
+ writeErr: (text) => {
14
+ runtime.stderr.write(text);
15
+ },
16
+ outputError: (text, write) => {
17
+ write(text);
18
+ }
19
+ }).exitOverride();
20
+ }
21
+ async function createCommandContext(runtime, flags) {
22
+ const fixturePath = runtime.fixturePath ?? runtime.env.PRISMA_CLI_MOCK_FIXTURE_PATH;
23
+ const stateDir = resolveStateDir(runtime);
24
+ let loadedApi;
25
+ if (fixturePath) loadedApi = await MockApi.load(fixturePath);
26
+ return {
27
+ get api() {
28
+ if (!loadedApi) throw new Error("context.api accessed in real mode. Set runtime.fixturePath or PRISMA_CLI_MOCK_FIXTURE_PATH to use fixture mode.");
29
+ return loadedApi;
30
+ },
31
+ stateStore: new LocalStateStore(stateDir),
32
+ output: {
33
+ stdout: runtime.stdout,
34
+ stderr: runtime.stderr
35
+ },
36
+ flags,
37
+ runtime,
38
+ ui: createShellUi(runtime, flags)
39
+ };
40
+ }
41
+ function resolveStateDir(runtime) {
42
+ return runtime.stateDir ?? runtime.env.PRISMA_CLI_STATE_DIR ?? path.join(runtime.cwd, DEFAULT_STATE_DIR_NAME);
43
+ }
44
+ function canPrompt(context) {
45
+ if (context.flags.json) return false;
46
+ if (context.flags.interactive === false) return false;
47
+ if (context.runtime.env.CI && context.flags.interactive !== true) return false;
48
+ return Boolean(context.runtime.stdin.isTTY && context.runtime.stderr.isTTY);
49
+ }
50
+ //#endregion
51
+ export { canPrompt, configureRuntimeCommand, createCommandContext };