@prisma/composer 0.6.0 → 0.8.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.
- package/dist/{app-config-Cbv_lA38-BHJsd1DF.d.mts → app-config-BinBcpPf-1akTl5h4.d.mts} +130 -17
- package/dist/app-config-BinBcpPf-1akTl5h4.d.mts.map +1 -0
- package/dist/config-647Wkm51.d.mts +1 -0
- package/dist/config.d.mts +3 -3
- package/dist/control.d.mts +260 -0
- package/dist/control.d.mts.map +1 -0
- package/dist/control.mjs +71 -0
- package/dist/control.mjs.map +1 -0
- package/dist/deploy-647Wkm51.d.mts +1 -0
- package/dist/deploy.d.mts +2 -2
- package/dist/deploy.mjs +312 -1
- package/dist/deploy.mjs.map +1 -0
- package/dist/deployment-summary-DswOl_9E-B9MhYYDt.mjs +70 -0
- package/dist/deployment-summary-DswOl_9E-B9MhYYDt.mjs.map +1 -0
- package/dist/{dist-BdvFDCLV.mjs → dist-C5rZnr4n.mjs} +2 -2
- package/dist/{dist-BdvFDCLV.mjs.map → dist-C5rZnr4n.mjs.map} +1 -1
- package/dist/dist-CVk7Pk4B.mjs +42 -0
- package/dist/dist-CVk7Pk4B.mjs.map +1 -0
- package/dist/emulator-retry-DGonap4g-S8BNrXFD.mjs +24 -0
- package/dist/emulator-retry-DGonap4g-S8BNrXFD.mjs.map +1 -0
- package/dist/errors-0e8IVwzi.mjs +88 -0
- package/dist/errors-0e8IVwzi.mjs.map +1 -0
- package/dist/execute-deploy-destroy-DRl6Tfg9-B8LE2Lh5.mjs +405 -0
- package/dist/execute-deploy-destroy-DRl6Tfg9-B8LE2Lh5.mjs.map +1 -0
- package/dist/execute-dev-BMTFWfFc-7MifQgpp.mjs +2014 -0
- package/dist/execute-dev-BMTFWfFc-7MifQgpp.mjs.map +1 -0
- package/dist/execute-log-Cay9hlKW-BcvKPOW1.mjs +160 -0
- package/dist/execute-log-Cay9hlKW-BcvKPOW1.mjs.map +1 -0
- package/dist/{graph-DgbALPDo-BEHF94BN.mjs → graph-BJgUfGB0-kvgFzT4q.mjs} +13 -7
- package/dist/graph-BJgUfGB0-kvgFzT4q.mjs.map +1 -0
- package/dist/{graph-DDpXh7S8-b-93BcHn.d.mts → graph-DqklX5Sf-BNS2aO1j.d.mts} +3 -3
- package/dist/graph-DqklX5Sf-BNS2aO1j.d.mts.map +1 -0
- package/dist/{graph-types-C3FOaaXm-C6_rGzfn.d.mts → graph-types-N6brq1zY-1VMNwtkJ.d.mts} +88 -5
- package/dist/graph-types-N6brq1zY-1VMNwtkJ.d.mts.map +1 -0
- package/dist/{index-BQVrMGfe.d.mts → index-DryPyF9U.d.mts} +3 -3
- package/dist/{index-BQVrMGfe.d.mts.map → index-DryPyF9U.d.mts.map} +1 -1
- package/dist/index.d.mts +3 -3
- package/dist/index.mjs +2 -2
- package/dist/internal-error-BIc-ehme-Ck_lgxD_.mjs +18 -0
- package/dist/internal-error-BIc-ehme-Ck_lgxD_.mjs.map +1 -0
- package/dist/local-target-DnA2E8IN.mjs +47 -0
- package/dist/local-target-DnA2E8IN.mjs.map +1 -0
- package/dist/local-target.d.mts +1 -1
- package/dist/local-target.mjs +2 -46
- package/dist/{nextjs-DLyeRR7M-D47aMmfr.d.mts → nextjs-DLyeRR7M-DZODs9tk.d.mts} +3 -3
- package/dist/{nextjs-DLyeRR7M-D47aMmfr.d.mts.map → nextjs-DLyeRR7M-DZODs9tk.d.mts.map} +1 -1
- package/dist/nextjs-control.d.mts +4 -4
- package/dist/nextjs-control.mjs +138 -34
- package/dist/nextjs-control.mjs.map +1 -1
- package/dist/nextjs.d.mts +1 -1
- package/dist/node-control.d.mts +3 -3
- package/dist/node-control.mjs +21814 -55
- package/dist/node-control.mjs.map +1 -1
- package/dist/node.d.mts +2 -2
- package/dist/pipeline-AoW8zq4I-Dg8xQ7nC.mjs +452 -0
- package/dist/pipeline-AoW8zq4I-Dg8xQ7nC.mjs.map +1 -0
- package/dist/report.d.mts +4 -3
- package/dist/report.d.mts.map +1 -1
- package/dist/report.mjs +4 -1
- package/dist/report.mjs.map +1 -1
- package/dist/result-D95kAAek.mjs +247 -0
- package/dist/result-D95kAAek.mjs.map +1 -0
- package/dist/run-alchemy-D44OZlyB-Cw5CVbUQ.mjs +93 -0
- package/dist/run-alchemy-D44OZlyB-Cw5CVbUQ.mjs.map +1 -0
- package/dist/run-report-C2o98uD--AX8kpz4Q.mjs +60 -0
- package/dist/run-report-C2o98uD--AX8kpz4Q.mjs.map +1 -0
- package/dist/service-rpc.d.mts +2 -2
- package/dist/service-rpc.mjs +2 -2
- package/dist/testing.d.mts +1 -1
- package/package.json +17 -21
- package/src/exports/control.ts +1 -0
- package/src/exports/testing.ts +5 -0
- package/dist/app-config-Cbv_lA38-BHJsd1DF.d.mts.map +0 -1
- package/dist/bin.mjs +0 -3283
- package/dist/bin.mjs.map +0 -1
- package/dist/config-whuqZ5xT.d.mts +0 -1
- package/dist/deploy-C4DxNkJ9-D73lmBqy.mjs +0 -313
- package/dist/deploy-C4DxNkJ9-D73lmBqy.mjs.map +0 -1
- package/dist/deploy-whuqZ5xT.d.mts +0 -1
- package/dist/graph-DDpXh7S8-b-93BcHn.d.mts.map +0 -1
- package/dist/graph-DgbALPDo-BEHF94BN.mjs.map +0 -1
- package/dist/graph-types-C3FOaaXm-C6_rGzfn.d.mts.map +0 -1
- package/dist/local-target.mjs.map +0 -1
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { t as blindCast } from "./casts-DpaahrlC-C5XMnP9S.mjs";
|
|
2
|
+
//#region ../../0-framework/0-foundation/foundation/dist/errors.mjs
|
|
3
|
+
/**
|
|
4
|
+
* Returns an object with the key/value if value is defined, otherwise an empty object.
|
|
5
|
+
*
|
|
6
|
+
* Use with spread to conditionally include optional properties while satisfying
|
|
7
|
+
* exactOptionalPropertyTypes. This is explicit about which properties are optional
|
|
8
|
+
* and won't inadvertently strip other undefined values.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```typescript
|
|
12
|
+
* // Instead of:
|
|
13
|
+
* const obj = {
|
|
14
|
+
* required: 'value',
|
|
15
|
+
* ...(optional ? { optional } : {}),
|
|
16
|
+
* };
|
|
17
|
+
*
|
|
18
|
+
* // Use:
|
|
19
|
+
* const obj = {
|
|
20
|
+
* required: 'value',
|
|
21
|
+
* ...ifDefined('optional', optional),
|
|
22
|
+
* };
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
function ifDefined(key, value) {
|
|
26
|
+
return value !== void 0 ? blindCast({ [key]: value }) : {};
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Structured CLI error that contains all information needed for error envelopes.
|
|
30
|
+
* Call sites throw these errors with full context.
|
|
31
|
+
*
|
|
32
|
+
* A `CliStructuredError` is a `StructuredError` (see
|
|
33
|
+
* `./structured-error.ts`): `code` is a dotted
|
|
34
|
+
* `NAMESPACE.SUBCODE` string, and the namespace prefix is the error's
|
|
35
|
+
* category — there is no separate `domain` field. See ADR 239 in
|
|
36
|
+
* prisma/prisma and composer's ADR-0044 for the namespace taxonomy.
|
|
37
|
+
*/
|
|
38
|
+
var CliStructuredError = class extends Error {
|
|
39
|
+
code;
|
|
40
|
+
severity;
|
|
41
|
+
constructor(code, summary, options) {
|
|
42
|
+
super(summary, options?.cause !== void 0 ? { cause: options.cause } : void 0);
|
|
43
|
+
this.name = "CliStructuredError";
|
|
44
|
+
this.code = code;
|
|
45
|
+
this.severity = options?.severity ?? "error";
|
|
46
|
+
const fix = options?.fix === options?.why ? void 0 : options?.fix;
|
|
47
|
+
const where = options?.where ? {
|
|
48
|
+
...ifDefined("path", options.where.path),
|
|
49
|
+
...ifDefined("line", options.where.line)
|
|
50
|
+
} : void 0;
|
|
51
|
+
Object.assign(this, {
|
|
52
|
+
...ifDefined("why", options?.why),
|
|
53
|
+
...ifDefined("fix", fix),
|
|
54
|
+
...ifDefined("where", where),
|
|
55
|
+
...ifDefined("meta", options?.meta),
|
|
56
|
+
...ifDefined("docsUrl", options?.docsUrl)
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Converts this error to a CLI error envelope for output formatting.
|
|
61
|
+
*/
|
|
62
|
+
toEnvelope() {
|
|
63
|
+
return {
|
|
64
|
+
ok: false,
|
|
65
|
+
code: this.code,
|
|
66
|
+
severity: this.severity,
|
|
67
|
+
summary: this.message,
|
|
68
|
+
...ifDefined("why", this.why),
|
|
69
|
+
...ifDefined("fix", this.fix),
|
|
70
|
+
...ifDefined("where", this.where),
|
|
71
|
+
...ifDefined("meta", this.meta),
|
|
72
|
+
...ifDefined("docsUrl", this.docsUrl)
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Type guard to check if an error is a CliStructuredError.
|
|
77
|
+
* Uses duck-typing to work across module boundaries where instanceof may fail.
|
|
78
|
+
*/
|
|
79
|
+
static is(error) {
|
|
80
|
+
if (!(error instanceof Error)) return false;
|
|
81
|
+
const candidate = blindCast(error);
|
|
82
|
+
return candidate.name === "CliStructuredError" && typeof candidate.code === "string" && typeof candidate.toEnvelope === "function";
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
//#endregion
|
|
86
|
+
export { CliStructuredError as t };
|
|
87
|
+
|
|
88
|
+
//# sourceMappingURL=errors-0e8IVwzi.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors-0e8IVwzi.mjs","names":[],"sources":["../../../0-framework/0-foundation/foundation/dist/errors.mjs"],"sourcesContent":["import { t as blindCast } from \"./casts-DpaahrlC.mjs\";\nimport { n as assertNever, r as isInternalError, t as InternalError } from \"./internal-error-BIc-ehme.mjs\";\n//#region src/defined.ts\n/**\n* Returns an object with the key/value if value is defined, otherwise an empty object.\n*\n* Use with spread to conditionally include optional properties while satisfying\n* exactOptionalPropertyTypes. This is explicit about which properties are optional\n* and won't inadvertently strip other undefined values.\n*\n* @example\n* ```typescript\n* // Instead of:\n* const obj = {\n* required: 'value',\n* ...(optional ? { optional } : {}),\n* };\n*\n* // Use:\n* const obj = {\n* required: 'value',\n* ...ifDefined('optional', optional),\n* };\n* ```\n*/\nfunction ifDefined(key, value) {\n\treturn value !== void 0 ? blindCast({ [key]: value }) : {};\n}\n//#endregion\n//#region src/cli-structured-error.ts\n/**\n* Structured CLI error that contains all information needed for error envelopes.\n* Call sites throw these errors with full context.\n*\n* A `CliStructuredError` is a `StructuredError` (see\n* `./structured-error.ts`): `code` is a dotted\n* `NAMESPACE.SUBCODE` string, and the namespace prefix is the error's\n* category — there is no separate `domain` field. See ADR 239 in\n* prisma/prisma and composer's ADR-0044 for the namespace taxonomy.\n*/\nvar CliStructuredError = class extends Error {\n\tcode;\n\tseverity;\n\tconstructor(code, summary, options) {\n\t\tsuper(summary, options?.cause !== void 0 ? { cause: options.cause } : void 0);\n\t\tthis.name = \"CliStructuredError\";\n\t\tthis.code = code;\n\t\tthis.severity = options?.severity ?? \"error\";\n\t\tconst fix = options?.fix === options?.why ? void 0 : options?.fix;\n\t\tconst where = options?.where ? {\n\t\t\t...ifDefined(\"path\", options.where.path),\n\t\t\t...ifDefined(\"line\", options.where.line)\n\t\t} : void 0;\n\t\tObject.assign(this, {\n\t\t\t...ifDefined(\"why\", options?.why),\n\t\t\t...ifDefined(\"fix\", fix),\n\t\t\t...ifDefined(\"where\", where),\n\t\t\t...ifDefined(\"meta\", options?.meta),\n\t\t\t...ifDefined(\"docsUrl\", options?.docsUrl)\n\t\t});\n\t}\n\t/**\n\t* Converts this error to a CLI error envelope for output formatting.\n\t*/\n\ttoEnvelope() {\n\t\treturn {\n\t\t\tok: false,\n\t\t\tcode: this.code,\n\t\t\tseverity: this.severity,\n\t\t\tsummary: this.message,\n\t\t\t...ifDefined(\"why\", this.why),\n\t\t\t...ifDefined(\"fix\", this.fix),\n\t\t\t...ifDefined(\"where\", this.where),\n\t\t\t...ifDefined(\"meta\", this.meta),\n\t\t\t...ifDefined(\"docsUrl\", this.docsUrl)\n\t\t};\n\t}\n\t/**\n\t* Type guard to check if an error is a CliStructuredError.\n\t* Uses duck-typing to work across module boundaries where instanceof may fail.\n\t*/\n\tstatic is(error) {\n\t\tif (!(error instanceof Error)) return false;\n\t\tconst candidate = blindCast(error);\n\t\treturn candidate.name === \"CliStructuredError\" && typeof candidate.code === \"string\" && typeof candidate.toEnvelope === \"function\";\n\t}\n};\n//#endregion\n//#region src/structured-error.ts\nconst STRUCTURED_CODE_RE = /^[A-Z][A-Z0-9]*\\.[A-Z][A-Z0-9_]*$/;\nfunction isStructuredError(e) {\n\treturn typeof e === \"object\" && e !== null && \"code\" in e && typeof e.code === \"string\" && STRUCTURED_CODE_RE.test(e.code) && \"message\" in e && typeof e.message === \"string\";\n}\nfunction structuredError(code, message, options) {\n\tconst error = options?.cause !== void 0 ? new Error(message, { cause: options.cause }) : new Error(message);\n\tObject.defineProperty(error, \"name\", {\n\t\tvalue: \"StructuredError\",\n\t\tconfigurable: true\n\t});\n\treturn Object.assign(error, {\n\t\tcode,\n\t\t...ifDefined(\"why\", options?.why),\n\t\t...ifDefined(\"fix\", options?.fix),\n\t\t...ifDefined(\"where\", options?.where),\n\t\t...ifDefined(\"severity\", options?.severity),\n\t\t...ifDefined(\"meta\", options?.meta),\n\t\t...ifDefined(\"docsUrl\", options?.docsUrl)\n\t});\n}\nconst DOCS_BASE = `https://docs.prisma.io/docs/orm/next/reference/error-reference`;\nfunction docsUrlFor(code) {\n\treturn `${DOCS_BASE}#${code}`;\n}\n//#endregion\nexport { CliStructuredError, DOCS_BASE, InternalError, assertNever, docsUrlFor, isInternalError, isStructuredError, structuredError };\n\n//# sourceMappingURL=errors.mjs.map"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAyBA,SAAS,UAAU,KAAK,OAAO;CAC9B,OAAO,UAAU,KAAK,IAAI,UAAU,GAAG,MAAM,MAAM,CAAC,IAAI,CAAC;AAC1D;;;;;;;;;;;AAaA,IAAI,qBAAqB,cAAc,MAAM;CAC5C;CACA;CACA,YAAY,MAAM,SAAS,SAAS;EACnC,MAAM,SAAS,SAAS,UAAU,KAAK,IAAI,EAAE,OAAO,QAAQ,MAAM,IAAI,KAAK,CAAC;EAC5E,KAAK,OAAO;EACZ,KAAK,OAAO;EACZ,KAAK,WAAW,SAAS,YAAY;EACrC,MAAM,MAAM,SAAS,QAAQ,SAAS,MAAM,KAAK,IAAI,SAAS;EAC9D,MAAM,QAAQ,SAAS,QAAQ;GAC9B,GAAG,UAAU,QAAQ,QAAQ,MAAM,IAAI;GACvC,GAAG,UAAU,QAAQ,QAAQ,MAAM,IAAI;EACxC,IAAI,KAAK;EACT,OAAO,OAAO,MAAM;GACnB,GAAG,UAAU,OAAO,SAAS,GAAG;GAChC,GAAG,UAAU,OAAO,GAAG;GACvB,GAAG,UAAU,SAAS,KAAK;GAC3B,GAAG,UAAU,QAAQ,SAAS,IAAI;GAClC,GAAG,UAAU,WAAW,SAAS,OAAO;EACzC,CAAC;CACF;;;;CAIA,aAAa;EACZ,OAAO;GACN,IAAI;GACJ,MAAM,KAAK;GACX,UAAU,KAAK;GACf,SAAS,KAAK;GACd,GAAG,UAAU,OAAO,KAAK,GAAG;GAC5B,GAAG,UAAU,OAAO,KAAK,GAAG;GAC5B,GAAG,UAAU,SAAS,KAAK,KAAK;GAChC,GAAG,UAAU,QAAQ,KAAK,IAAI;GAC9B,GAAG,UAAU,WAAW,KAAK,OAAO;EACrC;CACD;;;;;CAKA,OAAO,GAAG,OAAO;EAChB,IAAI,EAAE,iBAAiB,QAAQ,OAAO;EACtC,MAAM,YAAY,UAAU,KAAK;EACjC,OAAO,UAAU,SAAS,wBAAwB,OAAO,UAAU,SAAS,YAAY,OAAO,UAAU,eAAe;CACzH;AACD"}
|
|
@@ -0,0 +1,405 @@
|
|
|
1
|
+
import { t as CliStructuredError } from "./errors-0e8IVwzi.mjs";
|
|
2
|
+
import { t as containerEnv } from "./container-transport-DKmKg5JQ-DKWs0ubK.mjs";
|
|
3
|
+
import { n as ok, r as okVoid, s as toStructured, t as notOk } from "./result-D95kAAek.mjs";
|
|
4
|
+
import { a as writeRunReport, i as toRunReport, r as resolveRunReportPath, t as RUN_REPORT_FILE_ENV } from "./run-report-C2o98uD--AX8kpz4Q.mjs";
|
|
5
|
+
import { n as readDeploymentSummary, t as DEPLOYMENT_RESULT_FILE_ENV } from "./deployment-summary-DswOl_9E-B9MhYYDt.mjs";
|
|
6
|
+
import { n as spawnAlchemy, t as alchemyInvocation } from "./run-alchemy-D44OZlyB-Cw5CVbUQ.mjs";
|
|
7
|
+
import { n as runPipeline } from "./pipeline-AoW8zq4I-Dg8xQ7nC.mjs";
|
|
8
|
+
import * as fs$1 from "node:fs";
|
|
9
|
+
import * as path$1 from "node:path";
|
|
10
|
+
import { spawnSync } from "node:child_process";
|
|
11
|
+
import { randomUUID } from "node:crypto";
|
|
12
|
+
//#region ../../0-framework/3-tooling/cli/dist/generate-stack-BL6htaQb.mjs
|
|
13
|
+
/** Pipeline step 6: writes a regenerated-every-run, independently runnable stack module at `.prisma-composer/alchemy.run.ts`. */
|
|
14
|
+
const GENERATED_DIR = ".prisma-composer";
|
|
15
|
+
const GENERATED_FILE = "alchemy.run.ts";
|
|
16
|
+
/** A relative import specifier from `.prisma-composer/alchemy.run.ts` to `target` (posix separators). */
|
|
17
|
+
function relativeImportSpecifier(generatedDir, target) {
|
|
18
|
+
const rel = path$1.relative(generatedDir, target).split(path$1.sep).join("/");
|
|
19
|
+
return rel.startsWith(".") ? rel : `./${rel}`;
|
|
20
|
+
}
|
|
21
|
+
function quote(value) {
|
|
22
|
+
return JSON.stringify(value);
|
|
23
|
+
}
|
|
24
|
+
function renderBundle(bundle) {
|
|
25
|
+
return `{ dir: ${quote(bundle.dir)}, entry: ${quote(bundle.entry)} }`;
|
|
26
|
+
}
|
|
27
|
+
function renderOptions(input) {
|
|
28
|
+
const lines = [];
|
|
29
|
+
lines.push(` name: ${quote(input.name)},`);
|
|
30
|
+
lines.push(" bundles: {");
|
|
31
|
+
for (const [id, bundle] of Object.entries(input.assembled.bundles)) lines.push(` ${quote(id)}: ${renderBundle(bundle)},`);
|
|
32
|
+
lines.push(" },");
|
|
33
|
+
lines.push(" report: deploymentReport,");
|
|
34
|
+
return lines.join("\n");
|
|
35
|
+
}
|
|
36
|
+
/** 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. */
|
|
37
|
+
function renderStackFile(input) {
|
|
38
|
+
const generatedDir = path$1.join(input.cwd, GENERATED_DIR);
|
|
39
|
+
const appImport = relativeImportSpecifier(generatedDir, input.entryPath);
|
|
40
|
+
const configImport = relativeImportSpecifier(generatedDir, input.configPath);
|
|
41
|
+
return `// Generated by \`prisma-composer deploy\`/\`prisma-composer destroy\` — overwritten on every
|
|
42
|
+
// run; do not edit by hand. Independently runnable from ${quote(input.cwd)}:
|
|
43
|
+
//
|
|
44
|
+
// alchemy deploy ${GENERATED_DIR}/${GENERATED_FILE}
|
|
45
|
+
//
|
|
46
|
+
// bisects a CLI bug from an Alchemy bug (deploy-cli.md § Implementation decisions).
|
|
47
|
+
import { lower } from '@prisma/composer/deploy';
|
|
48
|
+
import { deploymentReport } from '@prisma/composer/report';
|
|
49
|
+
import config from ${quote(configImport)};
|
|
50
|
+
import app from ${quote(appImport)};
|
|
51
|
+
|
|
52
|
+
export default lower(app, config, {
|
|
53
|
+
${renderOptions(input)}
|
|
54
|
+
});
|
|
55
|
+
`;
|
|
56
|
+
}
|
|
57
|
+
/** Writes the stack file, returning its absolute path. */
|
|
58
|
+
function writeStackFile(input) {
|
|
59
|
+
const generatedDir = path$1.join(input.cwd, GENERATED_DIR);
|
|
60
|
+
fs$1.mkdirSync(generatedDir, { recursive: true });
|
|
61
|
+
const filePath = path$1.join(generatedDir, GENERATED_FILE);
|
|
62
|
+
fs$1.writeFileSync(filePath, renderStackFile(input));
|
|
63
|
+
return filePath;
|
|
64
|
+
}
|
|
65
|
+
const GENERATED_STACK_RELATIVE_PATH = path$1.join(GENERATED_DIR, GENERATED_FILE);
|
|
66
|
+
//#endregion
|
|
67
|
+
//#region ../../0-framework/3-tooling/cli/dist/execute-deploy-destroy-DRl6Tfg9.mjs
|
|
68
|
+
/** 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. */
|
|
69
|
+
function validateStageName(stage) {
|
|
70
|
+
const result = spawnSync("git", ["check-ref-format", `refs/heads/${stage}`], { stdio: "ignore" });
|
|
71
|
+
if (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 });
|
|
72
|
+
if (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}").`);
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* The deploy/destroy executor — main.ts's pipeline orchestration with argv,
|
|
76
|
+
* console, and exit codes removed: typed inputs in, structured results out.
|
|
77
|
+
* Reached only by lazy import from deploy.ts/destroy.ts — this module's
|
|
78
|
+
* static graph transitively loads alchemy's provider tree, so the control
|
|
79
|
+
* entry must never import it statically.
|
|
80
|
+
*/
|
|
81
|
+
const ALCHEMY_STATE_DIR = ".alchemy";
|
|
82
|
+
/** Destroy guardrail (moved from main.ts): true when `<cwd>/.alchemy` is missing or empty — likely wrong directory or nothing deployed yet. */
|
|
83
|
+
function hasNoLocalDeployState(cwd) {
|
|
84
|
+
const stateDir = path$1.join(cwd, ALCHEMY_STATE_DIR);
|
|
85
|
+
return !(fs$1.existsSync(stateDir) && fs$1.readdirSync(stateDir).length > 0);
|
|
86
|
+
}
|
|
87
|
+
async function executeDeploy(input, deps, cwd) {
|
|
88
|
+
const outcome = await runStackPipeline("deploy", {
|
|
89
|
+
entry: input.entry,
|
|
90
|
+
name: input.name,
|
|
91
|
+
stage: input.stage,
|
|
92
|
+
cwd,
|
|
93
|
+
onEvent: void 0,
|
|
94
|
+
deps,
|
|
95
|
+
reportId: input.reportId
|
|
96
|
+
});
|
|
97
|
+
const reportPath = resolveRunReportPath(input.reportPath, process.env[RUN_REPORT_FILE_ENV], cwd);
|
|
98
|
+
if (reportPath !== void 0) writeRunReport(reportPath, toRunReport({
|
|
99
|
+
summary: outcome.ok ? outcome.value : void 0,
|
|
100
|
+
stage: input.stage,
|
|
101
|
+
failure: outcome.ok ? void 0 : {
|
|
102
|
+
code: outcome.failure.code,
|
|
103
|
+
message: outcome.failure.message
|
|
104
|
+
}
|
|
105
|
+
}));
|
|
106
|
+
if (!outcome.ok) return outcome;
|
|
107
|
+
return ok({ summary: outcome.value });
|
|
108
|
+
}
|
|
109
|
+
async function executeDestroy(input, deps, cwd) {
|
|
110
|
+
const outcome = await runStackPipeline("destroy", {
|
|
111
|
+
entry: input.entry,
|
|
112
|
+
name: input.name,
|
|
113
|
+
stage: input.target.kind === "stage" ? input.target.stage : void 0,
|
|
114
|
+
cwd,
|
|
115
|
+
onEvent: input.onEvent,
|
|
116
|
+
deps,
|
|
117
|
+
reportId: void 0
|
|
118
|
+
});
|
|
119
|
+
if (!outcome.ok) return outcome;
|
|
120
|
+
return okVoid();
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Opens a session per extension that declares a reporter. A `begin` that
|
|
124
|
+
* throws costs that extension its reporting and nothing else — the deploy
|
|
125
|
+
* has not started, and refusing to run it because an observer failed would
|
|
126
|
+
* invert the relationship.
|
|
127
|
+
*/
|
|
128
|
+
async function beginReporters(extensions, context) {
|
|
129
|
+
return (await Promise.all(extensions.map(async (extension) => {
|
|
130
|
+
if (extension.reporter === void 0) return void 0;
|
|
131
|
+
try {
|
|
132
|
+
const reporter = await extension.reporter.begin(context);
|
|
133
|
+
return reporter === void 0 ? void 0 : {
|
|
134
|
+
extensionId: extension.id,
|
|
135
|
+
reporter
|
|
136
|
+
};
|
|
137
|
+
} catch (error) {
|
|
138
|
+
const detail = error instanceof Error ? error.message : String(error);
|
|
139
|
+
console.warn(`\nCould not start deploy reporting for ${extension.id}: ${detail}`);
|
|
140
|
+
return;
|
|
141
|
+
}
|
|
142
|
+
}))).filter((entry) => entry !== void 0);
|
|
143
|
+
}
|
|
144
|
+
/** Hands each session its own extension's resolved container, so it can attach the run to what that container names. */
|
|
145
|
+
async function attachReporters(reporters, containers) {
|
|
146
|
+
await Promise.all(reporters.map(async ({ extensionId, reporter }) => {
|
|
147
|
+
try {
|
|
148
|
+
await reporter.attach({ container: containers.get(extensionId) });
|
|
149
|
+
} catch (error) {
|
|
150
|
+
const detail = error instanceof Error ? error.message : String(error);
|
|
151
|
+
console.warn(`\nCould not attach this deploy to its project for ${extensionId}: ${detail}`);
|
|
152
|
+
}
|
|
153
|
+
}));
|
|
154
|
+
}
|
|
155
|
+
/** Every session's contribution to the alchemy child's environment, so reporting that happens inside the apply can find the run. */
|
|
156
|
+
function reporterChildEnv(reporters) {
|
|
157
|
+
const env = {};
|
|
158
|
+
for (const { extensionId, reporter } of reporters) try {
|
|
159
|
+
Object.assign(env, reporter.childEnv());
|
|
160
|
+
} catch (error) {
|
|
161
|
+
const detail = error instanceof Error ? error.message : String(error);
|
|
162
|
+
console.warn(`\nCould not pass deploy reporting into the apply for ${extensionId}: ${detail}`);
|
|
163
|
+
}
|
|
164
|
+
return env;
|
|
165
|
+
}
|
|
166
|
+
/** `failingStep` is capped at 500 by the platform and `errorMessage` at 5000; truncating here keeps a long message from costing the whole report. */
|
|
167
|
+
function truncate(value, limit) {
|
|
168
|
+
return value.length <= limit ? value : `${value.slice(0, limit - 1)}…`;
|
|
169
|
+
}
|
|
170
|
+
/** An interrupted converge (the engine settled a Ctrl-C) — reported as `cancelled`, never as `failed`. */
|
|
171
|
+
function wasInterrupted(failure) {
|
|
172
|
+
return typeof failure.meta?.["signal"] === "string";
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* Ends every reporting session, whatever the run did. Sessions never reject
|
|
176
|
+
* by contract, but a buggy one must not turn a converged deploy into a
|
|
177
|
+
* failure — so this swallows anyway, and reports each session independently
|
|
178
|
+
* so one bad implementation cannot silence another.
|
|
179
|
+
*/
|
|
180
|
+
async function finishReporters(reporters, outcome) {
|
|
181
|
+
const entities = outcome.summary?.nodes.flatMap((node) => node.entities) ?? [];
|
|
182
|
+
await Promise.all(reporters.map(async ({ reporter }) => {
|
|
183
|
+
try {
|
|
184
|
+
await reporter.finish({
|
|
185
|
+
ok: outcome.ok,
|
|
186
|
+
cancelled: outcome.cancelled,
|
|
187
|
+
failingStep: outcome.code === void 0 ? void 0 : truncate(outcome.code, 500),
|
|
188
|
+
errorMessage: outcome.message === void 0 ? void 0 : truncate(outcome.message, 5e3),
|
|
189
|
+
entities
|
|
190
|
+
});
|
|
191
|
+
} catch (error) {
|
|
192
|
+
const detail = error instanceof Error ? error.message : String(error);
|
|
193
|
+
console.warn(`\nCould not report this deploy's outcome: ${detail}`);
|
|
194
|
+
}
|
|
195
|
+
}));
|
|
196
|
+
}
|
|
197
|
+
/**
|
|
198
|
+
* Owns the reporting sessions around the pipeline: the inner run opens them
|
|
199
|
+
* once it knows which extensions are configured, and this closes them on
|
|
200
|
+
* every exit path — a returned failure, a success, or a thrown defect.
|
|
201
|
+
* Nothing here can change what the pipeline returns.
|
|
202
|
+
*/
|
|
203
|
+
async function runStackPipeline(action, opts) {
|
|
204
|
+
const reporters = [];
|
|
205
|
+
let outcome;
|
|
206
|
+
try {
|
|
207
|
+
outcome = await runStackPipelineInner(action, opts, reporters);
|
|
208
|
+
} catch (error) {
|
|
209
|
+
await finishReporters(reporters, {
|
|
210
|
+
ok: false,
|
|
211
|
+
cancelled: false,
|
|
212
|
+
code: "DEPLOY.UNEXPECTED",
|
|
213
|
+
message: error instanceof Error ? error.message : String(error)
|
|
214
|
+
});
|
|
215
|
+
throw error;
|
|
216
|
+
}
|
|
217
|
+
await finishReporters(reporters, outcome.ok ? {
|
|
218
|
+
ok: true,
|
|
219
|
+
cancelled: false,
|
|
220
|
+
summary: outcome.value
|
|
221
|
+
} : {
|
|
222
|
+
ok: false,
|
|
223
|
+
cancelled: wasInterrupted(outcome.failure),
|
|
224
|
+
code: outcome.failure.code,
|
|
225
|
+
message: outcome.failure.message
|
|
226
|
+
});
|
|
227
|
+
return outcome;
|
|
228
|
+
}
|
|
229
|
+
/** The pipeline both actions share: validate, resolve containers, preflight,
|
|
230
|
+
* write the stack file, run alchemy against it, then the destroy-only
|
|
231
|
+
* teardown/removal suffix. The value is only ever a summary for deploy. */
|
|
232
|
+
async function runStackPipelineInner(action, opts, reporters) {
|
|
233
|
+
const { entry, name, stage, cwd, onEvent, deps } = opts;
|
|
234
|
+
if (stage !== void 0) try {
|
|
235
|
+
validateStageName(stage);
|
|
236
|
+
} catch (error) {
|
|
237
|
+
if (CliStructuredError.is(error)) return notOk(error);
|
|
238
|
+
throw error;
|
|
239
|
+
}
|
|
240
|
+
if (action === "destroy" && hasNoLocalDeployState(cwd)) onEvent?.({
|
|
241
|
+
kind: "no-local-deploy-state",
|
|
242
|
+
cwd
|
|
243
|
+
});
|
|
244
|
+
let pipeline;
|
|
245
|
+
let containers;
|
|
246
|
+
let alchemyStage;
|
|
247
|
+
try {
|
|
248
|
+
pipeline = await runPipeline(entry, name, cwd, {
|
|
249
|
+
runAssembler: deps.runAssembler,
|
|
250
|
+
config: deps.config,
|
|
251
|
+
configPath: deps.configPath
|
|
252
|
+
}, action === "destroy" ? (error) => new CliStructuredError("DEPLOY.BUILD_REQUIRED", error.message, {
|
|
253
|
+
why: "destroy evaluates the same stack program as deploy, which packages the built artifacts — so the app must be built first.",
|
|
254
|
+
fix: "Run the build, then retry the destroy.",
|
|
255
|
+
cause: error
|
|
256
|
+
}) : void 0);
|
|
257
|
+
const { config, graph, name: resolvedName } = pipeline;
|
|
258
|
+
if (action === "deploy") reporters.push(...await beginReporters(config.extensions, {
|
|
259
|
+
appName: resolvedName,
|
|
260
|
+
stage,
|
|
261
|
+
cwd,
|
|
262
|
+
reportId: opts.reportId,
|
|
263
|
+
credentials: deps.credentials
|
|
264
|
+
}));
|
|
265
|
+
containers = /* @__PURE__ */ new Map();
|
|
266
|
+
for (const extension of config.extensions) {
|
|
267
|
+
if (extension.container === void 0) continue;
|
|
268
|
+
try {
|
|
269
|
+
if (action === "deploy") containers.set(extension.id, await extension.container.ensure({
|
|
270
|
+
appName: resolvedName,
|
|
271
|
+
stage
|
|
272
|
+
}, deps.credentials));
|
|
273
|
+
else {
|
|
274
|
+
const instance = await extension.container.locate({
|
|
275
|
+
appName: resolvedName,
|
|
276
|
+
stage
|
|
277
|
+
}, deps.credentials);
|
|
278
|
+
if (instance === void 0) throw new CliStructuredError("DEPLOY.TARGET_NOT_FOUND", `Nothing deployed for ${resolvedName}${stage !== void 0 ? `/${stage}` : ""}.`, { fix: "Deploy it first." });
|
|
279
|
+
containers.set(extension.id, instance);
|
|
280
|
+
}
|
|
281
|
+
} catch (error) {
|
|
282
|
+
throw toStructured("DEPLOY.CONTAINER_FAILED", error);
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
await attachReporters(reporters, containers);
|
|
286
|
+
const pinnedStage = containers.get(config.state.extension)?.alchemyStage ?? stage;
|
|
287
|
+
if (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." });
|
|
288
|
+
alchemyStage = pinnedStage;
|
|
289
|
+
if (action === "deploy") for (const extension of config.extensions) {
|
|
290
|
+
if (extension.preflight === void 0) continue;
|
|
291
|
+
try {
|
|
292
|
+
await extension.preflight({
|
|
293
|
+
graph,
|
|
294
|
+
container: containers.get(extension.id),
|
|
295
|
+
stage,
|
|
296
|
+
credentials: deps.credentials
|
|
297
|
+
});
|
|
298
|
+
} catch (error) {
|
|
299
|
+
throw toStructured("DEPLOY.PREFLIGHT_FAILED", error);
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
} catch (error) {
|
|
303
|
+
if (CliStructuredError.is(error)) return notOk(error);
|
|
304
|
+
throw error;
|
|
305
|
+
}
|
|
306
|
+
let stackPath;
|
|
307
|
+
const resultFilePath = path$1.join(cwd, ".prisma-composer", `deployment-result-${String(process.pid)}-${randomUUID()}.json`);
|
|
308
|
+
try {
|
|
309
|
+
try {
|
|
310
|
+
stackPath = writeStackFile({
|
|
311
|
+
entryPath: pipeline.entryModule.path,
|
|
312
|
+
cwd,
|
|
313
|
+
configPath: pipeline.configPath,
|
|
314
|
+
name: pipeline.name,
|
|
315
|
+
assembled: pipeline.assembled
|
|
316
|
+
});
|
|
317
|
+
} catch (error) {
|
|
318
|
+
return notOk(toStructured("DEPLOY.STACK_WRITE_FAILED", error));
|
|
319
|
+
}
|
|
320
|
+
const reproduceCommand = `alchemy ${action} ${GENERATED_STACK_RELATIVE_PATH} --yes --stage ${alchemyStage}`;
|
|
321
|
+
let outcome;
|
|
322
|
+
try {
|
|
323
|
+
outcome = await (deps.alchemy ?? spawnAlchemy)(alchemyInvocation({
|
|
324
|
+
command: action,
|
|
325
|
+
stackFileRelativePath: GENERATED_STACK_RELATIVE_PATH,
|
|
326
|
+
cwd,
|
|
327
|
+
stage: alchemyStage,
|
|
328
|
+
containerEnv: containerEnv(containers),
|
|
329
|
+
env: {
|
|
330
|
+
...reporterChildEnv(reporters),
|
|
331
|
+
[DEPLOYMENT_RESULT_FILE_ENV]: resultFilePath
|
|
332
|
+
}
|
|
333
|
+
}));
|
|
334
|
+
} catch (error) {
|
|
335
|
+
if (CliStructuredError.is(error)) return notOk(error);
|
|
336
|
+
return notOk(new CliStructuredError("DEPLOY.ENGINE_FAILED", error instanceof Error ? error.message : String(error), {
|
|
337
|
+
cause: error,
|
|
338
|
+
meta: { diagnostics: {
|
|
339
|
+
exitCode: void 0,
|
|
340
|
+
stackFilePath: stackPath,
|
|
341
|
+
reproduceCommand,
|
|
342
|
+
cwd
|
|
343
|
+
} }
|
|
344
|
+
}));
|
|
345
|
+
}
|
|
346
|
+
if (outcome.signal !== null) return notOk(new CliStructuredError("DEPLOY.ENGINE_FAILED", `alchemy ${action} was interrupted by ${outcome.signal}.`, { meta: {
|
|
347
|
+
signal: outcome.signal,
|
|
348
|
+
diagnostics: {
|
|
349
|
+
exitCode: void 0,
|
|
350
|
+
signal: outcome.signal,
|
|
351
|
+
stackFilePath: stackPath,
|
|
352
|
+
reproduceCommand,
|
|
353
|
+
cwd
|
|
354
|
+
}
|
|
355
|
+
} }));
|
|
356
|
+
const status = outcome.exitCode ?? 1;
|
|
357
|
+
if (status !== 0) return notOk(new CliStructuredError("DEPLOY.ENGINE_FAILED", `alchemy ${action} exited with status ${status}.`, { meta: {
|
|
358
|
+
exitCode: status,
|
|
359
|
+
diagnostics: {
|
|
360
|
+
exitCode: status,
|
|
361
|
+
stackFilePath: stackPath,
|
|
362
|
+
reproduceCommand,
|
|
363
|
+
cwd
|
|
364
|
+
}
|
|
365
|
+
} }));
|
|
366
|
+
try {
|
|
367
|
+
if (action === "destroy") {
|
|
368
|
+
for (const extension of pipeline.config.extensions) {
|
|
369
|
+
if (extension.teardown === void 0) continue;
|
|
370
|
+
try {
|
|
371
|
+
await extension.teardown({
|
|
372
|
+
container: containers.get(extension.id),
|
|
373
|
+
stage
|
|
374
|
+
});
|
|
375
|
+
} catch (error) {
|
|
376
|
+
throw toStructured("DEPLOY.TEARDOWN_FAILED", error);
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
for (const extension of pipeline.config.extensions) {
|
|
380
|
+
if (extension.container === void 0) continue;
|
|
381
|
+
const instance = containers.get(extension.id);
|
|
382
|
+
if (instance === void 0) continue;
|
|
383
|
+
try {
|
|
384
|
+
await extension.container.remove(instance, deps.credentials);
|
|
385
|
+
} catch (error) {
|
|
386
|
+
throw toStructured("DEPLOY.CONTAINER_REMOVE_FAILED", error);
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
} catch (error) {
|
|
391
|
+
if (CliStructuredError.is(error)) return notOk(error);
|
|
392
|
+
throw error;
|
|
393
|
+
}
|
|
394
|
+
if (action === "deploy") return ok(readDeploymentSummary(resultFilePath));
|
|
395
|
+
return ok(void 0);
|
|
396
|
+
} finally {
|
|
397
|
+
try {
|
|
398
|
+
fs$1.rmSync(resultFilePath, { force: true });
|
|
399
|
+
} catch {}
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
//#endregion
|
|
403
|
+
export { executeDeploy, executeDestroy };
|
|
404
|
+
|
|
405
|
+
//# sourceMappingURL=execute-deploy-destroy-DRl6Tfg9-B8LE2Lh5.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"execute-deploy-destroy-DRl6Tfg9-B8LE2Lh5.mjs","names":["path","path","fs"],"sources":["../../../0-framework/3-tooling/cli/dist/generate-stack-BL6htaQb.mjs","../../../0-framework/3-tooling/cli/dist/execute-deploy-destroy-DRl6Tfg9.mjs"],"sourcesContent":["import * 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: 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.configPath);\n\treturn `// Generated by \\`prisma-composer deploy\\`/\\`prisma-composer destroy\\` — overwritten on every\n// run; do not edit by hand. Independently runnable from ${quote(input.cwd)}:\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 { deploymentReport } from '@prisma/composer/report';\nimport config from ${quote(configImport)};\nimport app from ${quote(appImport)};\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-BL6htaQb.mjs.map","import { r as toStructured } from \"./shared-BTnATsqm.mjs\";\nimport { i as spawnAlchemy, n as alchemyInvocation } from \"./run-alchemy-D44OZlyB.mjs\";\nimport { r as writeStackFile, t as GENERATED_STACK_RELATIVE_PATH } from \"./generate-stack-BL6htaQb.mjs\";\nimport { n as readDeploymentSummary, t as DEPLOYMENT_RESULT_FILE_ENV } from \"./deployment-summary-DswOl_9E.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-AoW8zq4I.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 { spawnSync } from \"node:child_process\";\nimport { randomUUID } from \"node:crypto\";\nimport { containerEnv } from \"@internal/core/config\";\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\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\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, 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\ttry {\n\t\tpipeline = await runPipeline(entry, name, cwd, {\n\t\t\trunAssembler: deps.runAssembler,\n\t\t\tconfig: deps.config,\n\t\t\tconfigPath: deps.configPath\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\tconst { config, graph, name: resolvedName } = pipeline;\n\t\tif (action === \"deploy\") reporters.push(...await beginReporters(config.extensions, {\n\t\t\tappName: resolvedName,\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\") for (const extension of config.extensions) {\n\t\t\tif (extension.preflight === void 0) continue;\n\t\t\ttry {\n\t\t\t\tawait extension.preflight({\n\t\t\t\t\tgraph,\n\t\t\t\t\tcontainer: containers.get(extension.id),\n\t\t\t\t\tstage,\n\t\t\t\t\tcredentials: deps.credentials\n\t\t\t\t});\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} 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\tconfigPath: pipeline.configPath,\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\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) return notOk(new CliStructuredError(\"DEPLOY.ENGINE_FAILED\", `alchemy ${action} exited with status ${status}.`, { meta: {\n\t\t\texitCode: status,\n\t\t\tdiagnostics: {\n\t\t\t\texitCode: status,\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\ttry {\n\t\t\tif (action === \"destroy\") {\n\t\t\t\tfor (const extension of pipeline.config.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.config.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} catch {}\n\t}\n}\n//#endregion\nexport { executeDeploy, executeDestroy };\n\n//# sourceMappingURL=execute-deploy-destroy-DRl6Tfg9.mjs.map"],"mappings":";;;;;;;;;;;;;AAIA,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;CAC7B,MAAM,QAAQ,CAAC;CACf,MAAM,KAAK,WAAW,MAAM,MAAM,IAAI,EAAE,EAAE;CAC1C,MAAM,KAAK,cAAc;CACzB,KAAK,MAAM,CAAC,IAAI,WAAW,OAAO,QAAQ,MAAM,UAAU,OAAO,GAAG,MAAM,KAAK,OAAO,MAAM,EAAE,EAAE,IAAI,aAAa,MAAM,EAAE,EAAE;CAC3H,MAAM,KAAK,MAAM;CACjB,MAAM,KAAK,6BAA6B;CACxC,OAAO,MAAM,KAAK,IAAI;AACvB;;AAEA,SAAS,gBAAgB,OAAO;CAC/B,MAAM,eAAeA,OAAK,KAAK,MAAM,KAAK,aAAa;CACvD,MAAM,YAAY,wBAAwB,cAAc,MAAM,SAAS;CACvE,MAA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