@prisma/composer 0.30.0 → 0.31.0-dev.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (69) hide show
  1. package/dist/{app-config-BqBRS3nH-Cskusz-T.d.mts → app-config-BBPLNnZX-DzU21TVb.d.mts} +57 -7
  2. package/dist/{app-config-BqBRS3nH-Cskusz-T.d.mts.map → app-config-BBPLNnZX-DzU21TVb.d.mts.map} +1 -1
  3. package/dist/config-CRHoX2Pq.d.mts +1 -0
  4. package/dist/config.d.mts +3 -3
  5. package/dist/control.d.mts +53 -10
  6. package/dist/control.d.mts.map +1 -1
  7. package/dist/control.mjs +4 -4
  8. package/dist/control.mjs.map +1 -1
  9. package/dist/deploy-CRHoX2Pq.d.mts +1 -0
  10. package/dist/deploy.d.mts +2 -2
  11. package/dist/deploy.mjs +1 -1
  12. package/dist/deploy.mjs.map +1 -1
  13. package/dist/{deployment-summary-CU-eVvJM-J6GE7DdU.d.mts → deployment-summary-CU-eVvJM-rJHGy-BV.d.mts} +3 -3
  14. package/dist/{deployment-summary-CU-eVvJM-J6GE7DdU.d.mts.map → deployment-summary-CU-eVvJM-rJHGy-BV.d.mts.map} +1 -1
  15. package/dist/{dev-CqS1W82b-gZEtkFO1.mjs → dev-current-Bm7Yrsmt-BokQtx_Z.mjs} +24 -5
  16. package/dist/dev-current-Bm7Yrsmt-BokQtx_Z.mjs.map +1 -0
  17. package/dist/{dist-CR0-3j9o.mjs → dist-D5tj8ZhD.mjs} +2 -2
  18. package/dist/{dist-CR0-3j9o.mjs.map → dist-D5tj8ZhD.mjs.map} +1 -1
  19. package/dist/emulator-retry-CV8rl69G-BgUzkxc-.mjs +32 -0
  20. package/dist/emulator-retry-CV8rl69G-BgUzkxc-.mjs.map +1 -0
  21. package/dist/{execute-deploy-destroy-D4UdieU1-Q12Tpvij.mjs → execute-deploy-destroy-BK4R2qCX-C7pPemYB.mjs} +4 -4
  22. package/dist/execute-deploy-destroy-BK4R2qCX-C7pPemYB.mjs.map +1 -0
  23. package/dist/execute-dev-current-nYH8EiKK-B-GAyQFU.mjs +128 -0
  24. package/dist/execute-dev-current-nYH8EiKK-B-GAyQFU.mjs.map +1 -0
  25. package/dist/{execute-dev-BSPnsEv--Bz2s7o74.mjs → execute-dev-qKlYePGn-D6SHRPB4.mjs} +37 -17
  26. package/dist/{execute-dev-BSPnsEv--Bz2s7o74.mjs.map → execute-dev-qKlYePGn-D6SHRPB4.mjs.map} +1 -1
  27. package/dist/{execute-log-jcT5zhF8-C0bGq9-N.mjs → execute-log-B4lOgkOV-DRG7IyK8.mjs} +5 -5
  28. package/dist/execute-log-B4lOgkOV-DRG7IyK8.mjs.map +1 -0
  29. package/dist/{graph-BfKAg2Ap-LY3OAuK2.mjs → graph-BPLLRt2I-m78iETnF.mjs} +15 -6
  30. package/dist/graph-BPLLRt2I-m78iETnF.mjs.map +1 -0
  31. package/dist/{graph-CPeatmoF-DfDx8ctT.d.mts → graph-C4If3c5e-CVij_XGB.d.mts} +3 -3
  32. package/dist/graph-C4If3c5e-CVij_XGB.d.mts.map +1 -0
  33. package/dist/{graph-types-BTTaRnih-BF6PobQ3.d.mts → graph-types-Cegbwb_X-BU-H2pnt.d.mts} +27 -21
  34. package/dist/graph-types-Cegbwb_X-BU-H2pnt.d.mts.map +1 -0
  35. package/dist/http.d.mts +22 -0
  36. package/dist/http.d.mts.map +1 -0
  37. package/dist/http.mjs +40 -0
  38. package/dist/http.mjs.map +1 -0
  39. package/dist/{index-DeocL1di.d.mts → index-vUfxWpWf.d.mts} +3 -3
  40. package/dist/{index-DeocL1di.d.mts.map → index-vUfxWpWf.d.mts.map} +1 -1
  41. package/dist/index.d.mts +4 -4
  42. package/dist/index.mjs +2 -2
  43. package/dist/local-target.d.mts +2 -2
  44. package/dist/{nextjs-DLyeRR7M-D7UOddVQ.d.mts → nextjs-DLyeRR7M-Btfuot-v.d.mts} +3 -3
  45. package/dist/{nextjs-DLyeRR7M-D7UOddVQ.d.mts.map → nextjs-DLyeRR7M-Btfuot-v.d.mts.map} +1 -1
  46. package/dist/nextjs-control.d.mts +4 -4
  47. package/dist/nextjs.d.mts +1 -1
  48. package/dist/node-control.d.mts +3 -3
  49. package/dist/node.d.mts +2 -2
  50. package/dist/{pipeline-B-vJNch3-PBDKc8cX.mjs → pipeline-Dpesfd2j-CD3W79W6.mjs} +5 -5
  51. package/dist/{pipeline-B-vJNch3-PBDKc8cX.mjs.map → pipeline-Dpesfd2j-CD3W79W6.mjs.map} +1 -1
  52. package/dist/report.d.mts +3 -3
  53. package/dist/service-rpc.d.mts +2 -2
  54. package/dist/service-rpc.mjs +3 -2
  55. package/dist/service-rpc.mjs.map +1 -1
  56. package/dist/testing.d.mts +1 -1
  57. package/package.json +13 -11
  58. package/skills/prisma-composer-core-concepts/SKILL.md +67 -15
  59. package/src/exports/http.ts +1 -0
  60. package/dist/config-Du9pXwQX.d.mts +0 -1
  61. package/dist/deploy-Du9pXwQX.d.mts +0 -1
  62. package/dist/dev-CqS1W82b-gZEtkFO1.mjs.map +0 -1
  63. package/dist/emulator-retry-DGonap4g-S8BNrXFD.mjs +0 -24
  64. package/dist/emulator-retry-DGonap4g-S8BNrXFD.mjs.map +0 -1
  65. package/dist/execute-deploy-destroy-D4UdieU1-Q12Tpvij.mjs.map +0 -1
  66. package/dist/execute-log-jcT5zhF8-C0bGq9-N.mjs.map +0 -1
  67. package/dist/graph-BfKAg2Ap-LY3OAuK2.mjs.map +0 -1
  68. package/dist/graph-CPeatmoF-DfDx8ctT.d.mts.map +0 -1
  69. package/dist/graph-types-BTTaRnih-BF6PobQ3.d.mts.map +0 -1
@@ -0,0 +1,32 @@
1
+ import { t as CliStructuredError } from "./errors-0e8IVwzi.mjs";
2
+ //#region ../../0-framework/3-tooling/cli/dist/emulator-retry-CV8rl69G.mjs
3
+ /**
4
+ * An emulator admin call right after a converge that just PUT dozens of
5
+ * resources through the same daemon can fail to connect — a brief loopback
6
+ * hiccup under load, not a real failure. Only that is retried: the emulator
7
+ * client reports it as `DEV.EMULATOR_UNREACHABLE`. Anything else is final,
8
+ * including an error response (such as a service that failed to start) and a
9
+ * connection reset while a response body is read. Shared by the dev and log
10
+ * executors, which talk to the same daemons (`startServices`, `endpoints`,
11
+ * `attach`).
12
+ */
13
+ const EMULATOR_RETRY_ATTEMPTS = 5;
14
+ const EMULATOR_RETRY_DELAY_MS = 500;
15
+ function isUnreachable(error) {
16
+ return CliStructuredError.is(error) && error.code === "DEV.EMULATOR_UNREACHABLE";
17
+ }
18
+ async function withEmulatorRetry(call) {
19
+ let lastError;
20
+ for (let attempt = 1; attempt <= EMULATOR_RETRY_ATTEMPTS; attempt += 1) try {
21
+ return await call();
22
+ } catch (error) {
23
+ if (!isUnreachable(error)) throw error;
24
+ lastError = error;
25
+ if (attempt < EMULATOR_RETRY_ATTEMPTS) await new Promise((resolve) => setTimeout(resolve, EMULATOR_RETRY_DELAY_MS));
26
+ }
27
+ throw lastError instanceof Error ? lastError : new Error(String(lastError));
28
+ }
29
+ //#endregion
30
+ export { withEmulatorRetry as t };
31
+
32
+ //# sourceMappingURL=emulator-retry-CV8rl69G-BgUzkxc-.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"emulator-retry-CV8rl69G-BgUzkxc-.mjs","names":[],"sources":["../../../0-framework/3-tooling/cli/dist/emulator-retry-CV8rl69G.mjs"],"sourcesContent":["import { CliStructuredError } from \"@internal/foundation/errors\";\n//#region src/operations/emulator-retry.ts\n/**\n* An emulator admin call right after a converge that just PUT dozens of\n* resources through the same daemon can fail to connect — a brief loopback\n* hiccup under load, not a real failure. Only that is retried: the emulator\n* client reports it as `DEV.EMULATOR_UNREACHABLE`. Anything else is final,\n* including an error response (such as a service that failed to start) and a\n* connection reset while a response body is read. Shared by the dev and log\n* executors, which talk to the same daemons (`startServices`, `endpoints`,\n* `attach`).\n*/\nconst EMULATOR_RETRY_ATTEMPTS = 5;\nconst EMULATOR_RETRY_DELAY_MS = 500;\nfunction isUnreachable(error) {\n\treturn CliStructuredError.is(error) && error.code === \"DEV.EMULATOR_UNREACHABLE\";\n}\nasync function withEmulatorRetry(call) {\n\tlet lastError;\n\tfor (let attempt = 1; attempt <= EMULATOR_RETRY_ATTEMPTS; attempt += 1) try {\n\t\treturn await call();\n\t} catch (error) {\n\t\tif (!isUnreachable(error)) throw error;\n\t\tlastError = error;\n\t\tif (attempt < EMULATOR_RETRY_ATTEMPTS) await new Promise((resolve) => setTimeout(resolve, EMULATOR_RETRY_DELAY_MS));\n\t}\n\tthrow lastError instanceof Error ? lastError : new Error(String(lastError));\n}\n//#endregion\nexport { withEmulatorRetry as t };\n\n//# sourceMappingURL=emulator-retry-CV8rl69G.mjs.map"],"mappings":";;;;;;;;;;;;AAYA,MAAM,0BAA0B;AAChC,MAAM,0BAA0B;AAChC,SAAS,cAAc,OAAO;CAC7B,OAAO,mBAAmB,GAAG,KAAK,KAAK,MAAM,SAAS;AACvD;AACA,eAAe,kBAAkB,MAAM;CACtC,IAAI;CACJ,KAAK,IAAI,UAAU,GAAG,WAAW,yBAAyB,WAAW,GAAG,IAAI;EAC3E,OAAO,MAAM,KAAK;CACnB,SAAS,OAAO;EACf,IAAI,CAAC,cAAc,KAAK,GAAG,MAAM;EACjC,YAAY;EACZ,IAAI,UAAU,yBAAyB,MAAM,IAAI,SAAS,YAAY,WAAW,SAAS,uBAAuB,CAAC;CACnH;CACA,MAAM,qBAAqB,QAAQ,YAAY,IAAI,MAAM,OAAO,SAAS,CAAC;AAC3E"}
@@ -1,16 +1,16 @@
1
1
  import { t as CliStructuredError } from "./errors-0e8IVwzi.mjs";
2
2
  import { t as containerEnv } from "./container-transport-HcvNOGZL-twPi2TIv.mjs";
3
3
  import { n as preflightEnvVarName, t as preflightEnv } from "./config-CdxvLFzg.mjs";
4
- import { a as toStructured, c as okVoid, o as notOk, s as ok } from "./dev-CqS1W82b-gZEtkFO1.mjs";
4
+ import { c as notOk, l as ok, s as toStructured, u as okVoid } from "./dev-current-Bm7Yrsmt-BokQtx_Z.mjs";
5
5
  import { a as writeRunReport, i as toRunReport, r as resolveRunReportPath, t as RUN_REPORT_FILE_ENV } from "./run-report-C2o98uD--AX8kpz4Q.mjs";
6
6
  import { a as readEngineFailureCause, i as readDeploymentSummary, r as engineFailureFilePath, t as DEPLOYMENT_RESULT_FILE_ENV } from "./deployment-summary-37e6WEuh-BOTJynIi.mjs";
7
7
  import { n as reproduceCommand, r as spawnAlchemy, t as alchemyInvocation } from "./run-alchemy-BqHpStQn-sYiodM6y.mjs";
8
- import { n as runPipeline, r as noComposerExportMessage } from "./pipeline-B-vJNch3-PBDKc8cX.mjs";
8
+ import { i as noComposerExportMessage, r as runPipeline } from "./pipeline-Dpesfd2j-CD3W79W6.mjs";
9
9
  import * as fs$1 from "node:fs";
10
10
  import * as path$1 from "node:path";
11
11
  import { randomUUID } from "node:crypto";
12
12
  import { spawnSync } from "node:child_process";
13
- //#region ../../0-framework/3-tooling/cli/dist/execute-deploy-destroy-D4UdieU1.mjs
13
+ //#region ../../0-framework/3-tooling/cli/dist/execute-deploy-destroy-BK4R2qCX.mjs
14
14
  /** Pipeline step 6: writes a regenerated-every-run, independently runnable stack module at `.prisma-composer/alchemy.run.ts`. */
15
15
  const GENERATED_DIR = ".prisma-composer";
16
16
  const GENERATED_FILE = "alchemy.run.ts";
@@ -524,4 +524,4 @@ async function runStackPipelineInner(action, opts, reporters) {
524
524
  //#endregion
525
525
  export { executeDeploy, executeDestroy };
526
526
 
527
- //# sourceMappingURL=execute-deploy-destroy-D4UdieU1-Q12Tpvij.mjs.map
527
+ //# sourceMappingURL=execute-deploy-destroy-BK4R2qCX-C7pPemYB.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"execute-deploy-destroy-BK4R2qCX-C7pPemYB.mjs","names":["path","fs"],"sources":["../../../0-framework/3-tooling/cli/dist/execute-deploy-destroy-BK4R2qCX.mjs"],"sourcesContent":["import { a as readEngineFailureCause, i as readDeploymentSummary, r as engineFailureFilePath, t as DEPLOYMENT_RESULT_FILE_ENV } from \"./deployment-summary-37e6WEuh.mjs\";\nimport { l as toStructured } from \"./dev-current-Bm7Yrsmt.mjs\";\nimport { a as writeRunReport, i as toRunReport, r as resolveRunReportPath, t as RUN_REPORT_FILE_ENV } from \"./run-report-C2o98uD-.mjs\";\nimport { i as spawnAlchemy, n as alchemyInvocation, r as reproduceCommand } from \"./run-alchemy-BqHpStQn.mjs\";\nimport { r as noComposerExportMessage } from \"./composer-config-CY9fET8H.mjs\";\nimport { r as runPipeline } from \"./pipeline-Dpesfd2j.mjs\";\nimport * as fs from \"node:fs\";\nimport { notOk, ok, okVoid } from \"@internal/foundation/result\";\nimport { CliStructuredError } from \"@internal/foundation/errors\";\nimport * as path from \"node:path\";\nimport { randomUUID } from \"node:crypto\";\nimport { containerEnv, preflightEnv, preflightEnvVarName } from \"@internal/core/config\";\nimport { spawnSync } from \"node:child_process\";\n//#region src/generate-stack.ts\n/** Pipeline step 6: writes a regenerated-every-run, independently runnable stack module at `.prisma-composer/alchemy.run.ts`. */\nconst GENERATED_DIR = \".prisma-composer\";\nconst GENERATED_FILE = \"alchemy.run.ts\";\n/** A relative import specifier from `.prisma-composer/alchemy.run.ts` to `target` (posix separators). */\nfunction relativeImportSpecifier(generatedDir, target) {\n\tconst rel = path.relative(generatedDir, target).split(path.sep).join(\"/\");\n\treturn rel.startsWith(\".\") ? rel : `./${rel}`;\n}\nfunction quote(value) {\n\treturn JSON.stringify(value);\n}\nfunction renderBundle(bundle) {\n\treturn `{ dir: ${quote(bundle.dir)}, entry: ${quote(bundle.entry)} }`;\n}\nfunction renderOptions(input) {\n\tconst lines = [];\n\tlines.push(` name: ${quote(input.name)},`);\n\tlines.push(\" bundles: {\");\n\tfor (const [id, bundle] of Object.entries(input.assembled.bundles)) lines.push(` ${quote(id)}: ${renderBundle(bundle)},`);\n\tlines.push(\" },\");\n\tlines.push(\" report: report.deploymentReport,\");\n\treturn lines.join(\"\\n\");\n}\n/** Renders the stack module's source (tests assert on it without touching disk) — uses `//` headers, not a block comment, since a cwd path with a star-slash could close one early. */\nfunction renderStackFile(input) {\n\tconst generatedDir = path.join(input.cwd, GENERATED_DIR);\n\tconst appImport = relativeImportSpecifier(generatedDir, input.entryPath);\n\tconst configImport = relativeImportSpecifier(generatedDir, input.configFile);\n\treturn `// Generated by Composer's deploy and destroy operations — overwritten on every\n// run; do not edit by hand. Runnable from ${quote(input.cwd)} WITH the env the\n// CLI passes its child (the PRISMA_COMPOSER_CONTAINER_*/_PREFLIGHT_* vars —\n// without them lower() refuses because no container is resolved), by the\n// command Composer starts, which a failed run prints:\n//\n// <node> <bin of the alchemy @prisma/composer depends on> deploy ${GENERATED_DIR}/${GENERATED_FILE} --yes --stage <stage>\n//\n// bisects a CLI bug from an Alchemy bug (deploy-cli.md § Implementation decisions).\nimport { lower } from '@prisma/composer/deploy';\nimport * as report from '@prisma/composer/report';\nimport prismaConfig from ${quote(configImport)};\nimport app from ${quote(appImport)};\n\nconst config = prismaConfig.composer;\nif (config === undefined) {\n throw new Error(${quote(noComposerExportMessage(input.configFile))});\n}\n\n// The app's own @prisma/composer may predate the failure recorder.\nreport.captureEngineFailure?.();\n\nexport default lower(app, config, {\n${renderOptions(input)}\n});\n`;\n}\n/** Writes the stack file, returning its absolute path. */\nfunction writeStackFile(input) {\n\tconst generatedDir = path.join(input.cwd, GENERATED_DIR);\n\tfs.mkdirSync(generatedDir, { recursive: true });\n\tconst filePath = path.join(generatedDir, GENERATED_FILE);\n\tfs.writeFileSync(filePath, renderStackFile(input));\n\treturn filePath;\n}\nconst GENERATED_STACK_RELATIVE_PATH = path.join(GENERATED_DIR, GENERATED_FILE);\n//#endregion\n//#region src/validate-stage.ts\n/** A stage name must be a valid git ref (deploy-cli.md) — checked via `git check-ref-format`, never silently normalized. Runs before anything platform-specific. */\nfunction validateStageName(stage) {\n\tconst result = spawnSync(\"git\", [\"check-ref-format\", `refs/heads/${stage}`], { stdio: \"ignore\" });\n\tif (result.error) throw new CliStructuredError(\"DEPLOY.STAGE_UNVALIDATABLE\", `git is required to validate --stage \"${stage}\" (git check-ref-format): ${result.error.message}.`, { cause: result.error });\n\tif (result.status !== 0) throw new CliStructuredError(\"DEPLOY.STAGE_INVALID\", `Invalid --stage \"${stage}\": must be a valid git ref name (git check-ref-format rejected \"refs/heads/${stage}\").`);\n}\n//#endregion\n//#region src/operations/execute-deploy-destroy.ts\n/**\n* The deploy/destroy executor — main.ts's pipeline orchestration with argv,\n* console, and exit codes removed: typed inputs in, structured results out.\n* Reached only by lazy import from deploy.ts/destroy.ts — this module's\n* static graph transitively loads alchemy's provider tree, so the control\n* entry must never import it statically.\n*/\nconst ALCHEMY_STATE_DIR = \".alchemy\";\n/** Destroy guardrail (moved from main.ts): true when `<cwd>/.alchemy` is missing or empty — likely wrong directory or nothing deployed yet. */\nfunction hasNoLocalDeployState(cwd) {\n\tconst stateDir = path.join(cwd, ALCHEMY_STATE_DIR);\n\treturn !(fs.existsSync(stateDir) && fs.readdirSync(stateDir).length > 0);\n}\n/**\n* Times each deploy step for the host's `onEvent`. A step still open when the\n* run fails is closed as failed, innermost first. A host `onEvent` that throws\n* is the host's bug and cannot fail the deploy.\n*/\nfunction deploySteps(onEvent) {\n\tconst open = /* @__PURE__ */ new Map();\n\tconst keyOf = (step) => step.name === \"assemble-service\" ? `${step.name}:${step.address}` : step.name;\n\tconst emit = (event) => {\n\t\ttry {\n\t\t\tonEvent?.(event);\n\t\t} catch {}\n\t};\n\tconst finish = (step, outcome, data) => {\n\t\tconst entry = open.get(keyOf(step));\n\t\tif (entry === void 0) return;\n\t\topen.delete(keyOf(step));\n\t\tconst durationMs = Math.round(performance.now() - entry.startedAt);\n\t\temit({\n\t\t\tkind: \"step-finished\",\n\t\t\tstep,\n\t\t\toutcome,\n\t\t\tdurationMs,\n\t\t\tdata\n\t\t});\n\t};\n\treturn {\n\t\tstart(step) {\n\t\t\topen.set(keyOf(step), {\n\t\t\t\tstep,\n\t\t\t\tstartedAt: performance.now()\n\t\t\t});\n\t\t\temit({\n\t\t\t\tkind: \"step-started\",\n\t\t\t\tstep\n\t\t\t});\n\t\t},\n\t\tfinish(step, data) {\n\t\t\tfinish(step, \"ok\", data);\n\t\t},\n\t\tfail(step) {\n\t\t\tfinish(step, \"failed\");\n\t\t},\n\t\tfailOpen() {\n\t\t\tfor (const { step } of [...open.values()].reverse()) finish(step, \"failed\");\n\t\t}\n\t};\n}\nasync function executeDeploy(input, deps, cwd) {\n\tconst outcome = await runStackPipeline(\"deploy\", {\n\t\tentry: input.entry,\n\t\tconfig: input.config,\n\t\tname: input.name,\n\t\tstage: input.stage,\n\t\tcwd,\n\t\tonEvent: void 0,\n\t\tdeps,\n\t\treportId: input.reportId,\n\t\treportPath: resolveRunReportPath(input.reportPath, process.env[RUN_REPORT_FILE_ENV], cwd),\n\t\tsteps: deploySteps(input.onEvent)\n\t});\n\tif (!outcome.ok) return outcome;\n\treturn ok({ summary: outcome.value });\n}\nasync function executeDestroy(input, deps, cwd) {\n\tconst outcome = await runStackPipeline(\"destroy\", {\n\t\tentry: input.entry,\n\t\tconfig: input.config,\n\t\tname: input.name,\n\t\tstage: input.target.kind === \"stage\" ? input.target.stage : void 0,\n\t\tcwd,\n\t\tonEvent: input.onEvent,\n\t\tdeps,\n\t\treportId: void 0,\n\t\treportPath: void 0,\n\t\tsteps: deploySteps(void 0)\n\t});\n\tif (!outcome.ok) return outcome;\n\treturn okVoid();\n}\n/**\n* Opens a session per extension that declares a reporter. A `begin` that\n* throws costs that extension its reporting and nothing else — the deploy\n* has not started, and refusing to run it because an observer failed would\n* invert the relationship.\n*/\nasync function beginReporters(extensions, context) {\n\treturn (await Promise.all(extensions.map(async (extension) => {\n\t\tif (extension.reporter === void 0) return void 0;\n\t\ttry {\n\t\t\tconst reporter = await extension.reporter.begin(context);\n\t\t\treturn reporter === void 0 ? void 0 : {\n\t\t\t\textensionId: extension.id,\n\t\t\t\treporter\n\t\t\t};\n\t\t} catch (error) {\n\t\t\tconst detail = error instanceof Error ? error.message : String(error);\n\t\t\tconsole.warn(`\\nCould not start deploy reporting for ${extension.id}: ${detail}`);\n\t\t\treturn;\n\t\t}\n\t}))).filter((entry) => entry !== void 0);\n}\n/** Hands each session its own extension's resolved container, so it can attach the run to what that container names. */\nasync function attachReporters(reporters, containers) {\n\tawait Promise.all(reporters.map(async ({ extensionId, reporter }) => {\n\t\ttry {\n\t\t\tawait reporter.attach({ container: containers.get(extensionId) });\n\t\t} catch (error) {\n\t\t\tconst detail = error instanceof Error ? error.message : String(error);\n\t\t\tconsole.warn(`\\nCould not attach this deploy to its project for ${extensionId}: ${detail}`);\n\t\t}\n\t}));\n}\n/** Every session's contribution to the alchemy child's environment, so reporting that happens inside the apply can find the run. */\nfunction reporterChildEnv(reporters) {\n\tconst env = {};\n\tfor (const { extensionId, reporter } of reporters) try {\n\t\tObject.assign(env, reporter.childEnv());\n\t} catch (error) {\n\t\tconst detail = error instanceof Error ? error.message : String(error);\n\t\tconsole.warn(`\\nCould not pass deploy reporting into the apply for ${extensionId}: ${detail}`);\n\t}\n\treturn env;\n}\n/** `failingStep` is capped at 500 by the platform and `errorMessage` at 5000; truncating here keeps a long message from costing the whole report. */\nfunction truncate(value, limit) {\n\treturn value.length <= limit ? value : `${value.slice(0, limit - 1)}…`;\n}\n/** An interrupted converge (the engine settled a Ctrl-C) — reported as `cancelled`, never as `failed`. */\nfunction wasInterrupted(failure) {\n\treturn typeof failure.meta?.[\"signal\"] === \"string\";\n}\n/**\n* Ends every reporting session, whatever the run did. Sessions never reject\n* by contract, but a buggy one must not turn a converged deploy into a\n* failure — so this swallows anyway, and reports each session independently\n* so one bad implementation cannot silence another.\n*/\nasync function finishReporters(reporters, outcome) {\n\tconst entities = outcome.summary?.nodes.flatMap((node) => node.entities) ?? [];\n\tawait Promise.all(reporters.map(async ({ reporter }) => {\n\t\ttry {\n\t\t\tawait reporter.finish({\n\t\t\t\tok: outcome.ok,\n\t\t\t\tcancelled: outcome.cancelled,\n\t\t\t\tfailingStep: outcome.code === void 0 ? void 0 : truncate(outcome.code, 500),\n\t\t\t\terrorMessage: outcome.message === void 0 ? void 0 : truncate(outcome.message, 5e3),\n\t\t\t\tentities\n\t\t\t});\n\t\t} catch (error) {\n\t\t\tconst detail = error instanceof Error ? error.message : String(error);\n\t\t\tconsole.warn(`\\nCould not report this deploy's outcome: ${detail}`);\n\t\t}\n\t}));\n}\n/**\n* Owns the reporting sessions around the pipeline: the inner run opens them\n* once it knows which extensions are configured, and this closes them on\n* every exit path — a returned failure, a success, or a thrown defect — as\n* the `record` step, which also writes the run report.\n* Nothing here can change what the pipeline returns.\n*/\nasync function runStackPipeline(action, opts) {\n\tconst reporters = [];\n\tlet outcome;\n\ttry {\n\t\toutcome = await runStackPipelineInner(action, opts, reporters);\n\t} catch (error) {\n\t\topts.steps.failOpen();\n\t\topts.steps.start({ name: \"record\" });\n\t\tawait finishReporters(reporters, {\n\t\t\tok: false,\n\t\t\tcancelled: false,\n\t\t\tcode: \"DEPLOY.UNEXPECTED\",\n\t\t\tmessage: error instanceof Error ? error.message : String(error)\n\t\t});\n\t\topts.steps.finish({ name: \"record\" });\n\t\tthrow error;\n\t}\n\tif (!outcome.ok) opts.steps.failOpen();\n\topts.steps.start({ name: \"record\" });\n\tawait finishReporters(reporters, outcome.ok ? {\n\t\tok: true,\n\t\tcancelled: false,\n\t\tsummary: outcome.value\n\t} : {\n\t\tok: false,\n\t\tcancelled: wasInterrupted(outcome.failure),\n\t\tcode: outcome.failure.code,\n\t\tmessage: outcome.failure.message\n\t});\n\tif (opts.reportPath === void 0 || writeRunReport(opts.reportPath, toRunReport({\n\t\tsummary: outcome.ok ? outcome.value : void 0,\n\t\tstage: opts.stage,\n\t\tfailure: outcome.ok ? void 0 : {\n\t\t\tcode: outcome.failure.code,\n\t\t\tmessage: outcome.failure.message\n\t\t}\n\t}))) opts.steps.finish({ name: \"record\" });\n\telse opts.steps.fail({ name: \"record\" });\n\treturn outcome;\n}\n/** The pipeline both actions share: validate, resolve containers, preflight,\n* write the stack file, run alchemy against it, then the destroy-only\n* teardown/removal suffix. The value is only ever a summary for deploy. */\nasync function runStackPipelineInner(action, opts, reporters) {\n\tconst { entry, config: composerConfig, name, stage, cwd, onEvent, deps, steps } = opts;\n\tsteps.start({ name: \"prepare\" });\n\tif (stage !== void 0) try {\n\t\tvalidateStageName(stage);\n\t} catch (error) {\n\t\tif (CliStructuredError.is(error)) return notOk(error);\n\t\tthrow error;\n\t}\n\tif (action === \"destroy\" && hasNoLocalDeployState(cwd)) onEvent?.({\n\t\tkind: \"no-local-deploy-state\",\n\t\tcwd\n\t});\n\tlet pipeline;\n\tlet containers;\n\tlet alchemyStage;\n\tconst preflightPayloads = /* @__PURE__ */ new Map();\n\tlet preflightTransportEnv = {};\n\ttry {\n\t\tpipeline = await runPipeline(entry, name, cwd, composerConfig, {\n\t\t\trunAssembler: deps.runAssembler,\n\t\t\tonEvent: (event) => {\n\t\t\t\tswitch (event.kind) {\n\t\t\t\t\tcase \"loaded\":\n\t\t\t\t\t\tsteps.finish({ name: \"prepare\" });\n\t\t\t\t\t\tsteps.start({ name: \"assemble\" });\n\t\t\t\t\t\treturn;\n\t\t\t\t\tcase \"service-started\":\n\t\t\t\t\t\tsteps.start({\n\t\t\t\t\t\t\tname: \"assemble-service\",\n\t\t\t\t\t\t\taddress: event.address\n\t\t\t\t\t\t});\n\t\t\t\t\t\treturn;\n\t\t\t\t\tcase \"service-assembled\":\n\t\t\t\t\t\tsteps.finish({\n\t\t\t\t\t\t\tname: \"assemble-service\",\n\t\t\t\t\t\t\taddress: event.address\n\t\t\t\t\t\t}, event.data);\n\t\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\t\t}, action === \"destroy\" ? (error) => new CliStructuredError(\"DEPLOY.BUILD_REQUIRED\", error.message, {\n\t\t\twhy: \"destroy evaluates the same stack program as deploy, which packages the built artifacts — so the app must be built first.\",\n\t\t\tfix: \"Run the build, then retry the destroy.\",\n\t\t\tcause: error\n\t\t}) : void 0);\n\t\tsteps.finish({ name: \"assemble\" });\n\t\tconst { graph, name: resolvedName } = pipeline;\n\t\tconst config = pipeline.configSource.value;\n\t\tsteps.start({ name: \"connect\" });\n\t\tif (action === \"deploy\") reporters.push(...await beginReporters(config.extensions, {\n\t\t\tappName: resolvedName,\n\t\t\tgraph,\n\t\t\tstage,\n\t\t\tcwd,\n\t\t\treportId: opts.reportId,\n\t\t\tcredentials: deps.credentials\n\t\t}));\n\t\tcontainers = /* @__PURE__ */ new Map();\n\t\tfor (const extension of config.extensions) {\n\t\t\tif (extension.container === void 0) continue;\n\t\t\ttry {\n\t\t\t\tif (action === \"deploy\") containers.set(extension.id, await extension.container.ensure({\n\t\t\t\t\tappName: resolvedName,\n\t\t\t\t\tstage\n\t\t\t\t}, deps.credentials));\n\t\t\t\telse {\n\t\t\t\t\tconst instance = await extension.container.locate({\n\t\t\t\t\t\tappName: resolvedName,\n\t\t\t\t\t\tstage\n\t\t\t\t\t}, deps.credentials);\n\t\t\t\t\tif (instance === void 0) throw new CliStructuredError(\"DEPLOY.TARGET_NOT_FOUND\", `Nothing deployed for ${resolvedName}${stage !== void 0 ? `/${stage}` : \"\"}.`, { fix: \"Deploy it first.\" });\n\t\t\t\t\tcontainers.set(extension.id, instance);\n\t\t\t\t}\n\t\t\t} catch (error) {\n\t\t\t\tthrow toStructured(\"DEPLOY.CONTAINER_FAILED\", error);\n\t\t\t}\n\t\t}\n\t\tawait attachReporters(reporters, containers);\n\t\tconst pinnedStage = containers.get(config.state.extension)?.alchemyStage ?? stage;\n\t\tif (pinnedStage === void 0) throw new CliStructuredError(\"DEPLOY.SCOPE_MISSING\", \"The configured deploy target supplied no deploy scope (its container defines no alchemyStage), so Alchemy has no stage to run under.\", { fix: action === \"deploy\" ? \"Pass --stage <name> to choose the deploy scope explicitly.\" : \"Destroying production needs a target whose container supplies the production deploy scope.\" });\n\t\talchemyStage = pinnedStage;\n\t\tsteps.finish({ name: \"connect\" });\n\t\tif (action === \"deploy\") {\n\t\t\tsteps.start({ name: \"preflight\" });\n\t\t\tconst counts = {};\n\t\t\tconst report = (reported) => {\n\t\t\t\tfor (const [key, value] of Object.entries(reported)) counts[key] = (counts[key] ?? 0) + value;\n\t\t\t};\n\t\t\tfor (const extension of config.extensions) {\n\t\t\t\tif (extension.preflight === void 0) continue;\n\t\t\t\ttry {\n\t\t\t\t\tconst payload = await extension.preflight({\n\t\t\t\t\t\tgraph,\n\t\t\t\t\t\tcontainer: containers.get(extension.id),\n\t\t\t\t\t\tstage,\n\t\t\t\t\t\tcredentials: deps.credentials,\n\t\t\t\t\t\treport\n\t\t\t\t\t});\n\t\t\t\t\tif (payload !== void 0) preflightPayloads.set(extension.id, payload);\n\t\t\t\t} catch (error) {\n\t\t\t\t\tthrow toStructured(\"DEPLOY.PREFLIGHT_FAILED\", error);\n\t\t\t\t}\n\t\t\t}\n\t\t\ttry {\n\t\t\t\tpreflightTransportEnv = preflightEnv(preflightPayloads);\n\t\t\t} catch (error) {\n\t\t\t\tthrow toStructured(\"DEPLOY.PREFLIGHT_FAILED\", error);\n\t\t\t}\n\t\t\tsteps.finish({ name: \"preflight\" }, counts);\n\t\t}\n\t\tfor (const extension of config.extensions) preflightTransportEnv[preflightEnvVarName(extension.id)] ??= \"\";\n\t} catch (error) {\n\t\tif (CliStructuredError.is(error)) return notOk(error);\n\t\tthrow error;\n\t}\n\tlet stackPath;\n\tconst resultFilePath = path.join(cwd, \".prisma-composer\", `deployment-result-${String(process.pid)}-${randomUUID()}.json`);\n\ttry {\n\t\ttry {\n\t\t\tstackPath = writeStackFile({\n\t\t\t\tentryPath: pipeline.entryModule.path,\n\t\t\t\tcwd,\n\t\t\t\tconfigFile: pipeline.configSource.file,\n\t\t\t\tname: pipeline.name,\n\t\t\t\tassembled: pipeline.assembled\n\t\t\t});\n\t\t} catch (error) {\n\t\t\treturn notOk(toStructured(\"DEPLOY.STACK_WRITE_FAILED\", error));\n\t\t}\n\t\tconst invocation = alchemyInvocation({\n\t\t\tcommand: action,\n\t\t\tstackFileRelativePath: GENERATED_STACK_RELATIVE_PATH,\n\t\t\tcwd,\n\t\t\tstage: alchemyStage,\n\t\t\tcontainerEnv: containerEnv(containers),\n\t\t\tpreflightEnv: preflightTransportEnv,\n\t\t\tenv: {\n\t\t\t\t...reporterChildEnv(reporters),\n\t\t\t\t[DEPLOYMENT_RESULT_FILE_ENV]: resultFilePath\n\t\t\t}\n\t\t});\n\t\tsteps.start({ name: \"apply\" });\n\t\tlet outcome;\n\t\ttry {\n\t\t\toutcome = await (deps.alchemy ?? spawnAlchemy)(invocation);\n\t\t} catch (error) {\n\t\t\tif (CliStructuredError.is(error)) return notOk(error);\n\t\t\treturn notOk(new CliStructuredError(\"DEPLOY.ENGINE_FAILED\", error instanceof Error ? error.message : String(error), {\n\t\t\t\tcause: error,\n\t\t\t\tmeta: { diagnostics: {\n\t\t\t\t\texitCode: void 0,\n\t\t\t\t\tstackFilePath: stackPath,\n\t\t\t\t\treproduceCommand: reproduceCommand(invocation),\n\t\t\t\t\tcwd\n\t\t\t\t} }\n\t\t\t}));\n\t\t}\n\t\tconst reproduce = reproduceCommand(invocation, outcome);\n\t\tif (outcome.signal !== null) return notOk(new CliStructuredError(\"DEPLOY.ENGINE_FAILED\", `alchemy ${action} was interrupted by ${outcome.signal}.`, { meta: {\n\t\t\tsignal: outcome.signal,\n\t\t\tdiagnostics: {\n\t\t\t\texitCode: void 0,\n\t\t\t\tsignal: outcome.signal,\n\t\t\t\tstackFilePath: stackPath,\n\t\t\t\treproduceCommand: reproduce,\n\t\t\t\tcwd\n\t\t\t}\n\t\t} }));\n\t\tconst status = outcome.exitCode ?? 1;\n\t\tif (status !== 0) {\n\t\t\tconst engineCause = readEngineFailureCause(resultFilePath);\n\t\t\tconst withCause = (sentence) => engineCause === void 0 ? sentence : `${sentence}\\n${engineCause}`;\n\t\t\treturn notOk(new CliStructuredError(\"DEPLOY.ENGINE_FAILED\", withCause(`alchemy ${action} exited with status ${status}.`), { meta: {\n\t\t\t\texitCode: status,\n\t\t\t\t...engineCause !== void 0 ? { engineCause } : {},\n\t\t\t\tdiagnostics: {\n\t\t\t\t\texitCode: status,\n\t\t\t\t\tstackFilePath: stackPath,\n\t\t\t\t\treproduceCommand: reproduce,\n\t\t\t\t\tcwd\n\t\t\t\t}\n\t\t\t} }));\n\t\t}\n\t\tsteps.finish({ name: \"apply\" });\n\t\ttry {\n\t\t\tif (action === \"destroy\") {\n\t\t\t\tfor (const extension of pipeline.configSource.value.extensions) {\n\t\t\t\t\tif (extension.teardown === void 0) continue;\n\t\t\t\t\ttry {\n\t\t\t\t\t\tawait extension.teardown({\n\t\t\t\t\t\t\tcontainer: containers.get(extension.id),\n\t\t\t\t\t\t\tstage\n\t\t\t\t\t\t});\n\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\tthrow toStructured(\"DEPLOY.TEARDOWN_FAILED\", error);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tfor (const extension of pipeline.configSource.value.extensions) {\n\t\t\t\t\tif (extension.container === void 0) continue;\n\t\t\t\t\tconst instance = containers.get(extension.id);\n\t\t\t\t\tif (instance === void 0) continue;\n\t\t\t\t\ttry {\n\t\t\t\t\t\tawait extension.container.remove(instance, deps.credentials);\n\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\tthrow toStructured(\"DEPLOY.CONTAINER_REMOVE_FAILED\", error);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t} catch (error) {\n\t\t\tif (CliStructuredError.is(error)) return notOk(error);\n\t\t\tthrow error;\n\t\t}\n\t\tif (action === \"deploy\") return ok(readDeploymentSummary(resultFilePath));\n\t\treturn ok(void 0);\n\t} finally {\n\t\ttry {\n\t\t\tfs.rmSync(resultFilePath, { force: true });\n\t\t\tfs.rmSync(engineFailureFilePath(resultFilePath), { force: true });\n\t\t} catch {}\n\t}\n}\n//#endregion\nexport { executeDeploy, executeDestroy };\n\n//# sourceMappingURL=execute-deploy-destroy-BK4R2qCX.mjs.map"],"mappings":";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AAQ,CAAC;EAC9B,IAAI;GACH,IAAI,WAAW,WAAW;IACzB,KAAK,MAAM,aAAa,SAAS,aAAa,MAAM,YAAY;KAC/D,IAAI,UAAU,aAAa,KAAK,GAAG;KACnC,IAAI;MACH,MAAM,UAAU,SAAS;OACxB,WAAW,WAAW,IAAI,UAAU,EAAE;OACtC;MACD,CAAC;KACF,SAAS,OAAO;MACf,MAAM,aAAa,0BAA0B,KAAK;KACnD;IACD;IACA,KAAK,MAAM,aAAa,SAAS,aAAa,MAAM,YAAY;KAC/D,IAAI,UAAU,cAAc,KAAK,GAAG;KACpC,MAAM,WAAW,WAAW,IAAI,UAAU,EAAE;KAC5C,IAAI,aAAa,KAAK,GAAG;KACzB,IAAI;MACH,MAAM,UAAU,UAAU,OAAO,UAAU,KAAK,WAAW;KAC5D,SAAS,OAAO;MACf,MAAM,aAAa,kCAAkC,KAAK;KAC3D;IACD;GACD;EACD,SAAS,OAAO;GACf,IAAI,mBAAmB,GAAG,KAAK,GAAG,OAAO,MAAM,KAAK;GACpD,MAAM;EACP;EACA,IAAI,WAAW,UAAU,OAAO,GAAG,sBAAsB,cAAc,CAAC;EACxE,OAAO,GAAG,KAAK,CAAC;CACjB,UAAU;EACT,IAAI;GACH,KAAG,OAAO,gBAAgB,EAAE,OAAO,KAAK,CAAC;GACzC,KAAG,OAAO,sBAAsB,cAAc,GAAG,EAAE,OAAO,KAAK,CAAC;EACjE,QAAQ,CAAC;CACV;AACD"}
@@ -0,0 +1,128 @@
1
+ import { t as InternalError } from "./internal-error-Dfur7Zqt-D96dWHZK.mjs";
2
+ import { t as CliStructuredError } from "./errors-0e8IVwzi.mjs";
3
+ import { t as DEV_DIR } from "./app-config-CGJHcFb--CIEFCG4V.mjs";
4
+ import { c as notOk, l as ok, s as toStructured } from "./dev-current-Bm7Yrsmt-BokQtx_Z.mjs";
5
+ import { r as resolveLocalTargets } from "./local-target-BUZG9uLx.mjs";
6
+ import { t as checkConfigSource } from "./pipeline-Dpesfd2j-CD3W79W6.mjs";
7
+ import * as path$1 from "node:path";
8
+ //#region ../../0-framework/3-tooling/cli/dist/execute-dev-current-nYH8EiKK.mjs
9
+ /**
10
+ * The `devUrl` and `devStop` executor: config → each extension's local
11
+ * target → the app it recorded in the directory's dev state. Reached only by
12
+ * lazy import from dev-current.ts — resolving the local targets loads their
13
+ * descriptors, whose graphs reach alchemy's provider tree.
14
+ */
15
+ const RUN_DEV = "Run `prisma dev <entry>` in this directory.";
16
+ function platformUnsupported() {
17
+ return new CliStructuredError("DEV.PLATFORM_UNSUPPORTED", "local dev is not supported on Windows yet.");
18
+ }
19
+ /** A call into an extension's local target; its failures that carry no code are the emulator's. */
20
+ async function fromTarget(call) {
21
+ try {
22
+ return await call();
23
+ } catch (error) {
24
+ throw toStructured("DEV.EMULATOR_FAILED", error);
25
+ }
26
+ }
27
+ /** Every extension's record of the app `prisma dev` last ran from `cwd`; fails when none recorded one. */
28
+ async function currentApps(input, cwd) {
29
+ const { value } = checkConfigSource(input.config, cwd);
30
+ const devDir = path$1.join(cwd, DEV_DIR);
31
+ const apps = [];
32
+ for (const target of (await resolveLocalTargets(value)).values()) {
33
+ const current = await fromTarget(async () => target.current?.({ devDir }));
34
+ if (current !== void 0) apps.push(current);
35
+ }
36
+ if (apps.length === 0) throw new CliStructuredError("DEV.NOT_STARTED_HERE", `\`prisma dev\` has not run in ${cwd}.`, {
37
+ why: `The local services, databases and buckets of an app are recorded in ${devDir} when \`prisma dev\` runs there, and there is no such record.`,
38
+ fix: RUN_DEV,
39
+ meta: { cwd }
40
+ });
41
+ return apps;
42
+ }
43
+ async function locate(input, cwd) {
44
+ const apps = await currentApps(input, cwd);
45
+ const app = apps.find((candidate) => candidate.addresses.includes(input.address));
46
+ if (app === void 0) {
47
+ const known = apps.flatMap((candidate) => candidate.addresses).sort();
48
+ throw new CliStructuredError("DEV.ADDRESS_UNKNOWN", `"${apps.map((a) => a.app).join("\", \"")}" has no node at "${input.address}".`, {
49
+ why: `The addresses recorded for the app \`prisma dev\` last ran here are: ${known.join(", ")}.`,
50
+ fix: "Pass one of those addresses. A nested node has a dotted address, such as `catalog.database`.",
51
+ meta: {
52
+ address: input.address,
53
+ known
54
+ }
55
+ });
56
+ }
57
+ const location = await fromTarget(() => app.locate(input.address));
58
+ if (location === void 0) throw new InternalError(`the local target recorded "${input.address}" but cannot locate it`);
59
+ if (location.emulator === "not-running") throw new CliStructuredError("DEV.EMULATOR_UNREACHABLE", `The local ${location.kind} emulator that runs "${input.address}" is not running.`, {
60
+ why: "The local emulators run your services, databases and buckets on this machine; `prisma dev` starts the ones an app needs.",
61
+ fix: RUN_DEV,
62
+ meta: {
63
+ address: input.address,
64
+ kind: location.kind
65
+ }
66
+ });
67
+ if (location.condition !== "running") throw notRunning(input.address, location);
68
+ if (location.url === void 0) throw new InternalError(`the local target reports "${input.address}" running with no URL`);
69
+ return {
70
+ address: input.address,
71
+ kind: location.kind,
72
+ url: location.url,
73
+ state: location.state
74
+ };
75
+ }
76
+ function notRunning(address, location) {
77
+ const { kind, state, condition, logPath } = location;
78
+ const meta = {
79
+ address,
80
+ kind,
81
+ state,
82
+ ...logPath === void 0 ? {} : { logPath }
83
+ };
84
+ const message = `The ${kind} "${address}" is not running (${state}).`;
85
+ if (condition === "crashing") return new CliStructuredError("DEV.NOT_RUNNING", message, {
86
+ why: "It exited after it started, and it is being restarted or was held after repeated crashes.",
87
+ fix: logPath === void 0 ? "Read its output in the `prisma dev` terminal, fix the cause, and rebuild." : `Read its log at ${logPath}, fix the cause, and rebuild.`,
88
+ meta
89
+ });
90
+ if (condition === "missing") return new CliStructuredError("DEV.NOT_RUNNING", message, {
91
+ why: "The local emulator no longer has it, for example because a Composer upgrade discarded the emulator’s state.",
92
+ fix: `${RUN_DEV} It creates the ${kind} again, empty.`,
93
+ meta
94
+ });
95
+ return new CliStructuredError("DEV.NOT_RUNNING", message, {
96
+ why: "`prisma dev` stops the app when it ends, and a stopped node has no URL that answers.",
97
+ fix: RUN_DEV,
98
+ meta
99
+ });
100
+ }
101
+ async function executeDevUrl(input, cwd) {
102
+ if (process.platform === "win32") return notOk(platformUnsupported());
103
+ try {
104
+ return ok(await locate(input, cwd));
105
+ } catch (error) {
106
+ if (CliStructuredError.is(error)) return notOk(error);
107
+ throw error;
108
+ }
109
+ }
110
+ async function executeDevStop(input, cwd) {
111
+ if (process.platform === "win32") return notOk(platformUnsupported());
112
+ try {
113
+ const apps = await currentApps(input, cwd);
114
+ const stopped = [];
115
+ for (const app of apps) stopped.push(...await fromTarget(() => app.stop()));
116
+ return ok({
117
+ app: apps.map((a) => a.app).join(", "),
118
+ stopped
119
+ });
120
+ } catch (error) {
121
+ if (CliStructuredError.is(error)) return notOk(error);
122
+ throw error;
123
+ }
124
+ }
125
+ //#endregion
126
+ export { executeDevStop, executeDevUrl };
127
+
128
+ //# sourceMappingURL=execute-dev-current-nYH8EiKK-B-GAyQFU.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"execute-dev-current-nYH8EiKK-B-GAyQFU.mjs","names":["path"],"sources":["../../../0-framework/3-tooling/cli/dist/execute-dev-current-nYH8EiKK.mjs"],"sourcesContent":["import { l as toStructured } from \"./dev-current-Bm7Yrsmt.mjs\";\nimport { t as checkConfigSource } from \"./pipeline-Dpesfd2j.mjs\";\nimport { notOk, ok } from \"@internal/foundation/result\";\nimport { CliStructuredError, InternalError } from \"@internal/foundation/errors\";\nimport * as path from \"node:path\";\nimport { DEV_DIR, resolveLocalTargets } from \"@internal/core/local-target\";\n//#region src/operations/execute-dev-current.ts\n/**\n* The `devUrl` and `devStop` executor: config → each extension's local\n* target → the app it recorded in the directory's dev state. Reached only by\n* lazy import from dev-current.ts — resolving the local targets loads their\n* descriptors, whose graphs reach alchemy's provider tree.\n*/\nconst RUN_DEV = \"Run `prisma dev <entry>` in this directory.\";\nfunction platformUnsupported() {\n\treturn new CliStructuredError(\"DEV.PLATFORM_UNSUPPORTED\", \"local dev is not supported on Windows yet.\");\n}\n/** A call into an extension's local target; its failures that carry no code are the emulator's. */\nasync function fromTarget(call) {\n\ttry {\n\t\treturn await call();\n\t} catch (error) {\n\t\tthrow toStructured(\"DEV.EMULATOR_FAILED\", error);\n\t}\n}\n/** Every extension's record of the app `prisma dev` last ran from `cwd`; fails when none recorded one. */\nasync function currentApps(input, cwd) {\n\tconst { value } = checkConfigSource(input.config, cwd);\n\tconst devDir = path.join(cwd, DEV_DIR);\n\tconst apps = [];\n\tfor (const target of (await resolveLocalTargets(value)).values()) {\n\t\tconst current = await fromTarget(async () => target.current?.({ devDir }));\n\t\tif (current !== void 0) apps.push(current);\n\t}\n\tif (apps.length === 0) throw new CliStructuredError(\"DEV.NOT_STARTED_HERE\", `\\`prisma dev\\` has not run in ${cwd}.`, {\n\t\twhy: `The local services, databases and buckets of an app are recorded in ${devDir} when \\`prisma dev\\` runs there, and there is no such record.`,\n\t\tfix: RUN_DEV,\n\t\tmeta: { cwd }\n\t});\n\treturn apps;\n}\nasync function locate(input, cwd) {\n\tconst apps = await currentApps(input, cwd);\n\tconst app = apps.find((candidate) => candidate.addresses.includes(input.address));\n\tif (app === void 0) {\n\t\tconst known = apps.flatMap((candidate) => candidate.addresses).sort();\n\t\tthrow new CliStructuredError(\"DEV.ADDRESS_UNKNOWN\", `\"${apps.map((a) => a.app).join(\"\\\", \\\"\")}\" has no node at \"${input.address}\".`, {\n\t\t\twhy: `The addresses recorded for the app \\`prisma dev\\` last ran here are: ${known.join(\", \")}.`,\n\t\t\tfix: \"Pass one of those addresses. A nested node has a dotted address, such as `catalog.database`.\",\n\t\t\tmeta: {\n\t\t\t\taddress: input.address,\n\t\t\t\tknown\n\t\t\t}\n\t\t});\n\t}\n\tconst location = await fromTarget(() => app.locate(input.address));\n\tif (location === void 0) throw new InternalError(`the local target recorded \"${input.address}\" but cannot locate it`);\n\tif (location.emulator === \"not-running\") throw new CliStructuredError(\"DEV.EMULATOR_UNREACHABLE\", `The local ${location.kind} emulator that runs \"${input.address}\" is not running.`, {\n\t\twhy: \"The local emulators run your services, databases and buckets on this machine; `prisma dev` starts the ones an app needs.\",\n\t\tfix: RUN_DEV,\n\t\tmeta: {\n\t\t\taddress: input.address,\n\t\t\tkind: location.kind\n\t\t}\n\t});\n\tif (location.condition !== \"running\") throw notRunning(input.address, location);\n\tif (location.url === void 0) throw new InternalError(`the local target reports \"${input.address}\" running with no URL`);\n\treturn {\n\t\taddress: input.address,\n\t\tkind: location.kind,\n\t\turl: location.url,\n\t\tstate: location.state\n\t};\n}\nfunction notRunning(address, location) {\n\tconst { kind, state, condition, logPath } = location;\n\tconst meta = {\n\t\taddress,\n\t\tkind,\n\t\tstate,\n\t\t...logPath === void 0 ? {} : { logPath }\n\t};\n\tconst message = `The ${kind} \"${address}\" is not running (${state}).`;\n\tif (condition === \"crashing\") return new CliStructuredError(\"DEV.NOT_RUNNING\", message, {\n\t\twhy: \"It exited after it started, and it is being restarted or was held after repeated crashes.\",\n\t\tfix: logPath === void 0 ? \"Read its output in the `prisma dev` terminal, fix the cause, and rebuild.\" : `Read its log at ${logPath}, fix the cause, and rebuild.`,\n\t\tmeta\n\t});\n\tif (condition === \"missing\") return new CliStructuredError(\"DEV.NOT_RUNNING\", message, {\n\t\twhy: \"The local emulator no longer has it, for example because a Composer upgrade discarded the emulator’s state.\",\n\t\tfix: `${RUN_DEV} It creates the ${kind} again, empty.`,\n\t\tmeta\n\t});\n\treturn new CliStructuredError(\"DEV.NOT_RUNNING\", message, {\n\t\twhy: \"`prisma dev` stops the app when it ends, and a stopped node has no URL that answers.\",\n\t\tfix: RUN_DEV,\n\t\tmeta\n\t});\n}\nasync function executeDevUrl(input, cwd) {\n\tif (process.platform === \"win32\") return notOk(platformUnsupported());\n\ttry {\n\t\treturn ok(await locate(input, cwd));\n\t} catch (error) {\n\t\tif (CliStructuredError.is(error)) return notOk(error);\n\t\tthrow error;\n\t}\n}\nasync function executeDevStop(input, cwd) {\n\tif (process.platform === \"win32\") return notOk(platformUnsupported());\n\ttry {\n\t\tconst apps = await currentApps(input, cwd);\n\t\tconst stopped = [];\n\t\tfor (const app of apps) stopped.push(...await fromTarget(() => app.stop()));\n\t\treturn ok({\n\t\t\tapp: apps.map((a) => a.app).join(\", \"),\n\t\t\tstopped\n\t\t});\n\t} catch (error) {\n\t\tif (CliStructuredError.is(error)) return notOk(error);\n\t\tthrow error;\n\t}\n}\n//#endregion\nexport { executeDevStop, executeDevUrl };\n\n//# sourceMappingURL=execute-dev-current-nYH8EiKK.mjs.map"],"mappings":";;;;;;;;;;;;;;AAaA,MAAM,UAAU;AAChB,SAAS,sBAAsB;CAC9B,OAAO,IAAI,mBAAmB,4BAA4B,4CAA4C;AACvG;;AAEA,eAAe,WAAW,MAAM;CAC/B,IAAI;EACH,OAAO,MAAM,KAAK;CACnB,SAAS,OAAO;EACf,MAAM,aAAa,uBAAuB,KAAK;CAChD;AACD;;AAEA,eAAe,YAAY,OAAO,KAAK;CACtC,MAAM,EAAE,UAAU,kBAAkB,MAAM,QAAQ,GAAG;CACrD,MAAM,SAASA,OAAK,KAAK,KAAK,OAAO;CACrC,MAAM,OAAO,CAAC;CACd,KAAK,MAAM,WAAW,MAAM,oBAAoB,KAAK,EAAA,CAAG,OAAO,GAAG;EACjE,MAAM,UAAU,MAAM,WAAW,YAAY,OAAO,UAAU,EAAE,OAAO,CAAC,CAAC;EACzE,IAAI,YAAY,KAAK,GAAG,KAAK,KAAK,OAAO;CAC1C;CACA,IAAI,KAAK,WAAW,GAAG,MAAM,IAAI,mBAAmB,wBAAwB,iCAAiC,IAAI,IAAI;EACpH,KAAK,uEAAuE,OAAO;EACnF,KAAK;EACL,MAAM,EAAE,IAAI;CACb,CAAC;CACD,OAAO;AACR;AACA,eAAe,OAAO,OAAO,KAAK;CACjC,MAAM,OAAO,MAAM,YAAY,OAAO,GAAG;CACzC,MAAM,MAAM,KAAK,MAAM,cAAc,UAAU,UAAU,SAAS,MAAM,OAAO,CAAC;CAChF,IAAI,QAAQ,KAAK,GAAG;EACnB,MAAM,QAAQ,KAAK,SAAS,cA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O,IAAI,mBAAmB,mBAAmB,SAAS;EACtF,KAAK;EACL,KAAK,GAAG,QAAQ,kBAAkB,KAAK;EACvC;CACD,CAAC;CACD,OAAO,IAAI,mBAAmB,mBAAmB,SAAS;EACzD,KAAK;EACL,KAAK;EACL;CACD,CAAC;AACF;AACA,eAAe,cAAc,OAAO,KAAK;CACxC,IAAI,QAAQ,aAAa,SAAS,OAAO,MAAM,oBAAoB,CAAC;CACpE,IAAI;EACH,OAAO,GAAG,MAAM,OAAO,OAAO,GAAG,CAAC;CACnC,SAAS,OAAO;EACf,IAAI,mBAAmB,GAAG,KAAK,GAAG,OAAO,MAAM,KAAK;EACpD,MAAM;CACP;AACD;AACA,eAAe,eAAe,OAAO,KAAK;CACzC,IAAI,QAAQ,aAAa,SAAS,OAAO,MAAM,oBAAoB,CAAC;CACpE,IAAI;EACH,MAAM,OAAO,MAAM,YAAY,OAAO,GAAG;EACzC,MAAM,UAAU,CAAC;EACjB,KAAK,MAAM,OAAO,MAAM,QAAQ,KAAK,GAAG,MAAM,iBAAiB,IAAI,KAAK,CAAC,CAAC;EAC1E,OAAO,GAAG;GACT,KAAK,KAAK,KAAK,MAAM,EAAE,GAAG,CAAC,CAAC,KAAK,IAAI;GACrC;EACD,CAAC;CACF,SAAS,OAAO;EACf,IAAI,mBAAmB,GAAG,KAAK,GAAG,OAAO,MAAM,KAAK;EACpD,MAAM;CACP;AACD"}
@@ -1,11 +1,11 @@
1
1
  import { t as CliStructuredError } from "./errors-0e8IVwzi.mjs";
2
2
  import { t as containerEnv } from "./container-transport-HcvNOGZL-twPi2TIv.mjs";
3
3
  import { t as DEV_DIR } from "./app-config-CGJHcFb--CIEFCG4V.mjs";
4
- import { a as toStructured, o as notOk, s as ok } from "./dev-CqS1W82b-gZEtkFO1.mjs";
4
+ import { c as notOk, l as ok, s as toStructured } from "./dev-current-Bm7Yrsmt-BokQtx_Z.mjs";
5
5
  import { r as resolveLocalTargets } from "./local-target-BUZG9uLx.mjs";
6
6
  import { n as reproduceCommand, r as spawnAlchemy, t as alchemyInvocation } from "./run-alchemy-BqHpStQn-sYiodM6y.mjs";
7
- import { n as runPipeline, r as noComposerExportMessage } from "./pipeline-B-vJNch3-PBDKc8cX.mjs";
8
- import { t as withEmulatorRetry } from "./emulator-retry-DGonap4g-S8BNrXFD.mjs";
7
+ import { i as noComposerExportMessage, r as runPipeline } from "./pipeline-Dpesfd2j-CD3W79W6.mjs";
8
+ import { t as withEmulatorRetry } from "./emulator-retry-CV8rl69G-BgUzkxc-.mjs";
9
9
  import * as fs$1 from "node:fs";
10
10
  import * as path$1 from "node:path";
11
11
  import { join, relative, resolve, sep } from "node:path";
@@ -1646,7 +1646,7 @@ var esm_default = {
1646
1646
  FSWatcher
1647
1647
  };
1648
1648
  //#endregion
1649
- //#region ../../0-framework/3-tooling/cli/dist/execute-dev-BSPnsEv-.mjs
1649
+ //#region ../../0-framework/3-tooling/cli/dist/execute-dev-qKlYePGn.mjs
1650
1650
  /**
1651
1651
  * Local-dev spec § 6 `watch.ts`: watches each assembled bundle's declared
1652
1652
  * `watch` paths (a directory watched recursively, a file watched through
@@ -1879,24 +1879,36 @@ async function executeDev(input, deps, cwd) {
1879
1879
  stackPath
1880
1880
  };
1881
1881
  };
1882
+ const stopStartedServices = async () => {
1883
+ for (const [id, dev] of resolved) try {
1884
+ await (await dev.attach({
1885
+ container: containers.get(id),
1886
+ devDir
1887
+ })).stopApp();
1888
+ } catch {}
1889
+ };
1882
1890
  let first;
1883
1891
  try {
1884
1892
  first = await converge();
1885
1893
  } catch (error) {
1894
+ await stopStartedServices();
1886
1895
  if (CliStructuredError.is(error)) return notOk(error);
1887
1896
  throw error;
1888
1897
  }
1889
1898
  const firstStatus = first.outcome.signal !== null ? null : first.outcome.exitCode ?? 1;
1890
- if (firstStatus !== 0) return notOk(new CliStructuredError("DEV.CONVERGE_FAILED", first.outcome.signal !== null ? `alchemy deploy was interrupted by ${first.outcome.signal}.` : `alchemy deploy exited with status ${String(firstStatus)}.`, { meta: {
1891
- ...first.outcome.signal !== null ? { signal: first.outcome.signal } : { exitCode: firstStatus },
1892
- diagnostics: {
1893
- exitCode: firstStatus ?? void 0,
1894
- ...first.outcome.signal !== null ? { signal: first.outcome.signal } : {},
1895
- stackFilePath: first.stackPath,
1896
- reproduceCommand: reproduceCommand(invocation, first.outcome),
1897
- cwd
1898
- }
1899
- } }));
1899
+ if (firstStatus !== 0) {
1900
+ await stopStartedServices();
1901
+ return notOk(new CliStructuredError("DEV.CONVERGE_FAILED", first.outcome.signal !== null ? `alchemy deploy was interrupted by ${first.outcome.signal}.` : `alchemy deploy exited with status ${String(firstStatus)}.`, { meta: {
1902
+ ...first.outcome.signal !== null ? { signal: first.outcome.signal } : { exitCode: firstStatus },
1903
+ diagnostics: {
1904
+ exitCode: firstStatus ?? void 0,
1905
+ ...first.outcome.signal !== null ? { signal: first.outcome.signal } : {},
1906
+ stackFilePath: first.stackPath,
1907
+ reproduceCommand: reproduceCommand(invocation, first.outcome),
1908
+ cwd
1909
+ }
1910
+ } }));
1911
+ }
1900
1912
  const emit = (event) => {
1901
1913
  try {
1902
1914
  onEvent?.(event);
@@ -1933,6 +1945,14 @@ async function executeDev(input, deps, cwd) {
1933
1945
  kind: "ready",
1934
1946
  endpoints
1935
1947
  });
1948
+ if (input.detach === true) {
1949
+ const closed = Promise.resolve();
1950
+ return ok({
1951
+ endpoints,
1952
+ stop: () => closed,
1953
+ closed
1954
+ });
1955
+ }
1936
1956
  const { targets, unwatchable } = watchTargetsFrom(pipeline.assembled.bundles);
1937
1957
  for (const address of unwatchable) emit({
1938
1958
  kind: "unwatchable",
@@ -2025,7 +2045,7 @@ async function executeDev(input, deps, cwd) {
2025
2045
  startedConfigWatch.stop();
2026
2046
  (async () => {
2027
2047
  for (const attachment of attachments) try {
2028
- await attachment.stopServices();
2048
+ await attachment.stopApp();
2029
2049
  } catch (error) {
2030
2050
  emit({
2031
2051
  kind: "stop-error",
@@ -2046,7 +2066,7 @@ async function executeDev(input, deps, cwd) {
2046
2066
  } catch (error) {
2047
2067
  watch?.stop();
2048
2068
  configWatch?.stop();
2049
- await Promise.all(started.map((a) => a.stopServices().catch(() => void 0)));
2069
+ await Promise.all(started.map((a) => a.stopApp().catch(() => void 0)));
2050
2070
  if (CliStructuredError.is(error)) return notOk(error);
2051
2071
  throw error;
2052
2072
  }
@@ -2054,4 +2074,4 @@ async function executeDev(input, deps, cwd) {
2054
2074
  //#endregion
2055
2075
  export { executeDev };
2056
2076
 
2057
- //# sourceMappingURL=execute-dev-BSPnsEv--Bz2s7o74.mjs.map
2077
+ //# sourceMappingURL=execute-dev-qKlYePGn-D6SHRPB4.mjs.map