@prisma/composer 0.25.0-dev.3 → 0.25.0-dev.5

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 (49) hide show
  1. package/dist/{app-config-joXc-BKm-CdcXqNMD.mjs → app-config-CGJHcFb--CIEFCG4V.mjs} +3 -3
  2. package/dist/{app-config-joXc-BKm-CdcXqNMD.mjs.map → app-config-CGJHcFb--CIEFCG4V.mjs.map} +1 -1
  3. package/dist/{app-config-jGcCcxK4-DnzGGbDS.d.mts → app-config-Cay7dFv5-CMlgGodQ.d.mts} +3 -3
  4. package/dist/{app-config-jGcCcxK4-DnzGGbDS.d.mts.map → app-config-Cay7dFv5-CMlgGodQ.d.mts.map} +1 -1
  5. package/dist/config-CE3fmcF9.d.mts +1 -0
  6. package/dist/config-CdxvLFzg.mjs.map +1 -1
  7. package/dist/config.d.mts +2 -2
  8. package/dist/config.mjs +1 -1
  9. package/dist/control.d.mts +37 -5
  10. package/dist/control.d.mts.map +1 -1
  11. package/dist/control.mjs +10 -10
  12. package/dist/control.mjs.map +1 -1
  13. package/dist/deploy-CE3fmcF9.d.mts +1 -0
  14. package/dist/deploy.d.mts +2 -2
  15. package/dist/deploy.mjs +1 -1
  16. package/dist/deploy.mjs.map +1 -1
  17. package/dist/{deployment-summary-CU-eVvJM-pW7SAEre.d.mts → deployment-summary-CU-eVvJM-Cu9hKMdz.d.mts} +3 -3
  18. package/dist/{deployment-summary-CU-eVvJM-pW7SAEre.d.mts.map → deployment-summary-CU-eVvJM-Cu9hKMdz.d.mts.map} +1 -1
  19. package/dist/{execute-deploy-destroy-Bdi-RiN5-ByDTmL_F.mjs → execute-deploy-destroy-CF6DR7sA-pf8yhNfp.mjs} +21 -17
  20. package/dist/execute-deploy-destroy-CF6DR7sA-pf8yhNfp.mjs.map +1 -0
  21. package/dist/{execute-dev-BLCK5wF7-CJvkj5wl.mjs → execute-dev-DAIUT0es-B3iBKmAS.mjs} +179 -130
  22. package/dist/execute-dev-DAIUT0es-B3iBKmAS.mjs.map +1 -0
  23. package/dist/{execute-log-B_zCJ17b-CE954g1a.mjs → execute-log-PLs9-Qn3-BvONZ358.mjs} +7 -10
  24. package/dist/execute-log-PLs9-Qn3-BvONZ358.mjs.map +1 -0
  25. package/dist/{local-target-DnA2E8IN.mjs → local-target-B4xoiDAV.mjs} +2 -2
  26. package/dist/{local-target-DnA2E8IN.mjs.map → local-target-B4xoiDAV.mjs.map} +1 -1
  27. package/dist/local-target.d.mts +1 -1
  28. package/dist/local-target.mjs +2 -2
  29. package/dist/nextjs-control.d.mts +4 -4
  30. package/dist/nextjs-control.mjs +2 -2
  31. package/dist/nextjs-control.mjs.map +1 -1
  32. package/dist/node-control.d.mts +4 -4
  33. package/dist/node-control.mjs +2 -2
  34. package/dist/node-control.mjs.map +1 -1
  35. package/dist/{pipeline-C7gNjMzJ-CzM8DNS_.mjs → pipeline-DAYhea3J-B6PQu2QB.mjs} +231 -262
  36. package/dist/pipeline-DAYhea3J-B6PQu2QB.mjs.map +1 -0
  37. package/dist/report.d.mts +3 -3
  38. package/dist/result-B1SzJJoE.mjs +122 -0
  39. package/dist/result-B1SzJJoE.mjs.map +1 -0
  40. package/package.json +10 -11
  41. package/skills/prisma-composer-core-concepts/SKILL.md +58 -18
  42. package/dist/config-BGtKERz-.d.mts +0 -1
  43. package/dist/deploy-BGtKERz-.d.mts +0 -1
  44. package/dist/execute-deploy-destroy-Bdi-RiN5-ByDTmL_F.mjs.map +0 -1
  45. package/dist/execute-dev-BLCK5wF7-CJvkj5wl.mjs.map +0 -1
  46. package/dist/execute-log-B_zCJ17b-CE954g1a.mjs.map +0 -1
  47. package/dist/pipeline-C7gNjMzJ-CzM8DNS_.mjs.map +0 -1
  48. package/dist/result-CQIOBgdW.mjs +0 -247
  49. package/dist/result-CQIOBgdW.mjs.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"execute-deploy-destroy-CF6DR7sA-pf8yhNfp.mjs","names":["path","path","fs"],"sources":["../../../0-framework/3-tooling/cli/dist/generate-stack-DlooNx6k.mjs","../../../0-framework/3-tooling/cli/dist/execute-deploy-destroy-CF6DR7sA.mjs"],"sourcesContent":["import { r as noComposerExportMessage } from \"./composer-config-CY9fET8H.mjs\";\nimport * as fs from \"node:fs\";\nimport * as path from \"node:path\";\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 \\`prisma-composer deploy\\`/\\`prisma-composer destroy\\` — 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):\n//\n// alchemy deploy ${GENERATED_DIR}/${GENERATED_FILE}\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\nexport { renderStackFile as n, writeStackFile as r, GENERATED_STACK_RELATIVE_PATH as t };\n\n//# sourceMappingURL=generate-stack-DlooNx6k.mjs.map","import { r as toStructured } from \"./shared-BAIiDgXa.mjs\";\nimport { i as spawnAlchemy, n as alchemyInvocation } from \"./run-alchemy-pANK8XNX.mjs\";\nimport { r as writeStackFile, t as GENERATED_STACK_RELATIVE_PATH } from \"./generate-stack-DlooNx6k.mjs\";\nimport { a as readEngineFailureCause, i as readDeploymentSummary, r as engineFailureFilePath, t as DEPLOYMENT_RESULT_FILE_ENV } from \"./deployment-summary-BtvC7Z73.mjs\";\nimport { a as writeRunReport, i as toRunReport, r as resolveRunReportPath, t as RUN_REPORT_FILE_ENV } from \"./run-report-C2o98uD-.mjs\";\nimport { n as runPipeline } from \"./pipeline-DAYhea3J.mjs\";\nimport { CliStructuredError } from \"@internal/foundation/errors\";\nimport * as fs from \"node:fs\";\nimport * as path from \"node:path\";\nimport { notOk, ok, okVoid } from \"@internal/foundation/result\";\nimport { randomUUID } from \"node:crypto\";\nimport { containerEnv, preflightEnv, preflightEnvVarName } from \"@internal/core/config\";\nimport { spawnSync } from \"node:child_process\";\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}\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});\n\tconst reportPath = resolveRunReportPath(input.reportPath, process.env[RUN_REPORT_FILE_ENV], cwd);\n\tif (reportPath !== void 0) writeRunReport(reportPath, toRunReport({\n\t\tsummary: outcome.ok ? outcome.value : void 0,\n\t\tstage: input.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}));\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});\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.\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\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\tthrow error;\n\t}\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\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 } = opts;\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, { runAssembler: deps.runAssembler }, 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\tconst { graph, name: resolvedName } = pipeline;\n\t\tconst config = pipeline.configSource.value;\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.\" : \"destroy --production needs a target whose container supplies the production deploy scope.\" });\n\t\talchemyStage = pinnedStage;\n\t\tif (action === \"deploy\") {\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});\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}\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 reproduceCommand = `alchemy ${action} ${GENERATED_STACK_RELATIVE_PATH} --yes --stage ${alchemyStage}`;\n\t\tlet outcome;\n\t\ttry {\n\t\t\toutcome = await (deps.alchemy ?? spawnAlchemy)(alchemyInvocation({\n\t\t\t\tcommand: action,\n\t\t\t\tstackFileRelativePath: GENERATED_STACK_RELATIVE_PATH,\n\t\t\t\tcwd,\n\t\t\t\tstage: alchemyStage,\n\t\t\t\tcontainerEnv: containerEnv(containers),\n\t\t\t\tpreflightEnv: preflightTransportEnv,\n\t\t\t\tenv: {\n\t\t\t\t\t...reporterChildEnv(reporters),\n\t\t\t\t\t[DEPLOYMENT_RESULT_FILE_ENV]: resultFilePath\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\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,\n\t\t\t\t\tcwd\n\t\t\t\t} }\n\t\t\t}));\n\t\t}\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,\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,\n\t\t\t\t\tcwd\n\t\t\t\t}\n\t\t\t} }));\n\t\t}\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-CF6DR7sA.mjs.map"],"mappings":";;;;;;;;;;;;;;AAKA,MAAM,gBAAgB;AACtB,MAAM,iBAAiB;;AAEvB,SAAS,wBAAwB,cAAc,QAAQ;CACtD,MAAM,MAAMA,OAAK,SAAS,cAAc,MAAM,CAAC,CAAC,MAAMA,OAAK,GAAG,CAAC,CAAC,KAAK,GAAG;CACxE,OAAO,IAAI,WAAW,GAAG,IAAI,MAAM,KAAK;AACzC;AACA,SAAS,MAAM,OAAO;CACrB,OAAO,KAAK,UAAU,KAAK;AAC5B;AACA,SAAS,aAAa,QAAQ;CAC7B,OAAO,UAAU,MAAM,OAAO,GAAG,EAAE,WAAW,MAAM,OAAO,KAAK,EAAE;AACnE;AACA,SAAS,cAAc,OAAO;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,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"}
@@ -1,10 +1,10 @@
1
1
  import { t as CliStructuredError } from "./errors-0e8IVwzi.mjs";
2
2
  import { t as containerEnv } from "./container-transport-HcvNOGZL-twPi2TIv.mjs";
3
- import { t as DEV_DIR } from "./app-config-joXc-BKm-CdcXqNMD.mjs";
4
- import { n as ok, s as toStructured, t as notOk } from "./result-CQIOBgdW.mjs";
5
- import { n as resolveLocalTargets } from "./local-target-DnA2E8IN.mjs";
3
+ import { t as DEV_DIR } from "./app-config-CGJHcFb--CIEFCG4V.mjs";
4
+ import { n as ok, o as toStructured, t as notOk } from "./result-B1SzJJoE.mjs";
5
+ import { n as resolveLocalTargets } from "./local-target-B4xoiDAV.mjs";
6
6
  import { n as spawnAlchemy, t as alchemyInvocation } from "./run-alchemy-pANK8XNX-CgCpXLkG.mjs";
7
- import { n as runPipeline } from "./pipeline-C7gNjMzJ-CzM8DNS_.mjs";
7
+ import { n as runPipeline, r as noComposerExportMessage } from "./pipeline-DAYhea3J-B6PQu2QB.mjs";
8
8
  import { t as withEmulatorRetry } from "./emulator-retry-DGonap4g-S8BNrXFD.mjs";
9
9
  import * as fs$1 from "node:fs";
10
10
  import * as path$1 from "node:path";
@@ -15,7 +15,89 @@ import { Readable } from "node:stream";
15
15
  import { lstat, readdir, realpath, stat as stat$1 } from "node:fs/promises";
16
16
  import { type } from "os";
17
17
  import { EventEmitter } from "events";
18
+ import { createHash } from "node:crypto";
18
19
  import { lstat as lstat$1, open, readdir as readdir$1, realpath as realpath$1, stat as stat$2 } from "fs/promises";
20
+ //#region ../../0-framework/3-tooling/cli/dist/generate-dev-stack-CPpjJdTG.mjs
21
+ /**
22
+ * Local-dev spec § 6 `generate-dev-stack.ts`: like generate-stack.ts but at
23
+ * `.prisma-composer/dev/alchemy.run.ts`, always Alchemy stage `dev`, using
24
+ * Alchemy's own `localState()` and no `report` — dev prints its own front
25
+ * door (run-dev.ts), so core's presentation-free lower() gets nothing to
26
+ * call back into. The generated module IS the one orchestration point where
27
+ * dev provenance is resolved (spec § 3 REVISED): it deserializes the
28
+ * containers, top-level-awaits `resolveLocalTargets(config)` (the lazy
29
+ * `localTarget` thunks, ADR-0041), and passes
30
+ * `providers: localTargetProviders(...)` + `state: localState()` explicitly
31
+ * — `lower()` learns nothing about dev.
32
+ */
33
+ const DEV_GENERATED_DIR = ".prisma-composer/dev";
34
+ const DEV_GENERATED_FILE = "alchemy.run.ts";
35
+ /** A relative import specifier from `.prisma-composer/dev/alchemy.run.ts` to `target` (posix separators). */
36
+ function relativeImportSpecifier(generatedDir, target) {
37
+ const rel = path$1.relative(generatedDir, target).split(path$1.sep).join("/");
38
+ return rel.startsWith(".") ? rel : `./${rel}`;
39
+ }
40
+ function quote(value) {
41
+ return JSON.stringify(value);
42
+ }
43
+ function renderBundle(bundle) {
44
+ return `{ dir: ${quote(bundle.dir)}, entry: ${quote(bundle.entry)} }`;
45
+ }
46
+ function renderOptions(input) {
47
+ const lines = [];
48
+ lines.push(` name: ${quote(input.name)},`);
49
+ lines.push(" bundles: {");
50
+ for (const [id, bundle] of Object.entries(input.assembled.bundles)) lines.push(` ${quote(id)}: ${renderBundle(bundle)},`);
51
+ lines.push(" },");
52
+ lines.push(" providers: localTargetProviders(resolved, containers, devDir),");
53
+ lines.push(" state: localState(),");
54
+ return lines.join("\n");
55
+ }
56
+ /** Renders the dev stack module's source (tests assert on it without touching disk). */
57
+ function renderDevStackFile(input) {
58
+ const generatedDir = path$1.join(input.cwd, DEV_GENERATED_DIR);
59
+ const appImport = relativeImportSpecifier(generatedDir, input.entryPath);
60
+ const imports = [
61
+ "import * as path from 'node:path';",
62
+ "import { deserializeContainers } from '@prisma/composer/config';",
63
+ "import { lower } from '@prisma/composer/deploy';",
64
+ "import { DEV_DIR, localTargetProviders, resolveLocalTargets } from '@prisma/composer/local-target';",
65
+ "import { localState } from 'alchemy/State/LocalState';",
66
+ `import prismaConfig from ${quote(relativeImportSpecifier(generatedDir, input.configFile))};`,
67
+ `import app from ${quote(appImport)};`
68
+ ].join("\n");
69
+ return `// Generated by \`prisma-composer dev\` — overwritten on every run; do not
70
+ // edit by hand. Independently runnable from ${quote(input.cwd)}:
71
+ //
72
+ // alchemy deploy ${DEV_GENERATED_DIR}/${DEV_GENERATED_FILE} --stage dev
73
+ //
74
+ // bisects a CLI bug from an Alchemy bug (deploy-cli.md § Implementation decisions).
75
+ ${imports}
76
+
77
+ const config = prismaConfig.composer;
78
+ if (config === undefined) {
79
+ throw new Error(${quote(noComposerExportMessage(input.configFile))});
80
+ }
81
+
82
+ const containers = deserializeContainers(config.extensions, process.env);
83
+ const resolved = await resolveLocalTargets(config);
84
+ const devDir = path.join(process.cwd(), DEV_DIR);
85
+
86
+ export default lower(app, config, {
87
+ ${renderOptions(input)}
88
+ });
89
+ `;
90
+ }
91
+ /** Writes the dev stack file, returning its absolute path. */
92
+ function writeDevStackFile(input) {
93
+ const generatedDir = path$1.join(input.cwd, DEV_GENERATED_DIR);
94
+ fs$1.mkdirSync(generatedDir, { recursive: true });
95
+ const filePath = path$1.join(generatedDir, DEV_GENERATED_FILE);
96
+ fs$1.writeFileSync(filePath, renderDevStackFile(input));
97
+ return filePath;
98
+ }
99
+ const DEV_STACK_RELATIVE_PATH = path$1.join(DEV_GENERATED_DIR, DEV_GENERATED_FILE);
100
+ //#endregion
19
101
  //#region ../../0-framework/3-tooling/cli/node_modules/readdirp/esm/index.js
20
102
  const EntryTypes = {
21
103
  FILE_TYPE: "files",
@@ -1564,79 +1646,7 @@ var esm_default = {
1564
1646
  FSWatcher
1565
1647
  };
1566
1648
  //#endregion
1567
- //#region ../../0-framework/3-tooling/cli/dist/execute-dev-BLCK5wF7.mjs
1568
- /**
1569
- * Local-dev spec § 6 `generate-dev-stack.ts`: like generate-stack.ts but at
1570
- * `.prisma-composer/dev/alchemy.run.ts`, always Alchemy stage `dev`, using
1571
- * Alchemy's own `localState()` and no `report` — dev prints its own front
1572
- * door (run-dev.ts), so core's presentation-free lower() gets nothing to
1573
- * call back into. The generated module IS the one orchestration point where
1574
- * dev provenance is resolved (spec § 3 REVISED): it deserializes the
1575
- * containers, top-level-awaits `resolveLocalTargets(config)` (the lazy
1576
- * `localTarget` thunks, ADR-0041), and passes
1577
- * `providers: localTargetProviders(...)` + `state: localState()` explicitly
1578
- * — `lower()` learns nothing about dev.
1579
- */
1580
- const DEV_GENERATED_DIR = ".prisma-composer/dev";
1581
- const DEV_GENERATED_FILE = "alchemy.run.ts";
1582
- /** A relative import specifier from `.prisma-composer/dev/alchemy.run.ts` to `target` (posix separators). */
1583
- function relativeImportSpecifier(generatedDir, target) {
1584
- const rel = path$1.relative(generatedDir, target).split(path$1.sep).join("/");
1585
- return rel.startsWith(".") ? rel : `./${rel}`;
1586
- }
1587
- function quote(value) {
1588
- return JSON.stringify(value);
1589
- }
1590
- function renderBundle(bundle) {
1591
- return `{ dir: ${quote(bundle.dir)}, entry: ${quote(bundle.entry)} }`;
1592
- }
1593
- function renderOptions(input) {
1594
- const lines = [];
1595
- lines.push(` name: ${quote(input.name)},`);
1596
- lines.push(" bundles: {");
1597
- for (const [id, bundle] of Object.entries(input.assembled.bundles)) lines.push(` ${quote(id)}: ${renderBundle(bundle)},`);
1598
- lines.push(" },");
1599
- lines.push(" providers: localTargetProviders(resolved, containers, devDir),");
1600
- lines.push(" state: localState(),");
1601
- return lines.join("\n");
1602
- }
1603
- /** Renders the dev stack module's source (tests assert on it without touching disk). */
1604
- function renderDevStackFile(input) {
1605
- const generatedDir = path$1.join(input.cwd, DEV_GENERATED_DIR);
1606
- const appImport = relativeImportSpecifier(generatedDir, input.entryPath);
1607
- const configImport = relativeImportSpecifier(generatedDir, input.configPath);
1608
- return `// Generated by \`prisma-composer dev\` — overwritten on every run; do not
1609
- // edit by hand. Independently runnable from ${quote(input.cwd)}:
1610
- //
1611
- // alchemy deploy ${DEV_GENERATED_DIR}/${DEV_GENERATED_FILE} --stage dev
1612
- //
1613
- // bisects a CLI bug from an Alchemy bug (deploy-cli.md § Implementation decisions).
1614
- import * as path from 'node:path';
1615
- import { deserializeContainers } from '@prisma/composer/config';
1616
- import { lower } from '@prisma/composer/deploy';
1617
- import { DEV_DIR, localTargetProviders, resolveLocalTargets } from '@prisma/composer/local-target';
1618
- import { localState } from 'alchemy/State/LocalState';
1619
- import config from ${quote(configImport)};
1620
- import app from ${quote(appImport)};
1621
-
1622
- const containers = deserializeContainers(config.extensions, process.env);
1623
- const resolved = await resolveLocalTargets(config);
1624
- const devDir = path.join(process.cwd(), DEV_DIR);
1625
-
1626
- export default lower(app, config, {
1627
- ${renderOptions(input)}
1628
- });
1629
- `;
1630
- }
1631
- /** Writes the dev stack file, returning its absolute path. */
1632
- function writeDevStackFile(input) {
1633
- const generatedDir = path$1.join(input.cwd, DEV_GENERATED_DIR);
1634
- fs$1.mkdirSync(generatedDir, { recursive: true });
1635
- const filePath = path$1.join(generatedDir, DEV_GENERATED_FILE);
1636
- fs$1.writeFileSync(filePath, renderDevStackFile(input));
1637
- return filePath;
1638
- }
1639
- const DEV_STACK_RELATIVE_PATH = path$1.join(DEV_GENERATED_DIR, DEV_GENERATED_FILE);
1649
+ //#region ../../0-framework/3-tooling/cli/dist/execute-dev-DAIUT0es.mjs
1640
1650
  /**
1641
1651
  * Local-dev spec § 6 `watch.ts`: watches each assembled bundle's declared
1642
1652
  * `watch` paths (a directory watched recursively, a file watched through
@@ -1761,6 +1771,14 @@ async function mergedEndpoints(attachments) {
1761
1771
  return (await Promise.all(attachments.map((a) => withEmulatorRetry(() => a.endpoints())))).flat();
1762
1772
  }
1763
1773
  /** Runs the full dev pipeline; resolves to a running session or a structured failure. */
1774
+ /** The file's content hash; undefined when it cannot be read, which counts as a change. */
1775
+ function contentHash(file) {
1776
+ try {
1777
+ return createHash("sha256").update(fs$1.readFileSync(file)).digest("hex");
1778
+ } catch {
1779
+ return;
1780
+ }
1781
+ }
1764
1782
  async function executeDev(input, deps, cwd) {
1765
1783
  if (process.platform === "win32") return notOk(new CliStructuredError("DEV.PLATFORM_UNSUPPORTED", "local dev is not supported on Windows yet."));
1766
1784
  const { onEvent } = input;
@@ -1769,13 +1787,10 @@ async function executeDev(input, deps, cwd) {
1769
1787
  let resolved;
1770
1788
  const containers = /* @__PURE__ */ new Map();
1771
1789
  try {
1772
- const pipelineDeps = {
1773
- runAssembler: deps.runAssembler,
1774
- config: deps.config,
1775
- configPath: deps.configPath
1776
- };
1777
- pipeline = await runPipeline(input.entry, input.name, cwd, pipelineDeps);
1778
- const { config, graph, name } = pipeline;
1790
+ const pipelineDeps = { runAssembler: deps.runAssembler };
1791
+ pipeline = await runPipeline(input.entry, input.name, cwd, input.config, pipelineDeps);
1792
+ const { graph, name } = pipeline;
1793
+ const config = pipeline.configSource.value;
1779
1794
  resolved = await resolveLocalTargets(config);
1780
1795
  for (const [id, dev] of resolved) try {
1781
1796
  containers.set(id, await dev.container.ensure({
@@ -1831,7 +1846,7 @@ async function executeDev(input, deps, cwd) {
1831
1846
  stackPath = writeDevStackFile({
1832
1847
  entryPath: pipeline.entryModule.path,
1833
1848
  cwd,
1834
- configPath: pipeline.configPath,
1849
+ configFile: pipeline.configSource.file,
1835
1850
  name: pipeline.name,
1836
1851
  assembled: pipeline.assembled
1837
1852
  });
@@ -1890,6 +1905,7 @@ async function executeDev(input, deps, cwd) {
1890
1905
  const attachments = [];
1891
1906
  const started = [];
1892
1907
  let watch;
1908
+ let configWatch;
1893
1909
  try {
1894
1910
  for (const [id, dev] of resolved) try {
1895
1911
  attachments.push(await dev.attach({
@@ -1922,55 +1938,86 @@ async function executeDev(input, deps, cwd) {
1922
1938
  kind: "unwatchable",
1923
1939
  address
1924
1940
  });
1925
- const watchDeps = {
1926
- runAssembler: deps.runAssembler,
1927
- config: deps.config,
1928
- configPath: deps.configPath
1941
+ const watchDeps = { runAssembler: deps.runAssembler };
1942
+ const watchFiles = deps.watch ?? startWatch;
1943
+ const onWatchError = (error) => emit({
1944
+ kind: "watch-error",
1945
+ message: failureMessage(error)
1946
+ });
1947
+ const configFile = pipeline.configSource.file;
1948
+ const startedConfig = contentHash(configFile);
1949
+ let configChanged = false;
1950
+ const pausedForConfig = () => {
1951
+ if (!configChanged && contentHash(configFile) === startedConfig) return false;
1952
+ configChanged = true;
1953
+ emit({
1954
+ kind: "config-changed",
1955
+ file: configFile
1956
+ });
1957
+ return true;
1929
1958
  };
1930
- watch = startWatch(targets, () => {
1931
- (async () => {
1932
- try {
1933
- const rePipeline = await runPipeline(input.entry, input.name, cwd, watchDeps);
1934
- const stackPath = writeDevStackFile({
1935
- entryPath: rePipeline.entryModule.path,
1936
- cwd,
1937
- configPath: rePipeline.configPath,
1938
- name: rePipeline.name,
1939
- assembled: rePipeline.assembled
1940
- });
1941
- const outcome = await (deps.alchemy ?? spawnAlchemy)(alchemyInvocation({
1942
- command: "deploy",
1943
- stackFileRelativePath: DEV_STACK_RELATIVE_PATH,
1944
- cwd,
1945
- stage: "dev",
1946
- containerEnv: containerEnv(containers)
1947
- }));
1948
- if (outcome.signal !== null || outcome.exitCode !== 0) {
1949
- emit({
1950
- kind: "converge-failed",
1951
- stackFilePath: stackPath,
1952
- reproduceCommand,
1953
- cwd
1954
- });
1955
- return;
1956
- }
1957
- emit({
1958
- kind: "ready",
1959
- endpoints: await mergedEndpoints(attachments)
1960
- });
1961
- } catch (error) {
1959
+ configWatch = watchFiles([{
1960
+ address: configFile,
1961
+ paths: [configFile]
1962
+ }], () => void pausedForConfig(), onWatchError);
1963
+ const rebuild = async () => {
1964
+ try {
1965
+ const rePipeline = await runPipeline(input.entry, input.name, cwd, input.config, watchDeps);
1966
+ const stackPath = writeDevStackFile({
1967
+ entryPath: rePipeline.entryModule.path,
1968
+ cwd,
1969
+ configFile: rePipeline.configSource.file,
1970
+ name: rePipeline.name,
1971
+ assembled: rePipeline.assembled
1972
+ });
1973
+ const outcome = await (deps.alchemy ?? spawnAlchemy)(alchemyInvocation({
1974
+ command: "deploy",
1975
+ stackFileRelativePath: DEV_STACK_RELATIVE_PATH,
1976
+ cwd,
1977
+ stage: "dev",
1978
+ containerEnv: containerEnv(containers)
1979
+ }));
1980
+ if (outcome.signal !== null || outcome.exitCode !== 0) {
1962
1981
  emit({
1963
- kind: "rebuild-failed",
1964
- message: failureMessage(error)
1982
+ kind: "converge-failed",
1983
+ stackFilePath: stackPath,
1984
+ reproduceCommand,
1985
+ cwd
1965
1986
  });
1987
+ return;
1966
1988
  }
1967
- })();
1968
- }, (error) => emit({
1969
- kind: "watch-error",
1970
- message: failureMessage(error)
1971
- }));
1989
+ emit({
1990
+ kind: "ready",
1991
+ endpoints: await mergedEndpoints(attachments)
1992
+ });
1993
+ } catch (error) {
1994
+ emit({
1995
+ kind: "rebuild-failed",
1996
+ message: failureMessage(error)
1997
+ });
1998
+ }
1999
+ };
2000
+ let rebuilding = false;
2001
+ let changedDuringRebuild = false;
2002
+ const rebuildUntilSettled = async () => {
2003
+ rebuilding = true;
2004
+ do {
2005
+ changedDuringRebuild = false;
2006
+ await rebuild();
2007
+ } while (changedDuringRebuild && !pausedForConfig());
2008
+ rebuilding = false;
2009
+ };
2010
+ watch = watchFiles(targets, () => {
2011
+ if (pausedForConfig()) return;
2012
+ if (rebuilding) {
2013
+ changedDuringRebuild = true;
2014
+ return;
2015
+ }
2016
+ rebuildUntilSettled();
2017
+ }, onWatchError);
1972
2018
  const startedWatch = watch;
1973
- await watch.ready;
2019
+ const startedConfigWatch = configWatch;
2020
+ await Promise.all([watch.ready, configWatch.ready]);
1974
2021
  let stopping = false;
1975
2022
  let resolveClosed = () => void 0;
1976
2023
  const closed = new Promise((resolve) => {
@@ -1981,6 +2028,7 @@ async function executeDev(input, deps, cwd) {
1981
2028
  stopping = true;
1982
2029
  emit({ kind: "stopping" });
1983
2030
  startedWatch.stop();
2031
+ startedConfigWatch.stop();
1984
2032
  (async () => {
1985
2033
  for (const attachment of attachments) try {
1986
2034
  await attachment.stopServices();
@@ -2003,6 +2051,7 @@ async function executeDev(input, deps, cwd) {
2003
2051
  });
2004
2052
  } catch (error) {
2005
2053
  watch?.stop();
2054
+ configWatch?.stop();
2006
2055
  await Promise.all(started.map((a) => a.stopServices().catch(() => void 0)));
2007
2056
  if (CliStructuredError.is(error)) return notOk(error);
2008
2057
  throw error;
@@ -2011,4 +2060,4 @@ async function executeDev(input, deps, cwd) {
2011
2060
  //#endregion
2012
2061
  export { executeDev };
2013
2062
 
2014
- //# sourceMappingURL=execute-dev-BLCK5wF7-CJvkj5wl.mjs.map
2063
+ //# sourceMappingURL=execute-dev-DAIUT0es-B3iBKmAS.mjs.map