@prisma/composer 0.39.0-dev.1 → 0.39.0-dev.11
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-UeKFBma7-CohaMmWp.d.mts → app-config-DriAu5RU-C8hYpR38.d.mts} +88 -83
- package/dist/app-config-DriAu5RU-C8hYpR38.d.mts.map +1 -0
- package/dist/{app-configuration-file-CeJvBAti-D3uDlheX.mjs → app-configuration-file-D0rB5g65-CdMrjkCc.mjs} +50 -85
- package/dist/app-configuration-file-D0rB5g65-CdMrjkCc.mjs.map +1 -0
- package/dist/app-converge-bS1l9jIf-DRGbjw2D.mjs +88 -0
- package/dist/app-converge-bS1l9jIf-DRGbjw2D.mjs.map +1 -0
- package/dist/arktype.d.mts +7 -5
- package/dist/arktype.d.mts.map +1 -1
- package/dist/arktype.mjs +7 -5
- package/dist/arktype.mjs.map +1 -1
- package/dist/config-Bpi8QVLB.d.mts +1 -0
- package/dist/config.d.mts +3 -3
- package/dist/config.mjs +2 -2
- package/dist/control.d.mts +19 -21
- package/dist/control.d.mts.map +1 -1
- package/dist/control.mjs +4 -4
- package/dist/control.mjs.map +1 -1
- package/dist/converge-in-process-CTomEXaD-BnDylZP8.d.mts +67 -0
- package/dist/converge-in-process-CTomEXaD-BnDylZP8.d.mts.map +1 -0
- package/dist/converge-in-process-x89zb2MF-Dvj-J8xo.mjs +258 -0
- package/dist/converge-in-process-x89zb2MF-Dvj-J8xo.mjs.map +1 -0
- package/dist/{deploy-3EXLVrtG.mjs → deploy-CSU0kr4j.mjs} +130 -38
- package/dist/deploy-CSU0kr4j.mjs.map +1 -0
- package/dist/deploy-DHgEJDpg.d.mts +32 -0
- package/dist/deploy-DHgEJDpg.d.mts.map +1 -0
- package/dist/deploy.d.mts +4 -4
- package/dist/deploy.mjs +3 -3
- package/dist/{deployment-summary-p88NV5m5-SgniM8TX.d.mts → deployment-summary-6LgQDUuu-Cu_6UNhc.d.mts} +7 -4
- package/dist/deployment-summary-6LgQDUuu-Cu_6UNhc.d.mts.map +1 -0
- package/dist/{deployment-summary-D74WrJX7-DQ3LDUuO.mjs → deployment-summary-CVJZn2v0-Dz-gX1rp.mjs} +16 -44
- package/dist/deployment-summary-CVJZn2v0-Dz-gX1rp.mjs.map +1 -0
- package/dist/{describe-kind-Cpm_euxo-CkhlGJUL.mjs → describe-kind-Cpm_euxo-DsSPENQa.mjs} +4 -4
- package/dist/describe-kind-Cpm_euxo-DsSPENQa.mjs.map +1 -0
- package/dist/dev-converge-messages-DML4rTz7-C_EAB5M_.mjs +165 -0
- package/dist/dev-converge-messages-DML4rTz7-C_EAB5M_.mjs.map +1 -0
- package/dist/dev-converge-worker.d.mts +1 -0
- package/dist/dev-converge-worker.mjs +142 -0
- package/dist/dev-converge-worker.mjs.map +1 -0
- package/dist/{dev-current-wD5YDLjA-CzyFYXni.mjs → dev-current-lAlj53eX-DrtBnAmA.mjs} +11 -7
- package/dist/dev-current-lAlj53eX-DrtBnAmA.mjs.map +1 -0
- package/dist/{dev-environment-name-6eEr5PW8-BwusWVKi.mjs → dev-environment-name-6eEr5PW8-7ntm9Xhs.mjs} +3 -3
- package/dist/{dev-environment-name-6eEr5PW8-BwusWVKi.mjs.map → dev-environment-name-6eEr5PW8-7ntm9Xhs.mjs.map} +1 -1
- package/dist/{dist-ynqBR6y8.mjs → dist-Cf_mZHaH.mjs} +4 -26
- package/dist/dist-Cf_mZHaH.mjs.map +1 -0
- package/dist/{emulator-retry-CV8rl69G-BgUzkxc-.mjs → emulator-retry-CV8rl69G-scQ105wk.mjs} +2 -2
- package/dist/{emulator-retry-CV8rl69G-BgUzkxc-.mjs.map → emulator-retry-CV8rl69G-scQ105wk.mjs.map} +1 -1
- package/dist/{errors-0e8IVwzi.mjs → errors-DI3TBXE-.mjs} +7 -2
- package/dist/{errors-0e8IVwzi.mjs.map → errors-DI3TBXE-.mjs.map} +1 -1
- package/dist/{execute-deploy-destroy-DOzo2Psp-DmS5miT4.mjs → execute-deploy-destroy-DN16ETAk-BaopEKsA.mjs} +376 -86
- package/dist/execute-deploy-destroy-DN16ETAk-BaopEKsA.mjs.map +1 -0
- package/dist/{execute-dev-BIyOI3Ys-BbDOLlV4.mjs → execute-dev-DnVmNpc1-kSyPML7l.mjs} +455 -221
- package/dist/execute-dev-DnVmNpc1-kSyPML7l.mjs.map +1 -0
- package/dist/{execute-dev-current-CKOzjWuO-BPecs6Lf.mjs → execute-dev-current-CZdmxVQ4-Bij2LeBY.mjs} +7 -7
- package/dist/{execute-dev-current-CKOzjWuO-BPecs6Lf.mjs.map → execute-dev-current-CZdmxVQ4-Bij2LeBY.mjs.map} +1 -1
- package/dist/{execute-log-BDdHor71-B2p8Zae2.mjs → execute-log-Bl-j6izb-BTAo6tRM.mjs} +8 -8
- package/dist/{execute-log-BDdHor71-B2p8Zae2.mjs.map → execute-log-Bl-j6izb-BTAo6tRM.mjs.map} +1 -1
- package/dist/{graph-C7mdtisq-RnKiwVsx.d.mts → graph-CUYXjK8S-BzL-mhjq.d.mts} +3 -3
- package/dist/graph-CUYXjK8S-BzL-mhjq.d.mts.map +1 -0
- package/dist/{graph-BzPLUUsB-D7EnB1F5.mjs → graph-D2WMLL43-CeiC5wdy.mjs} +150 -107
- package/dist/graph-D2WMLL43-CeiC5wdy.mjs.map +1 -0
- package/dist/{graph-types-s5V7pGj2-BxSqB1ZH.d.mts → graph-types-D4PrtP-l-B0uuchTl.d.mts} +101 -98
- package/dist/graph-types-D4PrtP-l-B0uuchTl.d.mts.map +1 -0
- package/dist/http.d.mts +2 -2
- package/dist/http.mjs +2 -2
- package/dist/{index-DyuwxTtd.d.mts → index-D8chHe55.d.mts} +3 -3
- package/dist/{index-DyuwxTtd.d.mts.map → index-D8chHe55.d.mts.map} +1 -1
- package/dist/index.d.mts +5 -5
- package/dist/index.mjs +4 -4
- package/dist/internal-app-configuration-file.d.mts +7 -10
- package/dist/internal-app-configuration-file.d.mts.map +1 -1
- package/dist/internal-app-configuration-file.mjs +2 -2
- package/dist/internal-converge-contract.d.mts +16 -0
- package/dist/internal-converge-contract.d.mts.map +1 -0
- package/dist/internal-converge-contract.mjs +16 -0
- package/dist/internal-converge-contract.mjs.map +1 -0
- package/dist/internal-converge.d.mts +5 -0
- package/dist/internal-converge.mjs +4 -0
- package/dist/load-entry-CEoVBdMj-CHOz7jKf.mjs +527 -0
- package/dist/load-entry-CEoVBdMj-CHOz7jKf.mjs.map +1 -0
- package/dist/local-target-7KRsLMDO.d.mts +31 -0
- package/dist/local-target-7KRsLMDO.d.mts.map +1 -0
- package/dist/{local-target-Dd8FJEb5.mjs → local-target-DhU1vaxd.mjs} +8 -8
- package/dist/{local-target-Dd8FJEb5.mjs.map → local-target-DhU1vaxd.mjs.map} +1 -1
- package/dist/local-target.d.mts +3 -31
- package/dist/local-target.mjs +1 -1
- package/dist/{nextjs-DLyeRR7M-0lw_cBIr.d.mts → nextjs-DLyeRR7M-CzUbvPaJ.d.mts} +3 -3
- package/dist/{nextjs-DLyeRR7M-0lw_cBIr.d.mts.map → nextjs-DLyeRR7M-CzUbvPaJ.d.mts.map} +1 -1
- package/dist/nextjs-control.d.mts +4 -4
- package/dist/nextjs.d.mts +1 -1
- package/dist/node-control.d.mts +3 -3
- package/dist/node.d.mts +2 -2
- package/dist/{pointer-CyQZZugO-D7k3vibs.d.mts → pointer-BX2KJ720-BxcfpaHP.d.mts} +8 -6
- package/dist/{pointer-CyQZZugO-D7k3vibs.d.mts.map → pointer-BX2KJ720-BxcfpaHP.d.mts.map} +1 -1
- package/dist/{preflight-transport-DmmtoFPH-CnDWufmu.mjs → preflight-transport-2d6iIchu-B-v7Di6I.mjs} +7 -44
- package/dist/preflight-transport-2d6iIchu-B-v7Di6I.mjs.map +1 -0
- package/dist/{redaction-DXung4ip-bBoNomi3.mjs → redaction-DY6eDC12-W-FzW7_r.mjs} +32 -15
- package/dist/redaction-DY6eDC12-W-FzW7_r.mjs.map +1 -0
- package/dist/{redaction-Bf8FvTFH-D_HvoMrf.d.mts → redaction-Dn7BRdaP-BcLSPhLV.d.mts} +65 -16
- package/dist/redaction-Dn7BRdaP-BcLSPhLV.d.mts.map +1 -0
- package/dist/report.d.mts +3 -3
- package/dist/report.mjs +2 -2
- package/dist/report.mjs.map +1 -1
- package/dist/service-rpc.d.mts +2 -2
- package/dist/service-rpc.mjs +2 -2
- package/dist/steps-BZXNqW6U-C_ME2VLd.mjs +112 -0
- package/dist/steps-BZXNqW6U-C_ME2VLd.mjs.map +1 -0
- package/dist/testing.d.mts +1 -1
- package/dist/validate-environment-DCZiNSlR-C7lv0cH1.mjs +344 -0
- package/dist/validate-environment-DCZiNSlR-C7lv0cH1.mjs.map +1 -0
- package/dist/zod.d.mts +6 -5
- package/dist/zod.d.mts.map +1 -1
- package/dist/zod.mjs +6 -5
- package/dist/zod.mjs.map +1 -1
- package/package.json +15 -13
- package/skills/prisma-composer-core-concepts/SKILL.md +47 -66
- package/src/exports/dev-converge-worker.ts +2 -0
- package/src/exports/internal-converge-contract.ts +1 -0
- package/src/exports/internal-converge.ts +1 -0
- package/dist/app-config-UeKFBma7-CohaMmWp.d.mts.map +0 -1
- package/dist/app-configuration-file-CeJvBAti-D3uDlheX.mjs.map +0 -1
- package/dist/config-BeZEgGCg.d.mts +0 -1
- package/dist/deploy-3EXLVrtG.mjs.map +0 -1
- package/dist/deploy-Xi4_JrtE.d.mts +0 -2
- package/dist/deployment-summary-D74WrJX7-DQ3LDUuO.mjs.map +0 -1
- package/dist/deployment-summary-p88NV5m5-SgniM8TX.d.mts.map +0 -1
- package/dist/describe-kind-Cpm_euxo-CkhlGJUL.mjs.map +0 -1
- package/dist/dev-current-wD5YDLjA-CzyFYXni.mjs.map +0 -1
- package/dist/dist-ynqBR6y8.mjs.map +0 -1
- package/dist/execute-deploy-destroy-DOzo2Psp-DmS5miT4.mjs.map +0 -1
- package/dist/execute-dev-BIyOI3Ys-BbDOLlV4.mjs.map +0 -1
- package/dist/graph-BzPLUUsB-D7EnB1F5.mjs.map +0 -1
- package/dist/graph-C7mdtisq-RnKiwVsx.d.mts.map +0 -1
- package/dist/graph-types-s5V7pGj2-BxSqB1ZH.d.mts.map +0 -1
- package/dist/local-target.d.mts.map +0 -1
- package/dist/preflight-transport-DmmtoFPH-CnDWufmu.mjs.map +0 -1
- package/dist/redaction-Bf8FvTFH-D_HvoMrf.d.mts.map +0 -1
- package/dist/redaction-DXung4ip-bBoNomi3.mjs.map +0 -1
- package/dist/run-alchemy-CRLAyOtt-CBUV28We.mjs +0 -236
- package/dist/run-alchemy-CRLAyOtt-CBUV28We.mjs.map +0 -1
- package/dist/validate-environment-D1BTCkTs-BQprjyNP.mjs +0 -739
- package/dist/validate-environment-D1BTCkTs-BQprjyNP.mjs.map +0 -1
|
@@ -1,18 +1,23 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { t as
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
1
|
+
import { y as nodeAddresses } from "./graph-D2WMLL43-CeiC5wdy.mjs";
|
|
2
|
+
import { t as InternalError } from "./internal-error-Dfur7Zqt-D96dWHZK.mjs";
|
|
3
|
+
import { t as CliStructuredError } from "./errors-DI3TBXE-.mjs";
|
|
4
|
+
import { o as preflightEnvVarName, t as containerEnv } from "./preflight-transport-2d6iIchu-B-v7Di6I.mjs";
|
|
5
|
+
import { a as refuseSecretsInRootInput, n as prepareSecondProcess, o as removeLeftoverAppConfigurationFiles, t as deployAppConfigurationFile } from "./app-configuration-file-D0rB5g65-CdMrjkCc.mjs";
|
|
6
|
+
import "./deploy-CSU0kr4j.mjs";
|
|
7
|
+
import { c as requireContainerForEnvironment, d as ok, f as okVoid, l as toStructured, t as convergeReasonsText, u as notOk } from "./dev-current-lAlj53eX-DrtBnAmA.mjs";
|
|
6
8
|
import { a as writeRunReport, i as toRunReport, r as resolveRunReportPath, t as RUN_REPORT_FILE_ENV } from "./run-report-CmBz2-xc-Cc8rV1CX.mjs";
|
|
7
|
-
import "./
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import { a as
|
|
11
|
-
import {
|
|
9
|
+
import { c as noComposerExportMessage } from "./load-entry-CEoVBdMj-CHOz7jKf.mjs";
|
|
10
|
+
import { t as loadAppConvergeEntry } from "./app-converge-bS1l9jIf-DRGbjw2D.mjs";
|
|
11
|
+
import { c as redactThrown, l as redactUnsetPlatformVariable, n as StreamRedactor, o as redactError, r as credentialLookingValues, s as redactSummary, t as SecretRedaction } from "./redaction-DY6eDC12-W-FzW7_r.mjs";
|
|
12
|
+
import { a as readEngineFailureCause, i as engineFailureFilePath, n as capFailureCause, o as toDeploymentSummary, s as withComposerAdvice, t as DEPLOYMENT_RESULT_FILE_ENV } from "./deployment-summary-CVJZn2v0-Dz-gX1rp.mjs";
|
|
13
|
+
import { i as validateEnvironmentName, r as runPipeline } from "./validate-environment-DCZiNSlR-C7lv0cH1.mjs";
|
|
14
|
+
import { n as reportConvergeEvent, r as stepTracker, t as interactionMessages } from "./steps-BZXNqW6U-C_ME2VLd.mjs";
|
|
15
|
+
import { createRequire } from "node:module";
|
|
12
16
|
import * as path$1 from "node:path";
|
|
13
17
|
import * as fs$1 from "node:fs";
|
|
14
18
|
import { randomUUID } from "node:crypto";
|
|
15
|
-
|
|
19
|
+
import spawn from "cross-spawn";
|
|
20
|
+
//#region ../../0-framework/3-tooling/cli/dist/execute-deploy-destroy-DN16ETAk.mjs
|
|
16
21
|
/** Pipeline step 6: writes a regenerated-every-run, independently runnable stack module at `.prisma-composer/alchemy.run.ts`. */
|
|
17
22
|
const GENERATED_DIR = ".prisma-composer";
|
|
18
23
|
const GENERATED_FILE = "alchemy.run.ts";
|
|
@@ -85,6 +90,228 @@ function writeStackFile(input) {
|
|
|
85
90
|
}
|
|
86
91
|
const GENERATED_STACK_RELATIVE_PATH = path$1.join(GENERATED_DIR, GENERATED_FILE);
|
|
87
92
|
/**
|
|
93
|
+
* Which Alchemy CLI runs a generated stack file: the `alchemy` that
|
|
94
|
+
* `@prisma/composer` depends on, found from the app the way the stack file's
|
|
95
|
+
* own `@prisma/composer/...` imports are. The CLI and the stack code then
|
|
96
|
+
* come from one install, so the child loads one copy of `alchemy`.
|
|
97
|
+
*
|
|
98
|
+
* Node's resolver finds `@prisma/composer` from the app. It cannot find
|
|
99
|
+
* `alchemy` from there: alchemy exports neither its `package.json` nor its
|
|
100
|
+
* bin, and has no `require` condition. Bun has no `module.findPackageJSON`.
|
|
101
|
+
* So the last step is Node's own lookup written out: each `node_modules`
|
|
102
|
+
* above `@prisma/composer`'s real location, nearest first.
|
|
103
|
+
*/
|
|
104
|
+
const FIX = "Check that the app depends on @prisma/composer and that `alchemy`, which @prisma/composer depends on, is installed in a node_modules directory. Layouts without one, such as Yarn Plug'n'Play, are not supported.";
|
|
105
|
+
function binMissing(message) {
|
|
106
|
+
return new CliStructuredError("DEPLOY.ALCHEMY_BIN_MISSING", message, { fix: FIX });
|
|
107
|
+
}
|
|
108
|
+
function composerPackageDir(appDir) {
|
|
109
|
+
try {
|
|
110
|
+
const manifest = createRequire(path$1.join(appDir, "package.json")).resolve("@prisma/composer/package.json");
|
|
111
|
+
return path$1.dirname(fs$1.realpathSync(manifest));
|
|
112
|
+
} catch {
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
function alchemyPackageDirAbove(dir) {
|
|
117
|
+
for (let current = dir;; current = path$1.dirname(current)) {
|
|
118
|
+
const candidate = path$1.join(current, "node_modules", "alchemy");
|
|
119
|
+
if (fs$1.existsSync(path$1.join(candidate, "package.json"))) return candidate;
|
|
120
|
+
if (path$1.dirname(current) === current) return void 0;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
function readPackageJson(packageDir) {
|
|
124
|
+
try {
|
|
125
|
+
return JSON.parse(fs$1.readFileSync(path$1.join(packageDir, "package.json"), "utf8"));
|
|
126
|
+
} catch {
|
|
127
|
+
return;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
function binOf(packageDir) {
|
|
131
|
+
const manifest = readPackageJson(packageDir);
|
|
132
|
+
if (typeof manifest !== "object" || manifest === null || !("bin" in manifest)) return void 0;
|
|
133
|
+
const bin = manifest.bin;
|
|
134
|
+
const relative = typeof bin === "string" ? bin : typeof bin === "object" && bin !== null && "alchemy" in bin ? bin.alchemy : void 0;
|
|
135
|
+
if (typeof relative !== "string") return void 0;
|
|
136
|
+
const entry = path$1.join(packageDir, relative);
|
|
137
|
+
return fs$1.existsSync(entry) ? entry : void 0;
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* The JavaScript file `alchemy`'s `bin` names, for the app in `appDir`.
|
|
141
|
+
* Raises DEPLOY.ALCHEMY_BIN_MISSING when the app does not resolve
|
|
142
|
+
* `@prisma/composer` or no usable `alchemy` is installed beside it.
|
|
143
|
+
*/
|
|
144
|
+
function resolveAlchemyBin(appDir) {
|
|
145
|
+
const composerDir = composerPackageDir(appDir);
|
|
146
|
+
if (composerDir === void 0) throw binMissing(`Could not resolve @prisma/composer from "${appDir}".`);
|
|
147
|
+
const alchemyDir = alchemyPackageDirAbove(composerDir);
|
|
148
|
+
const entry = alchemyDir === void 0 ? void 0 : binOf(alchemyDir);
|
|
149
|
+
if (entry === void 0) throw binMissing(`Could not resolve the bin of the \`alchemy\` package @prisma/composer depends on, from "${composerDir}".`);
|
|
150
|
+
return entry;
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* Pipeline step 9 (deploy-cli.md § The pipeline; design-notes.md's "Driving
|
|
154
|
+
* Alchemy" call): run the generated stack file and, for programmatic hosts, pipe its
|
|
155
|
+
* output through redaction.
|
|
156
|
+
*
|
|
157
|
+
* Runs the bin of the `alchemy` the app's `@prisma/composer` depends on
|
|
158
|
+
* (`resolveAlchemyBin`), started with Node (`nodeExecutable`). Never a
|
|
159
|
+
* `node_modules/.bin` link, which pnpm creates only for an app's direct
|
|
160
|
+
* dependencies.
|
|
161
|
+
*
|
|
162
|
+
* Only `destroy` still runs Alchemy in a child; `deploy` and `dev` converge
|
|
163
|
+
* in-process (ADR-0066). This module composes the invocation; `spawnAlchemy`
|
|
164
|
+
* starts it, piping the child's output through the stream redactor
|
|
165
|
+
* (ADR-0062), and tests substitute their own runner.
|
|
166
|
+
*/
|
|
167
|
+
function currentRuntime() {
|
|
168
|
+
return {
|
|
169
|
+
bun: process.versions.bun !== void 0,
|
|
170
|
+
execPath: process.execPath,
|
|
171
|
+
env: process.env,
|
|
172
|
+
platform: process.platform,
|
|
173
|
+
exists: fs$1.existsSync
|
|
174
|
+
};
|
|
175
|
+
}
|
|
176
|
+
function envValue(env, name) {
|
|
177
|
+
return Object.entries(env).find(([key]) => key.toLowerCase() === name.toLowerCase())?.[1];
|
|
178
|
+
}
|
|
179
|
+
/** The file names `node` may have in a PATH directory: PATHEXT's extensions on Windows. */
|
|
180
|
+
function nodeFileNames(runtime) {
|
|
181
|
+
if (runtime.platform !== "win32") return ["node"];
|
|
182
|
+
return (envValue(runtime.env, "PATHEXT") ?? ".COM;.EXE;.BAT;.CMD").split(";").filter((extension) => extension.length > 0).map((extension) => `node${extension}`);
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* The Node that starts Alchemy's launcher: this process's own runtime under
|
|
186
|
+
* Node, and the first `node` on PATH under Bun. Alchemy's launcher may still
|
|
187
|
+
* move itself to Bun when the package-manager environment says Bun invoked
|
|
188
|
+
* it (`bunx`, `bun run`), so the runtime Alchemy ends up on follows how
|
|
189
|
+
* `prisma` was invoked.
|
|
190
|
+
*/
|
|
191
|
+
function nodeExecutable(runtime = currentRuntime()) {
|
|
192
|
+
if (!runtime.bun) return runtime.execPath;
|
|
193
|
+
const paths = runtime.platform === "win32" ? path$1.win32 : path$1.posix;
|
|
194
|
+
const names = nodeFileNames(runtime);
|
|
195
|
+
for (const rawDir of (envValue(runtime.env, "PATH") ?? "").split(paths.delimiter)) {
|
|
196
|
+
const dir = rawDir.replace(/^"(.*)"$/, "$1");
|
|
197
|
+
if (dir.length === 0) continue;
|
|
198
|
+
for (const name of names) {
|
|
199
|
+
const candidate = paths.join(dir, name);
|
|
200
|
+
if (runtime.exists(candidate)) return candidate;
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
throw new CliStructuredError("DEPLOY.NODE_MISSING", "Composer starts Alchemy with Node, and no `node` was found on PATH.", { fix: "Install Node.js 22.18 or newer on the 22 line, 24.11 or newer on the 24 line, or 26 or newer, and put it on PATH, or run `prisma` under Node." });
|
|
204
|
+
}
|
|
205
|
+
/**
|
|
206
|
+
* Resolves the invocation against this machine — the step every adapter takes
|
|
207
|
+
* and no caller should. Runs alchemy's JavaScript entry with Node, so no shell
|
|
208
|
+
* shim is involved on any platform. Raises DEPLOY.ALCHEMY_BIN_MISSING when
|
|
209
|
+
* Composer's alchemy cannot be resolved, and DEPLOY.NODE_MISSING when no Node
|
|
210
|
+
* can run it.
|
|
211
|
+
*/
|
|
212
|
+
function alchemyCommandLine(invocation, alchemyBin = resolveAlchemyBin(invocation.cwd), node = nodeExecutable()) {
|
|
213
|
+
return {
|
|
214
|
+
command: node,
|
|
215
|
+
args: [
|
|
216
|
+
alchemyBin,
|
|
217
|
+
invocation.action,
|
|
218
|
+
invocation.stackFileRelativePath,
|
|
219
|
+
"--yes",
|
|
220
|
+
"--stage",
|
|
221
|
+
invocation.stage
|
|
222
|
+
],
|
|
223
|
+
cwd: invocation.cwd,
|
|
224
|
+
env: invocation.env
|
|
225
|
+
};
|
|
226
|
+
}
|
|
227
|
+
/** What becomes `alchemy deploy|destroy <stack file> --yes --stage <stage>`. */
|
|
228
|
+
function alchemyInvocation(input) {
|
|
229
|
+
return {
|
|
230
|
+
action: input.command,
|
|
231
|
+
stackFileRelativePath: input.stackFileRelativePath,
|
|
232
|
+
cwd: input.cwd,
|
|
233
|
+
stage: input.stage,
|
|
234
|
+
env: {
|
|
235
|
+
...input.containerEnv,
|
|
236
|
+
...input.preflightEnv,
|
|
237
|
+
...input.env
|
|
238
|
+
},
|
|
239
|
+
redactedValues: input.redactedValues
|
|
240
|
+
};
|
|
241
|
+
}
|
|
242
|
+
/**
|
|
243
|
+
* The default runner for hosts with no engine: stdin inherited and output piped through redaction, the caller's
|
|
244
|
+
* own process group, and the child's status returned verbatim. It does not
|
|
245
|
+
* collapse a signal into an exit code — that collapse is what made a
|
|
246
|
+
* Ctrl-C'd deploy report itself as a failure.
|
|
247
|
+
*/
|
|
248
|
+
const spawnAlchemy = async (invocation) => {
|
|
249
|
+
const commandLine = alchemyCommandLine(invocation);
|
|
250
|
+
return {
|
|
251
|
+
...await spawnCommandLine(commandLine, invocation.redactedValues),
|
|
252
|
+
commandLine
|
|
253
|
+
};
|
|
254
|
+
};
|
|
255
|
+
/**
|
|
256
|
+
* One argument as the platform's shell reads it literally: single quotes for
|
|
257
|
+
* POSIX shells, double quotes for cmd.exe. cmd.exe expands `%VAR%` inside
|
|
258
|
+
* double quotes, and strips or expands `!` when delayed expansion is on; no
|
|
259
|
+
* quoting prevents either, so an argument containing them is not fully
|
|
260
|
+
* literal there.
|
|
261
|
+
*/
|
|
262
|
+
function shellArg(arg, platform) {
|
|
263
|
+
if (platform === "win32") return /^[\w@+=:,./\\~-]+$/.test(arg) ? arg : `"${arg.replaceAll("\"", "\"\"")}"`;
|
|
264
|
+
return /^[\w@%+=:,./-]+$/.test(arg) ? arg : `'${arg.replaceAll("'", "'\\''")}'`;
|
|
265
|
+
}
|
|
266
|
+
/**
|
|
267
|
+
* The command a user runs from the invocation's directory to repeat a
|
|
268
|
+
* converge: the command line the adapter started, or, from an adapter that
|
|
269
|
+
* does not report one, `alchemy` with the same arguments.
|
|
270
|
+
*/
|
|
271
|
+
function reproduceCommand(invocation, outcome, platform = process.platform) {
|
|
272
|
+
return (outcome?.commandLine === void 0 ? [
|
|
273
|
+
"alchemy",
|
|
274
|
+
invocation.action,
|
|
275
|
+
invocation.stackFileRelativePath,
|
|
276
|
+
"--yes",
|
|
277
|
+
"--stage",
|
|
278
|
+
invocation.stage
|
|
279
|
+
] : [outcome.commandLine.command, ...outcome.commandLine.args]).map((arg) => shellArg(arg, platform)).join(" ");
|
|
280
|
+
}
|
|
281
|
+
/** Starts a resolved command line with stdin inherited and its output piped through redaction, and returns how it ended. */
|
|
282
|
+
function spawnCommandLine(line, redactedValues, outputs = process) {
|
|
283
|
+
return new Promise((resolve, reject) => {
|
|
284
|
+
const child = spawn(line.command, [...line.args], {
|
|
285
|
+
cwd: line.cwd,
|
|
286
|
+
stdio: [
|
|
287
|
+
"inherit",
|
|
288
|
+
"pipe",
|
|
289
|
+
"pipe"
|
|
290
|
+
],
|
|
291
|
+
env: {
|
|
292
|
+
...process.env,
|
|
293
|
+
...line.env
|
|
294
|
+
}
|
|
295
|
+
});
|
|
296
|
+
const stdout = new StreamRedactor(redactedValues);
|
|
297
|
+
const stderr = new StreamRedactor(redactedValues);
|
|
298
|
+
const write = (stream, text) => {
|
|
299
|
+
if (text.length > 0) stream.write(text);
|
|
300
|
+
};
|
|
301
|
+
child.stdout?.setEncoding("utf8").on("data", (chunk) => write(outputs.stdout, stdout.push(chunk)));
|
|
302
|
+
child.stderr?.setEncoding("utf8").on("data", (chunk) => write(outputs.stderr, stderr.push(chunk)));
|
|
303
|
+
child.on("error", reject);
|
|
304
|
+
child.on("close", (exitCode, signal) => {
|
|
305
|
+
write(outputs.stdout, stdout.end());
|
|
306
|
+
write(outputs.stderr, stderr.end());
|
|
307
|
+
resolve({
|
|
308
|
+
exitCode,
|
|
309
|
+
signal
|
|
310
|
+
});
|
|
311
|
+
});
|
|
312
|
+
});
|
|
313
|
+
}
|
|
314
|
+
/**
|
|
88
315
|
* The deploy/destroy executor — main.ts's pipeline orchestration with argv,
|
|
89
316
|
* console, and exit codes removed: typed inputs in, structured results out.
|
|
90
317
|
* Reached only by lazy import from deploy.ts/destroy.ts — this module's
|
|
@@ -97,54 +324,9 @@ function hasNoLocalDeployState(cwd) {
|
|
|
97
324
|
const stateDir = path$1.join(cwd, ALCHEMY_STATE_DIR);
|
|
98
325
|
return !(fs$1.existsSync(stateDir) && fs$1.readdirSync(stateDir).length > 0);
|
|
99
326
|
}
|
|
100
|
-
/**
|
|
101
|
-
* Times each deploy step for the host's `onEvent`. A step still open when the
|
|
102
|
-
* run fails is closed as failed, innermost first. A host `onEvent` that throws
|
|
103
|
-
* is the host's bug and cannot fail the deploy.
|
|
104
|
-
*/
|
|
327
|
+
/** Times each deploy step for the host's `onEvent`. A step still open when the run fails is closed as failed, innermost first. */
|
|
105
328
|
function deploySteps(onEvent) {
|
|
106
|
-
|
|
107
|
-
const keyOf = (step) => step.name === "assemble-service" ? `${step.name}:${step.address}` : step.name;
|
|
108
|
-
const emit = (event) => {
|
|
109
|
-
try {
|
|
110
|
-
onEvent?.(event);
|
|
111
|
-
} catch {}
|
|
112
|
-
};
|
|
113
|
-
const finish = (step, outcome, data) => {
|
|
114
|
-
const entry = open.get(keyOf(step));
|
|
115
|
-
if (entry === void 0) return;
|
|
116
|
-
open.delete(keyOf(step));
|
|
117
|
-
const durationMs = Math.round(performance.now() - entry.startedAt);
|
|
118
|
-
emit({
|
|
119
|
-
kind: "step-finished",
|
|
120
|
-
step,
|
|
121
|
-
outcome,
|
|
122
|
-
durationMs,
|
|
123
|
-
data
|
|
124
|
-
});
|
|
125
|
-
};
|
|
126
|
-
return {
|
|
127
|
-
start(step) {
|
|
128
|
-
open.set(keyOf(step), {
|
|
129
|
-
step,
|
|
130
|
-
startedAt: performance.now()
|
|
131
|
-
});
|
|
132
|
-
emit({
|
|
133
|
-
kind: "step-started",
|
|
134
|
-
step
|
|
135
|
-
});
|
|
136
|
-
},
|
|
137
|
-
finish(step, data) {
|
|
138
|
-
finish(step, "ok", data);
|
|
139
|
-
},
|
|
140
|
-
fail(step) {
|
|
141
|
-
finish(step, "failed");
|
|
142
|
-
},
|
|
143
|
-
failOpen() {
|
|
144
|
-
for (const { step } of [...open.values()].reverse()) finish(step, "failed");
|
|
145
|
-
},
|
|
146
|
-
emit
|
|
147
|
-
};
|
|
329
|
+
return stepTracker((step) => step.name === "assemble-service" ? `${step.name}:${step.address}` : step.name === "apply-resource" ? `${step.name}:${step.resourceId}` : step.name, onEvent);
|
|
148
330
|
}
|
|
149
331
|
async function executeDeploy(input, deps, cwd) {
|
|
150
332
|
const outcome = await runStackPipeline("deploy", {
|
|
@@ -158,7 +340,8 @@ async function executeDeploy(input, deps, cwd) {
|
|
|
158
340
|
reportId: input.reportId,
|
|
159
341
|
reportPath: resolveRunReportPath(input.reportPath, process.env[RUN_REPORT_FILE_ENV], cwd),
|
|
160
342
|
steps: deploySteps(input.onEvent),
|
|
161
|
-
|
|
343
|
+
signal: input.signal,
|
|
344
|
+
redaction: deps.redaction ?? new SecretRedaction(process.env)
|
|
162
345
|
});
|
|
163
346
|
if (!outcome.ok) return outcome;
|
|
164
347
|
return ok({ summary: outcome.value });
|
|
@@ -175,6 +358,7 @@ async function executeDestroy(input, deps, cwd) {
|
|
|
175
358
|
reportId: void 0,
|
|
176
359
|
reportPath: void 0,
|
|
177
360
|
steps: deploySteps(void 0),
|
|
361
|
+
signal: void 0,
|
|
178
362
|
redaction: new SecretRedaction(process.env)
|
|
179
363
|
});
|
|
180
364
|
if (!outcome.ok) return outcome;
|
|
@@ -213,8 +397,8 @@ async function attachReporters(reporters, containers, redaction) {
|
|
|
213
397
|
}
|
|
214
398
|
}));
|
|
215
399
|
}
|
|
216
|
-
/** Every session's contribution to the
|
|
217
|
-
function
|
|
400
|
+
/** Every session's contribution to the apply's environment, so reporting that happens inside the apply can find the run. */
|
|
401
|
+
function reporterEnv(reporters, redaction) {
|
|
218
402
|
const env = {};
|
|
219
403
|
for (const { extensionId, reporter } of reporters) try {
|
|
220
404
|
Object.assign(env, reporter.childEnv());
|
|
@@ -228,9 +412,9 @@ function reporterChildEnv(reporters, redaction) {
|
|
|
228
412
|
function truncate(value, limit) {
|
|
229
413
|
return value.length <= limit ? value : `${value.slice(0, limit - 1)}…`;
|
|
230
414
|
}
|
|
231
|
-
/** An interrupted converge
|
|
415
|
+
/** An interrupted converge — reported as `cancelled`, never as `failed`. */
|
|
232
416
|
function wasInterrupted(failure) {
|
|
233
|
-
return typeof failure.meta?.["signal"] === "string";
|
|
417
|
+
return failure.code === "DEPLOY.INTERRUPTED" || typeof failure.meta?.["signal"] === "string";
|
|
234
418
|
}
|
|
235
419
|
/**
|
|
236
420
|
* Ends every reporting session, whatever the run did. Sessions never reject
|
|
@@ -268,7 +452,7 @@ async function runStackPipeline(action, opts) {
|
|
|
268
452
|
try {
|
|
269
453
|
outcome = await runStackPipelineInner(action, opts, reporters);
|
|
270
454
|
} catch (error) {
|
|
271
|
-
opts.steps.
|
|
455
|
+
opts.steps.closeOpen("failed");
|
|
272
456
|
opts.steps.start({ name: "record" });
|
|
273
457
|
const thrown = redactThrown(error, opts.redaction);
|
|
274
458
|
await finishReporters(reporters, {
|
|
@@ -281,7 +465,7 @@ async function runStackPipeline(action, opts) {
|
|
|
281
465
|
throw thrown;
|
|
282
466
|
}
|
|
283
467
|
if (!outcome.ok) outcome = notOk(redactError(outcome.failure, opts.redaction));
|
|
284
|
-
if (!outcome.ok) opts.steps.
|
|
468
|
+
if (!outcome.ok) opts.steps.closeOpen("failed");
|
|
285
469
|
opts.steps.start({ name: "record" });
|
|
286
470
|
await finishReporters(reporters, outcome.ok ? {
|
|
287
471
|
ok: true,
|
|
@@ -304,9 +488,10 @@ async function runStackPipeline(action, opts) {
|
|
|
304
488
|
else opts.steps.fail({ name: "record" });
|
|
305
489
|
return outcome;
|
|
306
490
|
}
|
|
307
|
-
/** The pipeline both actions share: validate, resolve containers,
|
|
308
|
-
*
|
|
309
|
-
* teardown/removal suffix. The value is only
|
|
491
|
+
/** The pipeline both actions share: validate, resolve containers, then for
|
|
492
|
+
* deploy preflight and the in-process converge, and for destroy the stack
|
|
493
|
+
* file, the alchemy child and the teardown/removal suffix. The value is only
|
|
494
|
+
* ever a summary for deploy. */
|
|
310
495
|
async function runStackPipelineInner(action, opts, reporters) {
|
|
311
496
|
const { entry, config: composerConfig, name, environment, cwd, onEvent, deps, steps } = opts;
|
|
312
497
|
steps.start({ name: "prepare" });
|
|
@@ -317,6 +502,13 @@ async function runStackPipelineInner(action, opts, reporters) {
|
|
|
317
502
|
if (CliStructuredError.is(error)) return notOk(error);
|
|
318
503
|
throw error;
|
|
319
504
|
}
|
|
505
|
+
let appConvergeEntry;
|
|
506
|
+
if (action === "deploy") {
|
|
507
|
+
const loaded = await prepareAppConvergeEntry(deps, path$1.dirname(path$1.resolve(cwd, composerConfig.file)));
|
|
508
|
+
if (!loaded.ok) return loaded;
|
|
509
|
+
appConvergeEntry = loaded.value;
|
|
510
|
+
}
|
|
511
|
+
const platformCredentials = deps.credentials;
|
|
320
512
|
if (action === "destroy" && hasNoLocalDeployState(cwd)) onEvent?.({
|
|
321
513
|
kind: "no-local-deploy-state",
|
|
322
514
|
cwd
|
|
@@ -325,7 +517,8 @@ async function runStackPipelineInner(action, opts, reporters) {
|
|
|
325
517
|
let containers;
|
|
326
518
|
let alchemyStage;
|
|
327
519
|
const preflightPayloads = /* @__PURE__ */ new Map();
|
|
328
|
-
|
|
520
|
+
const unset = [];
|
|
521
|
+
const preflightTransportEnv = {};
|
|
329
522
|
try {
|
|
330
523
|
pipeline = await runPipeline(entry, name, environment, cwd, composerConfig, {
|
|
331
524
|
runAssembler: deps.runAssembler,
|
|
@@ -359,6 +552,7 @@ async function runStackPipelineInner(action, opts, reporters) {
|
|
|
359
552
|
steps.finish({ name: "assemble" });
|
|
360
553
|
const { graph, name: resolvedName } = pipeline;
|
|
361
554
|
const config = pipeline.configSource.value;
|
|
555
|
+
if (action === "deploy") refuseSecretsInRootInput(graph.appConfigurationRead, opts.redaction.knownSecrets, "A deploy sends every plain value Load read to the platform as plain configuration, and never sends a secret that way.");
|
|
362
556
|
steps.start({ name: "connect" });
|
|
363
557
|
if (action === "deploy") reporters.push(...await beginReporters(config.extensions, {
|
|
364
558
|
appName: resolvedName,
|
|
@@ -366,7 +560,7 @@ async function runStackPipelineInner(action, opts, reporters) {
|
|
|
366
560
|
environment,
|
|
367
561
|
cwd,
|
|
368
562
|
reportId: opts.reportId,
|
|
369
|
-
credentials:
|
|
563
|
+
credentials: platformCredentials
|
|
370
564
|
}, opts.redaction));
|
|
371
565
|
containers = /* @__PURE__ */ new Map();
|
|
372
566
|
for (const extension of config.extensions) {
|
|
@@ -376,14 +570,14 @@ async function runStackPipelineInner(action, opts, reporters) {
|
|
|
376
570
|
const instance = await extension.container.ensure({
|
|
377
571
|
appName: resolvedName,
|
|
378
572
|
environment
|
|
379
|
-
},
|
|
573
|
+
}, platformCredentials);
|
|
380
574
|
requireContainerForEnvironment(action, extension.id, extension.container, instance, environment);
|
|
381
575
|
containers.set(extension.id, instance);
|
|
382
576
|
} else {
|
|
383
577
|
const instance = await extension.container.locate({
|
|
384
578
|
appName: resolvedName,
|
|
385
579
|
environment
|
|
386
|
-
},
|
|
580
|
+
}, platformCredentials);
|
|
387
581
|
if (instance === void 0) throw new CliStructuredError("DEPLOY.TARGET_NOT_FOUND", `Nothing deployed for ${resolvedName} in the environment ${environment}.`, { fix: "Deploy it first." });
|
|
388
582
|
requireContainerForEnvironment(action, extension.id, extension.container, instance, environment);
|
|
389
583
|
containers.set(extension.id, instance);
|
|
@@ -395,7 +589,6 @@ async function runStackPipelineInner(action, opts, reporters) {
|
|
|
395
589
|
await attachReporters(reporters, containers, opts.redaction);
|
|
396
590
|
alchemyStage = containers.get(config.state.extension)?.alchemyStage ?? environment;
|
|
397
591
|
steps.finish({ name: "connect" });
|
|
398
|
-
const unset = [];
|
|
399
592
|
if (action === "deploy") {
|
|
400
593
|
steps.start({ name: "preflight" });
|
|
401
594
|
let checked = 0;
|
|
@@ -412,7 +605,7 @@ async function runStackPipelineInner(action, opts, reporters) {
|
|
|
412
605
|
environment,
|
|
413
606
|
configuration: pipeline.configuration,
|
|
414
607
|
secrets: pipeline.secrets,
|
|
415
|
-
credentials:
|
|
608
|
+
credentials: platformCredentials,
|
|
416
609
|
report
|
|
417
610
|
});
|
|
418
611
|
if (payload !== void 0) preflightPayloads.set(extension.id, payload);
|
|
@@ -420,11 +613,6 @@ async function runStackPipelineInner(action, opts, reporters) {
|
|
|
420
613
|
throw toStructured("DEPLOY.PREFLIGHT_FAILED", error);
|
|
421
614
|
}
|
|
422
615
|
}
|
|
423
|
-
try {
|
|
424
|
-
preflightTransportEnv = preflightEnv(preflightPayloads);
|
|
425
|
-
} catch (error) {
|
|
426
|
-
throw toStructured("DEPLOY.PREFLIGHT_FAILED", error);
|
|
427
|
-
}
|
|
428
616
|
steps.finish({ name: "preflight" }, {
|
|
429
617
|
checked,
|
|
430
618
|
unset: unset.length
|
|
@@ -434,12 +622,18 @@ async function runStackPipelineInner(action, opts, reporters) {
|
|
|
434
622
|
findings: { unset }
|
|
435
623
|
});
|
|
436
624
|
}
|
|
437
|
-
for (const extension of config.extensions) preflightTransportEnv[preflightEnvVarName(extension.id)]
|
|
438
|
-
Object.assign(preflightTransportEnv, preflightFindingsEnv({ unset }));
|
|
625
|
+
if (action === "destroy") for (const extension of config.extensions) preflightTransportEnv[preflightEnvVarName(extension.id)] = "";
|
|
439
626
|
} catch (error) {
|
|
440
627
|
if (CliStructuredError.is(error)) return notOk(error);
|
|
441
628
|
throw error;
|
|
442
629
|
}
|
|
630
|
+
if (appConvergeEntry !== void 0) return convergeDeploy(opts, pipeline, appConvergeEntry, {
|
|
631
|
+
containers,
|
|
632
|
+
stage: alchemyStage,
|
|
633
|
+
preflightPayloads,
|
|
634
|
+
findings: { unset },
|
|
635
|
+
env: reporterEnv(reporters, opts.redaction)
|
|
636
|
+
});
|
|
443
637
|
let stackPath;
|
|
444
638
|
const resultFilePath = path$1.join(cwd, ".prisma-composer", `deployment-result-${String(process.pid)}-${randomUUID()}.json`);
|
|
445
639
|
let handover;
|
|
@@ -448,8 +642,8 @@ async function runStackPipelineInner(action, opts, reporters) {
|
|
|
448
642
|
handover = prepareSecondProcess({
|
|
449
643
|
file: deployAppConfigurationFile(cwd, randomUUID()),
|
|
450
644
|
appConfigurationRead: pipeline.graph.appConfigurationRead,
|
|
645
|
+
plainVariableText: {},
|
|
451
646
|
nodeAddresses: nodeAddresses(pipeline.graph),
|
|
452
|
-
secretsKeys: secretsKeys(pipeline.graph),
|
|
453
647
|
knownSecrets: opts.redaction.knownSecrets
|
|
454
648
|
});
|
|
455
649
|
stackPath = writeStackFile({
|
|
@@ -472,7 +666,7 @@ async function runStackPipelineInner(action, opts, reporters) {
|
|
|
472
666
|
containerEnv: containerEnv(containers),
|
|
473
667
|
preflightEnv: preflightTransportEnv,
|
|
474
668
|
env: {
|
|
475
|
-
...
|
|
669
|
+
...reporterEnv(reporters, opts.redaction),
|
|
476
670
|
...handover.env,
|
|
477
671
|
[DEPLOYMENT_RESULT_FILE_ENV]: resultFilePath
|
|
478
672
|
},
|
|
@@ -539,7 +733,7 @@ async function runStackPipelineInner(action, opts, reporters) {
|
|
|
539
733
|
const instance = containers.get(extension.id);
|
|
540
734
|
if (instance === void 0) continue;
|
|
541
735
|
try {
|
|
542
|
-
await extension.container.remove(instance,
|
|
736
|
+
await extension.container.remove(instance, platformCredentials);
|
|
543
737
|
} catch (error) {
|
|
544
738
|
throw toStructured("DEPLOY.CONTAINER_REMOVE_FAILED", error);
|
|
545
739
|
}
|
|
@@ -549,7 +743,6 @@ async function runStackPipelineInner(action, opts, reporters) {
|
|
|
549
743
|
if (CliStructuredError.is(error)) return notOk(error);
|
|
550
744
|
throw error;
|
|
551
745
|
}
|
|
552
|
-
if (action === "deploy") return ok(redactSummary(readDeploymentSummary(resultFilePath), opts.redaction));
|
|
553
746
|
return ok(void 0);
|
|
554
747
|
} finally {
|
|
555
748
|
try {
|
|
@@ -559,7 +752,104 @@ async function runStackPipelineInner(action, opts, reporters) {
|
|
|
559
752
|
handover?.removeFile();
|
|
560
753
|
}
|
|
561
754
|
}
|
|
755
|
+
/** Loaded before anything is created, so a missing or incompatible install fails first. */
|
|
756
|
+
async function prepareAppConvergeEntry(deps, appDir) {
|
|
757
|
+
try {
|
|
758
|
+
return ok(deps.appConvergeEntry ?? await loadAppConvergeEntry(appDir));
|
|
759
|
+
} catch (error) {
|
|
760
|
+
if (CliStructuredError.is(error)) return notOk(error);
|
|
761
|
+
throw error;
|
|
762
|
+
}
|
|
763
|
+
}
|
|
764
|
+
/** The structured failure a converge that did not apply settles as. */
|
|
765
|
+
function convergeFailure(outcome, redact) {
|
|
766
|
+
switch (outcome.kind) {
|
|
767
|
+
case "interrupted": return new CliStructuredError("DEPLOY.INTERRUPTED", "The deploy was interrupted.", {
|
|
768
|
+
why: "It stopped while Alchemy planned or applied it. Resources it had already changed stay as they are.",
|
|
769
|
+
fix: "Deploy again to finish."
|
|
770
|
+
});
|
|
771
|
+
case "refused": return outcome.reason === "already-running" ? new CliStructuredError("DEPLOY.CONVERGE_RUNNING", "Another deploy is already running in this process.", {
|
|
772
|
+
why: "A deploy sets the process's environment and working directory while Alchemy runs, so two cannot overlap.",
|
|
773
|
+
fix: "Wait for the other deploy to finish, or run this one in its own process."
|
|
774
|
+
}) : new CliStructuredError("DEPLOY.WORKER_THREAD", "Deploy cannot run in a worker thread when its cwd is not the process working directory.", {
|
|
775
|
+
why: "Alchemy reads `.env` and keeps `.alchemy` in the working directory, and a worker thread cannot change it.",
|
|
776
|
+
fix: "Call deploy from the main thread, or with the process's working directory as its cwd."
|
|
777
|
+
});
|
|
778
|
+
case "failed": {
|
|
779
|
+
const cause = capFailureCause(redact(withComposerAdvice(convergeReasonsText(outcome.reasons))));
|
|
780
|
+
return new CliStructuredError("DEPLOY.ENGINE_FAILED", `Alchemy could not deploy the app.\n${cause}`, { meta: {
|
|
781
|
+
engineCause: cause,
|
|
782
|
+
reasons: outcome.reasons.map(({ tag, message }) => ({
|
|
783
|
+
tag,
|
|
784
|
+
message: redact(message)
|
|
785
|
+
}))
|
|
786
|
+
} });
|
|
787
|
+
}
|
|
788
|
+
}
|
|
789
|
+
return new CliStructuredError("DEPLOY.ENGINE_FAILED", "The converge ended with an outcome this Composer does not know.");
|
|
790
|
+
}
|
|
791
|
+
/**
|
|
792
|
+
* Deploy's converge: lowers the app with the containers and preflight
|
|
793
|
+
* payloads this run resolved, then plans and applies it in this process.
|
|
794
|
+
* The report hook runs inside the apply, here, so the summary comes back as
|
|
795
|
+
* a value.
|
|
796
|
+
*/
|
|
797
|
+
async function convergeDeploy(opts, pipeline, entry, resolved) {
|
|
798
|
+
const { cwd, environment, steps } = opts;
|
|
799
|
+
const config = pipeline.configSource.value;
|
|
800
|
+
const env = resolved.env;
|
|
801
|
+
opts.redaction.addCredentialLookingValues(credentialLookingValues(env));
|
|
802
|
+
const redact = (text) => opts.redaction.redact(text);
|
|
803
|
+
let summary;
|
|
804
|
+
const root = pipeline.graph.root.node;
|
|
805
|
+
if (root.kind !== "module") throw new InternalError("runPipeline admitted a root that is not a module");
|
|
806
|
+
steps.start({ name: "apply" });
|
|
807
|
+
let stack;
|
|
808
|
+
try {
|
|
809
|
+
stack = entry.lower(root, config, {
|
|
810
|
+
name: pipeline.name,
|
|
811
|
+
environment,
|
|
812
|
+
appConfigurationRead: pipeline.graph.appConfigurationRead,
|
|
813
|
+
firstProcessNodeAddresses: nodeAddresses(pipeline.graph),
|
|
814
|
+
bundles: pipeline.assembled.bundles,
|
|
815
|
+
containers: resolved.containers,
|
|
816
|
+
preflightPayloads: resolved.preflightPayloads,
|
|
817
|
+
findings: resolved.findings,
|
|
818
|
+
credentials: opts.deps.credentials,
|
|
819
|
+
report: (result) => {
|
|
820
|
+
summary = toDeploymentSummary(result);
|
|
821
|
+
}
|
|
822
|
+
});
|
|
823
|
+
} catch (error) {
|
|
824
|
+
if (CliStructuredError.is(error)) return notOk(error);
|
|
825
|
+
return notOk(new CliStructuredError("DEPLOY.ENGINE_FAILED", redact(error instanceof Error ? error.message : String(error))));
|
|
826
|
+
}
|
|
827
|
+
const output = interactionMessages(steps, opts.redaction);
|
|
828
|
+
let outcome;
|
|
829
|
+
try {
|
|
830
|
+
outcome = await entry.converge({
|
|
831
|
+
operation: "deploy",
|
|
832
|
+
stack,
|
|
833
|
+
stage: resolved.stage,
|
|
834
|
+
cwd,
|
|
835
|
+
env,
|
|
836
|
+
signal: opts.signal,
|
|
837
|
+
onEvent: (event) => reportConvergeEvent(steps, event, redact, (resource) => ({
|
|
838
|
+
name: "apply-resource",
|
|
839
|
+
...resource
|
|
840
|
+
})),
|
|
841
|
+
output: (text) => output.push(text)
|
|
842
|
+
});
|
|
843
|
+
} catch (error) {
|
|
844
|
+
return notOk(new CliStructuredError("DEPLOY.ENGINE_FAILED", redact(`Alchemy could not deploy the app.\n${error instanceof Error ? error.message : String(error)}`)));
|
|
845
|
+
} finally {
|
|
846
|
+
output.end();
|
|
847
|
+
}
|
|
848
|
+
if (outcome.kind !== "applied") return notOk(convergeFailure(outcome, redact));
|
|
849
|
+
steps.finish({ name: "apply" });
|
|
850
|
+
return ok(redactSummary(summary, opts.redaction));
|
|
851
|
+
}
|
|
562
852
|
//#endregion
|
|
563
853
|
export { executeDeploy, executeDestroy };
|
|
564
854
|
|
|
565
|
-
//# sourceMappingURL=execute-deploy-destroy-
|
|
855
|
+
//# sourceMappingURL=execute-deploy-destroy-DN16ETAk-BaopEKsA.mjs.map
|