@prisma/composer-cli 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.
Files changed (74) hide show
  1. package/dist/app-converge-bS1l9jIf-B1FOgxBQ.mjs +88 -0
  2. package/dist/app-converge-bS1l9jIf-B1FOgxBQ.mjs.map +1 -0
  3. package/dist/composer-config-QKdY85G--CEXrb2Uc.mjs +254 -0
  4. package/dist/composer-config-QKdY85G--CEXrb2Uc.mjs.map +1 -0
  5. package/dist/{validate-environment-D1BTCkTs-C5m4rL6t.mjs → deploy-Br1yvLe3.mjs} +335 -1091
  6. package/dist/deploy-Br1yvLe3.mjs.map +1 -0
  7. package/dist/dev-converge-messages-DML4rTz7-B6uxtpZG.mjs +256 -0
  8. package/dist/dev-converge-messages-DML4rTz7-B6uxtpZG.mjs.map +1 -0
  9. package/dist/dev-converge-worker.d.mts +1 -0
  10. package/dist/dev-converge-worker.mjs +143 -0
  11. package/dist/dev-converge-worker.mjs.map +1 -0
  12. package/dist/{dev-current-wD5YDLjA-CFI8XTAK.mjs → dev-current-lAlj53eX-DvAHNZFo.mjs} +12 -18
  13. package/dist/dev-current-lAlj53eX-DvAHNZFo.mjs.map +1 -0
  14. package/dist/dev-environment-name-6eEr5PW8-CCY7WNWz.mjs +43 -0
  15. package/dist/dev-environment-name-6eEr5PW8-CCY7WNWz.mjs.map +1 -0
  16. package/dist/{dist-D0rWRHos.mjs → dist-C0OGaDnj.mjs} +4 -3
  17. package/dist/{dist-D0rWRHos.mjs.map → dist-C0OGaDnj.mjs.map} +1 -1
  18. package/dist/errors-CVYwN2km.mjs +93 -0
  19. package/dist/errors-CVYwN2km.mjs.map +1 -0
  20. package/dist/{execute-deploy-destroy-DOzo2Psp-2iWcFbD9.mjs → execute-deploy-destroy-DN16ETAk-CzORriUO.mjs} +374 -141
  21. package/dist/execute-deploy-destroy-DN16ETAk-CzORriUO.mjs.map +1 -0
  22. package/dist/{execute-dev-BIyOI3Ys-DGpTd9rP.mjs → execute-dev-DnVmNpc1-BzK9Qns_.mjs} +444 -128
  23. package/dist/execute-dev-DnVmNpc1-BzK9Qns_.mjs.map +1 -0
  24. package/dist/{execute-dev-current-CKOzjWuO-DTOVqZzZ.mjs → execute-dev-current-CZdmxVQ4-DxDflvNG.mjs} +9 -6
  25. package/dist/{execute-dev-current-CKOzjWuO-DTOVqZzZ.mjs.map → execute-dev-current-CZdmxVQ4-DxDflvNG.mjs.map} +1 -1
  26. package/dist/{redaction-Bf8FvTFH-XGchRgrK.d.mts → family-DfwviKFj-CS1L-EvS.d.mts} +439 -204
  27. package/dist/family-DfwviKFj-CS1L-EvS.d.mts.map +1 -0
  28. package/dist/family.d.mts +1 -1
  29. package/dist/family.mjs +259 -269
  30. package/dist/family.mjs.map +1 -1
  31. package/dist/internal-error-Dfur7Zqt-B8J8e7ac.mjs +58 -0
  32. package/dist/internal-error-Dfur7Zqt-B8J8e7ac.mjs.map +1 -0
  33. package/dist/{list-deployed-BFJJxt_W.mjs → list-deployed-D6vTzpWu.mjs} +6 -5
  34. package/dist/list-deployed-D6vTzpWu.mjs.map +1 -0
  35. package/dist/local-target-CZzICh5R.mjs +34 -0
  36. package/dist/local-target-CZzICh5R.mjs.map +1 -0
  37. package/dist/{preflight-transport-DmmtoFPH-CZ0o7QPf.mjs → preflight-transport-2d6iIchu-ArIJUY1L.mjs} +7 -28
  38. package/dist/preflight-transport-2d6iIchu-ArIJUY1L.mjs.map +1 -0
  39. package/dist/{redaction-DXung4ip-Co_fv4Zl.mjs → redaction-DY6eDC12-BrK1aSN5.mjs} +33 -267
  40. package/dist/redaction-DY6eDC12-BrK1aSN5.mjs.map +1 -0
  41. package/dist/result-CttmabB6.mjs +91 -0
  42. package/dist/result-CttmabB6.mjs.map +1 -0
  43. package/dist/rolldown-runtime-C7HZzL1F.mjs +26 -0
  44. package/dist/steps-BZXNqW6U-BM2Aa8Bp.mjs +287 -0
  45. package/dist/steps-BZXNqW6U-BM2Aa8Bp.mjs.map +1 -0
  46. package/dist/testing.d.mts +4 -49
  47. package/dist/testing.d.mts.map +1 -1
  48. package/dist/testing.mjs +2 -75
  49. package/dist/testing.mjs.map +1 -1
  50. package/dist/validate-environment-DCZiNSlR-idVge-kq.mjs +983 -0
  51. package/dist/validate-environment-DCZiNSlR-idVge-kq.mjs.map +1 -0
  52. package/dist/value-reads-change-text-DcRCv7Zy-Ca8m3bal.mjs +15 -0
  53. package/dist/value-reads-change-text-DcRCv7Zy-Ca8m3bal.mjs.map +1 -0
  54. package/package.json +9 -9
  55. package/src/exports/dev-converge-worker.ts +2 -0
  56. package/src/exports/testing.ts +1 -4
  57. package/dist/app-configuration-file-CeJvBAti-DA4EKwFq.mjs +0 -140
  58. package/dist/app-configuration-file-CeJvBAti-DA4EKwFq.mjs.map +0 -1
  59. package/dist/dev-current-wD5YDLjA-CFI8XTAK.mjs.map +0 -1
  60. package/dist/dev-environment-name-6eEr5PW8-Bs4Dl0vW.mjs +0 -71
  61. package/dist/dev-environment-name-6eEr5PW8-Bs4Dl0vW.mjs.map +0 -1
  62. package/dist/execute-deploy-destroy-DOzo2Psp-2iWcFbD9.mjs.map +0 -1
  63. package/dist/execute-dev-BIyOI3Ys-DGpTd9rP.mjs.map +0 -1
  64. package/dist/generate-dev-stack-BV_n-X9n-DM5faH3-.mjs +0 -100
  65. package/dist/generate-dev-stack-BV_n-X9n-DM5faH3-.mjs.map +0 -1
  66. package/dist/list-deployed-BFJJxt_W.mjs.map +0 -1
  67. package/dist/preflight-transport-DmmtoFPH-CZ0o7QPf.mjs.map +0 -1
  68. package/dist/redaction-Bf8FvTFH-XGchRgrK.d.mts.map +0 -1
  69. package/dist/redaction-DXung4ip-Co_fv4Zl.mjs.map +0 -1
  70. package/dist/result-sR7PBi61.mjs +0 -229
  71. package/dist/result-sR7PBi61.mjs.map +0 -1
  72. package/dist/run-alchemy-CRLAyOtt-CwFLe4Zg.mjs +0 -236
  73. package/dist/run-alchemy-CRLAyOtt-CwFLe4Zg.mjs.map +0 -1
  74. package/dist/validate-environment-D1BTCkTs-C5m4rL6t.mjs.map +0 -1
@@ -1,236 +0,0 @@
1
- import { r as StreamRedactor } from "./redaction-DXung4ip-Co_fv4Zl.mjs";
2
- import { i as CliStructuredError } from "./result-sR7PBi61.mjs";
3
- import { createRequire } from "node:module";
4
- import * as fs from "node:fs";
5
- import * as path from "node:path";
6
- import spawn from "cross-spawn";
7
- //#region ../../0-framework/3-tooling/cli/dist/run-alchemy-CRLAyOtt.mjs
8
- /**
9
- * Which Alchemy CLI runs a generated stack file: the `alchemy` that
10
- * `@prisma/composer` depends on, found from the app the way the stack file's
11
- * own `@prisma/composer/...` imports are. The CLI and the stack code then
12
- * come from one install, so the child loads one copy of `alchemy`.
13
- *
14
- * Node's resolver finds `@prisma/composer` from the app. It cannot find
15
- * `alchemy` from there: alchemy exports neither its `package.json` nor its
16
- * bin, and has no `require` condition. Bun has no `module.findPackageJSON`.
17
- * So the last step is Node's own lookup written out: each `node_modules`
18
- * above `@prisma/composer`'s real location, nearest first.
19
- */
20
- 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.";
21
- function binMissing(message) {
22
- return new CliStructuredError("DEPLOY.ALCHEMY_BIN_MISSING", message, { fix: FIX });
23
- }
24
- function composerPackageDir(appDir) {
25
- try {
26
- const manifest = createRequire(path.join(appDir, "package.json")).resolve("@prisma/composer/package.json");
27
- return path.dirname(fs.realpathSync(manifest));
28
- } catch {
29
- return;
30
- }
31
- }
32
- function alchemyPackageDirAbove(dir) {
33
- for (let current = dir;; current = path.dirname(current)) {
34
- const candidate = path.join(current, "node_modules", "alchemy");
35
- if (fs.existsSync(path.join(candidate, "package.json"))) return candidate;
36
- if (path.dirname(current) === current) return void 0;
37
- }
38
- }
39
- function readPackageJson(packageDir) {
40
- try {
41
- return JSON.parse(fs.readFileSync(path.join(packageDir, "package.json"), "utf8"));
42
- } catch {
43
- return;
44
- }
45
- }
46
- function binOf(packageDir) {
47
- const manifest = readPackageJson(packageDir);
48
- if (typeof manifest !== "object" || manifest === null || !("bin" in manifest)) return void 0;
49
- const bin = manifest.bin;
50
- const relative = typeof bin === "string" ? bin : typeof bin === "object" && bin !== null && "alchemy" in bin ? bin.alchemy : void 0;
51
- if (typeof relative !== "string") return void 0;
52
- const entry = path.join(packageDir, relative);
53
- return fs.existsSync(entry) ? entry : void 0;
54
- }
55
- /**
56
- * The JavaScript file `alchemy`'s `bin` names, for the app in `appDir`.
57
- * Raises DEPLOY.ALCHEMY_BIN_MISSING when the app does not resolve
58
- * `@prisma/composer` or no usable `alchemy` is installed beside it.
59
- */
60
- function resolveAlchemyBin(appDir) {
61
- const composerDir = composerPackageDir(appDir);
62
- if (composerDir === void 0) throw binMissing(`Could not resolve @prisma/composer from "${appDir}".`);
63
- const alchemyDir = alchemyPackageDirAbove(composerDir);
64
- const entry = alchemyDir === void 0 ? void 0 : binOf(alchemyDir);
65
- if (entry === void 0) throw binMissing(`Could not resolve the bin of the \`alchemy\` package @prisma/composer depends on, from "${composerDir}".`);
66
- return entry;
67
- }
68
- /**
69
- * Pipeline step 9 (deploy-cli.md § The pipeline; design-notes.md's "Driving
70
- * Alchemy" call): run the generated stack file and, for programmatic hosts, pipe its
71
- * output through redaction.
72
- *
73
- * Runs the bin of the `alchemy` the app's `@prisma/composer` depends on
74
- * (`resolveAlchemyBin`), started with Node (`nodeExecutable`). Never a
75
- * `node_modules/.bin` link, which pnpm creates only for an app's direct
76
- * dependencies.
77
- *
78
- * This module composes the invocation; it does not decide how the child is
79
- * started. Under the CLI the engine starts it (`ctx.spawn`), which is what
80
- * makes Ctrl-C reach the child natively and keeps signal policy in one place.
81
- * `spawnAlchemy` is the default for programmatic hosts driving
82
- * `@prisma/composer/control`, which have no engine to borrow. Only
83
- * `spawnAlchemy` redacts the child's output; under the CLI the child gets the
84
- * terminal and its output is not redacted (ADR-0062).
85
- */
86
- function currentRuntime() {
87
- return {
88
- bun: process.versions.bun !== void 0,
89
- execPath: process.execPath,
90
- env: process.env,
91
- platform: process.platform,
92
- exists: fs.existsSync
93
- };
94
- }
95
- function envValue(env, name) {
96
- return Object.entries(env).find(([key]) => key.toLowerCase() === name.toLowerCase())?.[1];
97
- }
98
- /** The file names `node` may have in a PATH directory: PATHEXT's extensions on Windows. */
99
- function nodeFileNames(runtime) {
100
- if (runtime.platform !== "win32") return ["node"];
101
- return (envValue(runtime.env, "PATHEXT") ?? ".COM;.EXE;.BAT;.CMD").split(";").filter((extension) => extension.length > 0).map((extension) => `node${extension}`);
102
- }
103
- /**
104
- * The Node that starts Alchemy's launcher: this process's own runtime under
105
- * Node, and the first `node` on PATH under Bun. Alchemy's launcher may still
106
- * move itself to Bun when the package-manager environment says Bun invoked
107
- * it (`bunx`, `bun run`), so the runtime Alchemy ends up on follows how
108
- * `prisma` was invoked.
109
- */
110
- function nodeExecutable(runtime = currentRuntime()) {
111
- if (!runtime.bun) return runtime.execPath;
112
- const paths = runtime.platform === "win32" ? path.win32 : path.posix;
113
- const names = nodeFileNames(runtime);
114
- for (const rawDir of (envValue(runtime.env, "PATH") ?? "").split(paths.delimiter)) {
115
- const dir = rawDir.replace(/^"(.*)"$/, "$1");
116
- if (dir.length === 0) continue;
117
- for (const name of names) {
118
- const candidate = paths.join(dir, name);
119
- if (runtime.exists(candidate)) return candidate;
120
- }
121
- }
122
- 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." });
123
- }
124
- /**
125
- * Resolves the invocation against this machine — the step every adapter takes
126
- * and no caller should. Runs alchemy's JavaScript entry with Node, so no shell
127
- * shim is involved on any platform. Raises DEPLOY.ALCHEMY_BIN_MISSING when
128
- * Composer's alchemy cannot be resolved, and DEPLOY.NODE_MISSING when no Node
129
- * can run it.
130
- */
131
- function alchemyCommandLine(invocation, alchemyBin = resolveAlchemyBin(invocation.cwd), node = nodeExecutable()) {
132
- return {
133
- command: node,
134
- args: [
135
- alchemyBin,
136
- invocation.action,
137
- invocation.stackFileRelativePath,
138
- "--yes",
139
- "--stage",
140
- invocation.stage
141
- ],
142
- cwd: invocation.cwd,
143
- env: invocation.env
144
- };
145
- }
146
- /** What becomes `alchemy deploy|destroy <stack file> --yes --stage <stage>`. */
147
- function alchemyInvocation(input) {
148
- return {
149
- action: input.command,
150
- stackFileRelativePath: input.stackFileRelativePath,
151
- cwd: input.cwd,
152
- stage: input.stage,
153
- env: {
154
- ...input.containerEnv,
155
- ...input.preflightEnv,
156
- ...input.env
157
- },
158
- redactedValues: input.redactedValues
159
- };
160
- }
161
- /**
162
- * The default runner for hosts with no engine: stdin inherited and output piped through redaction, the caller's
163
- * own process group, and the child's status returned verbatim. It does not
164
- * collapse a signal into an exit code — that collapse is what made a
165
- * Ctrl-C'd deploy report itself as a failure.
166
- */
167
- const spawnAlchemy = async (invocation) => {
168
- const commandLine = alchemyCommandLine(invocation);
169
- return {
170
- ...await spawnCommandLine(commandLine, invocation.redactedValues),
171
- commandLine
172
- };
173
- };
174
- /**
175
- * One argument as the platform's shell reads it literally: single quotes for
176
- * POSIX shells, double quotes for cmd.exe. cmd.exe expands `%VAR%` inside
177
- * double quotes, and strips or expands `!` when delayed expansion is on; no
178
- * quoting prevents either, so an argument containing them is not fully
179
- * literal there.
180
- */
181
- function shellArg(arg, platform) {
182
- if (platform === "win32") return /^[\w@+=:,./\\~-]+$/.test(arg) ? arg : `"${arg.replaceAll("\"", "\"\"")}"`;
183
- return /^[\w@%+=:,./-]+$/.test(arg) ? arg : `'${arg.replaceAll("'", "'\\''")}'`;
184
- }
185
- /**
186
- * The command a user runs from the invocation's directory to repeat a
187
- * converge: the command line the adapter started, or, from an adapter that
188
- * does not report one, `alchemy` with the same arguments.
189
- */
190
- function reproduceCommand(invocation, outcome, platform = process.platform) {
191
- return (outcome?.commandLine === void 0 ? [
192
- "alchemy",
193
- invocation.action,
194
- invocation.stackFileRelativePath,
195
- "--yes",
196
- "--stage",
197
- invocation.stage
198
- ] : [outcome.commandLine.command, ...outcome.commandLine.args]).map((arg) => shellArg(arg, platform)).join(" ");
199
- }
200
- /** Starts a resolved command line with stdin inherited and its output piped through redaction, and returns how it ended. */
201
- function spawnCommandLine(line, redactedValues, outputs = process) {
202
- return new Promise((resolve, reject) => {
203
- const child = spawn(line.command, [...line.args], {
204
- cwd: line.cwd,
205
- stdio: [
206
- "inherit",
207
- "pipe",
208
- "pipe"
209
- ],
210
- env: {
211
- ...process.env,
212
- ...line.env
213
- }
214
- });
215
- const stdout = new StreamRedactor(redactedValues);
216
- const stderr = new StreamRedactor(redactedValues);
217
- const write = (stream, text) => {
218
- if (text.length > 0) stream.write(text);
219
- };
220
- child.stdout?.setEncoding("utf8").on("data", (chunk) => write(outputs.stdout, stdout.push(chunk)));
221
- child.stderr?.setEncoding("utf8").on("data", (chunk) => write(outputs.stderr, stderr.push(chunk)));
222
- child.on("error", reject);
223
- child.on("close", (exitCode, signal) => {
224
- write(outputs.stdout, stdout.end());
225
- write(outputs.stderr, stderr.end());
226
- resolve({
227
- exitCode,
228
- signal
229
- });
230
- });
231
- });
232
- }
233
- //#endregion
234
- export { spawnAlchemy as i, alchemyInvocation as n, reproduceCommand as r, alchemyCommandLine as t };
235
-
236
- //# sourceMappingURL=run-alchemy-CRLAyOtt-CwFLe4Zg.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"run-alchemy-CRLAyOtt-CwFLe4Zg.mjs","names":[],"sources":["../../../0-framework/3-tooling/cli/dist/run-alchemy-CRLAyOtt.mjs"],"sourcesContent":["import { r as StreamRedactor } from \"./redaction-DXung4ip.mjs\";\nimport { createRequire } from \"node:module\";\nimport * as fs from \"node:fs\";\nimport * as path from \"node:path\";\nimport { CliStructuredError } from \"@internal/foundation/errors\";\nimport spawn from \"cross-spawn\";\n//#region src/alchemy-bin.ts\n/**\n* Which Alchemy CLI runs a generated stack file: the `alchemy` that\n* `@prisma/composer` depends on, found from the app the way the stack file's\n* own `@prisma/composer/...` imports are. The CLI and the stack code then\n* come from one install, so the child loads one copy of `alchemy`.\n*\n* Node's resolver finds `@prisma/composer` from the app. It cannot find\n* `alchemy` from there: alchemy exports neither its `package.json` nor its\n* bin, and has no `require` condition. Bun has no `module.findPackageJSON`.\n* So the last step is Node's own lookup written out: each `node_modules`\n* above `@prisma/composer`'s real location, nearest first.\n*/\nconst 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.\";\nfunction binMissing(message) {\n\treturn new CliStructuredError(\"DEPLOY.ALCHEMY_BIN_MISSING\", message, { fix: FIX });\n}\nfunction composerPackageDir(appDir) {\n\ttry {\n\t\tconst manifest = createRequire(path.join(appDir, \"package.json\")).resolve(\"@prisma/composer/package.json\");\n\t\treturn path.dirname(fs.realpathSync(manifest));\n\t} catch {\n\t\treturn;\n\t}\n}\nfunction alchemyPackageDirAbove(dir) {\n\tfor (let current = dir;; current = path.dirname(current)) {\n\t\tconst candidate = path.join(current, \"node_modules\", \"alchemy\");\n\t\tif (fs.existsSync(path.join(candidate, \"package.json\"))) return candidate;\n\t\tif (path.dirname(current) === current) return void 0;\n\t}\n}\nfunction readPackageJson(packageDir) {\n\ttry {\n\t\treturn JSON.parse(fs.readFileSync(path.join(packageDir, \"package.json\"), \"utf8\"));\n\t} catch {\n\t\treturn;\n\t}\n}\nfunction binOf(packageDir) {\n\tconst manifest = readPackageJson(packageDir);\n\tif (typeof manifest !== \"object\" || manifest === null || !(\"bin\" in manifest)) return void 0;\n\tconst bin = manifest.bin;\n\tconst relative = typeof bin === \"string\" ? bin : typeof bin === \"object\" && bin !== null && \"alchemy\" in bin ? bin.alchemy : void 0;\n\tif (typeof relative !== \"string\") return void 0;\n\tconst entry = path.join(packageDir, relative);\n\treturn fs.existsSync(entry) ? entry : void 0;\n}\n/**\n* The JavaScript file `alchemy`'s `bin` names, for the app in `appDir`.\n* Raises DEPLOY.ALCHEMY_BIN_MISSING when the app does not resolve\n* `@prisma/composer` or no usable `alchemy` is installed beside it.\n*/\nfunction resolveAlchemyBin(appDir) {\n\tconst composerDir = composerPackageDir(appDir);\n\tif (composerDir === void 0) throw binMissing(`Could not resolve @prisma/composer from \"${appDir}\".`);\n\tconst alchemyDir = alchemyPackageDirAbove(composerDir);\n\tconst entry = alchemyDir === void 0 ? void 0 : binOf(alchemyDir);\n\tif (entry === void 0) throw binMissing(`Could not resolve the bin of the \\`alchemy\\` package @prisma/composer depends on, from \"${composerDir}\".`);\n\treturn entry;\n}\n//#endregion\n//#region src/run-alchemy.ts\n/**\n* Pipeline step 9 (deploy-cli.md § The pipeline; design-notes.md's \"Driving\n* Alchemy\" call): run the generated stack file and, for programmatic hosts, pipe its\n* output through redaction.\n*\n* Runs the bin of the `alchemy` the app's `@prisma/composer` depends on\n* (`resolveAlchemyBin`), started with Node (`nodeExecutable`). Never a\n* `node_modules/.bin` link, which pnpm creates only for an app's direct\n* dependencies.\n*\n* This module composes the invocation; it does not decide how the child is\n* started. Under the CLI the engine starts it (`ctx.spawn`), which is what\n* makes Ctrl-C reach the child natively and keeps signal policy in one place.\n* `spawnAlchemy` is the default for programmatic hosts driving\n* `@prisma/composer/control`, which have no engine to borrow. Only\n* `spawnAlchemy` redacts the child's output; under the CLI the child gets the\n* terminal and its output is not redacted (ADR-0062).\n*/\nfunction currentRuntime() {\n\treturn {\n\t\tbun: process.versions.bun !== void 0,\n\t\texecPath: process.execPath,\n\t\tenv: process.env,\n\t\tplatform: process.platform,\n\t\texists: fs.existsSync\n\t};\n}\nfunction envValue(env, name) {\n\treturn Object.entries(env).find(([key]) => key.toLowerCase() === name.toLowerCase())?.[1];\n}\n/** The file names `node` may have in a PATH directory: PATHEXT's extensions on Windows. */\nfunction nodeFileNames(runtime) {\n\tif (runtime.platform !== \"win32\") return [\"node\"];\n\treturn (envValue(runtime.env, \"PATHEXT\") ?? \".COM;.EXE;.BAT;.CMD\").split(\";\").filter((extension) => extension.length > 0).map((extension) => `node${extension}`);\n}\n/**\n* The Node that starts Alchemy's launcher: this process's own runtime under\n* Node, and the first `node` on PATH under Bun. Alchemy's launcher may still\n* move itself to Bun when the package-manager environment says Bun invoked\n* it (`bunx`, `bun run`), so the runtime Alchemy ends up on follows how\n* `prisma` was invoked.\n*/\nfunction nodeExecutable(runtime = currentRuntime()) {\n\tif (!runtime.bun) return runtime.execPath;\n\tconst paths = runtime.platform === \"win32\" ? path.win32 : path.posix;\n\tconst names = nodeFileNames(runtime);\n\tfor (const rawDir of (envValue(runtime.env, \"PATH\") ?? \"\").split(paths.delimiter)) {\n\t\tconst dir = rawDir.replace(/^\"(.*)\"$/, \"$1\");\n\t\tif (dir.length === 0) continue;\n\t\tfor (const name of names) {\n\t\t\tconst candidate = paths.join(dir, name);\n\t\t\tif (runtime.exists(candidate)) return candidate;\n\t\t}\n\t}\n\tthrow 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.\" });\n}\n/**\n* Resolves the invocation against this machine — the step every adapter takes\n* and no caller should. Runs alchemy's JavaScript entry with Node, so no shell\n* shim is involved on any platform. Raises DEPLOY.ALCHEMY_BIN_MISSING when\n* Composer's alchemy cannot be resolved, and DEPLOY.NODE_MISSING when no Node\n* can run it.\n*/\nfunction alchemyCommandLine(invocation, alchemyBin = resolveAlchemyBin(invocation.cwd), node = nodeExecutable()) {\n\treturn {\n\t\tcommand: node,\n\t\targs: [\n\t\t\talchemyBin,\n\t\t\tinvocation.action,\n\t\t\tinvocation.stackFileRelativePath,\n\t\t\t\"--yes\",\n\t\t\t\"--stage\",\n\t\t\tinvocation.stage\n\t\t],\n\t\tcwd: invocation.cwd,\n\t\tenv: invocation.env\n\t};\n}\n/** What becomes `alchemy deploy|destroy <stack file> --yes --stage <stage>`. */\nfunction alchemyInvocation(input) {\n\treturn {\n\t\taction: input.command,\n\t\tstackFileRelativePath: input.stackFileRelativePath,\n\t\tcwd: input.cwd,\n\t\tstage: input.stage,\n\t\tenv: {\n\t\t\t...input.containerEnv,\n\t\t\t...input.preflightEnv,\n\t\t\t...input.env\n\t\t},\n\t\tredactedValues: input.redactedValues\n\t};\n}\n/**\n* The default runner for hosts with no engine: stdin inherited and output piped through redaction, the caller's\n* own process group, and the child's status returned verbatim. It does not\n* collapse a signal into an exit code — that collapse is what made a\n* Ctrl-C'd deploy report itself as a failure.\n*/\nconst spawnAlchemy = async (invocation) => {\n\tconst commandLine = alchemyCommandLine(invocation);\n\treturn {\n\t\t...await spawnCommandLine(commandLine, invocation.redactedValues),\n\t\tcommandLine\n\t};\n};\n/**\n* One argument as the platform's shell reads it literally: single quotes for\n* POSIX shells, double quotes for cmd.exe. cmd.exe expands `%VAR%` inside\n* double quotes, and strips or expands `!` when delayed expansion is on; no\n* quoting prevents either, so an argument containing them is not fully\n* literal there.\n*/\nfunction shellArg(arg, platform) {\n\tif (platform === \"win32\") return /^[\\w@+=:,./\\\\~-]+$/.test(arg) ? arg : `\"${arg.replaceAll(\"\\\"\", \"\\\"\\\"\")}\"`;\n\treturn /^[\\w@%+=:,./-]+$/.test(arg) ? arg : `'${arg.replaceAll(\"'\", \"'\\\\''\")}'`;\n}\n/**\n* The command a user runs from the invocation's directory to repeat a\n* converge: the command line the adapter started, or, from an adapter that\n* does not report one, `alchemy` with the same arguments.\n*/\nfunction reproduceCommand(invocation, outcome, platform = process.platform) {\n\treturn (outcome?.commandLine === void 0 ? [\n\t\t\"alchemy\",\n\t\tinvocation.action,\n\t\tinvocation.stackFileRelativePath,\n\t\t\"--yes\",\n\t\t\"--stage\",\n\t\tinvocation.stage\n\t] : [outcome.commandLine.command, ...outcome.commandLine.args]).map((arg) => shellArg(arg, platform)).join(\" \");\n}\n/** Starts a resolved command line with stdin inherited and its output piped through redaction, and returns how it ended. */\nfunction spawnCommandLine(line, redactedValues, outputs = process) {\n\treturn new Promise((resolve, reject) => {\n\t\tconst child = spawn(line.command, [...line.args], {\n\t\t\tcwd: line.cwd,\n\t\t\tstdio: [\n\t\t\t\t\"inherit\",\n\t\t\t\t\"pipe\",\n\t\t\t\t\"pipe\"\n\t\t\t],\n\t\t\tenv: {\n\t\t\t\t...process.env,\n\t\t\t\t...line.env\n\t\t\t}\n\t\t});\n\t\tconst stdout = new StreamRedactor(redactedValues);\n\t\tconst stderr = new StreamRedactor(redactedValues);\n\t\tconst write = (stream, text) => {\n\t\t\tif (text.length > 0) stream.write(text);\n\t\t};\n\t\tchild.stdout?.setEncoding(\"utf8\").on(\"data\", (chunk) => write(outputs.stdout, stdout.push(chunk)));\n\t\tchild.stderr?.setEncoding(\"utf8\").on(\"data\", (chunk) => write(outputs.stderr, stderr.push(chunk)));\n\t\tchild.on(\"error\", reject);\n\t\tchild.on(\"close\", (exitCode, signal) => {\n\t\t\twrite(outputs.stdout, stdout.end());\n\t\t\twrite(outputs.stderr, stderr.end());\n\t\t\tresolve({\n\t\t\t\texitCode,\n\t\t\t\tsignal\n\t\t\t});\n\t\t});\n\t});\n}\n//#endregion\nexport { spawnAlchemy as i, alchemyInvocation as n, reproduceCommand as r, alchemyCommandLine as t };\n\n//# sourceMappingURL=run-alchemy-CRLAyOtt.mjs.map"],"mappings":";;;;;;;;;;;;;;;;;;;AAmBA,MAAM,MAAM;AACZ,SAAS,WAAW,SAAS;CAC5B,OAAO,IAAI,mBAAmB,8BAA8B,SAAS,EAAE,KAAK,IAAI,CAAC;AAClF;AACA,SAAS,mBAAmB,QAAQ;CACnC,IAAI;EACH,MAAM,WAAW,cAAc,KAAK,KAAK,QAAQ,cAAc,CAAC,CAAC,CAAC,QAAQ,+BAA+B;EACzG,OAAO,KAAK,QAAQ,GAAG,aAAa,QAAQ,CAAC;CAC9C,QAAQ;EACP;CAC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