@prisma/composer 0.6.0-dev.17 → 0.6.0-dev.19

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 (91) hide show
  1. package/dist/{app-config-aIrriqVU-D6lJHzh2.d.mts → app-config-aIrriqVU-Dpj1RqnY.d.mts} +3 -2
  2. package/dist/app-config-aIrriqVU-Dpj1RqnY.d.mts.map +1 -0
  3. package/dist/config-BeBRB-6m.d.mts +1 -0
  4. package/dist/config.d.mts +2 -2
  5. package/dist/control.d.mts +219 -3
  6. package/dist/control.d.mts.map +1 -0
  7. package/dist/control.mjs +69 -1
  8. package/dist/control.mjs.map +1 -0
  9. package/dist/deploy-BeBRB-6m.d.mts +1 -0
  10. package/dist/deploy.d.mts +2 -2
  11. package/dist/deploy.mjs +1 -1
  12. package/dist/{dist-C0dNEgS-.mjs → dist-C5rZnr4n.mjs} +2 -2
  13. package/dist/{dist-C0dNEgS-.mjs.map → dist-C5rZnr4n.mjs.map} +1 -1
  14. package/dist/{errors-DkXcnjPx.mjs → errors-0e8IVwzi.mjs} +2 -3
  15. package/dist/{errors-DkXcnjPx.mjs.map → errors-0e8IVwzi.mjs.map} +1 -1
  16. package/dist/{execute-deploy-destroy-DfVJUICu-AMM8CwgV.mjs → execute-deploy-destroy-DfVJUICu-Dbgn1GR_.mjs} +5 -6
  17. package/dist/{execute-deploy-destroy-DfVJUICu-AMM8CwgV.mjs.map → execute-deploy-destroy-DfVJUICu-Dbgn1GR_.mjs.map} +1 -1
  18. package/dist/{execute-dev-BMTFWfFc-BoKbcFVF.mjs → execute-dev-BMTFWfFc-CGDFqR4w.mjs} +6 -7
  19. package/dist/{execute-dev-BMTFWfFc-BoKbcFVF.mjs.map → execute-dev-BMTFWfFc-CGDFqR4w.mjs.map} +1 -1
  20. package/dist/{execute-log-Cay9hlKW-B0tmRtrY.mjs → execute-log-Cay9hlKW-ChlIv192.mjs} +5 -6
  21. package/dist/{execute-log-Cay9hlKW-DrMeVOXq.mjs.map → execute-log-Cay9hlKW-ChlIv192.mjs.map} +1 -1
  22. package/dist/{graph-BJgUfGB0-7fmubS_y.mjs → graph-BJgUfGB0-kvgFzT4q.mjs} +2 -2
  23. package/dist/{graph-BJgUfGB0-7fmubS_y.mjs.map → graph-BJgUfGB0-kvgFzT4q.mjs.map} +1 -1
  24. package/dist/graph-DqklX5Sf-BNS2aO1j.d.mts +18 -0
  25. package/dist/graph-DqklX5Sf-BNS2aO1j.d.mts.map +1 -0
  26. package/dist/{graph-DqklX5Sf-CdNH3lA7.d.mts → graph-types-N6brq1zY-1VMNwtkJ.d.mts} +2 -17
  27. package/dist/graph-types-N6brq1zY-1VMNwtkJ.d.mts.map +1 -0
  28. package/dist/{index-DuF5iI3i.d.mts → index-DryPyF9U.d.mts} +3 -2
  29. package/dist/index-DryPyF9U.d.mts.map +1 -0
  30. package/dist/index.d.mts +3 -2
  31. package/dist/index.mjs +2 -2
  32. package/dist/{local-target-D3u_wuNF.mjs → local-target-DnA2E8IN.mjs} +2 -2
  33. package/dist/{local-target-D3u_wuNF.mjs.map → local-target-DnA2E8IN.mjs.map} +1 -1
  34. package/dist/local-target.d.mts +1 -1
  35. package/dist/local-target.mjs +1 -1
  36. package/dist/{nextjs-DLyeRR7M-BfUbLXwr.d.mts → nextjs-DLyeRR7M-DZODs9tk.d.mts} +3 -3
  37. package/dist/{nextjs-DLyeRR7M-BfUbLXwr.d.mts.map → nextjs-DLyeRR7M-DZODs9tk.d.mts.map} +1 -1
  38. package/dist/nextjs-control.d.mts +4 -4
  39. package/dist/nextjs.d.mts +1 -1
  40. package/dist/node-control.d.mts +3 -3
  41. package/dist/node.d.mts +2 -2
  42. package/dist/{pipeline-AoW8zq4I-DM74ygtH.mjs → pipeline-AoW8zq4I-CUon5KZH.mjs} +5 -5
  43. package/dist/{pipeline-AoW8zq4I-DM74ygtH.mjs.map → pipeline-AoW8zq4I-CUon5KZH.mjs.map} +1 -1
  44. package/dist/report.d.mts +2 -2
  45. package/dist/{log-DfT2hHqi-CDp9nfI5.mjs → result-CY_TB7bn.mjs} +84 -63
  46. package/dist/result-CY_TB7bn.mjs.map +1 -0
  47. package/dist/{run-alchemy-D44OZlyB-DA7s331N.mjs → run-alchemy-D44OZlyB-gVq_0gf4.mjs} +3 -3
  48. package/dist/{run-alchemy-D44OZlyB-DA7s331N.mjs.map → run-alchemy-D44OZlyB-gVq_0gf4.mjs.map} +1 -1
  49. package/dist/service-rpc.d.mts +2 -2
  50. package/dist/service-rpc.mjs +2 -2
  51. package/dist/testing.d.mts +2 -54
  52. package/dist/testing.d.mts.map +1 -1
  53. package/dist/testing.mjs +1 -150
  54. package/dist/testing.mjs.map +1 -1
  55. package/package.json +11 -16
  56. package/src/exports/testing.ts +5 -1
  57. package/dist/app-config-aIrriqVU-D6lJHzh2.d.mts.map +0 -1
  58. package/dist/bin.mjs +0 -1344
  59. package/dist/bin.mjs.map +0 -1
  60. package/dist/config-CL7Jbve2.d.mts +0 -1
  61. package/dist/container-transport-DKmKg5JQ-CoY4XPma.mjs +0 -30
  62. package/dist/container-transport-DKmKg5JQ-CoY4XPma.mjs.map +0 -1
  63. package/dist/deploy-CL7Jbve2.d.mts +0 -1
  64. package/dist/execute-deploy-destroy-DfVJUICu-quUQ08T8.mjs +0 -316
  65. package/dist/execute-deploy-destroy-DfVJUICu-quUQ08T8.mjs.map +0 -1
  66. package/dist/execute-dev-BMTFWfFc-B1whS-Rr.mjs +0 -2011
  67. package/dist/execute-dev-BMTFWfFc-B1whS-Rr.mjs.map +0 -1
  68. package/dist/execute-log-Cay9hlKW-B0tmRtrY.mjs.map +0 -1
  69. package/dist/execute-log-Cay9hlKW-DrMeVOXq.mjs +0 -157
  70. package/dist/family-DkH0si4D-Uov_MuHV.d.mts +0 -27
  71. package/dist/family-DkH0si4D-Uov_MuHV.d.mts.map +0 -1
  72. package/dist/family.d.mts +0 -53
  73. package/dist/family.d.mts.map +0 -1
  74. package/dist/family.mjs +0 -1226
  75. package/dist/family.mjs.map +0 -1
  76. package/dist/graph-DqklX5Sf-CdNH3lA7.d.mts.map +0 -1
  77. package/dist/index-DuF5iI3i.d.mts.map +0 -1
  78. package/dist/local-target-H0IWu_FM.mjs +0 -68
  79. package/dist/local-target-H0IWu_FM.mjs.map +0 -1
  80. package/dist/log-DRnnWupy-9jbzL64M.d.mts +0 -324
  81. package/dist/log-DRnnWupy-9jbzL64M.d.mts.map +0 -1
  82. package/dist/log-DfT2hHqi-CDp9nfI5.mjs.map +0 -1
  83. package/dist/pipeline-AoW8zq4I-C6Qe0VaZ.mjs +0 -976
  84. package/dist/pipeline-AoW8zq4I-C6Qe0VaZ.mjs.map +0 -1
  85. package/dist/result-B4XjxVK6.mjs +0 -384
  86. package/dist/result-B4XjxVK6.mjs.map +0 -1
  87. package/dist/result-wonf1deB.mjs +0 -92
  88. package/dist/result-wonf1deB.mjs.map +0 -1
  89. package/dist/run-alchemy-D44OZlyB-DeDTFsB6.mjs +0 -93
  90. package/dist/run-alchemy-D44OZlyB-DeDTFsB6.mjs.map +0 -1
  91. package/src/exports/family.ts +0 -14
package/dist/bin.mjs DELETED
@@ -1,1344 +0,0 @@
1
- #!/usr/bin/env node
2
- import { a as executionDiagnostics, l as DOCS_BASE, o as executorLoadFailure, t as notOk$1 } from "./result-B4XjxVK6.mjs";
3
- import { t as alchemyCommandLine } from "./run-alchemy-D44OZlyB-DA7s331N.mjs";
4
- import "node:module";
5
- import * as fs from "node:fs";
6
- import * as path from "node:path";
7
- import { spawn } from "node:child_process";
8
- import { EnvironmentCredentialManager, createCli, defineCommand, defineCommandFamily, defineConfigSection, defineSessionCommand, exitWithChildStatus, flag, loadConfig, positional } from "@prisma/cli-engine";
9
- import { CliStructuredError, notOk, ok } from "@prisma/cli-engine/protocol";
10
- import { fileURLToPath } from "node:url";
11
- //#region \0rolldown/runtime.js
12
- var __commonJSMin = (cb, mod) => () => (mod || (cb((mod = { exports: {} }).exports, mod), cb = null), mod.exports);
13
- //#endregion
14
- //#region ../../0-framework/3-tooling/cli/dist/log-DfT2hHqi.mjs
15
- /** In-package variant threading the injection seam (the CLI's RunDeps, unit
16
- * tests). Deliberately NOT re-exported through `./control` — the seam mirrors
17
- * internal types and is not part of the published surface. */
18
- async function deployWithDeps(input, deps) {
19
- const cwd = input.cwd ?? process.cwd();
20
- let executor;
21
- try {
22
- executor = await import("./execute-deploy-destroy-DfVJUICu-quUQ08T8.mjs");
23
- } catch (error) {
24
- return notOk$1(executorLoadFailure("deploy", error, cwd));
25
- }
26
- return executor.executeDeploy(input, deps, cwd);
27
- }
28
- /** In-package variant threading the injection seam (the CLI's RunDeps, unit
29
- * tests). Deliberately NOT re-exported through `./control` — the seam mirrors
30
- * internal types and is not part of the published surface. */
31
- async function destroyWithDeps(input, deps) {
32
- const cwd = input.cwd ?? process.cwd();
33
- let executor;
34
- try {
35
- executor = await import("./execute-deploy-destroy-DfVJUICu-quUQ08T8.mjs");
36
- } catch (error) {
37
- return notOk$1(executorLoadFailure("destroy", error, cwd));
38
- }
39
- return executor.executeDestroy(input, deps, cwd);
40
- }
41
- /** In-package variant threading the injection seam (the CLI's RunDeps, unit
42
- * tests). Deliberately NOT re-exported through `./control` — the seam mirrors
43
- * internal types and is not part of the published surface. */
44
- async function devWithDeps(input, deps) {
45
- const cwd = input.cwd ?? process.cwd();
46
- let executor;
47
- try {
48
- executor = await import("./execute-dev-BMTFWfFc-B1whS-Rr.mjs");
49
- } catch (error) {
50
- return notOk$1(executorLoadFailure("dev", error, cwd));
51
- }
52
- return executor.executeDev(input, deps, cwd);
53
- }
54
- /** In-package variant threading the injection seam (the CLI's LogRunDeps,
55
- * unit tests). Deliberately NOT re-exported through `./control` — the seam
56
- * mirrors internal types and is not part of the published surface. */
57
- async function logWithDeps(input, deps) {
58
- const cwd = input.cwd ?? process.cwd();
59
- let executor;
60
- try {
61
- executor = await import("./execute-log-Cay9hlKW-DrMeVOXq.mjs");
62
- } catch (error) {
63
- return notOk$1(executorLoadFailure("log", error, cwd));
64
- }
65
- return executor.executeLog(input, deps, cwd);
66
- }
67
- //#endregion
68
- //#region ../../../node_modules/ci-info/vendors.json
69
- var require_vendors = /* @__PURE__ */ __commonJSMin(((exports, module) => {
70
- module.exports = [
71
- {
72
- "name": "Agola CI",
73
- "constant": "AGOLA",
74
- "env": "AGOLA_GIT_REF",
75
- "pr": "AGOLA_PULL_REQUEST_ID"
76
- },
77
- {
78
- "name": "Alpic",
79
- "constant": "ALPIC",
80
- "env": "ALPIC_HOST"
81
- },
82
- {
83
- "name": "Appcircle",
84
- "constant": "APPCIRCLE",
85
- "env": "AC_APPCIRCLE",
86
- "pr": {
87
- "env": "AC_GIT_PR",
88
- "ne": "false"
89
- }
90
- },
91
- {
92
- "name": "AppVeyor",
93
- "constant": "APPVEYOR",
94
- "env": "APPVEYOR",
95
- "pr": "APPVEYOR_PULL_REQUEST_NUMBER"
96
- },
97
- {
98
- "name": "AWS CodeBuild",
99
- "constant": "CODEBUILD",
100
- "env": "CODEBUILD_BUILD_ARN",
101
- "pr": {
102
- "env": "CODEBUILD_WEBHOOK_EVENT",
103
- "any": [
104
- "PULL_REQUEST_CREATED",
105
- "PULL_REQUEST_UPDATED",
106
- "PULL_REQUEST_REOPENED"
107
- ]
108
- }
109
- },
110
- {
111
- "name": "Azure Pipelines",
112
- "constant": "AZURE_PIPELINES",
113
- "env": "TF_BUILD",
114
- "pr": { "BUILD_REASON": "PullRequest" }
115
- },
116
- {
117
- "name": "Bamboo",
118
- "constant": "BAMBOO",
119
- "env": "bamboo_planKey"
120
- },
121
- {
122
- "name": "Bitbucket Pipelines",
123
- "constant": "BITBUCKET",
124
- "env": "BITBUCKET_COMMIT",
125
- "pr": "BITBUCKET_PR_ID"
126
- },
127
- {
128
- "name": "Bitrise",
129
- "constant": "BITRISE",
130
- "env": "BITRISE_IO",
131
- "pr": "BITRISE_PULL_REQUEST"
132
- },
133
- {
134
- "name": "Buddy",
135
- "constant": "BUDDY",
136
- "env": "BUDDY_WORKSPACE_ID",
137
- "pr": "BUDDY_EXECUTION_PULL_REQUEST_ID"
138
- },
139
- {
140
- "name": "Buildkite",
141
- "constant": "BUILDKITE",
142
- "env": "BUILDKITE",
143
- "pr": {
144
- "env": "BUILDKITE_PULL_REQUEST",
145
- "ne": "false"
146
- }
147
- },
148
- {
149
- "name": "CircleCI",
150
- "constant": "CIRCLE",
151
- "env": "CIRCLECI",
152
- "pr": "CIRCLE_PULL_REQUEST"
153
- },
154
- {
155
- "name": "Cirrus CI",
156
- "constant": "CIRRUS",
157
- "env": "CIRRUS_CI",
158
- "pr": "CIRRUS_PR"
159
- },
160
- {
161
- "name": "Cloudflare Pages",
162
- "constant": "CLOUDFLARE_PAGES",
163
- "env": "CF_PAGES"
164
- },
165
- {
166
- "name": "Cloudflare Workers",
167
- "constant": "CLOUDFLARE_WORKERS",
168
- "env": "WORKERS_CI"
169
- },
170
- {
171
- "name": "Codefresh",
172
- "constant": "CODEFRESH",
173
- "env": "CF_BUILD_ID",
174
- "pr": { "any": ["CF_PULL_REQUEST_NUMBER", "CF_PULL_REQUEST_ID"] }
175
- },
176
- {
177
- "name": "Codemagic",
178
- "constant": "CODEMAGIC",
179
- "env": "CM_BUILD_ID",
180
- "pr": "CM_PULL_REQUEST"
181
- },
182
- {
183
- "name": "Codeship",
184
- "constant": "CODESHIP",
185
- "env": { "CI_NAME": "codeship" }
186
- },
187
- {
188
- "name": "Drone",
189
- "constant": "DRONE",
190
- "env": "DRONE",
191
- "pr": { "DRONE_BUILD_EVENT": "pull_request" }
192
- },
193
- {
194
- "name": "dsari",
195
- "constant": "DSARI",
196
- "env": "DSARI"
197
- },
198
- {
199
- "name": "Earthly",
200
- "constant": "EARTHLY",
201
- "env": "EARTHLY_CI"
202
- },
203
- {
204
- "name": "Expo Application Services",
205
- "constant": "EAS",
206
- "env": "EAS_BUILD"
207
- },
208
- {
209
- "name": "Gerrit",
210
- "constant": "GERRIT",
211
- "env": "GERRIT_PROJECT"
212
- },
213
- {
214
- "name": "Gitea Actions",
215
- "constant": "GITEA_ACTIONS",
216
- "env": "GITEA_ACTIONS"
217
- },
218
- {
219
- "name": "GitHub Actions",
220
- "constant": "GITHUB_ACTIONS",
221
- "env": "GITHUB_ACTIONS",
222
- "pr": { "GITHUB_EVENT_NAME": "pull_request" }
223
- },
224
- {
225
- "name": "GitLab CI",
226
- "constant": "GITLAB",
227
- "env": "GITLAB_CI",
228
- "pr": "CI_MERGE_REQUEST_ID"
229
- },
230
- {
231
- "name": "GoCD",
232
- "constant": "GOCD",
233
- "env": "GO_PIPELINE_LABEL"
234
- },
235
- {
236
- "name": "Google Cloud Build",
237
- "constant": "GOOGLE_CLOUD_BUILD",
238
- "env": "BUILDER_OUTPUT"
239
- },
240
- {
241
- "name": "Harness CI",
242
- "constant": "HARNESS",
243
- "env": "HARNESS_BUILD_ID"
244
- },
245
- {
246
- "name": "Heroku",
247
- "constant": "HEROKU",
248
- "env": {
249
- "env": "NODE",
250
- "includes": "/app/.heroku/node/bin/node"
251
- }
252
- },
253
- {
254
- "name": "Hudson",
255
- "constant": "HUDSON",
256
- "env": "HUDSON_URL"
257
- },
258
- {
259
- "name": "Jenkins",
260
- "constant": "JENKINS",
261
- "env": ["JENKINS_URL", "BUILD_ID"],
262
- "pr": { "any": ["ghprbPullId", "CHANGE_ID"] }
263
- },
264
- {
265
- "name": "LayerCI",
266
- "constant": "LAYERCI",
267
- "env": "LAYERCI",
268
- "pr": "LAYERCI_PULL_REQUEST"
269
- },
270
- {
271
- "name": "Magnum CI",
272
- "constant": "MAGNUM",
273
- "env": "MAGNUM"
274
- },
275
- {
276
- "name": "Netlify CI",
277
- "constant": "NETLIFY",
278
- "env": "NETLIFY",
279
- "pr": {
280
- "env": "PULL_REQUEST",
281
- "ne": "false"
282
- }
283
- },
284
- {
285
- "name": "Nevercode",
286
- "constant": "NEVERCODE",
287
- "env": "NEVERCODE",
288
- "pr": {
289
- "env": "NEVERCODE_PULL_REQUEST",
290
- "ne": "false"
291
- }
292
- },
293
- {
294
- "name": "Prow",
295
- "constant": "PROW",
296
- "env": "PROW_JOB_ID"
297
- },
298
- {
299
- "name": "ReleaseHub",
300
- "constant": "RELEASEHUB",
301
- "env": "RELEASE_BUILD_ID"
302
- },
303
- {
304
- "name": "Render",
305
- "constant": "RENDER",
306
- "env": "RENDER",
307
- "pr": { "IS_PULL_REQUEST": "true" }
308
- },
309
- {
310
- "name": "Sail CI",
311
- "constant": "SAIL",
312
- "env": "SAILCI",
313
- "pr": "SAIL_PULL_REQUEST_NUMBER"
314
- },
315
- {
316
- "name": "Screwdriver",
317
- "constant": "SCREWDRIVER",
318
- "env": "SCREWDRIVER",
319
- "pr": {
320
- "env": "SD_PULL_REQUEST",
321
- "ne": "false"
322
- }
323
- },
324
- {
325
- "name": "Semaphore",
326
- "constant": "SEMAPHORE",
327
- "env": "SEMAPHORE",
328
- "pr": "PULL_REQUEST_NUMBER"
329
- },
330
- {
331
- "name": "Sourcehut",
332
- "constant": "SOURCEHUT",
333
- "env": { "CI_NAME": "sourcehut" }
334
- },
335
- {
336
- "name": "Strider CD",
337
- "constant": "STRIDER",
338
- "env": "STRIDER"
339
- },
340
- {
341
- "name": "TaskCluster",
342
- "constant": "TASKCLUSTER",
343
- "env": ["TASK_ID", "RUN_ID"]
344
- },
345
- {
346
- "name": "TeamCity",
347
- "constant": "TEAMCITY",
348
- "env": "TEAMCITY_VERSION"
349
- },
350
- {
351
- "name": "Travis CI",
352
- "constant": "TRAVIS",
353
- "env": "TRAVIS",
354
- "pr": {
355
- "env": "TRAVIS_PULL_REQUEST",
356
- "ne": "false"
357
- }
358
- },
359
- {
360
- "name": "Vela",
361
- "constant": "VELA",
362
- "env": "VELA",
363
- "pr": { "VELA_PULL_REQUEST": "1" }
364
- },
365
- {
366
- "name": "Vercel",
367
- "constant": "VERCEL",
368
- "env": { "any": ["NOW_BUILDER", "VERCEL"] },
369
- "pr": "VERCEL_GIT_PULL_REQUEST_ID"
370
- },
371
- {
372
- "name": "Visual Studio App Center",
373
- "constant": "APPCENTER",
374
- "env": "APPCENTER_BUILD_ID"
375
- },
376
- {
377
- "name": "Woodpecker",
378
- "constant": "WOODPECKER",
379
- "env": { "CI": "woodpecker" },
380
- "pr": { "CI_BUILD_EVENT": "pull_request" }
381
- },
382
- {
383
- "name": "Xcode Cloud",
384
- "constant": "XCODE_CLOUD",
385
- "env": "CI_XCODE_PROJECT",
386
- "pr": "CI_PULL_REQUEST_NUMBER"
387
- },
388
- {
389
- "name": "Xcode Server",
390
- "constant": "XCODE_SERVER",
391
- "env": "XCS"
392
- }
393
- ];
394
- }));
395
- //#endregion
396
- //#region ../../0-framework/3-tooling/cli/dist/engine-cli-BXXH4fM-.mjs
397
- var import_ci_info = (/* @__PURE__ */ __commonJSMin(((exports) => {
398
- const vendors = require_vendors();
399
- const env = process.env;
400
- Object.defineProperty(exports, "_vendors", { value: vendors.map(function(v) {
401
- return v.constant;
402
- }) });
403
- exports.name = null;
404
- exports.isPR = null;
405
- exports.id = null;
406
- if (env.CI !== "false") vendors.forEach(function(vendor) {
407
- const isCI = (Array.isArray(vendor.env) ? vendor.env : [vendor.env]).every(function(obj) {
408
- return checkEnv(obj);
409
- });
410
- exports[vendor.constant] = isCI;
411
- if (!isCI) return;
412
- exports.name = vendor.name;
413
- exports.isPR = checkPR(vendor);
414
- exports.id = vendor.constant;
415
- });
416
- exports.isCI = !!(env.CI !== "false" && (env.BUILD_ID || env.BUILD_NUMBER || env.CI || env.CI_APP_ID || env.CI_BUILD_ID || env.CI_BUILD_NUMBER || env.CI_NAME || env.CONTINUOUS_INTEGRATION || env.RUN_ID || exports.name || false));
417
- function checkEnv(obj) {
418
- if (typeof obj === "string") return !!env[obj];
419
- if ("env" in obj) return env[obj.env] && env[obj.env].includes(obj.includes);
420
- if ("any" in obj) return obj.any.some(function(k) {
421
- return !!env[k];
422
- });
423
- return Object.keys(obj).every(function(k) {
424
- return env[k] === obj[k];
425
- });
426
- }
427
- function checkPR(vendor) {
428
- switch (typeof vendor.pr) {
429
- case "string": return !!env[vendor.pr];
430
- case "object": if ("env" in vendor.pr) if ("any" in vendor.pr) return vendor.pr.any.some(function(key) {
431
- return env[vendor.pr.env] === key;
432
- });
433
- else return vendor.pr.env in env && env[vendor.pr.env] !== vendor.pr.ne;
434
- else if ("any" in vendor.pr) return vendor.pr.any.some(function(key) {
435
- return !!env[key];
436
- });
437
- else return checkEnv(vendor.pr);
438
- default: return null;
439
- }
440
- }
441
- })))();
442
- /**
443
- * The family boundary's error translation.
444
- *
445
- * Composer and the engine each carry a class called `CliStructuredError`, both
446
- * descended from the same prisma/prisma foundation, and both recognize errors
447
- * by duck-typing on `name === 'CliStructuredError'`. That means a composer
448
- * error handed to the engine untranslated is ACCEPTED — it does not fail
449
- * loudly, it renders. What it loses is its `fix`: composer's foundation
450
- * carries remediation as one prose string on that field, the engine carries it
451
- * as a `nextActions` list and has no `fix` at all, so the fix text is dropped
452
- * silently and the user is told what broke with no word on what to do about
453
- * it. Nothing about that failure is visible without a test that looks for the
454
- * fix on the other side, which is why there is one.
455
- *
456
- * Everything else on the envelope survives as-is; only remediation changes
457
- * representation.
458
- */
459
- /**
460
- * Composer's `fix` is free prose — "add this overrides block and reinstall",
461
- * "run the build, then retry" — with no machine-readable command inside it.
462
- * `user-choice` is the engine's own kind for exactly that (it is what the
463
- * engine uses for its own config and prompt failures), so the text carries
464
- * over verbatim as one action rather than being parsed into a command the
465
- * author never wrote.
466
- */
467
- function fixAsNextActions(fix) {
468
- return fix === void 0 ? [] : [{
469
- kind: "user-choice",
470
- label: fix
471
- }];
472
- }
473
- /** Translates a composer failure into the engine's error type. Composer-side detail — `meta`, `where`, `docsUrl` — rides along untouched. */
474
- function toEngineError(error) {
475
- return new CliStructuredError(error.code, error.message, {
476
- severity: error.severity,
477
- nextActions: fixAsNextActions(error.fix),
478
- ...error.why === void 0 ? {} : { why: error.why },
479
- ...error.where === void 0 ? {} : { where: error.where },
480
- ...error.meta === void 0 ? {} : { meta: error.meta },
481
- ...error.docsUrl === void 0 ? {} : { docsUrl: error.docsUrl },
482
- cause: error
483
- });
484
- }
485
- /** The adapter the operations call, backed by the engine's `ctx.spawn` so the
486
- * terminal reaches alchemy natively and the engine owns signal policy. */
487
- function convergeSpawn(ctx) {
488
- return async (invocation) => {
489
- const line = alchemyCommandLine(invocation);
490
- return await ctx.spawn({
491
- command: line.command,
492
- args: line.args,
493
- cwd: line.cwd,
494
- env: line.env
495
- });
496
- };
497
- }
498
- /** The in-process leg's deps: composer's existing seam, carrying the engine's
499
- * own client and workspace id rather than anything read from the env. */
500
- function operationDeps(spec) {
501
- return {
502
- alchemy: spec.alchemy,
503
- configPath: spec.configPath,
504
- credentials: {
505
- workspaceId: spec.workspaceId,
506
- client: spec.client
507
- }
508
- };
509
- }
510
- /**
511
- * The reproduce hint a failed converge carries. Deliberately absent for an
512
- * aborted one: the user stopped it, so there is nothing to reproduce.
513
- */
514
- function reproduceHint(failure) {
515
- const diagnostics = executionDiagnostics(failure);
516
- if (diagnostics === void 0) return [];
517
- return [{
518
- kind: "run-command",
519
- label: `Run the converge directly from ${diagnostics.cwd} to reproduce this`,
520
- command: diagnostics.reproduceCommand,
521
- reason: `Generated stack file: ${diagnostics.stackFilePath}`
522
- }];
523
- }
524
- /**
525
- * How a FAILED converge settles. `deploy`, `destroy` and `dev` all end this
526
- * way and must not drift apart, so the decision lives here once rather than
527
- * inline in each handler.
528
- *
529
- * A failure that reached the child exits with the child's status verbatim and
530
- * carries the reproduce hint; a failure that never reached the child is an
531
- * ordinary structured error and gets the normal envelope. Nothing here reads
532
- * `signal` — see settleConverge.
533
- */
534
- function settleConvergeFailure(failure, ctx) {
535
- const child = ctx.lastChild();
536
- if (child !== void 0 && child.exitCode !== 0) return ok(exitWithChildStatus({ nextActions: reproduceHint(failure) }));
537
- return notOk(toEngineError(failure));
538
- }
539
- /**
540
- * How a converge settles, now that the engine owns the child's status.
541
- *
542
- * Nothing here reads `signal`. `exitWithChildStatus` settles from the engine's
543
- * own record of the child, and a signal-killed one overrules whatever this
544
- * function asked for: 128 + the signal, no failure envelope, and the reproduce
545
- * hint dropped, because the user stopped the run and there is nothing to
546
- * reproduce.
547
- *
548
- * What is left is the operation's own verdict. A failure that reached the
549
- * child exits with the child's status verbatim and carries the reproduce hint;
550
- * a failure that never reached the child is an ordinary structured error and
551
- * gets the normal envelope.
552
- *
553
- * A SUCCESS presents its result even when the child was signal-killed. No
554
- * composer operation produces that pair today — each one reports a
555
- * signal-killed converge as a failure — and an operation that ever did would
556
- * have a real result worth showing. The run still exits 130, because the
557
- * engine settles a signal-terminated run from its own record of the signal
558
- * whatever the handler returns.
559
- */
560
- function settleConverge(result, ctx, present) {
561
- if (!result.ok) return settleConvergeFailure(result.failure, ctx);
562
- return ok(present(result.value));
563
- }
564
- /**
565
- * Composer's projection into `prisma.config.ts` — the `composer` section.
566
- *
567
- * The section is deliberately tiny. Composer's real configuration lives in
568
- * `prisma-composer.config.ts`, which holds executable values (Effect layers,
569
- * provider factories, container lifecycles) and can only be understood by
570
- * evaluating it inside a running command. A config-section validator loads
571
- * with the command tree at start-up and must be dependency-light and total,
572
- * so it is the wrong place to evaluate any of that. What the section carries
573
- * is therefore only the one fact the engine can usefully know before a
574
- * command runs: WHERE that file is, when the user wants to say so.
575
- *
576
- * Its fields grow only by amending the slice contract.
577
- */
578
- const KNOWN_FIELDS = ["configPath"];
579
- function diagnostic(spec) {
580
- return {
581
- code: spec.code,
582
- severity: spec.severity,
583
- summary: spec.summary,
584
- ...spec.why === void 0 ? {} : { why: spec.why },
585
- nextActions: spec.fix === void 0 ? [] : [{
586
- kind: "edit-file",
587
- label: spec.fix
588
- }]
589
- };
590
- }
591
- function validate(raw) {
592
- if (raw === void 0) return {
593
- ok: true,
594
- value: {},
595
- diagnostics: []
596
- };
597
- if (typeof raw !== "object" || raw === null || Array.isArray(raw)) return {
598
- ok: false,
599
- diagnostics: [diagnostic({
600
- code: "CONFIG.FIELD_INVALID",
601
- severity: "error",
602
- summary: "The `composer` section of prisma.config.ts must be an object.",
603
- fix: "Write `composer: { configPath: \"./prisma-composer.config.ts\" }`, or remove the section entirely."
604
- })]
605
- };
606
- let record;
607
- try {
608
- record = { ...raw };
609
- } catch {
610
- return {
611
- ok: false,
612
- diagnostics: [diagnostic({
613
- code: "CONFIG.FIELD_INVALID",
614
- severity: "error",
615
- summary: "The `composer` section of prisma.config.ts could not be read.",
616
- why: "Reading its fields threw, so nothing in it can be trusted.",
617
- fix: "Write it as a plain object literal, e.g. `composer: { configPath: \"./prisma-composer.config.ts\" }`."
618
- })]
619
- };
620
- }
621
- const configPath = record["configPath"];
622
- if (configPath !== void 0 && (typeof configPath !== "string" || configPath.length === 0)) return {
623
- ok: false,
624
- diagnostics: [diagnostic({
625
- code: "CONFIG.FIELD_INVALID",
626
- severity: "error",
627
- summary: "`composer.configPath` must be a non-empty string.",
628
- why: "It names the prisma-composer.config.ts file to load.",
629
- fix: "Set it to a path, or remove it to search upward from the entry."
630
- })]
631
- };
632
- const unknown = Object.keys(record).filter((key) => !KNOWN_FIELDS.includes(key));
633
- return {
634
- ok: true,
635
- value: configPath === void 0 ? {} : { configPath },
636
- diagnostics: unknown.map((key) => diagnostic({
637
- code: "CONFIG.FIELD_UNKNOWN",
638
- severity: "warn",
639
- summary: `The \`composer\` section has no field \`${key}\`; it is ignored.`,
640
- fix: `Remove \`${key}\`, or check it against the version of @prisma/composer you have installed.`
641
- }))
642
- };
643
- }
644
- const composerSection = defineConfigSection({
645
- name: "composer",
646
- validate
647
- });
648
- /**
649
- * The workspace the in-process leg acts in, from the engine's credential
650
- * read. Handlers never decode a token and never read PRISMA_WORKSPACE_ID:
651
- * whether the credential came from a stored session or the environment, the
652
- * engine has already resolved it, and branching on where it came from is a
653
- * defect by the credential-manager design.
654
- *
655
- * Undefined when the active credential names no workspace — an environment
656
- * token whose claims carry none. The container descriptors raise their own
657
- * "workspace required" error in that case, which is the error the user needs.
658
- */
659
- async function workspaceIdOf(ctx) {
660
- return (await ctx.activeCredential())?.workspaceId;
661
- }
662
- /**
663
- * `deploy <entry>` — a result command that hands the terminal to alchemy.
664
- *
665
- * `--production` is gone. It was accepted and then always errored ("only
666
- * valid with destroy"), so no invocation using it could ever have succeeded;
667
- * deploy targets production by default when no `--stage` is given.
668
- */
669
- const createDeployCommand = (operations) => defineCommand({
670
- help: {
671
- summary: "Deploy the application whose root node is <entry>'s default export.",
672
- examples: ["{bin} deploy src/service.ts", "{bin} deploy src/service.ts --stage feat-auth"]
673
- },
674
- args: {
675
- positionals: { entry: positional.string({
676
- brief: "The module whose default export is the application root.",
677
- placeholder: "entry"
678
- }) },
679
- flags: {
680
- name: flag.string({
681
- brief: "Override the root node's name — the deploy's application name.",
682
- placeholder: "name"
683
- }),
684
- stage: flag.string({
685
- brief: "Deploy scope to target; omit for production.",
686
- placeholder: "stage"
687
- })
688
- }
689
- },
690
- needs: {
691
- config: composerSection,
692
- credentials: "child"
693
- },
694
- maySpawn: true,
695
- handler: async (args, ctx) => {
696
- const alchemy = convergeSpawn(ctx);
697
- return settleConverge(await operations.deploy({
698
- entry: args.positionals.entry,
699
- name: args.flags.name,
700
- stage: args.flags.stage,
701
- cwd: ctx.cwd
702
- }, operationDeps({
703
- alchemy,
704
- configPath: ctx.config.configPath,
705
- workspaceId: await workspaceIdOf(ctx),
706
- client: ctx.api
707
- })), ctx, ({ summary }) => ctx.present({ data: { summary: summary ?? null } }, {
708
- human: (ui) => summary === void 0 ? [{
709
- kind: "summary",
710
- status: "ok",
711
- text: "Deployed."
712
- }] : [{
713
- kind: "summary",
714
- status: "ok",
715
- text: `Deployed ${ui.emphasize(summary.app)}.`
716
- }, {
717
- kind: "table",
718
- columns: ["Address", "Deployed"],
719
- rows: summary.nodes.map((node) => [node.address, node.entities.map((entity) => `${entity.kind} ${entity.id}`).join(", ")])
720
- }],
721
- json: () => ({ summary: summary ?? null })
722
- }));
723
- }
724
- });
725
- /**
726
- * `destroy`'s target, from its two mutually exclusive flags. Kept out of the
727
- * grammar because the engine's flag layer has no "exactly one of these"
728
- * construct — and because both wrong shapes need their own remedy, which a
729
- * generic arity error could not give.
730
- */
731
- function targetOf(stage, production) {
732
- if (stage !== void 0 && production) return notOk(new CliStructuredError("DEPLOY.TARGET_CONFLICT", "Pass either --stage <name> or --production to `destroy`, not both."));
733
- if (stage === void 0 && !production) return notOk(new CliStructuredError("DEPLOY.TARGET_MISSING", "`destroy` requires an explicit target.", { nextActions: [{
734
- kind: "user-choice",
735
- label: "Pass --stage <name> to tear down a branch environment, or --production to tear down the production environment."
736
- }] }));
737
- return ok(stage !== void 0 ? {
738
- kind: "stage",
739
- stage
740
- } : { kind: "production" });
741
- }
742
- /**
743
- * `destroy <entry>` — deploy's mirror: same derivation, alchemy destroy.
744
- *
745
- * No confirmation prompt, matching the CLI this replaces. The front door
746
- * cannot know what the child will tear down, so a consent step here would be
747
- * asking the user to approve a list nobody has computed yet; if destroy
748
- * deserves one it belongs in composer's own operation, not in the grammar.
749
- */
750
- const createDestroyCommand = (operations) => defineCommand({
751
- help: {
752
- summary: "Tear down the application whose root node is <entry>'s default export.",
753
- description: "Same derivation as deploy. Requires an explicit target: --stage <name> for a branch environment, or --production for the production environment.",
754
- examples: ["{bin} destroy src/service.ts --stage feat-auth", "{bin} destroy src/service.ts --production"]
755
- },
756
- args: {
757
- positionals: { entry: positional.string({
758
- brief: "The module whose default export is the application root.",
759
- placeholder: "entry"
760
- }) },
761
- flags: {
762
- name: flag.string({
763
- brief: "Override the root node's name — the application name to tear down.",
764
- placeholder: "name"
765
- }),
766
- stage: flag.string({
767
- brief: "Tear down this branch environment.",
768
- placeholder: "stage"
769
- }),
770
- production: flag.boolean({ brief: "Tear down the project-level production environment." })
771
- }
772
- },
773
- needs: {
774
- config: composerSection,
775
- credentials: "child"
776
- },
777
- maySpawn: true,
778
- handler: async (args, ctx) => {
779
- const target = targetOf(args.flags.stage, args.flags.production);
780
- if (!target.ok) return target;
781
- const alchemy = convergeSpawn(ctx);
782
- return settleConverge(await operations.destroy({
783
- entry: args.positionals.entry,
784
- name: args.flags.name,
785
- target: target.value,
786
- cwd: ctx.cwd,
787
- onEvent: (event) => {
788
- if (event.kind !== "no-local-deploy-state") return;
789
- ctx.report({
790
- kind: "message",
791
- severity: "warn",
792
- text: `No prior deploy state under ${event.cwd} — if you deployed from a different directory, run destroy from there; otherwise this is a no-op.`
793
- });
794
- }
795
- }, operationDeps({
796
- alchemy,
797
- configPath: ctx.config.configPath,
798
- workspaceId: await workspaceIdOf(ctx),
799
- client: ctx.api
800
- })), ctx, () => ctx.present({ data: void 0 }, { human: () => [{
801
- kind: "summary",
802
- status: "ok",
803
- text: "Destroyed."
804
- }] }));
805
- }
806
- });
807
- const STOP_STEP = "Stopping the app's services — emulators and data stay up";
808
- /** Resolves when the run is asked to stop. */
809
- function stopRequested(signal) {
810
- if (signal.aborted) return Promise.resolve();
811
- return new Promise((resolve) => {
812
- signal.addEventListener("abort", () => resolve(), { once: true });
813
- });
814
- }
815
- /**
816
- * One converge at a time. `ctx.spawn` refuses a second live child, and the
817
- * watch loop can well fire a rebuild while the previous converge is still
818
- * running — so a request that arrives during a live converge joins the single
819
- * queued follow-up instead of starting its own. That extends the coalescing
820
- * the watcher already does across a burst of edits to cover the converge
821
- * itself, and it is sound because every dev converge is the SAME invocation:
822
- * one stack file at one fixed path, rewritten in place before each request.
823
- */
824
- function coalescedConverge(run) {
825
- let live;
826
- let queued;
827
- const start = (invocation) => {
828
- const outcome = run(invocation);
829
- const settled = outcome.then(() => void 0, () => void 0);
830
- live = settled;
831
- settled.then(() => {
832
- if (live === settled) live = void 0;
833
- });
834
- return outcome;
835
- };
836
- return (invocation) => {
837
- const running = live;
838
- if (running === void 0) return start(invocation);
839
- queued ??= running.then(() => {
840
- queued = void 0;
841
- return start(invocation);
842
- });
843
- return queued;
844
- };
845
- }
846
- /** The front door, ordered by address depth (fewest dots first) then lexicographically. */
847
- function frontDoorOrder(endpoints) {
848
- return [...endpoints].sort((a, b) => {
849
- const depth = a.address.split(".").length - b.address.split(".").length;
850
- if (depth !== 0) return depth;
851
- return a.address < b.address ? -1 : a.address > b.address ? 1 : 0;
852
- });
853
- }
854
- /**
855
- * The operation's events as engine events. The legacy `[dev]` console prefix
856
- * is gone: these are commentary the engine renders and frames.
857
- */
858
- function reportDevEvent(report, lastChild) {
859
- let stopFailed = false;
860
- return (event) => {
861
- switch (event.kind) {
862
- case "ready":
863
- report({
864
- kind: "status",
865
- subject: "dev",
866
- status: "ready"
867
- });
868
- for (const endpoint of frontDoorOrder(event.endpoints)) report({
869
- kind: "endpoint",
870
- name: endpoint.address,
871
- url: endpoint.url
872
- });
873
- return;
874
- case "unwatchable":
875
- report({
876
- kind: "message",
877
- severity: "warn",
878
- text: `${event.address} has no watchable inputs.`
879
- });
880
- return;
881
- case "rebuild-failed":
882
- report({
883
- kind: "message",
884
- severity: "warn",
885
- text: `Rebuild failed: ${event.message}`
886
- });
887
- return;
888
- case "watch-error":
889
- report({
890
- kind: "message",
891
- severity: "warn",
892
- text: `Watch error: ${event.message}`
893
- });
894
- return;
895
- case "converge-failed": {
896
- const child = lastChild();
897
- if (child !== void 0 && child.signal !== null) return;
898
- report({
899
- kind: "message",
900
- severity: "warn",
901
- text: `Converge failed — the running app is untouched; still watching.
902
- Generated stack file: ${event.stackFilePath}\nRun \`${event.reproduceCommand}\` from ${event.cwd} to reproduce this directly.`
903
- });
904
- report({
905
- kind: "remediation",
906
- action: {
907
- kind: "run-command",
908
- label: `Run the converge directly from ${event.cwd} to reproduce this`,
909
- command: event.reproduceCommand,
910
- reason: `Generated stack file: ${event.stackFilePath}`
911
- }
912
- });
913
- return;
914
- }
915
- case "stopping":
916
- report({
917
- kind: "step-started",
918
- step: STOP_STEP,
919
- id: "dev-stop"
920
- });
921
- return;
922
- case "stop-error":
923
- stopFailed = true;
924
- report({
925
- kind: "message",
926
- severity: "warn",
927
- text: `A service refused to stop: ${event.message}`
928
- });
929
- return;
930
- case "stopped":
931
- report({
932
- kind: "step-finished",
933
- step: STOP_STEP,
934
- id: "dev-stop",
935
- outcome: stopFailed ? "warning" : "ok"
936
- });
937
- return;
938
- }
939
- };
940
- }
941
- const createDevCommand = (operations) => defineSessionCommand({
942
- help: {
943
- summary: "Bring up the application whose root node is <entry>'s default export, entirely on this machine.",
944
- description: "Runs credential-free and watches the app for changes, reconverging on every edit. Logs are a separate command; run `log <entry>` to tail them.",
945
- examples: ["{bin} dev src/service.ts", "{bin} dev src/service.ts --fresh"]
946
- },
947
- args: {
948
- positionals: { entry: positional.string({
949
- brief: "The module whose default export is the application root.",
950
- placeholder: "entry"
951
- }) },
952
- flags: {
953
- name: flag.string({
954
- brief: "Override the root node's name — the dev instance's application name.",
955
- placeholder: "name"
956
- }),
957
- fresh: flag.boolean({ brief: "Destroy the dev stack and wipe the dev state directory before starting." })
958
- }
959
- },
960
- needs: { config: composerSection },
961
- maySpawn: true,
962
- handler: async (args, ctx) => {
963
- const alchemy = convergeSpawn(ctx);
964
- const result = await operations.dev({
965
- entry: args.positionals.entry,
966
- name: args.flags.name,
967
- fresh: args.flags.fresh,
968
- cwd: ctx.cwd,
969
- onEvent: reportDevEvent(ctx.report, ctx.lastChild)
970
- }, {
971
- alchemy: coalescedConverge(alchemy),
972
- configPath: ctx.config.configPath
973
- });
974
- if (!result.ok) return settleConvergeFailure(result.failure, ctx);
975
- await stopRequested(ctx.signal);
976
- await result.value.stop();
977
- return ok(void 0);
978
- }
979
- });
980
- /**
981
- * `log <entry> [address]` — a session command that tails the merged logs of
982
- * the app running locally on this machine.
983
- *
984
- * It reads the LOCAL dev-emulator daemon, not the platform's logs surface, so
985
- * it is credential-free. It hands the terminal to nothing, which is why it
986
- * does not declare `maySpawn` and keeps json support: the log lines ARE its
987
- * json surface.
988
- *
989
- * Windows is refused inside the operation itself (LOG.PLATFORM_UNSUPPORTED),
990
- * which is why nothing here reads the platform.
991
- */
992
- /** An empty screen reads as broken, so show a little recent history before going live. */
993
- const DEFAULT_TAIL = 20;
994
- const createLogCommand = (operations) => defineSessionCommand({
995
- help: {
996
- summary: "Tail the merged logs of the locally-running application whose root node is <entry>'s default export.",
997
- examples: ["{bin} log src/service.ts", "{bin} log src/service.ts catalog.service"]
998
- },
999
- args: {
1000
- positionals: {
1001
- entry: positional.string({
1002
- brief: "The module whose default export is the application root.",
1003
- placeholder: "entry"
1004
- }),
1005
- address: positional.optionalString({
1006
- brief: "Only this service's lines, by its dotted address (catalog.service); every service when absent.",
1007
- placeholder: "address"
1008
- })
1009
- },
1010
- flags: {
1011
- name: flag.string({
1012
- brief: "Override the root node's name — the dev instance's application name.",
1013
- placeholder: "name"
1014
- }),
1015
- tail: flag.number({
1016
- brief: `How many trailing history lines to show before live output (default ${String(DEFAULT_TAIL)}).`,
1017
- placeholder: "lines",
1018
- default: DEFAULT_TAIL
1019
- })
1020
- }
1021
- },
1022
- needs: { config: composerSection },
1023
- handler: async (args, ctx) => {
1024
- const reportLogEvent = (event) => {
1025
- ctx.report({
1026
- kind: "message",
1027
- severity: "warn",
1028
- text: event.kind === "stream-failed" ? `Stream failed: ${event.message}` : `Falling behind — dropped the ${String(event.count)} oldest lines.`
1029
- });
1030
- };
1031
- const result = await operations.log({
1032
- entry: args.positionals.entry,
1033
- name: args.flags.name,
1034
- address: args.positionals.address,
1035
- tail: args.flags.tail ?? DEFAULT_TAIL,
1036
- cwd: ctx.cwd,
1037
- signal: ctx.signal,
1038
- onEvent: reportLogEvent
1039
- }, { configPath: ctx.config.configPath });
1040
- if (!result.ok) return notOk(toEngineError(result.failure));
1041
- const attached = result.value;
1042
- if (attached.services.length === 0) {
1043
- ctx.report({
1044
- kind: "message",
1045
- severity: "warn",
1046
- text: `No running services for "${attached.appName}" — start it first with \`dev ${args.positionals.entry}\`.`
1047
- });
1048
- return ok(void 0);
1049
- }
1050
- for await (const { service, line } of attached.lines) ctx.report({
1051
- kind: "output",
1052
- source: service,
1053
- channel: "data",
1054
- line: `[${service}] ${line}`
1055
- });
1056
- return ok(void 0);
1057
- }
1058
- });
1059
- /**
1060
- * Composer's `CommandFamily` — the unit the engine mounts, whether the process
1061
- * is composer's own CLI or the `prisma` bin.
1062
- *
1063
- * This module and everything it reaches statically must stay free of alchemy
1064
- * and of effect VALUE imports: the `prisma` bin imports the family directly,
1065
- * so anything in this static graph loads on `prisma --version`. The mechanism
1066
- * that holds it is the existing lazy boundary inside the operation modules —
1067
- * `operations/deploy.ts`, `destroy.ts`, `dev.ts` and `log.ts` each `await
1068
- * import()` their executor, and it is the executors that reach the provider
1069
- * tree. Importing the operations here is therefore free; importing an
1070
- * executor, or flattening one of those dynamic imports, is not.
1071
- * scripts/check-family-static-graph.mjs enforces this against BUILT output,
1072
- * where type-only imports have already been erased.
1073
- *
1074
- * The four commands close over the operations they are given, so a host can
1075
- * mount this family against the test double and exercise real grammar, real
1076
- * arg validation and real handlers with no alchemy behind them.
1077
- */
1078
- const realOperations = {
1079
- deploy: deployWithDeps,
1080
- destroy: destroyWithDeps,
1081
- dev: devWithDeps,
1082
- log: logWithDeps
1083
- };
1084
- function createComposerFamily(options = {}) {
1085
- const operations = options.operations ?? realOperations;
1086
- return defineCommandFamily({
1087
- configSection: composerSection,
1088
- commands: {
1089
- deploy: createDeployCommand(operations),
1090
- destroy: createDestroyCommand(operations),
1091
- dev: createDevCommand(operations),
1092
- log: createLogCommand(operations)
1093
- },
1094
- docsBaseUrl: DOCS_BASE
1095
- });
1096
- }
1097
- /**
1098
- * Everything environmental the engine needs, assembled from a host process.
1099
- *
1100
- * The engine takes no globals: streams, cwd, env, TTY-ness, exit and signal
1101
- * subscription all arrive through `Runtime`, which is what lets a test drive a
1102
- * whole run without touching `process`. Composing one is the substantive part
1103
- * of hosting the engine — `createCli` and `Cli.run` are two calls.
1104
- *
1105
- * Credentials come from the engine's own environment-only manager, which
1106
- * composes a session from PRISMA_SERVICE_TOKEN / PRISMA_WORKSPACE_ID and
1107
- * refuses every mutation. That is the whole of composer's standalone auth
1108
- * story: this CLI has no login flow and mounts no auth commands, so there is
1109
- * nothing to store — the two variables ARE the credential.
1110
- */
1111
- /** Where the management API lives. Matches the lowering client's default origin; the env var is the escape hatch for staging. */
1112
- const DEFAULT_MANAGEMENT_API_BASE_URL = "https://api.prisma.io";
1113
- const DEFAULT_AUTH_BASE_URL = "https://auth.prisma.io";
1114
- /**
1115
- * Starts the converge child: inherited stdio, this process's own group, no
1116
- * `detached` and no new console — which is what lets the terminal deliver
1117
- * Ctrl-C to the child natively instead of the CLI forwarding it. The engine
1118
- * never imports node:child_process; this adapter is the whole of the host's
1119
- * side of that seam.
1120
- */
1121
- const spawnChild = (request) => {
1122
- const child = spawn(request.command, [...request.args], {
1123
- cwd: request.cwd,
1124
- stdio: "inherit",
1125
- env: request.env
1126
- });
1127
- return {
1128
- ended: new Promise((resolve, reject) => {
1129
- child.on("error", reject);
1130
- child.on("close", (exitCode, signal) => {
1131
- resolve({
1132
- exitCode,
1133
- signal
1134
- });
1135
- });
1136
- }),
1137
- kill: (signal) => {
1138
- child.kill(signal);
1139
- }
1140
- };
1141
- };
1142
- /**
1143
- * The SDK's client construction config. The engine requires all four fields
1144
- * whenever a credential manager is wired, but this host reaches none of the
1145
- * login paths: an environment credential carries no refresh token, so nothing
1146
- * ever refreshes and `clientId`/`redirectUri` are never read. They are
1147
- * env-overridable rather than hard-coded so a staging run can point the whole
1148
- * client somewhere else in one place.
1149
- */
1150
- function clientConfig(env, apiBaseUrl) {
1151
- return {
1152
- clientId: env["PRISMA_CLIENT_ID"] ?? "prisma-composer-cli",
1153
- redirectUri: env["PRISMA_REDIRECT_URI"] ?? "http://127.0.0.1/callback",
1154
- apiBaseUrl,
1155
- authBaseUrl: env["PRISMA_AUTH_URL"] ?? DEFAULT_AUTH_BASE_URL
1156
- };
1157
- }
1158
- /**
1159
- * Which package manager invoked us, read from the `npm_config_user_agent`
1160
- * every major manager sets (`pnpm/10.27.0 npm/? node/v24.16.0 darwin arm64`).
1161
- * `undefined` when the CLI was run directly rather than through a manager — a
1162
- * normal case, not a failure, so nothing is inferred from the filesystem, and
1163
- * the engine falls back to its own detection from the project at cwd.
1164
- */
1165
- function detectPackageManager(env) {
1166
- const agent = env["npm_config_user_agent"];
1167
- if (agent === void 0) return void 0;
1168
- const name = agent.split("/")[0];
1169
- switch (name) {
1170
- case "npm":
1171
- case "pnpm":
1172
- case "yarn":
1173
- case "bun":
1174
- case "deno": return name;
1175
- default: return;
1176
- }
1177
- }
1178
- /**
1179
- * The config loader arrives as a function rather than an already-loaded config
1180
- * because the engine reads `prisma.config.ts` on demand — only when the command
1181
- * it is about to run declares a config section, and with whatever file
1182
- * `--config` named. A host that loaded the file up front would read it for runs
1183
- * that never needed it, and would have nowhere to put `--config`.
1184
- *
1185
- * `inCI` is the one thing here not derived from the host: `ci-info` answers it
1186
- * from the real `process.env` at import, which is what the engine's `isCI` doc
1187
- * asks a host to wire and what the `prisma` bin already does. Production passes
1188
- * nothing. It is a parameter so a test can still drive CI state without
1189
- * touching a process global.
1190
- */
1191
- function createRuntime(host, loadConfig, inCI = import_ci_info.isCI) {
1192
- const env = host.env;
1193
- const apiBaseUrl = env["PRISMA_MANAGEMENT_API_URL"] ?? DEFAULT_MANAGEMENT_API_BASE_URL;
1194
- const packageManager = detectPackageManager(env);
1195
- return {
1196
- stdout: host.stdout,
1197
- stderr: host.stderr,
1198
- stdin: host.stdin,
1199
- cwd: host.cwd(),
1200
- env,
1201
- isTty: {
1202
- stdin: host.stdin.isTTY === true,
1203
- stdout: host.stdout.isTTY === true,
1204
- stderr: host.stderr.isTTY === true
1205
- },
1206
- exit: (code) => host.exit(code),
1207
- onSignal: (cb) => {
1208
- const onSigint = () => {
1209
- cb("SIGINT");
1210
- };
1211
- const onSigterm = () => {
1212
- cb("SIGTERM");
1213
- };
1214
- host.on("SIGINT", onSigint);
1215
- host.on("SIGTERM", onSigterm);
1216
- return () => {
1217
- host.off("SIGINT", onSigint);
1218
- host.off("SIGTERM", onSigterm);
1219
- };
1220
- },
1221
- loadConfig,
1222
- credentialManager: new EnvironmentCredentialManager({ env }),
1223
- managementApiClientConfig: clientConfig(env, apiBaseUrl),
1224
- spawn: spawnChild,
1225
- managementApi: { baseUrl: apiBaseUrl },
1226
- ...packageManager !== void 0 && { packageManager },
1227
- isCI: inCI
1228
- };
1229
- }
1230
- /**
1231
- * Composer's own CLI, rebuilt as a thin composition of the family it
1232
- * publishes: `createCli` over `createComposerFamily()`, `Cli.run` with a
1233
- * Runtime. Grammar, help, arg validation, output framing, exit codes and
1234
- * signal ownership all belong to the engine now — this module contributes the
1235
- * family and the environment, and nothing else.
1236
- *
1237
- * Running composer's commands through the same path an external host uses is
1238
- * the point: it is what proves the family works standalone before the `prisma`
1239
- * bin mounts it.
1240
- *
1241
- * This IS composer's CLI. The clipanion shell it replaced, and the bespoke
1242
- * runner that shelled out to alchemy, are gone; `bin.ts` is a call into here.
1243
- */
1244
- const BINARY_NAME = "prisma-composer";
1245
- /**
1246
- * Composer's commands mount at the top level of its own CLI (`prisma-composer
1247
- * deploy`); under the `prisma` bin the same family mounts one level down
1248
- * (`prisma composer deploy`). The family is identical either way — only the
1249
- * mount paths differ, which is exactly the split `createCli` draws between
1250
- * `commandFamilies` and `commands`.
1251
- */
1252
- function mountedTree(family) {
1253
- return { ...family.commands };
1254
- }
1255
- function createComposerCli(spec) {
1256
- const family = createComposerFamily({ operations: spec.operations });
1257
- return createCli({
1258
- name: BINARY_NAME,
1259
- version: spec.version,
1260
- commandFamilies: [family],
1261
- groups: {},
1262
- commands: mountedTree(family)
1263
- });
1264
- }
1265
- /**
1266
- * Composes the Runtime and runs one invocation. Returns the exit code rather
1267
- * than exiting, so the caller owns the process — a bin assigns it to
1268
- * `process.exitCode` and lets the streams drain, as composer's CLI has always
1269
- * done.
1270
- *
1271
- * `prisma.config.ts` is not read here. The loader goes in as a function, and the
1272
- * engine calls it only when the command it is about to run declares a config
1273
- * section, passing it the file `--config` named; the loader resolves that
1274
- * against the host's cwd.
1275
- */
1276
- function runComposerCli(argv, host, spec, hooks) {
1277
- const runtime = createRuntime(host, (configPath) => loadConfig(host.cwd(), configPath));
1278
- return createComposerCli(spec).run(argv, runtime, hooks);
1279
- }
1280
- //#endregion
1281
- //#region ../../0-framework/3-tooling/cli/dist/cli-C8cVG9HU.mjs
1282
- /**
1283
- * The `prisma-composer` entrypoint: adapt this process into the engine's
1284
- * `HostProcess`, run one invocation of composer's own CLI, and hand back an
1285
- * exit code. Grammar, help, argument validation, output framing, exit codes
1286
- * and signal policy all belong to the engine — this module contributes the
1287
- * process and the version, and nothing else.
1288
- *
1289
- * Node's `process` already satisfies `HostProcess` structurally, so there is
1290
- * no adapter object here; that is the whole point of the engine taking a host
1291
- * surface rather than reading globals.
1292
- */
1293
- /** Printed for a throw that escapes the engine entirely — by the shared base-type rules that is a bug, not a user failure. */
1294
- const REPORT_HINT = "This is a bug in prisma-composer, not in your app — please report it: https://github.com/prisma/composer/issues";
1295
- const UNKNOWN_VERSION = "unknown";
1296
- /**
1297
- * The version the CLI reports, read from the manifest of the package this
1298
- * module was BUNDLED INTO — `@prisma/composer` for the published bin, since
1299
- * that is the package whose executable the user installed. Walking up from the
1300
- * module's own location is what makes that true in both layouts: the published
1301
- * `dist/bin.mjs` finds `@prisma/composer`'s manifest, and a direct run of
1302
- * `src/bin.ts` finds this package's.
1303
- */
1304
- function shippedVersion(fromDir = path.dirname(fileURLToPath(import.meta.url))) {
1305
- let dir = fromDir;
1306
- while (true) {
1307
- const manifest = path.join(dir, "package.json");
1308
- if (fs.existsSync(manifest)) try {
1309
- const version = JSON.parse(fs.readFileSync(manifest, "utf-8")).version;
1310
- return typeof version === "string" ? version : UNKNOWN_VERSION;
1311
- } catch {
1312
- return UNKNOWN_VERSION;
1313
- }
1314
- const parent = path.dirname(dir);
1315
- if (parent === dir) return UNKNOWN_VERSION;
1316
- dir = parent;
1317
- }
1318
- }
1319
- /**
1320
- * Runs `prisma-composer` end to end and returns the process exit code. The
1321
- * caller assigns it to `process.exitCode` rather than exiting, so the streams
1322
- * drain — the engine returns a code for exactly this reason.
1323
- *
1324
- * The catch is not error handling for commands: the engine renders every
1325
- * command failure itself. It catches a throw that escaped the engine — a
1326
- * construction fault, a broken config load — which by ADR-0044 is a bug in
1327
- * this CLI and exits 1 with a report hint.
1328
- */
1329
- async function cli(argv = process.argv.slice(2)) {
1330
- try {
1331
- return await runComposerCli(argv, process, { version: shippedVersion() });
1332
- } catch (error) {
1333
- console.error(`Error: ${error instanceof Error ? error.message : String(error)}`);
1334
- console.error(REPORT_HINT);
1335
- return 1;
1336
- }
1337
- }
1338
- //#endregion
1339
- //#region ../../0-framework/3-tooling/cli/dist/bin.mjs
1340
- process.exitCode = await cli();
1341
- //#endregion
1342
- export {};
1343
-
1344
- //# sourceMappingURL=bin.mjs.map