@prisma/composer-cli 0.39.0-dev.1 → 0.39.0-dev.10
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-converge-C_YkTIBF-RmqGOR45.mjs +88 -0
- package/dist/app-converge-C_YkTIBF-RmqGOR45.mjs.map +1 -0
- package/dist/composer-config-QKdY85G--CEXrb2Uc.mjs +254 -0
- package/dist/composer-config-QKdY85G--CEXrb2Uc.mjs.map +1 -0
- package/dist/{validate-environment-D1BTCkTs-C5m4rL6t.mjs → deploy-Br1yvLe3.mjs} +335 -1091
- package/dist/deploy-Br1yvLe3.mjs.map +1 -0
- package/dist/dev-converge-messages-DML4rTz7-B6uxtpZG.mjs +256 -0
- package/dist/dev-converge-messages-DML4rTz7-B6uxtpZG.mjs.map +1 -0
- package/dist/dev-converge-worker.d.mts +1 -0
- package/dist/dev-converge-worker.mjs +143 -0
- package/dist/dev-converge-worker.mjs.map +1 -0
- package/dist/{dev-current-wD5YDLjA-CFI8XTAK.mjs → dev-current-DANgmcle-RwunETUJ.mjs} +12 -18
- package/dist/dev-current-DANgmcle-RwunETUJ.mjs.map +1 -0
- package/dist/dev-environment-name-6eEr5PW8-CCY7WNWz.mjs +43 -0
- package/dist/dev-environment-name-6eEr5PW8-CCY7WNWz.mjs.map +1 -0
- package/dist/{dist-D0rWRHos.mjs → dist-C0OGaDnj.mjs} +4 -3
- package/dist/{dist-D0rWRHos.mjs.map → dist-C0OGaDnj.mjs.map} +1 -1
- package/dist/errors-CVYwN2km.mjs +93 -0
- package/dist/errors-CVYwN2km.mjs.map +1 -0
- package/dist/{execute-deploy-destroy-DOzo2Psp-2iWcFbD9.mjs → execute-deploy-destroy-DIR9uvA_-Bk0HBMTz.mjs} +374 -141
- package/dist/execute-deploy-destroy-DIR9uvA_-Bk0HBMTz.mjs.map +1 -0
- package/dist/{execute-dev-BIyOI3Ys-DGpTd9rP.mjs → execute-dev-Cu9_LsQi-CsyIqphZ.mjs} +444 -128
- package/dist/execute-dev-Cu9_LsQi-CsyIqphZ.mjs.map +1 -0
- package/dist/{execute-dev-current-CKOzjWuO-DTOVqZzZ.mjs → execute-dev-current-Bs0lE_5--BU3A2hsC.mjs} +9 -6
- package/dist/{execute-dev-current-CKOzjWuO-DTOVqZzZ.mjs.map → execute-dev-current-Bs0lE_5--BU3A2hsC.mjs.map} +1 -1
- package/dist/{redaction-Bf8FvTFH-XGchRgrK.d.mts → family-DfwviKFj-CS1L-EvS.d.mts} +439 -204
- package/dist/family-DfwviKFj-CS1L-EvS.d.mts.map +1 -0
- package/dist/family.d.mts +1 -1
- package/dist/family.mjs +259 -269
- package/dist/family.mjs.map +1 -1
- package/dist/internal-error-Dfur7Zqt-B8J8e7ac.mjs +58 -0
- package/dist/internal-error-Dfur7Zqt-B8J8e7ac.mjs.map +1 -0
- package/dist/{list-deployed-BFJJxt_W.mjs → list-deployed-slo4P7dl.mjs} +6 -5
- package/dist/list-deployed-slo4P7dl.mjs.map +1 -0
- package/dist/local-target-CZzICh5R.mjs +34 -0
- package/dist/local-target-CZzICh5R.mjs.map +1 -0
- package/dist/{preflight-transport-DmmtoFPH-CZ0o7QPf.mjs → preflight-transport-2d6iIchu-ArIJUY1L.mjs} +7 -28
- package/dist/preflight-transport-2d6iIchu-ArIJUY1L.mjs.map +1 -0
- package/dist/{redaction-DXung4ip-Co_fv4Zl.mjs → redaction-DY6eDC12-BrK1aSN5.mjs} +33 -267
- package/dist/redaction-DY6eDC12-BrK1aSN5.mjs.map +1 -0
- package/dist/result-CttmabB6.mjs +91 -0
- package/dist/result-CttmabB6.mjs.map +1 -0
- package/dist/rolldown-runtime-C7HZzL1F.mjs +26 -0
- package/dist/steps-BZXNqW6U-BM2Aa8Bp.mjs +287 -0
- package/dist/steps-BZXNqW6U-BM2Aa8Bp.mjs.map +1 -0
- package/dist/testing.d.mts +4 -49
- package/dist/testing.d.mts.map +1 -1
- package/dist/testing.mjs +2 -75
- package/dist/testing.mjs.map +1 -1
- package/dist/validate-environment-DCZiNSlR-idVge-kq.mjs +983 -0
- package/dist/validate-environment-DCZiNSlR-idVge-kq.mjs.map +1 -0
- package/dist/value-reads-change-text-DcRCv7Zy-Ca8m3bal.mjs +15 -0
- package/dist/value-reads-change-text-DcRCv7Zy-Ca8m3bal.mjs.map +1 -0
- package/package.json +9 -9
- package/src/exports/dev-converge-worker.ts +2 -0
- package/src/exports/testing.ts +1 -4
- package/dist/app-configuration-file-CeJvBAti-DA4EKwFq.mjs +0 -140
- package/dist/app-configuration-file-CeJvBAti-DA4EKwFq.mjs.map +0 -1
- package/dist/dev-current-wD5YDLjA-CFI8XTAK.mjs.map +0 -1
- package/dist/dev-environment-name-6eEr5PW8-Bs4Dl0vW.mjs +0 -71
- package/dist/dev-environment-name-6eEr5PW8-Bs4Dl0vW.mjs.map +0 -1
- package/dist/execute-deploy-destroy-DOzo2Psp-2iWcFbD9.mjs.map +0 -1
- package/dist/execute-dev-BIyOI3Ys-DGpTd9rP.mjs.map +0 -1
- package/dist/generate-dev-stack-BV_n-X9n-DM5faH3-.mjs +0 -100
- package/dist/generate-dev-stack-BV_n-X9n-DM5faH3-.mjs.map +0 -1
- package/dist/list-deployed-BFJJxt_W.mjs.map +0 -1
- package/dist/preflight-transport-DmmtoFPH-CZ0o7QPf.mjs.map +0 -1
- package/dist/redaction-Bf8FvTFH-XGchRgrK.d.mts.map +0 -1
- package/dist/redaction-DXung4ip-Co_fv4Zl.mjs.map +0 -1
- package/dist/result-sR7PBi61.mjs +0 -229
- package/dist/result-sR7PBi61.mjs.map +0 -1
- package/dist/run-alchemy-CRLAyOtt-CwFLe4Zg.mjs +0 -236
- package/dist/run-alchemy-CRLAyOtt-CwFLe4Zg.mjs.map +0 -1
- package/dist/validate-environment-D1BTCkTs-C5m4rL6t.mjs.map +0 -1
|
@@ -0,0 +1,287 @@
|
|
|
1
|
+
import { t as CliStructuredError } from "./errors-CVYwN2km.mjs";
|
|
2
|
+
import { n as StreamRedactor } from "./redaction-DY6eDC12-BrK1aSN5.mjs";
|
|
3
|
+
import { t as DEV_DIR } from "./app-config-CErnR6NK-DnKH4Kqc.mjs";
|
|
4
|
+
import * as fs from "node:fs";
|
|
5
|
+
import * as path from "node:path";
|
|
6
|
+
import "node:util";
|
|
7
|
+
//#region ../../0-framework/3-tooling/cli/dist/deployment-summary-CVJZn2v0.mjs
|
|
8
|
+
/**
|
|
9
|
+
* The deploy result as data, and what a stack file run as a child hands back
|
|
10
|
+
* to the CLI: the summary file the report hook writes, and the failure cause
|
|
11
|
+
* the child records when it exits non-zero. `DeploymentResult` holds live
|
|
12
|
+
* graph nodes (ADR-0033), so the summary keeps only what can be serialized.
|
|
13
|
+
* Both files are best-effort: a write failure never fails the child.
|
|
14
|
+
*/
|
|
15
|
+
/** Env var the deploy operation sets on the alchemy child: when present,
|
|
16
|
+
* the report hook also writes the JSON DeploymentSummary there. */
|
|
17
|
+
const DEPLOYMENT_RESULT_FILE_ENV = "PRISMA_COMPOSER_DEPLOYMENT_RESULT_FILE";
|
|
18
|
+
/** Pure projection: keeps app, each node's address/entities and the findings, drops the in-process `node`. */
|
|
19
|
+
function toDeploymentSummary(result) {
|
|
20
|
+
return {
|
|
21
|
+
app: result.app,
|
|
22
|
+
nodes: result.nodes.map((node) => ({
|
|
23
|
+
address: node.address,
|
|
24
|
+
entities: node.entities
|
|
25
|
+
})),
|
|
26
|
+
findings: result.findings
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
/** The child's failure cause rides beside the result file, so the one env var names both and the parent's cleanup removes both. */
|
|
30
|
+
function engineFailureFilePath(resultFilePath) {
|
|
31
|
+
return `${resultFilePath}.failure.txt`;
|
|
32
|
+
}
|
|
33
|
+
/** Fits the platform's 5000-character build `errorMessage` with room for the exit-status prefix. */
|
|
34
|
+
const ENGINE_FAILURE_CAUSE_LIMIT = 1e3;
|
|
35
|
+
/** Alchemy's advice to rerun its own CLI with `--adopt` or to import a resource with adoption, which a Composer user has no way to do. */
|
|
36
|
+
const ALCHEMY_ADOPT_ADVICE = [
|
|
37
|
+
[/Re-run with `--adopt` \(or wrap the effect in `adopt\(true\)`\) to take it over\./g, "Something other than this app holds it. Remove that resource, then deploy again."],
|
|
38
|
+
[/Re-run with `--adopt` \(or wrap the effect in `adopt\(true\)`\) to replace it anyway\./g, "Remove that resource, then deploy again."],
|
|
39
|
+
[/\(re-deploy with --adopt to take ownership, then destroy\)/g, "(remove it by hand)"],
|
|
40
|
+
[/Import it with explicit adoption (?:instead of silently taking it over|or choose a different [\w ]+ name)\./g, "Something other than this app holds it. Remove that resource, then deploy again."],
|
|
41
|
+
[/; rerun with adoption enabled if it is the intended [\w ]+\./g, ". Remove that resource, then deploy again."]
|
|
42
|
+
];
|
|
43
|
+
/** Replaces Alchemy CLI advice in engine output with steps that work from Composer. */
|
|
44
|
+
function withComposerAdvice(text) {
|
|
45
|
+
return ALCHEMY_ADOPT_ADVICE.reduce((current, [advice, replacement]) => current.replace(advice, replacement), text);
|
|
46
|
+
}
|
|
47
|
+
/** Parent half: the cause the child recorded, passed through `redact`, or undefined when it recorded none. The child redacts only what its own environment names as a credential; the parent also knows the known secrets. */
|
|
48
|
+
function readEngineFailureCause(resultFilePath, redact) {
|
|
49
|
+
let cause;
|
|
50
|
+
try {
|
|
51
|
+
cause = fs.readFileSync(engineFailureFilePath(resultFilePath), "utf8");
|
|
52
|
+
} catch {
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
return cause.length > 0 ? redact(cause) : void 0;
|
|
56
|
+
}
|
|
57
|
+
/** A failure cause capped to fit the platform build's error message. */
|
|
58
|
+
function capFailureCause(cause) {
|
|
59
|
+
return cause.length <= ENGINE_FAILURE_CAUSE_LIMIT ? cause : `${cause.slice(0, ENGINE_FAILURE_CAUSE_LIMIT - 1)}…`;
|
|
60
|
+
}
|
|
61
|
+
//#endregion
|
|
62
|
+
//#region ../../0-framework/3-tooling/cli/dist/app-configuration-file-D0rB5g65.mjs
|
|
63
|
+
function textIn(value, at) {
|
|
64
|
+
if (typeof value === "string") return [{
|
|
65
|
+
at,
|
|
66
|
+
text: value
|
|
67
|
+
}];
|
|
68
|
+
if (typeof value === "number" || typeof value === "boolean" || typeof value === "bigint") return [{
|
|
69
|
+
at,
|
|
70
|
+
text: String(value)
|
|
71
|
+
}];
|
|
72
|
+
if (Array.isArray(value)) return value.flatMap((member, index) => textIn(member, [...at, String(index)]));
|
|
73
|
+
if (typeof value === "object" && value !== null) return Object.entries(value).flatMap(([key, member]) => textIn(member, [...at, key]));
|
|
74
|
+
return [];
|
|
75
|
+
}
|
|
76
|
+
/** Throws `CONFIG.SECRET_AS_PLAIN_VALUE` when a root input field Load read holds a known secret. */
|
|
77
|
+
function refuseSecretsInRootInput(read, knownSecrets, consequence) {
|
|
78
|
+
const readPlaces = read.rootInput.flatMap((field) => textIn(field.value, field.path).map(({ at, text }) => ({
|
|
79
|
+
where: `Root input field input.${at.join(".")}`,
|
|
80
|
+
text
|
|
81
|
+
})));
|
|
82
|
+
for (const { where, text } of readPlaces) {
|
|
83
|
+
const name = knownSecrets.nameIn(text);
|
|
84
|
+
if (name === void 0) continue;
|
|
85
|
+
throw new CliStructuredError("CONFIG.SECRET_AS_PLAIN_VALUE", `${where} holds the value of the platform secret "${name}". ${consequence}`, { fix: `Pass the value of the platform secret "${name}" to where this value is used, or give this plain value text that does not contain the value of "${name}".` });
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
/** Throws `CONFIG.SECRET_AS_PLAIN_VALUE` when a plain platform variable's text holds a known secret. */
|
|
89
|
+
function refuseSecretsInPlainVariables(plainVariableText, knownSecrets, consequence) {
|
|
90
|
+
for (const [variable, text] of Object.entries(plainVariableText)) {
|
|
91
|
+
const name = knownSecrets.nameIn(text);
|
|
92
|
+
if (name === void 0) continue;
|
|
93
|
+
throw new CliStructuredError("CONFIG.SECRET_AS_PLAIN_VALUE", `The platform variable "${variable}", which prisma dev read from the \`config\` adapters, holds the value of the platform secret "${name}". ${consequence}`, { fix: `Keep the value of "${name}" out of the platform variable "${variable}", or give "${variable}" a different value.` });
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
/** Names the app configuration file the first process wrote for this run (ADR-0062). */
|
|
97
|
+
const APP_CONFIGURATION_FILE_ENV = "PRISMA_COMPOSER_APP_CONFIGURATION_FILE";
|
|
98
|
+
const FILE_NAME = /^app-configuration-(\d+)(-[^/]*)?\.json$/;
|
|
99
|
+
/** The app configuration file a destroy run writes: unique per run, so concurrent runs from one checkout never share one. */
|
|
100
|
+
function deployAppConfigurationFile(cwd, runId) {
|
|
101
|
+
return path.join(cwd, ".prisma-composer", `app-configuration-${String(process.pid)}-${runId}.json`);
|
|
102
|
+
}
|
|
103
|
+
function isRunning(pid) {
|
|
104
|
+
try {
|
|
105
|
+
process.kill(pid, 0);
|
|
106
|
+
return true;
|
|
107
|
+
} catch (error) {
|
|
108
|
+
return error instanceof Error && "code" in error && error.code === "EPERM";
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Deletes the app configuration files that earlier runs left in `.prisma-composer/` and in
|
|
113
|
+
* each dev environment's folder: a run killed before its exit handler ran leaves its file. A
|
|
114
|
+
* file is deleted only when its process is not running and it is older than
|
|
115
|
+
* `LEFTOVER_APP_CONFIGURATION_FILE_AGE_MS`. Never throws.
|
|
116
|
+
*/
|
|
117
|
+
function removeLeftoverAppConfigurationFiles(cwd) {
|
|
118
|
+
const devRoot = path.join(cwd, DEV_DIR);
|
|
119
|
+
const dirs = [path.join(cwd, ".prisma-composer")];
|
|
120
|
+
try {
|
|
121
|
+
for (const entry of fs.readdirSync(devRoot, { withFileTypes: true })) if (entry.isDirectory()) dirs.push(path.join(devRoot, entry.name));
|
|
122
|
+
} catch {}
|
|
123
|
+
for (const dir of dirs) {
|
|
124
|
+
let names;
|
|
125
|
+
try {
|
|
126
|
+
names = fs.readdirSync(dir);
|
|
127
|
+
} catch {
|
|
128
|
+
continue;
|
|
129
|
+
}
|
|
130
|
+
for (const name of names) {
|
|
131
|
+
const pid = Number(FILE_NAME.exec(name)?.[1]);
|
|
132
|
+
if (Number.isNaN(pid) || pid === process.pid || isRunning(pid)) continue;
|
|
133
|
+
const file = path.join(dir, name);
|
|
134
|
+
try {
|
|
135
|
+
if (Date.now() - fs.statSync(file).mtimeMs < 6e5) continue;
|
|
136
|
+
fs.rmSync(file, { force: true });
|
|
137
|
+
} catch {}
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* First process: the app configuration file and the environment the second process starts with (ADR-0062).
|
|
143
|
+
* Refuses a file that would hold any of `knownSecrets`.
|
|
144
|
+
*/
|
|
145
|
+
function prepareSecondProcess(input) {
|
|
146
|
+
const { file } = input;
|
|
147
|
+
refuseSecretsInRootInput(input.appConfigurationRead, input.knownSecrets, "Composer hands the second process every plain value Load read, in a file, and never writes a secret to a file.");
|
|
148
|
+
refuseSecretsInPlainVariables(input.plainVariableText, input.knownSecrets, "Composer hands the second process every plain value in a file, and never writes a secret to a file.");
|
|
149
|
+
const contents = {
|
|
150
|
+
appConfigurationRead: input.appConfigurationRead,
|
|
151
|
+
plainVariableText: input.plainVariableText,
|
|
152
|
+
nodeAddresses: input.nodeAddresses
|
|
153
|
+
};
|
|
154
|
+
const env = { [APP_CONFIGURATION_FILE_ENV]: file };
|
|
155
|
+
const remove = () => {
|
|
156
|
+
try {
|
|
157
|
+
fs.rmSync(file, { force: true });
|
|
158
|
+
} catch {}
|
|
159
|
+
};
|
|
160
|
+
return {
|
|
161
|
+
env,
|
|
162
|
+
writeFile() {
|
|
163
|
+
fs.rmSync(file, { force: true });
|
|
164
|
+
fs.writeFileSync(file, JSON.stringify(contents), {
|
|
165
|
+
mode: 384,
|
|
166
|
+
flag: "wx"
|
|
167
|
+
});
|
|
168
|
+
process.off("exit", remove);
|
|
169
|
+
process.on("exit", remove);
|
|
170
|
+
},
|
|
171
|
+
removeFile() {
|
|
172
|
+
process.off("exit", remove);
|
|
173
|
+
remove();
|
|
174
|
+
}
|
|
175
|
+
};
|
|
176
|
+
}
|
|
177
|
+
//#endregion
|
|
178
|
+
//#region ../../0-framework/3-tooling/cli/dist/steps-BZXNqW6U.mjs
|
|
179
|
+
/**
|
|
180
|
+
* Times each step for the host's `onEvent`. Steps are matched by `keyOf`, so
|
|
181
|
+
* a step can finish under a newer status than it started with. `emit` sends
|
|
182
|
+
* the operation's other events. A host `onEvent` that throws is the host's
|
|
183
|
+
* bug and cannot fail the operation.
|
|
184
|
+
*/
|
|
185
|
+
function stepTracker(keyOf, onEvent) {
|
|
186
|
+
const open = /* @__PURE__ */ new Map();
|
|
187
|
+
const emit = (event) => {
|
|
188
|
+
try {
|
|
189
|
+
onEvent?.(event);
|
|
190
|
+
} catch {}
|
|
191
|
+
};
|
|
192
|
+
const finish = (step, outcome, data) => {
|
|
193
|
+
const entry = open.get(keyOf(step));
|
|
194
|
+
if (entry === void 0) return;
|
|
195
|
+
open.delete(keyOf(step));
|
|
196
|
+
const durationMs = Math.round(performance.now() - entry.startedAt);
|
|
197
|
+
emit({
|
|
198
|
+
kind: "step-finished",
|
|
199
|
+
step,
|
|
200
|
+
outcome,
|
|
201
|
+
durationMs,
|
|
202
|
+
data
|
|
203
|
+
});
|
|
204
|
+
};
|
|
205
|
+
return {
|
|
206
|
+
start(step) {
|
|
207
|
+
open.set(keyOf(step), {
|
|
208
|
+
step,
|
|
209
|
+
startedAt: performance.now()
|
|
210
|
+
});
|
|
211
|
+
emit({
|
|
212
|
+
kind: "step-started",
|
|
213
|
+
step
|
|
214
|
+
});
|
|
215
|
+
},
|
|
216
|
+
finish(step, data) {
|
|
217
|
+
finish(step, "ok", data);
|
|
218
|
+
},
|
|
219
|
+
fail(step) {
|
|
220
|
+
finish(step, "failed");
|
|
221
|
+
},
|
|
222
|
+
/** Closes every open step with `outcome`, innermost first. */
|
|
223
|
+
closeOpen(outcome) {
|
|
224
|
+
for (const { step } of [...open.values()].reverse()) finish(step, outcome);
|
|
225
|
+
},
|
|
226
|
+
isOpen(step) {
|
|
227
|
+
return open.has(keyOf(step));
|
|
228
|
+
},
|
|
229
|
+
message(severity, text) {
|
|
230
|
+
emit({
|
|
231
|
+
kind: "message",
|
|
232
|
+
severity,
|
|
233
|
+
text
|
|
234
|
+
});
|
|
235
|
+
},
|
|
236
|
+
emit
|
|
237
|
+
};
|
|
238
|
+
}
|
|
239
|
+
/** One converge event as step events: each resource is a step, made by `resourceStep`; a log line is a message. */
|
|
240
|
+
function reportConvergeEvent(steps, event, redact, resourceStep) {
|
|
241
|
+
if (event.kind === "log") {
|
|
242
|
+
steps.message(event.severity, redact(withComposerAdvice(event.text)));
|
|
243
|
+
return;
|
|
244
|
+
}
|
|
245
|
+
const step = resourceStep({
|
|
246
|
+
resourceId: event.fqn,
|
|
247
|
+
resourceType: event.resourceType,
|
|
248
|
+
status: event.status
|
|
249
|
+
});
|
|
250
|
+
switch (event.phase) {
|
|
251
|
+
case "running":
|
|
252
|
+
if (!steps.isOpen(step)) steps.start(step);
|
|
253
|
+
return;
|
|
254
|
+
case "done":
|
|
255
|
+
if (!steps.isOpen(step)) steps.start(step);
|
|
256
|
+
steps.finish(step);
|
|
257
|
+
return;
|
|
258
|
+
case "failed":
|
|
259
|
+
if (!steps.isOpen(step)) steps.start(step);
|
|
260
|
+
steps.fail(step);
|
|
261
|
+
if (event.message !== void 0) steps.message("warn", redact(`${event.fqn}: ${withComposerAdvice(event.message)}`));
|
|
262
|
+
return;
|
|
263
|
+
case "pending": return;
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
/**
|
|
267
|
+
* Alchemy's terminal text as `info` messages, one per complete line, redacted. A secret split
|
|
268
|
+
* across writes or lines is still found, because the text passes through a `StreamRedactor`
|
|
269
|
+
* before it is cut into lines. `end` sends the last line that has no line break.
|
|
270
|
+
*/
|
|
271
|
+
function interactionMessages(steps, redaction) {
|
|
272
|
+
const stream = new StreamRedactor(redaction.allValues());
|
|
273
|
+
let partial = "";
|
|
274
|
+
const send = (text, last) => {
|
|
275
|
+
const lines = (partial + text).split("\n");
|
|
276
|
+
partial = last ? "" : lines.pop() ?? "";
|
|
277
|
+
for (const line of lines) if (line.trim() !== "") steps.message("info", redaction.redact(line));
|
|
278
|
+
};
|
|
279
|
+
return {
|
|
280
|
+
push: (text) => send(stream.push(text), false),
|
|
281
|
+
end: () => send(stream.end(), true)
|
|
282
|
+
};
|
|
283
|
+
}
|
|
284
|
+
//#endregion
|
|
285
|
+
export { prepareSecondProcess as a, removeLeftoverAppConfigurationFiles as c, engineFailureFilePath as d, readEngineFailureCause as f, deployAppConfigurationFile as i, DEPLOYMENT_RESULT_FILE_ENV as l, withComposerAdvice as m, reportConvergeEvent as n, refuseSecretsInPlainVariables as o, toDeploymentSummary as p, stepTracker as r, refuseSecretsInRootInput as s, interactionMessages as t, capFailureCause as u };
|
|
286
|
+
|
|
287
|
+
//# sourceMappingURL=steps-BZXNqW6U-BM2Aa8Bp.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"steps-BZXNqW6U-BM2Aa8Bp.mjs","names":[],"sources":["../../../0-framework/3-tooling/cli/dist/deployment-summary-CVJZn2v0.mjs","../../../0-framework/3-tooling/cli/dist/app-configuration-file-D0rB5g65.mjs","../../../0-framework/3-tooling/cli/dist/steps-BZXNqW6U.mjs"],"sourcesContent":["import { i as redactCredentialLooking } from \"./redaction-DY6eDC12.mjs\";\nimport * as fs from \"node:fs\";\nimport { format, stripVTControlCharacters } from \"node:util\";\n//#region src/deployment-summary.ts\n/**\n* The deploy result as data, and what a stack file run as a child hands back\n* to the CLI: the summary file the report hook writes, and the failure cause\n* the child records when it exits non-zero. `DeploymentResult` holds live\n* graph nodes (ADR-0033), so the summary keeps only what can be serialized.\n* Both files are best-effort: a write failure never fails the child.\n*/\n/** Env var the deploy operation sets on the alchemy child: when present,\n* the report hook also writes the JSON DeploymentSummary there. */\nconst DEPLOYMENT_RESULT_FILE_ENV = \"PRISMA_COMPOSER_DEPLOYMENT_RESULT_FILE\";\n/** Pure projection: keeps app, each node's address/entities and the findings, drops the in-process `node`. */\nfunction toDeploymentSummary(result) {\n\treturn {\n\t\tapp: result.app,\n\t\tnodes: result.nodes.map((node) => ({\n\t\t\taddress: node.address,\n\t\t\tentities: node.entities\n\t\t})),\n\t\tfindings: result.findings\n\t};\n}\n/**\n* Writer half, called by the report hook inside the alchemy child: when the\n* env var names a file, write the summary there. Best-effort — a write\n* failure must not fail a deploy that already converged, so it is swallowed.\n*/\nfunction writeDeploymentSummaryFile(result) {\n\tconst file = process.env[DEPLOYMENT_RESULT_FILE_ENV];\n\tif (file === void 0 || file.length === 0) return;\n\ttry {\n\t\tfs.writeFileSync(file, JSON.stringify(toDeploymentSummary(result)));\n\t} catch {}\n}\n/** The child's failure cause rides beside the result file, so the one env var names both and the parent's cleanup removes both. */\nfunction engineFailureFilePath(resultFilePath) {\n\treturn `${resultFilePath}.failure.txt`;\n}\n/** Fits the platform's 5000-character build `errorMessage` with room for the exit-status prefix. */\nconst ENGINE_FAILURE_CAUSE_LIMIT = 1e3;\n/** Alchemy's advice to rerun its own CLI with `--adopt` or to import a resource with adoption, which a Composer user has no way to do. */\nconst ALCHEMY_ADOPT_ADVICE = [\n\t[/Re-run with `--adopt` \\(or wrap the effect in `adopt\\(true\\)`\\) to take it over\\./g, \"Something other than this app holds it. Remove that resource, then deploy again.\"],\n\t[/Re-run with `--adopt` \\(or wrap the effect in `adopt\\(true\\)`\\) to replace it anyway\\./g, \"Remove that resource, then deploy again.\"],\n\t[/\\(re-deploy with --adopt to take ownership, then destroy\\)/g, \"(remove it by hand)\"],\n\t[/Import it with explicit adoption (?:instead of silently taking it over|or choose a different [\\w ]+ name)\\./g, \"Something other than this app holds it. Remove that resource, then deploy again.\"],\n\t[/; rerun with adoption enabled if it is the intended [\\w ]+\\./g, \". Remove that resource, then deploy again.\"]\n];\n/** Replaces Alchemy CLI advice in engine output with steps that work from Composer. */\nfunction withComposerAdvice(text) {\n\treturn ALCHEMY_ADOPT_ADVICE.reduce((current, [advice, replacement]) => current.replace(advice, replacement), text);\n}\nconst STDOUT_CONSOLE_METHODS = /* @__PURE__ */ new Set([\n\t\"log\",\n\t\"info\",\n\t\"debug\"\n]);\n/**\n* Child half of the failure protocol, called by the generated stack file.\n* Keeps a bounded tail of everything this process logs through `console`,\n* passing every call through except Alchemy's CLI advice (see\n* {@link withComposerAdvice}), and on a non-zero exit writes the\n* redacted cause beside the result file. `console`, not the output streams:\n* alchemy's logger and its error reporting both go through it, and under Bun\n* `console` does not reach `process.stdout.write`.\n*\n* When stdout is not a terminal it carries the parent's data lines, so\n* everything this process prints goes to stderr instead.\n*/\nfunction captureEngineFailure() {\n\tconst resultFile = process.env[DEPLOYMENT_RESULT_FILE_ENV];\n\tif (resultFile === void 0 || resultFile.length === 0) return;\n\tconst stdoutToStderr = process.stdout.isTTY !== true;\n\tif (stdoutToStderr) process.stdout.write = process.stderr.write.bind(process.stderr);\n\tlet tail = \"\";\n\tfor (const method of [\n\t\t\"log\",\n\t\t\"info\",\n\t\t\"warn\",\n\t\t\"error\",\n\t\t\"debug\"\n\t]) {\n\t\tconst original = stdoutToStderr && STDOUT_CONSOLE_METHODS.has(method) ? console.error : console[method];\n\t\tconsole[method] = (...args) => {\n\t\t\tconst text = format(...args);\n\t\t\tconst shown = withComposerAdvice(text);\n\t\t\ttail = `${tail}${redactCredentialLooking(shown, process.env)}\\n`.slice(-65536);\n\t\t\tif (shown === text) original.apply(console, args);\n\t\t\telse original.call(console, shown);\n\t\t};\n\t}\n\tprocess.once(\"exit\", (code) => {\n\t\tif (code === 0) return;\n\t\tconst cause = engineFailureCause(tail, process.env);\n\t\tif (cause === void 0) return;\n\t\ttry {\n\t\t\tfs.writeFileSync(engineFailureFilePath(resultFile), cause);\n\t\t} catch {}\n\t});\n}\n/** Parent half: the cause the child recorded, passed through `redact`, or undefined when it recorded none. The child redacts only what its own environment names as a credential; the parent also knows the known secrets. */\nfunction readEngineFailureCause(resultFilePath, redact) {\n\tlet cause;\n\ttry {\n\t\tcause = fs.readFileSync(engineFailureFilePath(resultFilePath), \"utf8\");\n\t} catch {\n\t\treturn;\n\t}\n\treturn cause.length > 0 ? redact(cause) : void 0;\n}\n/** Effect's pretty log prefix, e.g. `[10:29:16.556] INFO (#53): `. */\nconst LOG_PREFIX = /^\\[[\\d:.]+\\] ([A-Z]+) \\(#\\d+\\): ?/;\n/** Alchemy's per-resource failure row, e.g. `[web] fail — UnknownError: …`. */\nconst RESOURCE_FAIL_ROW = /^\\[[^\\]]+\\] fail\\b/;\nconst STACK_FRAME = /^\\s*at /;\n/**\n* The failure the output describes: every line from the first failure line\n* (a failed resource row, an ERROR log, or an `error:` line) to the end, minus\n* blank lines, stack frames and info logs; the last five lines when there is no\n* failure line. Redacted, then capped.\n*/\nfunction engineFailureCause(output, env) {\n\tconst lines = [];\n\tfor (const raw of stripVTControlCharacters(output).split(/\\r\\n|\\r|\\n/)) {\n\t\tconst clean = raw.replace(/(?![\\t])\\p{Cc}/gu, \"\").trimEnd();\n\t\tconst prefix = LOG_PREFIX.exec(clean);\n\t\tconst text = (prefix === null ? clean : clean.slice(prefix[0].length)).trim();\n\t\tif (text.length === 0 || text === \"{\" || text === \"}\" || STACK_FRAME.test(text)) continue;\n\t\tconst level = prefix?.[1];\n\t\tconst failure = level === \"ERROR\" || level === \"FATAL\" || RESOURCE_FAIL_ROW.test(text) || /^\\W*error:/i.test(text);\n\t\tlines.push({\n\t\t\ttext,\n\t\t\tfailure,\n\t\t\tinfo: !failure && level !== void 0\n\t\t});\n\t}\n\tconst start = lines.findIndex((line) => line.failure);\n\tconst kept = start === -1 ? lines.slice(-5) : lines.slice(start).filter((line) => !line.info);\n\tif (kept.length === 0) return void 0;\n\tconst cause = redactCredentialLooking(kept.map((line) => line.text).join(\"\\n\"), env);\n\treturn cause.length <= ENGINE_FAILURE_CAUSE_LIMIT ? cause : `${cause.slice(0, ENGINE_FAILURE_CAUSE_LIMIT - 1)}…`;\n}\n/** A failure cause capped to fit the platform build's error message. */\nfunction capFailureCause(cause) {\n\treturn cause.length <= ENGINE_FAILURE_CAUSE_LIMIT ? cause : `${cause.slice(0, ENGINE_FAILURE_CAUSE_LIMIT - 1)}…`;\n}\n//#endregion\nexport { readEngineFailureCause as a, writeDeploymentSummaryFile as c, engineFailureFilePath as i, capFailureCause as n, toDeploymentSummary as o, captureEngineFailure as r, withComposerAdvice as s, DEPLOYMENT_RESULT_FILE_ENV as t };\n\n//# sourceMappingURL=deployment-summary-CVJZn2v0.mjs.map","import * as fs from \"node:fs\";\nimport * as path from \"node:path\";\nimport { CliStructuredError } from \"@internal/foundation/errors\";\nimport { DEV_DIR } from \"@internal/core/config\";\n//#region src/secret-as-plain-value.ts\nfunction textIn(value, at) {\n\tif (typeof value === \"string\") return [{\n\t\tat,\n\t\ttext: value\n\t}];\n\tif (typeof value === \"number\" || typeof value === \"boolean\" || typeof value === \"bigint\") return [{\n\t\tat,\n\t\ttext: String(value)\n\t}];\n\tif (Array.isArray(value)) return value.flatMap((member, index) => textIn(member, [...at, String(index)]));\n\tif (typeof value === \"object\" && value !== null) return Object.entries(value).flatMap(([key, member]) => textIn(member, [...at, key]));\n\treturn [];\n}\n/** Throws `CONFIG.SECRET_AS_PLAIN_VALUE` when a root input field Load read holds a known secret. */\nfunction refuseSecretsInRootInput(read, knownSecrets, consequence) {\n\tconst readPlaces = read.rootInput.flatMap((field) => textIn(field.value, field.path).map(({ at, text }) => ({\n\t\twhere: `Root input field input.${at.join(\".\")}`,\n\t\ttext\n\t})));\n\tfor (const { where, text } of readPlaces) {\n\t\tconst name = knownSecrets.nameIn(text);\n\t\tif (name === void 0) continue;\n\t\tthrow new CliStructuredError(\"CONFIG.SECRET_AS_PLAIN_VALUE\", `${where} holds the value of the platform secret \"${name}\". ${consequence}`, { fix: `Pass the value of the platform secret \"${name}\" to where this value is used, or give this plain value text that does not contain the value of \"${name}\".` });\n\t}\n}\n/** Throws `CONFIG.SECRET_AS_PLAIN_VALUE` when a plain platform variable's text holds a known secret. */\nfunction refuseSecretsInPlainVariables(plainVariableText, knownSecrets, consequence) {\n\tfor (const [variable, text] of Object.entries(plainVariableText)) {\n\t\tconst name = knownSecrets.nameIn(text);\n\t\tif (name === void 0) continue;\n\t\tthrow new CliStructuredError(\"CONFIG.SECRET_AS_PLAIN_VALUE\", `The platform variable \"${variable}\", which prisma dev read from the \\`config\\` adapters, holds the value of the platform secret \"${name}\". ${consequence}`, { fix: `Keep the value of \"${name}\" out of the platform variable \"${variable}\", or give \"${variable}\" a different value.` });\n\t}\n}\n//#endregion\n//#region src/app-configuration-file.ts\n/** Names the app configuration file the first process wrote for this run (ADR-0062). */\nconst APP_CONFIGURATION_FILE_ENV = \"PRISMA_COMPOSER_APP_CONFIGURATION_FILE\";\nconst FILE_NAME = /^app-configuration-(\\d+)(-[^/]*)?\\.json$/;\n/** The app configuration file a destroy run writes: unique per run, so concurrent runs from one checkout never share one. */\nfunction deployAppConfigurationFile(cwd, runId) {\n\treturn path.join(cwd, \".prisma-composer\", `app-configuration-${String(process.pid)}-${runId}.json`);\n}\nfunction isRunning(pid) {\n\ttry {\n\t\tprocess.kill(pid, 0);\n\t\treturn true;\n\t} catch (error) {\n\t\treturn error instanceof Error && \"code\" in error && error.code === \"EPERM\";\n\t}\n}\n/**\n* Deletes the app configuration files that earlier runs left in `.prisma-composer/` and in\n* each dev environment's folder: a run killed before its exit handler ran leaves its file. A\n* file is deleted only when its process is not running and it is older than\n* `LEFTOVER_APP_CONFIGURATION_FILE_AGE_MS`. Never throws.\n*/\nfunction removeLeftoverAppConfigurationFiles(cwd) {\n\tconst devRoot = path.join(cwd, DEV_DIR);\n\tconst dirs = [path.join(cwd, \".prisma-composer\")];\n\ttry {\n\t\tfor (const entry of fs.readdirSync(devRoot, { withFileTypes: true })) if (entry.isDirectory()) dirs.push(path.join(devRoot, entry.name));\n\t} catch {}\n\tfor (const dir of dirs) {\n\t\tlet names;\n\t\ttry {\n\t\t\tnames = fs.readdirSync(dir);\n\t\t} catch {\n\t\t\tcontinue;\n\t\t}\n\t\tfor (const name of names) {\n\t\t\tconst pid = Number(FILE_NAME.exec(name)?.[1]);\n\t\t\tif (Number.isNaN(pid) || pid === process.pid || isRunning(pid)) continue;\n\t\t\tconst file = path.join(dir, name);\n\t\t\ttry {\n\t\t\t\tif (Date.now() - fs.statSync(file).mtimeMs < 6e5) continue;\n\t\t\t\tfs.rmSync(file, { force: true });\n\t\t\t} catch {}\n\t\t}\n\t}\n}\n/**\n* First process: the app configuration file and the environment the second process starts with (ADR-0062).\n* Refuses a file that would hold any of `knownSecrets`.\n*/\nfunction prepareSecondProcess(input) {\n\tconst { file } = input;\n\trefuseSecretsInRootInput(input.appConfigurationRead, input.knownSecrets, \"Composer hands the second process every plain value Load read, in a file, and never writes a secret to a file.\");\n\trefuseSecretsInPlainVariables(input.plainVariableText, input.knownSecrets, \"Composer hands the second process every plain value in a file, and never writes a secret to a file.\");\n\tconst contents = {\n\t\tappConfigurationRead: input.appConfigurationRead,\n\t\tplainVariableText: input.plainVariableText,\n\t\tnodeAddresses: input.nodeAddresses\n\t};\n\tconst env = { [APP_CONFIGURATION_FILE_ENV]: file };\n\tconst remove = () => {\n\t\ttry {\n\t\t\tfs.rmSync(file, { force: true });\n\t\t} catch {}\n\t};\n\treturn {\n\t\tenv,\n\t\twriteFile() {\n\t\t\tfs.rmSync(file, { force: true });\n\t\t\tfs.writeFileSync(file, JSON.stringify(contents), {\n\t\t\t\tmode: 384,\n\t\t\t\tflag: \"wx\"\n\t\t\t});\n\t\t\tprocess.off(\"exit\", remove);\n\t\t\tprocess.on(\"exit\", remove);\n\t\t},\n\t\tremoveFile() {\n\t\t\tprocess.off(\"exit\", remove);\n\t\t\tremove();\n\t\t}\n\t};\n}\nfunction missingVariable(name, what) {\n\treturn `${name} is not set. This stack file runs as the second process of a Composer destroy, which ${what}.`;\n}\nfunction isRecord(value) {\n\treturn typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\nfunction isTextList(value) {\n\treturn Array.isArray(value) && value.every((member) => typeof member === \"string\");\n}\nfunction rootFieldsOf(value) {\n\tif (!Array.isArray(value)) return void 0;\n\tconst fields = [];\n\tfor (const member of value) {\n\t\tif (!isRecord(member) || !isTextList(member[\"path\"])) return void 0;\n\t\tfields.push(\"value\" in member ? {\n\t\t\tpath: member[\"path\"],\n\t\t\tvalue: member[\"value\"]\n\t\t} : { path: member[\"path\"] });\n\t}\n\treturn fields;\n}\nfunction textByKeyOf(value) {\n\tif (!isRecord(value)) return void 0;\n\tconst byKey = {};\n\tfor (const [key, member] of Object.entries(value)) {\n\t\tif (typeof member !== \"string\") return void 0;\n\t\tbyKey[key] = member;\n\t}\n\treturn byKey;\n}\n/** Second process: the app configuration file the first process named in its environment. */\nfunction readAppConfigurationFile(env) {\n\tconst file = env[APP_CONFIGURATION_FILE_ENV];\n\tif (file === void 0 || file === \"\") throw new Error(missingVariable(APP_CONFIGURATION_FILE_ENV, \"names the app configuration file it wrote there\"));\n\tlet text;\n\ttry {\n\t\ttext = fs.readFileSync(file, \"utf8\");\n\t} catch (cause) {\n\t\tconst message = cause instanceof Error ? cause.message : String(cause);\n\t\tthrow new Error(`Could not read the app configuration file ${file}: ${message}. Composer deletes it when the run ends, so a stack file run by hand after that cannot read it; run the command again.`, { cause });\n\t}\n\tconst notComposers = (what) => /* @__PURE__ */ new Error(`The app configuration file ${file} is not in the shape this version of Composer reads: ${what}. The usual cause is a \\`prisma\\` CLI and an app on different Composer versions. Put the \\`prisma\\` CLI and the app's \\`@prisma/composer\\` on the same version.`);\n\tlet parsed;\n\ttry {\n\t\tparsed = JSON.parse(text);\n\t} catch {\n\t\tthrow notComposers(\"it is not JSON\");\n\t}\n\tif (!isRecord(parsed)) throw notComposers(\"it is not JSON\");\n\tconst read = parsed[\"appConfigurationRead\"];\n\tif (!isRecord(read)) throw notComposers(\"appConfigurationRead is not an object\");\n\tconst rootInput = rootFieldsOf(read[\"rootInput\"]);\n\tif (rootInput === void 0) throw notComposers(\"rootInput is not a list of fields\");\n\tconst plainVariableText = textByKeyOf(parsed[\"plainVariableText\"]);\n\tif (plainVariableText === void 0) throw notComposers(\"plainVariableText is not an object of text\");\n\tconst addresses = parsed[\"nodeAddresses\"];\n\tif (!isTextList(addresses)) throw notComposers(\"nodeAddresses is not a list of node addresses\");\n\treturn {\n\t\tappConfigurationRead: { rootInput },\n\t\tplainVariableText,\n\t\tnodeAddresses: addresses\n\t};\n}\n//#endregion\nexport { refuseSecretsInPlainVariables as a, removeLeftoverAppConfigurationFiles as i, prepareSecondProcess as n, refuseSecretsInRootInput as o, readAppConfigurationFile as r, deployAppConfigurationFile as t };\n\n//# sourceMappingURL=app-configuration-file-D0rB5g65.mjs.map","import { n as StreamRedactor } from \"./redaction-DY6eDC12.mjs\";\nimport { s as withComposerAdvice } from \"./deployment-summary-CVJZn2v0.mjs\";\n//#region src/operations/steps.ts\n/**\n* Times each step for the host's `onEvent`. Steps are matched by `keyOf`, so\n* a step can finish under a newer status than it started with. `emit` sends\n* the operation's other events. A host `onEvent` that throws is the host's\n* bug and cannot fail the operation.\n*/\nfunction stepTracker(keyOf, onEvent) {\n\tconst open = /* @__PURE__ */ new Map();\n\tconst emit = (event) => {\n\t\ttry {\n\t\t\tonEvent?.(event);\n\t\t} catch {}\n\t};\n\tconst finish = (step, outcome, data) => {\n\t\tconst entry = open.get(keyOf(step));\n\t\tif (entry === void 0) return;\n\t\topen.delete(keyOf(step));\n\t\tconst durationMs = Math.round(performance.now() - entry.startedAt);\n\t\temit({\n\t\t\tkind: \"step-finished\",\n\t\t\tstep,\n\t\t\toutcome,\n\t\t\tdurationMs,\n\t\t\tdata\n\t\t});\n\t};\n\treturn {\n\t\tstart(step) {\n\t\t\topen.set(keyOf(step), {\n\t\t\t\tstep,\n\t\t\t\tstartedAt: performance.now()\n\t\t\t});\n\t\t\temit({\n\t\t\t\tkind: \"step-started\",\n\t\t\t\tstep\n\t\t\t});\n\t\t},\n\t\tfinish(step, data) {\n\t\t\tfinish(step, \"ok\", data);\n\t\t},\n\t\tfail(step) {\n\t\t\tfinish(step, \"failed\");\n\t\t},\n\t\t/** Closes every open step with `outcome`, innermost first. */\n\t\tcloseOpen(outcome) {\n\t\t\tfor (const { step } of [...open.values()].reverse()) finish(step, outcome);\n\t\t},\n\t\tisOpen(step) {\n\t\t\treturn open.has(keyOf(step));\n\t\t},\n\t\tmessage(severity, text) {\n\t\t\temit({\n\t\t\t\tkind: \"message\",\n\t\t\t\tseverity,\n\t\t\t\ttext\n\t\t\t});\n\t\t},\n\t\temit\n\t};\n}\n/** One converge event as step events: each resource is a step, made by `resourceStep`; a log line is a message. */\nfunction reportConvergeEvent(steps, event, redact, resourceStep) {\n\tif (event.kind === \"log\") {\n\t\tsteps.message(event.severity, redact(withComposerAdvice(event.text)));\n\t\treturn;\n\t}\n\tconst step = resourceStep({\n\t\tresourceId: event.fqn,\n\t\tresourceType: event.resourceType,\n\t\tstatus: event.status\n\t});\n\tswitch (event.phase) {\n\t\tcase \"running\":\n\t\t\tif (!steps.isOpen(step)) steps.start(step);\n\t\t\treturn;\n\t\tcase \"done\":\n\t\t\tif (!steps.isOpen(step)) steps.start(step);\n\t\t\tsteps.finish(step);\n\t\t\treturn;\n\t\tcase \"failed\":\n\t\t\tif (!steps.isOpen(step)) steps.start(step);\n\t\t\tsteps.fail(step);\n\t\t\tif (event.message !== void 0) steps.message(\"warn\", redact(`${event.fqn}: ${withComposerAdvice(event.message)}`));\n\t\t\treturn;\n\t\tcase \"pending\": return;\n\t}\n}\n/**\n* Alchemy's terminal text as `info` messages, one per complete line, redacted. A secret split\n* across writes or lines is still found, because the text passes through a `StreamRedactor`\n* before it is cut into lines. `end` sends the last line that has no line break.\n*/\nfunction interactionMessages(steps, redaction) {\n\tconst stream = new StreamRedactor(redaction.allValues());\n\tlet partial = \"\";\n\tconst send = (text, last) => {\n\t\tconst lines = (partial + text).split(\"\\n\");\n\t\tpartial = last ? \"\" : lines.pop() ?? \"\";\n\t\tfor (const line of lines) if (line.trim() !== \"\") steps.message(\"info\", redaction.redact(line));\n\t};\n\treturn {\n\t\tpush: (text) => send(stream.push(text), false),\n\t\tend: () => send(stream.end(), true)\n\t};\n}\n//#endregion\nexport { reportConvergeEvent as n, stepTracker as r, interactionMessages as t };\n\n//# sourceMappingURL=steps-BZXNqW6U.mjs.map"],"mappings":";;;;;;;;;;;;;;;;AAaA,MAAM,6BAA6B;;AAEnC,SAAS,oBAAoB,QAAQ;CACpC,OAAO;EACN,KAAK,OAAO;EACZ,OAAO,OAAO,MAAM,KAAK,UAAU;GAClC,SAAS,KAAK;GACd,UAAU,KAAK;EAChB,EAAE;EACF,UAAU,OAAO;CAClB;AACD;;AAcA,SAAS,sBAAsB,gBAAgB;CAC9C,OAAO,GAAG,eAAe;AAC1B;;AAEA,MAAM,6BAA6B;;AAEnC,MAAM,uBAAuB;CAC5B,CAAC,sFAAsF,kFAAkF;CACzK,CAAC,2FAA2F,0CAA0C;CACtI,CAAC,+DAA+D,qBAAqB;CACrF,CAAC,gHAAgH,kFAAkF;CACnM,CAAC,iEAAiE,4CAA4C;AAC/G;;AAEA,SAAS,mBAAmB,MAAM;CACjC,OAAO,qBAAqB,QAAQ,SAAS,CAAC,QAAQ,iBAAiB,QAAQ,QAAQ,QAAQ,WAAW,GAAG,IAAI;AAClH;;AAkDA,SAAS,uBAAuB,gBAAgB,QAAQ;CACvD,IAAI;CACJ,IAAI;EACH,QAAQ,GAAG,aAAa,sBAAsB,cAAc,GAAG,MAAM;CACtE,QAAQ;EACP;CACD;CACA,OAAO,MAAM,SAAS,IAAI,OAAO,KAAK,IAAI,KAAK;AAChD;;AAkCA,SAAS,gBAAgB,OAAO;CAC/B,OAAO,MAAM,UAAU,6BAA6B,QAAQ,GAAG,MAAM,MAAM,GAAG,6BAA6B,CAAC,EAAE;AAC/G;;;AC/IA,SAAS,OAAO,OAAO,IAAI;CAC1B,IAAI,OAAO,UAAU,UAAU,OAAO,CAAC;EACtC;EACA,MAAM;CACP,CAAC;CACD,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AAI,MAAM,QAAQ,QAAQ,UAAU,OAAO,IAAI,CAAC;CAC/F;CACA,OAAO;EACN,OAAO,SAAS,KAAK,OAAO,KAAK,IAAI,GAAG,KAAK;EAC7C,WAAW,KAAK,OAAO,IAAI,GAAG,IAAI;CACnC;AACD"}
|
package/dist/testing.d.mts
CHANGED
|
@@ -1,50 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
//#region ../../0-framework/3-tooling/cli/dist/app-configuration-file-ptkFLQ7p.d.mts
|
|
3
|
-
/** What the first process hands the second: the app configuration file, and the environment that names it. */
|
|
4
|
-
interface SecondProcessHandover {
|
|
5
|
-
/** What the first process adds to the second process's environment. */
|
|
6
|
-
readonly env: Readonly<Record<string, string>>;
|
|
7
|
-
/** Writes the app configuration file, readable only by its owner, and deletes it when the process exits. A file already there is replaced. */
|
|
8
|
-
writeFile(): void;
|
|
9
|
-
/** Deletes the app configuration file. Never throws: the run's own result is the one to report. */
|
|
10
|
-
removeFile(): void;
|
|
11
|
-
}
|
|
12
|
-
/**
|
|
13
|
-
* First process: the handover to the second process (ADR-0062). The app configuration file at
|
|
14
|
-
* `file` holds what Load read and the graph's node addresses. With `appSecrets`, which only
|
|
15
|
-
* `prisma dev` passes, the environment also carries the named secrets: the app secrets under
|
|
16
|
-
* the graph's secrets keys, each with text. Refuses when the file would hold any of
|
|
17
|
-
* `knownSecrets`. Every other input is plain data from the graph, such as
|
|
18
|
-
* `graph.appConfigurationRead`, `nodeAddresses(graph)` and `secretsKeys(graph)`, so a caller with
|
|
19
|
-
* its own copy of Composer's core can pass them. The exception is `knownSecrets`, a
|
|
20
|
-
* `KnownSecrets`, which such a caller builds from the testing entry.
|
|
21
|
-
*/
|
|
22
|
-
declare function prepareSecondProcess(input: {
|
|
23
|
-
readonly file: string;
|
|
24
|
-
readonly appConfigurationRead: AppConfigurationRead;
|
|
25
|
-
readonly nodeAddresses: readonly string[];
|
|
26
|
-
readonly secretsKeys: readonly string[];
|
|
27
|
-
readonly knownSecrets: KnownSecrets;
|
|
28
|
-
readonly appSecrets?: AppSecrets;
|
|
29
|
-
}): SecondProcessHandover;
|
|
30
|
-
//#endregion
|
|
1
|
+
import { _ as ServiceEndpoint, a as DeployEvent, c as DevStopInput, d as DevUrlInput, g as OperationDeps, h as DevSession, l as DevStopped, m as DevInput, o as DeployInput, p as DevEvent, s as DeploySuccess, t as ComposerOperations, u as DevUrl, v as Result, y as CliStructuredError } from "./family-DfwviKFj-CS1L-EvS.mjs";
|
|
31
2
|
//#region ../../0-framework/3-tooling/cli/dist/testing.d.mts
|
|
32
|
-
//#region src/dev/generate-dev-stack.d.ts
|
|
33
|
-
interface DevStackFileInput {
|
|
34
|
-
/** Absolute path to the entry module (the app's default-exported node). */
|
|
35
|
-
readonly entryPath: string;
|
|
36
|
-
/** The process's cwd — where `.prisma-composer/dev/` is written. */
|
|
37
|
-
readonly cwd: string;
|
|
38
|
-
/** The environment the app runs as locally; its folder holds the stack file. */
|
|
39
|
-
readonly environment: string;
|
|
40
|
-
/** Absolute path to the `prisma.config.ts` that declared the `composer` section — imported by relative path. */
|
|
41
|
-
readonly configFile: string;
|
|
42
|
-
readonly name: string;
|
|
43
|
-
readonly assembled: AssembledServices;
|
|
44
|
-
}
|
|
45
|
-
/** Renders the dev stack module's source (tests assert on it without touching disk). */
|
|
46
|
-
declare function renderDevStackFile(input: DevStackFileInput): string;
|
|
47
|
-
//#endregion
|
|
48
3
|
//#region src/testing/operations-double.d.ts
|
|
49
4
|
interface OperationsDoubleFixtures {
|
|
50
5
|
/** Returned as-is; pass notOk(error) for a failing deploy. Default: ok with no summary and a zero duration. */
|
|
@@ -67,8 +22,8 @@ interface OperationsDoubleFixtures {
|
|
|
67
22
|
}
|
|
68
23
|
/**
|
|
69
24
|
* The deps each call carried, in the same order as the inputs beside them.
|
|
70
|
-
* These are the operation's SECOND argument — the seam the
|
|
71
|
-
* converge
|
|
25
|
+
* These are the operation's SECOND argument — the seam the credentials and
|
|
26
|
+
* the converge environment ride in on — so a host that
|
|
72
27
|
* drops one of those is caught here rather than by its absence downstream.
|
|
73
28
|
*/
|
|
74
29
|
interface OperationsDoubleDeps {
|
|
@@ -90,5 +45,5 @@ interface OperationsDouble {
|
|
|
90
45
|
}
|
|
91
46
|
declare function createOperationsDouble(fixtures?: OperationsDoubleFixtures): OperationsDouble;
|
|
92
47
|
//#endregion
|
|
93
|
-
export { type
|
|
48
|
+
export { type OperationsDouble, type OperationsDoubleCalls, type OperationsDoubleFixtures, createOperationsDouble };
|
|
94
49
|
//# sourceMappingURL=testing.d.mts.map
|
package/dist/testing.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"testing.d.mts","names":[],"sources":["../../../0-framework/3-tooling/cli/dist/
|
|
1
|
+
{"version":3,"file":"testing.d.mts","names":[],"sources":["../../../0-framework/3-tooling/cli/dist/testing.d.mts"],"mappings":";;;UAMU;;WAEC,SAAS,OAAO,eAAe;;WAE/B,wBAAwB;;;;;WAKxB,MAAM,OAAO,YAAY;;WAEzB,wBAAwB;;WAExB,qBAAqB;;WAErB,SAAS,OAAO,QAAQ;;WAExB,UAAU,OAAO,YAAY;;;;;;;;UAQ9B;WACC,iBAAiB;WACjB,cAAc;;;UAGf;WACC,iBAAiB;WACjB,cAAc;WACd,iBAAiB;WACjB,kBAAkB;WAClB,MAAM;;UAEP;;WAEC,YAAY;WACZ,OAAO;;iBAED,uBAAuB,WAAW,2BAA2B"}
|
package/dist/testing.mjs
CHANGED
|
@@ -1,28 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { i as CliStructuredError, n as ok, t as notOk } from "./result-sR7PBi61.mjs";
|
|
3
|
-
import { r as reproduceCommand } from "./run-alchemy-CRLAyOtt-CwFLe4Zg.mjs";
|
|
4
|
-
import { r as prepareSecondProcess } from "./app-configuration-file-CeJvBAti-DA4EKwFq.mjs";
|
|
5
|
-
import { n as renderDevStackFile } from "./generate-dev-stack-BV_n-X9n-DM5faH3-.mjs";
|
|
1
|
+
import { n as ok } from "./result-CttmabB6.mjs";
|
|
6
2
|
//#region ../../0-framework/3-tooling/cli/dist/testing.mjs
|
|
7
|
-
/**
|
|
8
|
-
* The published operations double (`@prisma/composer-cli/testing`): the
|
|
9
|
-
* operations the command family calls, `deploy`, `dev`, `devUrl` and
|
|
10
|
-
* `devStop`, with their real
|
|
11
|
-
* signatures and Result shapes, backed by fixtures instead of alchemy,
|
|
12
|
-
* containers, or a network. It does not cover `destroy` and `log`, which no
|
|
13
|
-
* command calls.
|
|
14
|
-
*
|
|
15
|
-
* Hosts that mount composer's command family — prisma-cli above all — test
|
|
16
|
-
* against this instead of the real operations, so their suites never spawn a
|
|
17
|
-
* converge and their typecheck never needs the alchemy/effect constellation.
|
|
18
|
-
* The conformance guarantee is carried by the types: `ComposerOperations` is
|
|
19
|
-
* defined as `typeof deployWithDeps` (etc.) of the REAL operations, and the
|
|
20
|
-
* double is declared against it, so a drift in any real signature fails
|
|
21
|
-
* `tsc --noEmit` right here. Every import of implementation modules is
|
|
22
|
-
* type-only and erases at build — the built `testing` chunk must contain no path to the real
|
|
23
|
-
* control implementation, which scripts/check-family-static-graph.mjs proves
|
|
24
|
-
* against the packed tarball.
|
|
25
|
-
*/
|
|
26
3
|
function devSessionDouble(input, endpoints, events) {
|
|
27
4
|
let resolveClosed;
|
|
28
5
|
const closed = new Promise((resolve) => {
|
|
@@ -46,54 +23,6 @@ function devSessionDouble(input, endpoints, events) {
|
|
|
46
23
|
}
|
|
47
24
|
};
|
|
48
25
|
}
|
|
49
|
-
/**
|
|
50
|
-
* Runs the caller's converge adapter, when it supplied one, against a
|
|
51
|
-
* synthetic invocation — no alchemy bin is resolved and no real child is
|
|
52
|
-
* started; the adapter decides what the child does.
|
|
53
|
-
*
|
|
54
|
-
* This is what makes a host's tests cover the settlement rules rather than
|
|
55
|
-
* just the grammar: a scripted fake child that exits non-zero, or is killed
|
|
56
|
-
* by a signal, produces the same failure shape the real executor produces, so
|
|
57
|
-
* the handler's settlement — and the engine's own child-status settlement
|
|
58
|
-
* behind it — is genuinely exercised. Returns undefined when no adapter was
|
|
59
|
-
* injected, leaving the fixture result untouched.
|
|
60
|
-
*/
|
|
61
|
-
async function runConverge(deps, cwd) {
|
|
62
|
-
if (deps.alchemy === void 0) return void 0;
|
|
63
|
-
const stackFilePath = ".prisma-composer/alchemy.run.ts";
|
|
64
|
-
const workingDirectory = cwd ?? ".";
|
|
65
|
-
const invocation = {
|
|
66
|
-
action: "deploy",
|
|
67
|
-
stackFileRelativePath: stackFilePath,
|
|
68
|
-
cwd: workingDirectory,
|
|
69
|
-
stage: "test",
|
|
70
|
-
env: {},
|
|
71
|
-
redactedValues: []
|
|
72
|
-
};
|
|
73
|
-
const outcome = await deps.alchemy(invocation);
|
|
74
|
-
const reproduce = reproduceCommand(invocation, outcome);
|
|
75
|
-
if (outcome.signal !== null) return notOk(new CliStructuredError("DEPLOY.ENGINE_FAILED", `alchemy deploy was interrupted by ${outcome.signal}.`, { meta: {
|
|
76
|
-
signal: outcome.signal,
|
|
77
|
-
diagnostics: {
|
|
78
|
-
exitCode: void 0,
|
|
79
|
-
signal: outcome.signal,
|
|
80
|
-
stackFilePath,
|
|
81
|
-
reproduceCommand: reproduce,
|
|
82
|
-
cwd: workingDirectory
|
|
83
|
-
}
|
|
84
|
-
} }));
|
|
85
|
-
const status = outcome.exitCode ?? 1;
|
|
86
|
-
if (status === 0) return void 0;
|
|
87
|
-
return notOk(new CliStructuredError("DEPLOY.ENGINE_FAILED", `alchemy deploy exited with status ${status}.`, { meta: {
|
|
88
|
-
exitCode: status,
|
|
89
|
-
diagnostics: {
|
|
90
|
-
exitCode: status,
|
|
91
|
-
stackFilePath,
|
|
92
|
-
reproduceCommand: reproduce,
|
|
93
|
-
cwd: workingDirectory
|
|
94
|
-
}
|
|
95
|
-
} }));
|
|
96
|
-
}
|
|
97
26
|
function createOperationsDouble(fixtures = {}) {
|
|
98
27
|
const deployCalls = [];
|
|
99
28
|
const devCalls = [];
|
|
@@ -118,8 +47,6 @@ function createOperationsDouble(fixtures = {}) {
|
|
|
118
47
|
for (const event of fixtures.deployEvents ?? []) try {
|
|
119
48
|
input.onEvent?.(event);
|
|
120
49
|
} catch {}
|
|
121
|
-
const converge = await runConverge(operationDeps, input.cwd);
|
|
122
|
-
if (converge !== void 0) return converge;
|
|
123
50
|
return fixtures.deploy ?? ok({
|
|
124
51
|
summary: void 0,
|
|
125
52
|
durationMs: 0
|
|
@@ -152,6 +79,6 @@ function createOperationsDouble(fixtures = {}) {
|
|
|
152
79
|
};
|
|
153
80
|
}
|
|
154
81
|
//#endregion
|
|
155
|
-
export {
|
|
82
|
+
export { createOperationsDouble };
|
|
156
83
|
|
|
157
84
|
//# sourceMappingURL=testing.mjs.map
|
package/dist/testing.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"testing.mjs","names":[],"sources":["../../../0-framework/3-tooling/cli/dist/testing.mjs"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"testing.mjs","names":[],"sources":["../../../0-framework/3-tooling/cli/dist/testing.mjs"],"sourcesContent":["import { ok } from \"@internal/foundation/result\";\n//#region src/testing/operations-double.ts\nfunction devSessionDouble(input, endpoints, events) {\n\tlet resolveClosed;\n\tconst closed = new Promise((resolve) => {\n\t\tresolveClosed = resolve;\n\t});\n\tlet stopped = false;\n\tinput.onEvent?.({\n\t\tkind: \"ready\",\n\t\tendpoints\n\t});\n\tfor (const event of events) input.onEvent?.(event);\n\treturn {\n\t\tendpoints,\n\t\tclosed,\n\t\tstop: async () => {\n\t\t\tif (stopped) return;\n\t\t\tstopped = true;\n\t\t\tinput.onEvent?.({ kind: \"stopping\" });\n\t\t\tinput.onEvent?.({ kind: \"stopped\" });\n\t\t\tresolveClosed();\n\t\t}\n\t};\n}\nfunction createOperationsDouble(fixtures = {}) {\n\tconst deployCalls = [];\n\tconst devCalls = [];\n\tconst deps = {\n\t\tdeploy: [],\n\t\tdev: []\n\t};\n\tconst devUrlCalls = [];\n\tconst devStopCalls = [];\n\tconst calls = {\n\t\tdeploy: deployCalls,\n\t\tdev: devCalls,\n\t\tdevUrl: devUrlCalls,\n\t\tdevStop: devStopCalls,\n\t\tdeps\n\t};\n\treturn {\n\t\toperations: {\n\t\t\tdeploy: async (input, operationDeps) => {\n\t\t\t\tcalls.deploy.push(input);\n\t\t\t\tdeps.deploy.push(operationDeps);\n\t\t\t\tfor (const event of fixtures.deployEvents ?? []) try {\n\t\t\t\t\tinput.onEvent?.(event);\n\t\t\t\t} catch {}\n\t\t\t\treturn fixtures.deploy ?? ok({\n\t\t\t\t\tsummary: void 0,\n\t\t\t\t\tdurationMs: 0\n\t\t\t\t});\n\t\t\t},\n\t\t\tdev: async (input, operationDeps) => {\n\t\t\t\tcalls.dev.push(input);\n\t\t\t\tdeps.dev.push(operationDeps);\n\t\t\t\treturn fixtures.dev ?? ok(devSessionDouble(input, fixtures.devEndpoints ?? [], fixtures.devEvents ?? []));\n\t\t\t},\n\t\t\tdevUrl: async (input) => {\n\t\t\t\tdevUrlCalls.push(input);\n\t\t\t\treturn fixtures.devUrl ?? ok({\n\t\t\t\t\taddress: input.address,\n\t\t\t\t\tkind: \"service\",\n\t\t\t\t\turl: \"http://localhost:3000\",\n\t\t\t\t\tstate: \"running\"\n\t\t\t\t});\n\t\t\t},\n\t\t\tdevStop: async (input) => {\n\t\t\t\tdevStopCalls.push(input);\n\t\t\t\treturn fixtures.devStop ?? ok({\n\t\t\t\t\tapp: \"app\",\n\t\t\t\t\tenvironment: input.environment ?? \"dev\",\n\t\t\t\t\tstopped: []\n\t\t\t\t});\n\t\t\t}\n\t\t},\n\t\tcalls\n\t};\n}\n//#endregion\nexport { createOperationsDouble };\n\n//# sourceMappingURL=testing.mjs.map"],"mappings":";;AAEA,SAAS,iBAAiB,OAAO,WAAW,QAAQ;CACnD,IAAI;CACJ,MAAM,SAAS,IAAI,SAAS,YAAY;EACvC,gBAAgB;CACjB,CAAC;CACD,IAAI,UAAU;CACd,MA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