@prisma/composer 0.5.0 → 0.6.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-config-bsTo57A8-BfG21wAI.d.mts → app-config-CFsSXEVj-B242oUnm.d.mts} +7 -5
- package/dist/app-config-CFsSXEVj-B242oUnm.d.mts.map +1 -0
- package/dist/bin.mjs +11 -3274
- package/dist/bin.mjs.map +1 -1
- package/dist/cli-B3sWzFlb-CxEIzKsQ.mjs +401 -0
- package/dist/cli-B3sWzFlb-CxEIzKsQ.mjs.map +1 -0
- package/dist/config-ku5b_2YD.d.mts +1 -0
- package/dist/config.d.mts +2 -2
- package/dist/container-transport-DKmKg5JQ-BMRhx5w-.mjs +75 -0
- package/dist/container-transport-DKmKg5JQ-BMRhx5w-.mjs.map +1 -0
- package/dist/control.d.mts +216 -0
- package/dist/control.d.mts.map +1 -0
- package/dist/control.mjs +70 -0
- package/dist/control.mjs.map +1 -0
- package/dist/deploy-ku5b_2YD.d.mts +1 -0
- package/dist/deploy.d.mts +2 -2
- package/dist/deploy.mjs +312 -1
- package/dist/deploy.mjs.map +1 -0
- package/dist/deployment-summary-r47O6kFr-CcMYVOn5.mjs +70 -0
- package/dist/deployment-summary-r47O6kFr-CcMYVOn5.mjs.map +1 -0
- package/dist/{dist-BdvFDCLV.mjs → dist-C5rZnr4n.mjs} +2 -2
- package/dist/{dist-BdvFDCLV.mjs.map → dist-C5rZnr4n.mjs.map} +1 -1
- package/dist/emulator-retry-DGonap4g-S8BNrXFD.mjs +24 -0
- package/dist/emulator-retry-DGonap4g-S8BNrXFD.mjs.map +1 -0
- package/dist/errors-0e8IVwzi.mjs +88 -0
- package/dist/errors-0e8IVwzi.mjs.map +1 -0
- package/dist/execute-deploy-destroy-IT4vGkMc-YM1Cv6cu.mjs +306 -0
- package/dist/execute-deploy-destroy-IT4vGkMc-YM1Cv6cu.mjs.map +1 -0
- package/dist/execute-deploy-destroy-IT4vGkMc-oO8yjHPH.mjs +265 -0
- package/dist/execute-deploy-destroy-IT4vGkMc-oO8yjHPH.mjs.map +1 -0
- package/dist/execute-dev-DLYyduEM-88uyvrbj.mjs +2009 -0
- package/dist/execute-dev-DLYyduEM-88uyvrbj.mjs.map +1 -0
- package/dist/execute-dev-DLYyduEM-BuUGTm0g.mjs +2006 -0
- package/dist/execute-dev-DLYyduEM-BuUGTm0g.mjs.map +1 -0
- package/dist/execute-log-VIOL4DBz-DBPH8By4.mjs +157 -0
- package/dist/execute-log-VIOL4DBz-DBPH8By4.mjs.map +1 -0
- package/dist/execute-log-VIOL4DBz-DKodBrxS.mjs +155 -0
- package/dist/execute-log-VIOL4DBz-DKodBrxS.mjs.map +1 -0
- package/dist/{graph-DgbALPDo-BEHF94BN.mjs → graph-BJgUfGB0-kvgFzT4q.mjs} +13 -7
- package/dist/graph-BJgUfGB0-kvgFzT4q.mjs.map +1 -0
- package/dist/{graph-DDpXh7S8-b-93BcHn.d.mts → graph-DqklX5Sf-BNS2aO1j.d.mts} +3 -3
- package/dist/graph-DqklX5Sf-BNS2aO1j.d.mts.map +1 -0
- package/dist/{graph-types-C3FOaaXm-C6_rGzfn.d.mts → graph-types-N6brq1zY-1VMNwtkJ.d.mts} +88 -5
- package/dist/graph-types-N6brq1zY-1VMNwtkJ.d.mts.map +1 -0
- package/dist/{index-BQVrMGfe.d.mts → index-DryPyF9U.d.mts} +3 -3
- package/dist/{index-BQVrMGfe.d.mts.map → index-DryPyF9U.d.mts.map} +1 -1
- package/dist/index.d.mts +3 -3
- package/dist/index.mjs +2 -2
- package/dist/internal-error-BIc-ehme-Ck_lgxD_.mjs +18 -0
- package/dist/internal-error-BIc-ehme-Ck_lgxD_.mjs.map +1 -0
- package/dist/local-target-DnA2E8IN.mjs +47 -0
- package/dist/local-target-DnA2E8IN.mjs.map +1 -0
- package/dist/local-target-DuSyWeYc.mjs +68 -0
- package/dist/local-target-DuSyWeYc.mjs.map +1 -0
- package/dist/local-target.d.mts +1 -1
- package/dist/local-target.mjs +2 -46
- package/dist/{nextjs-DLyeRR7M-D47aMmfr.d.mts → nextjs-DLyeRR7M-DZODs9tk.d.mts} +3 -3
- package/dist/{nextjs-DLyeRR7M-D47aMmfr.d.mts.map → nextjs-DLyeRR7M-DZODs9tk.d.mts.map} +1 -1
- package/dist/nextjs-control.d.mts +4 -4
- package/dist/nextjs.d.mts +1 -1
- package/dist/node-control.d.mts +3 -3
- package/dist/node.d.mts +2 -2
- package/dist/pipeline-D3QoVzAB-Ci2aJ2mE.mjs +331 -0
- package/dist/pipeline-D3QoVzAB-Ci2aJ2mE.mjs.map +1 -0
- package/dist/pipeline-D3QoVzAB-D_ufjg3N.mjs +857 -0
- package/dist/pipeline-D3QoVzAB-D_ufjg3N.mjs.map +1 -0
- package/dist/render-error-DsPN5qfr-CkVGj9uP.mjs +30 -0
- package/dist/render-error-DsPN5qfr-CkVGj9uP.mjs.map +1 -0
- package/dist/report.d.mts +4 -3
- package/dist/report.d.mts.map +1 -1
- package/dist/report.mjs +4 -1
- package/dist/report.mjs.map +1 -1
- package/dist/result-CFqJKiqg.mjs +106 -0
- package/dist/result-CFqJKiqg.mjs.map +1 -0
- package/dist/result-CzGChwbZ.mjs +231 -0
- package/dist/result-CzGChwbZ.mjs.map +1 -0
- package/dist/run-alchemy-hghRtddF-CQHOzlrW.mjs +48 -0
- package/dist/run-alchemy-hghRtddF-CQHOzlrW.mjs.map +1 -0
- package/dist/service-rpc.d.mts +2 -2
- package/dist/service-rpc.mjs +2 -2
- package/dist/shared-CCaR42wo-BvegvmA_.mjs +265 -0
- package/dist/shared-CCaR42wo-BvegvmA_.mjs.map +1 -0
- package/dist/testing.d.mts +1 -1
- package/package.json +15 -14
- package/src/exports/control.ts +1 -0
- package/dist/app-config-bsTo57A8-BfG21wAI.d.mts.map +0 -1
- package/dist/config-DUzvB5cQ.d.mts +0 -1
- package/dist/deploy-C4DxNkJ9-D73lmBqy.mjs +0 -313
- package/dist/deploy-C4DxNkJ9-D73lmBqy.mjs.map +0 -1
- package/dist/deploy-DUzvB5cQ.d.mts +0 -1
- package/dist/graph-DDpXh7S8-b-93BcHn.d.mts.map +0 -1
- package/dist/graph-DgbALPDo-BEHF94BN.mjs.map +0 -1
- package/dist/graph-types-C3FOaaXm-C6_rGzfn.d.mts.map +0 -1
- package/dist/local-target.mjs.map +0 -1
|
@@ -0,0 +1,401 @@
|
|
|
1
|
+
import { a as CliStructuredError, r as executorLoadFailure } from "./shared-CCaR42wo-BvegvmA_.mjs";
|
|
2
|
+
import { t as notOk } from "./result-CFqJKiqg.mjs";
|
|
3
|
+
import { n as renderErrorEnvelope, t as renderChildStatusHints } from "./render-error-DsPN5qfr-CkVGj9uP.mjs";
|
|
4
|
+
import { Cli, Command, Option, UsageError } from "clipanion";
|
|
5
|
+
//#region ../../0-framework/3-tooling/cli/dist/destroy-DPAo6kVj.mjs
|
|
6
|
+
/** In-package variant threading the injection seam (the CLI's RunDeps, unit
|
|
7
|
+
* tests). Deliberately NOT re-exported through `./control` — the seam mirrors
|
|
8
|
+
* internal types and is not part of the published surface. */
|
|
9
|
+
async function devWithDeps(input, deps) {
|
|
10
|
+
const cwd = input.cwd ?? process.cwd();
|
|
11
|
+
let executor;
|
|
12
|
+
try {
|
|
13
|
+
executor = await import("./execute-dev-DLYyduEM-BuUGTm0g.mjs");
|
|
14
|
+
} catch (error) {
|
|
15
|
+
return notOk(executorLoadFailure("dev", error, cwd));
|
|
16
|
+
}
|
|
17
|
+
return executor.executeDev(input, deps, cwd);
|
|
18
|
+
}
|
|
19
|
+
/** In-package variant threading the injection seam (the CLI's LogRunDeps,
|
|
20
|
+
* unit tests). Deliberately NOT re-exported through `./control` — the seam
|
|
21
|
+
* mirrors internal types and is not part of the published surface. */
|
|
22
|
+
async function logWithDeps(input, deps) {
|
|
23
|
+
const cwd = input.cwd ?? process.cwd();
|
|
24
|
+
let executor;
|
|
25
|
+
try {
|
|
26
|
+
executor = await import("./execute-log-VIOL4DBz-DKodBrxS.mjs");
|
|
27
|
+
} catch (error) {
|
|
28
|
+
return notOk(executorLoadFailure("log", error, cwd));
|
|
29
|
+
}
|
|
30
|
+
return executor.executeLog(input, deps, cwd);
|
|
31
|
+
}
|
|
32
|
+
/** In-package variant threading the injection seam (the CLI's RunDeps, unit
|
|
33
|
+
* tests). Deliberately NOT re-exported through `./control` — the seam mirrors
|
|
34
|
+
* internal types and is not part of the published surface. */
|
|
35
|
+
async function deployWithDeps(input, deps) {
|
|
36
|
+
const cwd = input.cwd ?? process.cwd();
|
|
37
|
+
let executor;
|
|
38
|
+
try {
|
|
39
|
+
executor = await import("./execute-deploy-destroy-IT4vGkMc-YM1Cv6cu.mjs");
|
|
40
|
+
} catch (error) {
|
|
41
|
+
return notOk(executorLoadFailure("deploy", error, cwd));
|
|
42
|
+
}
|
|
43
|
+
return executor.executeDeploy(input, deps, cwd);
|
|
44
|
+
}
|
|
45
|
+
/** In-package variant threading the injection seam (the CLI's RunDeps, unit
|
|
46
|
+
* tests). Deliberately NOT re-exported through `./control` — the seam mirrors
|
|
47
|
+
* internal types and is not part of the published surface. */
|
|
48
|
+
async function destroyWithDeps(input, deps) {
|
|
49
|
+
const cwd = input.cwd ?? process.cwd();
|
|
50
|
+
let executor;
|
|
51
|
+
try {
|
|
52
|
+
executor = await import("./execute-deploy-destroy-IT4vGkMc-YM1Cv6cu.mjs");
|
|
53
|
+
} catch (error) {
|
|
54
|
+
return notOk(executorLoadFailure("destroy", error, cwd));
|
|
55
|
+
}
|
|
56
|
+
return executor.executeDestroy(input, deps, cwd);
|
|
57
|
+
}
|
|
58
|
+
//#endregion
|
|
59
|
+
//#region ../../0-framework/3-tooling/cli/dist/cli-M2oUU0IV.mjs
|
|
60
|
+
/**
|
|
61
|
+
* Local-dev spec § 6 `run-dev.ts`: `prisma-composer dev <entry>` — the CLI
|
|
62
|
+
* adapter over the programmatic `dev()` operation
|
|
63
|
+
* (../operations/execute-dev.ts): parse-shaped args in, events rendered to the
|
|
64
|
+
* console, signal handling and exit codes owned here. The pipeline itself
|
|
65
|
+
* (capability check, containers, `--fresh` teardown, preflight, emulators,
|
|
66
|
+
* converge, attach, watch loop) lives in the operation.
|
|
67
|
+
*/
|
|
68
|
+
/** `[dev] ready:` then one line per endpoint, ordered by address depth (fewest dots first) then lexicographic. Exported for tests. */
|
|
69
|
+
function renderFrontDoor(endpoints) {
|
|
70
|
+
return ["[dev] ready:", ...[...endpoints].sort((a, b) => {
|
|
71
|
+
const depthA = a.address.split(".").length;
|
|
72
|
+
const depthB = b.address.split(".").length;
|
|
73
|
+
if (depthA !== depthB) return depthA - depthB;
|
|
74
|
+
return a.address < b.address ? -1 : a.address > b.address ? 1 : 0;
|
|
75
|
+
}).map((e) => `[dev] ${e.address} ${e.url}`)];
|
|
76
|
+
}
|
|
77
|
+
function printFrontDoor(endpoints) {
|
|
78
|
+
for (const line of renderFrontDoor(endpoints)) console.log(line);
|
|
79
|
+
}
|
|
80
|
+
/** Runs the full dev pipeline; returns the process exit code. */
|
|
81
|
+
async function runDev(args, deps = {}) {
|
|
82
|
+
let hintPrinted = false;
|
|
83
|
+
const pendingUnwatchable = [];
|
|
84
|
+
const result = await devWithDeps({
|
|
85
|
+
entry: args.entry,
|
|
86
|
+
name: args.name,
|
|
87
|
+
fresh: args.fresh,
|
|
88
|
+
onEvent: (event) => {
|
|
89
|
+
switch (event.kind) {
|
|
90
|
+
case "ready":
|
|
91
|
+
printFrontDoor(event.endpoints);
|
|
92
|
+
break;
|
|
93
|
+
case "unwatchable": {
|
|
94
|
+
const line = `[dev] ${event.address} has no watchable inputs`;
|
|
95
|
+
if (hintPrinted) console.log(line);
|
|
96
|
+
else pendingUnwatchable.push(line);
|
|
97
|
+
break;
|
|
98
|
+
}
|
|
99
|
+
case "converge-failed":
|
|
100
|
+
console.error("[dev] converge failed — the running app is untouched; still watching.");
|
|
101
|
+
console.error(`\nGenerated stack file: ${event.stackFilePath}`);
|
|
102
|
+
console.error(`Run \`${event.reproduceCommand}\` from ${event.cwd} to reproduce this directly.`);
|
|
103
|
+
break;
|
|
104
|
+
case "rebuild-failed":
|
|
105
|
+
console.error(`[dev] rebuild failed: ${event.message}`);
|
|
106
|
+
break;
|
|
107
|
+
case "watch-error":
|
|
108
|
+
console.error(`[dev] watch error: ${event.message}`);
|
|
109
|
+
break;
|
|
110
|
+
case "stop-error":
|
|
111
|
+
console.error(`[dev] a service refused to stop: ${event.message}`);
|
|
112
|
+
break;
|
|
113
|
+
case "stopping":
|
|
114
|
+
console.log("[dev] stopping — the app's services are stopping; emulators and data stay up.");
|
|
115
|
+
break;
|
|
116
|
+
case "stopped":
|
|
117
|
+
console.log("[dev] stopped.");
|
|
118
|
+
break;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
}, deps);
|
|
122
|
+
if (!result.ok) {
|
|
123
|
+
const failure = result.failure;
|
|
124
|
+
const status = renderChildStatusHints(failure);
|
|
125
|
+
if (status !== void 0) return status;
|
|
126
|
+
throw failure;
|
|
127
|
+
}
|
|
128
|
+
const session = result.value;
|
|
129
|
+
console.log(`[dev] logs: prisma-composer log ${args.entry}`);
|
|
130
|
+
hintPrinted = true;
|
|
131
|
+
for (const line of pendingUnwatchable.splice(0)) console.log(line);
|
|
132
|
+
const finish = () => {
|
|
133
|
+
session.stop();
|
|
134
|
+
};
|
|
135
|
+
process.removeAllListeners("SIGINT");
|
|
136
|
+
process.removeAllListeners("SIGTERM");
|
|
137
|
+
process.on("SIGINT", finish);
|
|
138
|
+
process.on("SIGTERM", finish);
|
|
139
|
+
await session.closed;
|
|
140
|
+
process.off("SIGINT", finish);
|
|
141
|
+
process.off("SIGTERM", finish);
|
|
142
|
+
return 0;
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* `prisma-composer log <entry> [address]` — the CLI adapter over the
|
|
146
|
+
* programmatic `log()` operation (../operations/execute-log.ts): it owns the
|
|
147
|
+
* SIGINT/SIGTERM → abort wiring, the empty-services notice, and the
|
|
148
|
+
* `[service] line` rendering. Resolution, attach, and the merged stream live
|
|
149
|
+
* in the operation. `dev` no longer streams logs inline (that drowned the
|
|
150
|
+
* front door once it supervises more than one service); this is where logs
|
|
151
|
+
* live.
|
|
152
|
+
*/
|
|
153
|
+
/** Runs the log tail until interrupted; returns the process exit code. */
|
|
154
|
+
async function runLog(args, deps = {}) {
|
|
155
|
+
const controller = new AbortController();
|
|
156
|
+
const finish = () => controller.abort();
|
|
157
|
+
process.on("SIGINT", finish);
|
|
158
|
+
process.on("SIGTERM", finish);
|
|
159
|
+
try {
|
|
160
|
+
const result = await logWithDeps({
|
|
161
|
+
entry: args.entry,
|
|
162
|
+
name: args.name,
|
|
163
|
+
address: args.address,
|
|
164
|
+
tail: args.tail,
|
|
165
|
+
signal: controller.signal,
|
|
166
|
+
onEvent: (event) => {
|
|
167
|
+
if (event.kind === "stream-failed") console.error(`[log] stream failed: ${event.message}`);
|
|
168
|
+
else if (event.kind === "lines-dropped") console.error(`[log] falling behind — dropped the ${String(event.count)} oldest lines.`);
|
|
169
|
+
}
|
|
170
|
+
}, {
|
|
171
|
+
config: deps.config,
|
|
172
|
+
identity: deps.identity
|
|
173
|
+
});
|
|
174
|
+
if (!result.ok) throw result.failure;
|
|
175
|
+
const attached = result.value;
|
|
176
|
+
if (attached.services.length === 0) {
|
|
177
|
+
console.error(`[log] no running services for "${attached.appName}" — start it first with \`prisma-composer dev ${args.entry}\`.`);
|
|
178
|
+
return 0;
|
|
179
|
+
}
|
|
180
|
+
for await (const { service, line } of attached.lines) console.log(`[${service}] ${line}`);
|
|
181
|
+
} finally {
|
|
182
|
+
process.off("SIGINT", finish);
|
|
183
|
+
process.off("SIGTERM", finish);
|
|
184
|
+
}
|
|
185
|
+
return 0;
|
|
186
|
+
}
|
|
187
|
+
/**
|
|
188
|
+
* Argument parsing (clipanion — prisma-next's CLI idiom, see
|
|
189
|
+
* prisma-next/packages/1-framework/3-tooling/cli/src/migration-cli.ts) +
|
|
190
|
+
* orchestration of deploy-cli.md § The pipeline.
|
|
191
|
+
*/
|
|
192
|
+
const BINARY_NAME = "prisma-composer";
|
|
193
|
+
/** The <entry>/--name/--stage surface shared by deploy and destroy; execute() is unused — run() drives the pipeline directly so error handling stays under this module's control. */
|
|
194
|
+
var DeployCliCommand = class extends Command {
|
|
195
|
+
entry = Option.String({ name: "entry" });
|
|
196
|
+
name = Option.String("--name", { description: "Override the root node's name — the deploy's application name." });
|
|
197
|
+
stage = Option.String("--stage", { description: "Alchemy stage to target." });
|
|
198
|
+
production = Option.Boolean("--production", false, { description: "destroy: tear down the project-level production environment (required to destroy production)." });
|
|
199
|
+
async execute() {
|
|
200
|
+
return 0;
|
|
201
|
+
}
|
|
202
|
+
};
|
|
203
|
+
var DeployCommand = class extends DeployCliCommand {
|
|
204
|
+
static paths = [["deploy"]];
|
|
205
|
+
static usage = Command.Usage({
|
|
206
|
+
description: "Deploy the application whose root node is <entry>'s default export.",
|
|
207
|
+
examples: [["Deploy an app", "$0 deploy src/service.ts"]]
|
|
208
|
+
});
|
|
209
|
+
action = "deploy";
|
|
210
|
+
};
|
|
211
|
+
var DestroyCommand = class extends DeployCliCommand {
|
|
212
|
+
static paths = [["destroy"]];
|
|
213
|
+
static usage = Command.Usage({
|
|
214
|
+
description: "Tear down the application whose root node is <entry>'s default export — same derivation as deploy, Alchemy destroy.",
|
|
215
|
+
examples: [["Destroy an app", "$0 destroy src/service.ts"]]
|
|
216
|
+
});
|
|
217
|
+
action = "destroy";
|
|
218
|
+
};
|
|
219
|
+
/** `<entry>`/`--name`/`--fresh` only — no `--stage`/`--production` (local-dev spec § 6: a working directory has exactly one dev instance, no stages). */
|
|
220
|
+
var DevCommand = class extends Command {
|
|
221
|
+
static paths = [["dev"]];
|
|
222
|
+
static usage = Command.Usage({
|
|
223
|
+
description: "Bring up the application whose root node is <entry>'s default export, entirely on this machine, credential-free.",
|
|
224
|
+
examples: [["Run an app locally", "$0 dev src/service.ts"]]
|
|
225
|
+
});
|
|
226
|
+
entry = Option.String({ name: "entry" });
|
|
227
|
+
name = Option.String("--name", { description: "Override the root node's name — the dev instance's application name." });
|
|
228
|
+
fresh = Option.Boolean("--fresh", false, { description: "Destroy the dev stack and wipe the dev state directory before starting." });
|
|
229
|
+
async execute() {
|
|
230
|
+
return 0;
|
|
231
|
+
}
|
|
232
|
+
};
|
|
233
|
+
var LogCommand = class extends Command {
|
|
234
|
+
static paths = [["log"]];
|
|
235
|
+
static usage = Command.Usage({
|
|
236
|
+
description: "Tail the merged logs of the locally-running application whose root node is <entry>'s default export.",
|
|
237
|
+
examples: [["Tail every service", "$0 log src/service.ts"], ["Tail one service", "$0 log src/service.ts catalog.service"]]
|
|
238
|
+
});
|
|
239
|
+
entry = Option.String({ name: "entry" });
|
|
240
|
+
address = Option.String({
|
|
241
|
+
name: "address",
|
|
242
|
+
required: false
|
|
243
|
+
});
|
|
244
|
+
name = Option.String("--name", { description: "Override the root node's name — the dev instance's application name." });
|
|
245
|
+
tail = Option.String("--tail", { description: `How many trailing history lines to show before live output (default ${String(DEFAULT_LOG_TAIL)}).` });
|
|
246
|
+
async execute() {
|
|
247
|
+
return 0;
|
|
248
|
+
}
|
|
249
|
+
};
|
|
250
|
+
function buildCli() {
|
|
251
|
+
return Cli.from([
|
|
252
|
+
DeployCommand,
|
|
253
|
+
DestroyCommand,
|
|
254
|
+
DevCommand,
|
|
255
|
+
LogCommand
|
|
256
|
+
], {
|
|
257
|
+
binaryName: BINARY_NAME,
|
|
258
|
+
binaryLabel: "The prisma-composer deploy CLI"
|
|
259
|
+
});
|
|
260
|
+
}
|
|
261
|
+
/** Thrown internally when the user explicitly asked for `--help`/`-h` — run() prints it to stdout and exits 0; not a usage error. */
|
|
262
|
+
var HelpRequested = class extends Error {};
|
|
263
|
+
/** Duck-typed: clipanion's UnknownSyntaxError isn't re-exported, so match its name + clipanion.type discriminator (mirrors prisma-next's migration-cli.ts). */
|
|
264
|
+
function isUnknownSyntaxError(error) {
|
|
265
|
+
if (!(error instanceof Error) || error.name !== "UnknownSyntaxError") return false;
|
|
266
|
+
const meta = error.clipanion;
|
|
267
|
+
return typeof meta === "object" && meta !== null && meta.type === "none";
|
|
268
|
+
}
|
|
269
|
+
/** `log`'s default backlog: an empty screen reads as broken, so show a little recent history before going live. */
|
|
270
|
+
const DEFAULT_LOG_TAIL = 20;
|
|
271
|
+
/** Exported for direct testing (main.test.ts) — not part of the package's public barrel (see index.ts). */
|
|
272
|
+
function parseArgs(argv) {
|
|
273
|
+
const cli = buildCli();
|
|
274
|
+
let command;
|
|
275
|
+
try {
|
|
276
|
+
command = cli.process([...argv]);
|
|
277
|
+
} catch (error) {
|
|
278
|
+
if (isUnknownSyntaxError(error) || error instanceof UsageError) throw new UsageError(cli.usage(null, { detailed: true }));
|
|
279
|
+
throw error;
|
|
280
|
+
}
|
|
281
|
+
if (command instanceof DeployCommand || command instanceof DestroyCommand) return {
|
|
282
|
+
command: command.action,
|
|
283
|
+
entry: command.entry,
|
|
284
|
+
name: command.name,
|
|
285
|
+
stage: command.stage,
|
|
286
|
+
production: command.production,
|
|
287
|
+
fresh: false
|
|
288
|
+
};
|
|
289
|
+
if (command instanceof DevCommand) return {
|
|
290
|
+
command: "dev",
|
|
291
|
+
entry: command.entry,
|
|
292
|
+
name: command.name,
|
|
293
|
+
stage: void 0,
|
|
294
|
+
production: false,
|
|
295
|
+
fresh: command.fresh
|
|
296
|
+
};
|
|
297
|
+
if (command instanceof LogCommand) {
|
|
298
|
+
const tail = command.tail === void 0 ? DEFAULT_LOG_TAIL : Number.parseInt(command.tail, 10);
|
|
299
|
+
if (Number.isNaN(tail) || tail < 0) throw new UsageError("`--tail` must be a non-negative integer.");
|
|
300
|
+
return {
|
|
301
|
+
command: "log",
|
|
302
|
+
entry: command.entry,
|
|
303
|
+
name: command.name,
|
|
304
|
+
stage: void 0,
|
|
305
|
+
production: false,
|
|
306
|
+
fresh: false,
|
|
307
|
+
address: command.address,
|
|
308
|
+
tail
|
|
309
|
+
};
|
|
310
|
+
}
|
|
311
|
+
if (argv.includes("--help") || argv.includes("-h")) throw new HelpRequested(cli.usage(null, { detailed: true }));
|
|
312
|
+
throw new UsageError(cli.usage(null, { detailed: true }));
|
|
313
|
+
}
|
|
314
|
+
/**
|
|
315
|
+
* Renders a deploy/destroy operation failure the way run() always has: an
|
|
316
|
+
* alchemy exit becomes the two console.error hint lines and the child's own
|
|
317
|
+
* status (the documented ADR-0044 child-status exception); everything else
|
|
318
|
+
* rethrows the structured failure so cli.ts renders its envelope.
|
|
319
|
+
*/
|
|
320
|
+
function renderDeployDestroyFailure(failure) {
|
|
321
|
+
const status = renderChildStatusHints(failure);
|
|
322
|
+
if (status !== void 0) return status;
|
|
323
|
+
throw failure;
|
|
324
|
+
}
|
|
325
|
+
/** Runs the full pipeline; returns the process exit code. */
|
|
326
|
+
async function run(argv, deps = {}) {
|
|
327
|
+
let args;
|
|
328
|
+
try {
|
|
329
|
+
args = parseArgs(argv);
|
|
330
|
+
} catch (error) {
|
|
331
|
+
if (error instanceof HelpRequested) {
|
|
332
|
+
console.log(error.message);
|
|
333
|
+
return 0;
|
|
334
|
+
}
|
|
335
|
+
throw error;
|
|
336
|
+
}
|
|
337
|
+
if (args.command === "dev") return runDev(args, deps);
|
|
338
|
+
if (args.command === "log") return runLog({
|
|
339
|
+
entry: args.entry,
|
|
340
|
+
name: args.name,
|
|
341
|
+
address: args.address,
|
|
342
|
+
tail: args.tail ?? DEFAULT_LOG_TAIL
|
|
343
|
+
}, { config: deps.config });
|
|
344
|
+
if (args.command === "deploy") {
|
|
345
|
+
if (args.production) throw new CliStructuredError("DEPLOY.FLAG_INVALID", "--production is only valid with `destroy`.", { fix: "`deploy` targets production by default (omit --stage)." });
|
|
346
|
+
const result = await deployWithDeps({
|
|
347
|
+
entry: args.entry,
|
|
348
|
+
name: args.name,
|
|
349
|
+
stage: args.stage
|
|
350
|
+
}, deps);
|
|
351
|
+
if (result.ok) return 0;
|
|
352
|
+
return renderDeployDestroyFailure(result.failure);
|
|
353
|
+
}
|
|
354
|
+
if (args.stage !== void 0 && args.production) throw new CliStructuredError("DEPLOY.TARGET_CONFLICT", "Pass either --stage <name> or --production to `destroy`, not both.");
|
|
355
|
+
if (args.stage === void 0 && !args.production) throw new CliStructuredError("DEPLOY.TARGET_MISSING", "`destroy` requires an explicit target.", { fix: "Pass --stage <name> to tear down a branch environment, or --production to tear down the production environment." });
|
|
356
|
+
const target = args.stage !== void 0 ? {
|
|
357
|
+
kind: "stage",
|
|
358
|
+
stage: args.stage
|
|
359
|
+
} : { kind: "production" };
|
|
360
|
+
const result = await destroyWithDeps({
|
|
361
|
+
entry: args.entry,
|
|
362
|
+
name: args.name,
|
|
363
|
+
target,
|
|
364
|
+
onEvent: (event) => {
|
|
365
|
+
if (event.kind === "no-local-deploy-state") console.warn(`\nNo prior deploy state under ${event.cwd} — if you deployed from a different directory, run destroy from there; otherwise this is a no-op.`);
|
|
366
|
+
}
|
|
367
|
+
}, deps);
|
|
368
|
+
if (result.ok) return 0;
|
|
369
|
+
return renderDeployDestroyFailure(result.failure);
|
|
370
|
+
}
|
|
371
|
+
/** Printed for a non-structured escape — by the shared base-type rules that is a bug, not a user failure. */
|
|
372
|
+
const REPORT_HINT = "This is a bug in prisma-composer, not in your app — please report it: https://github.com/prisma/composer/issues";
|
|
373
|
+
/**
|
|
374
|
+
* Run the `prisma-composer` CLI end to end: dispatch `argv`, map errors to exit
|
|
375
|
+
* codes — usage errors and structured failures exit 2 (expected failures),
|
|
376
|
+
* anything else is a bug and exits 1 with a report hint. Shared by this
|
|
377
|
+
* package's `bin` and the unscoped `prisma-composer` launcher.
|
|
378
|
+
*/
|
|
379
|
+
async function cli(argv = process.argv.slice(2)) {
|
|
380
|
+
try {
|
|
381
|
+
process.exitCode = await run(argv);
|
|
382
|
+
} catch (error) {
|
|
383
|
+
if (error instanceof UsageError) {
|
|
384
|
+
console.error(error.message);
|
|
385
|
+
process.exitCode = 2;
|
|
386
|
+
return;
|
|
387
|
+
}
|
|
388
|
+
if (CliStructuredError.is(error)) {
|
|
389
|
+
console.error(renderErrorEnvelope(error.toEnvelope()));
|
|
390
|
+
process.exitCode = 2;
|
|
391
|
+
return;
|
|
392
|
+
}
|
|
393
|
+
console.error(`Error: ${error instanceof Error ? error.message : String(error)}`);
|
|
394
|
+
console.error(REPORT_HINT);
|
|
395
|
+
process.exitCode = 1;
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
//#endregion
|
|
399
|
+
export { cli };
|
|
400
|
+
|
|
401
|
+
//# sourceMappingURL=cli-B3sWzFlb-CxEIzKsQ.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli-B3sWzFlb-CxEIzKsQ.mjs","names":[],"sources":["../../../0-framework/3-tooling/cli/dist/destroy-DPAo6kVj.mjs","../../../0-framework/3-tooling/cli/dist/cli-M2oUU0IV.mjs"],"sourcesContent":["import { n as executorLoadFailure } from \"./shared-CCaR42wo.mjs\";\nimport { notOk } from \"@internal/foundation/result\";\n//#region src/operations/dev.ts\nasync function dev(input) {\n\treturn devWithDeps(input, {});\n}\n/** In-package variant threading the injection seam (the CLI's RunDeps, unit\n* tests). Deliberately NOT re-exported through `./control` — the seam mirrors\n* internal types and is not part of the published surface. */\nasync function devWithDeps(input, deps) {\n\tconst cwd = input.cwd ?? process.cwd();\n\tlet executor;\n\ttry {\n\t\texecutor = await import(\"./execute-dev-DLYyduEM.mjs\");\n\t} catch (error) {\n\t\treturn notOk(executorLoadFailure(\"dev\", error, cwd));\n\t}\n\treturn executor.executeDev(input, deps, cwd);\n}\n//#endregion\n//#region src/operations/log.ts\nasync function log(input) {\n\treturn logWithDeps(input, {});\n}\n/** In-package variant threading the injection seam (the CLI's LogRunDeps,\n* unit tests). Deliberately NOT re-exported through `./control` — the seam\n* mirrors internal types and is not part of the published surface. */\nasync function logWithDeps(input, deps) {\n\tconst cwd = input.cwd ?? process.cwd();\n\tlet executor;\n\ttry {\n\t\texecutor = await import(\"./execute-log-VIOL4DBz.mjs\");\n\t} catch (error) {\n\t\treturn notOk(executorLoadFailure(\"log\", error, cwd));\n\t}\n\treturn executor.executeLog(input, deps, cwd);\n}\n//#endregion\n//#region src/operations/deploy.ts\nasync function deploy(input) {\n\treturn deployWithDeps(input, {});\n}\n/** In-package variant threading the injection seam (the CLI's RunDeps, unit\n* tests). Deliberately NOT re-exported through `./control` — the seam mirrors\n* internal types and is not part of the published surface. */\nasync function deployWithDeps(input, deps) {\n\tconst cwd = input.cwd ?? process.cwd();\n\tlet executor;\n\ttry {\n\t\texecutor = await import(\"./execute-deploy-destroy-IT4vGkMc.mjs\");\n\t} catch (error) {\n\t\treturn notOk(executorLoadFailure(\"deploy\", error, cwd));\n\t}\n\treturn executor.executeDeploy(input, deps, cwd);\n}\n//#endregion\n//#region src/operations/destroy.ts\nasync function destroy(input) {\n\treturn destroyWithDeps(input, {});\n}\n/** In-package variant threading the injection seam (the CLI's RunDeps, unit\n* tests). Deliberately NOT re-exported through `./control` — the seam mirrors\n* internal types and is not part of the published surface. */\nasync function destroyWithDeps(input, deps) {\n\tconst cwd = input.cwd ?? process.cwd();\n\tlet executor;\n\ttry {\n\t\texecutor = await import(\"./execute-deploy-destroy-IT4vGkMc.mjs\");\n\t} catch (error) {\n\t\treturn notOk(executorLoadFailure(\"destroy\", error, cwd));\n\t}\n\treturn executor.executeDestroy(input, deps, cwd);\n}\n//#endregion\nexport { log as a, devWithDeps as c, deployWithDeps as i, destroyWithDeps as n, logWithDeps as o, deploy as r, dev as s, destroy as t };\n\n//# sourceMappingURL=destroy-DPAo6kVj.mjs.map","import { c as devWithDeps, i as deployWithDeps, n as destroyWithDeps, o as logWithDeps } from \"./destroy-DPAo6kVj.mjs\";\nimport { n as renderErrorEnvelope, t as renderChildStatusHints } from \"./render-error-DsPN5qfr.mjs\";\nimport { CliStructuredError } from \"@internal/foundation/errors\";\nimport { Cli, Command, Option, UsageError } from \"clipanion\";\n//#region src/dev/run-dev.ts\n/**\n* Local-dev spec § 6 `run-dev.ts`: `prisma-composer dev <entry>` — the CLI\n* adapter over the programmatic `dev()` operation\n* (../operations/execute-dev.ts): parse-shaped args in, events rendered to the\n* console, signal handling and exit codes owned here. The pipeline itself\n* (capability check, containers, `--fresh` teardown, preflight, emulators,\n* converge, attach, watch loop) lives in the operation.\n*/\n/** `[dev] ready:` then one line per endpoint, ordered by address depth (fewest dots first) then lexicographic. Exported for tests. */\nfunction renderFrontDoor(endpoints) {\n\treturn [\"[dev] ready:\", ...[...endpoints].sort((a, b) => {\n\t\tconst depthA = a.address.split(\".\").length;\n\t\tconst depthB = b.address.split(\".\").length;\n\t\tif (depthA !== depthB) return depthA - depthB;\n\t\treturn a.address < b.address ? -1 : a.address > b.address ? 1 : 0;\n\t}).map((e) => `[dev] ${e.address} ${e.url}`)];\n}\nfunction printFrontDoor(endpoints) {\n\tfor (const line of renderFrontDoor(endpoints)) console.log(line);\n}\n/** Runs the full dev pipeline; returns the process exit code. */\nasync function runDev(args, deps = {}) {\n\tlet hintPrinted = false;\n\tconst pendingUnwatchable = [];\n\tconst result = await devWithDeps({\n\t\tentry: args.entry,\n\t\tname: args.name,\n\t\tfresh: args.fresh,\n\t\tonEvent: (event) => {\n\t\t\tswitch (event.kind) {\n\t\t\t\tcase \"ready\":\n\t\t\t\t\tprintFrontDoor(event.endpoints);\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"unwatchable\": {\n\t\t\t\t\tconst line = `[dev] ${event.address} has no watchable inputs`;\n\t\t\t\t\tif (hintPrinted) console.log(line);\n\t\t\t\t\telse pendingUnwatchable.push(line);\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tcase \"converge-failed\":\n\t\t\t\t\tconsole.error(\"[dev] converge failed — the running app is untouched; still watching.\");\n\t\t\t\t\tconsole.error(`\\nGenerated stack file: ${event.stackFilePath}`);\n\t\t\t\t\tconsole.error(`Run \\`${event.reproduceCommand}\\` from ${event.cwd} to reproduce this directly.`);\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"rebuild-failed\":\n\t\t\t\t\tconsole.error(`[dev] rebuild failed: ${event.message}`);\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"watch-error\":\n\t\t\t\t\tconsole.error(`[dev] watch error: ${event.message}`);\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"stop-error\":\n\t\t\t\t\tconsole.error(`[dev] a service refused to stop: ${event.message}`);\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"stopping\":\n\t\t\t\t\tconsole.log(\"[dev] stopping — the app's services are stopping; emulators and data stay up.\");\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"stopped\":\n\t\t\t\t\tconsole.log(\"[dev] stopped.\");\n\t\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}, deps);\n\tif (!result.ok) {\n\t\tconst failure = result.failure;\n\t\tconst status = renderChildStatusHints(failure);\n\t\tif (status !== void 0) return status;\n\t\tthrow failure;\n\t}\n\tconst session = result.value;\n\tconsole.log(`[dev] logs: prisma-composer log ${args.entry}`);\n\thintPrinted = true;\n\tfor (const line of pendingUnwatchable.splice(0)) console.log(line);\n\tconst finish = () => {\n\t\tsession.stop();\n\t};\n\tprocess.removeAllListeners(\"SIGINT\");\n\tprocess.removeAllListeners(\"SIGTERM\");\n\tprocess.on(\"SIGINT\", finish);\n\tprocess.on(\"SIGTERM\", finish);\n\tawait session.closed;\n\tprocess.off(\"SIGINT\", finish);\n\tprocess.off(\"SIGTERM\", finish);\n\treturn 0;\n}\n//#endregion\n//#region src/log/run-log.ts\n/**\n* `prisma-composer log <entry> [address]` — the CLI adapter over the\n* programmatic `log()` operation (../operations/execute-log.ts): it owns the\n* SIGINT/SIGTERM → abort wiring, the empty-services notice, and the\n* `[service] line` rendering. Resolution, attach, and the merged stream live\n* in the operation. `dev` no longer streams logs inline (that drowned the\n* front door once it supervises more than one service); this is where logs\n* live.\n*/\n/** Runs the log tail until interrupted; returns the process exit code. */\nasync function runLog(args, deps = {}) {\n\tconst controller = new AbortController();\n\tconst finish = () => controller.abort();\n\tprocess.on(\"SIGINT\", finish);\n\tprocess.on(\"SIGTERM\", finish);\n\ttry {\n\t\tconst result = await logWithDeps({\n\t\t\tentry: args.entry,\n\t\t\tname: args.name,\n\t\t\taddress: args.address,\n\t\t\ttail: args.tail,\n\t\t\tsignal: controller.signal,\n\t\t\tonEvent: (event) => {\n\t\t\t\tif (event.kind === \"stream-failed\") console.error(`[log] stream failed: ${event.message}`);\n\t\t\t\telse if (event.kind === \"lines-dropped\") console.error(`[log] falling behind — dropped the ${String(event.count)} oldest lines.`);\n\t\t\t}\n\t\t}, {\n\t\t\tconfig: deps.config,\n\t\t\tidentity: deps.identity\n\t\t});\n\t\tif (!result.ok) throw result.failure;\n\t\tconst attached = result.value;\n\t\tif (attached.services.length === 0) {\n\t\t\tconsole.error(`[log] no running services for \"${attached.appName}\" — start it first with \\`prisma-composer dev ${args.entry}\\`.`);\n\t\t\treturn 0;\n\t\t}\n\t\tfor await (const { service, line } of attached.lines) console.log(`[${service}] ${line}`);\n\t} finally {\n\t\tprocess.off(\"SIGINT\", finish);\n\t\tprocess.off(\"SIGTERM\", finish);\n\t}\n\treturn 0;\n}\n//#endregion\n//#region src/main.ts\n/**\n* Argument parsing (clipanion — prisma-next's CLI idiom, see\n* prisma-next/packages/1-framework/3-tooling/cli/src/migration-cli.ts) +\n* orchestration of deploy-cli.md § The pipeline.\n*/\nconst BINARY_NAME = \"prisma-composer\";\n/** The <entry>/--name/--stage surface shared by deploy and destroy; execute() is unused — run() drives the pipeline directly so error handling stays under this module's control. */\nvar DeployCliCommand = class extends Command {\n\tentry = Option.String({ name: \"entry\" });\n\tname = Option.String(\"--name\", { description: \"Override the root node's name — the deploy's application name.\" });\n\tstage = Option.String(\"--stage\", { description: \"Alchemy stage to target.\" });\n\tproduction = Option.Boolean(\"--production\", false, { description: \"destroy: tear down the project-level production environment (required to destroy production).\" });\n\tasync execute() {\n\t\treturn 0;\n\t}\n};\nvar DeployCommand = class extends DeployCliCommand {\n\tstatic paths = [[\"deploy\"]];\n\tstatic usage = Command.Usage({\n\t\tdescription: \"Deploy the application whose root node is <entry>'s default export.\",\n\t\texamples: [[\"Deploy an app\", \"$0 deploy src/service.ts\"]]\n\t});\n\taction = \"deploy\";\n};\nvar DestroyCommand = class extends DeployCliCommand {\n\tstatic paths = [[\"destroy\"]];\n\tstatic usage = Command.Usage({\n\t\tdescription: \"Tear down the application whose root node is <entry>'s default export — same derivation as deploy, Alchemy destroy.\",\n\t\texamples: [[\"Destroy an app\", \"$0 destroy src/service.ts\"]]\n\t});\n\taction = \"destroy\";\n};\n/** `<entry>`/`--name`/`--fresh` only — no `--stage`/`--production` (local-dev spec § 6: a working directory has exactly one dev instance, no stages). */\nvar DevCommand = class extends Command {\n\tstatic paths = [[\"dev\"]];\n\tstatic usage = Command.Usage({\n\t\tdescription: \"Bring up the application whose root node is <entry>'s default export, entirely on this machine, credential-free.\",\n\t\texamples: [[\"Run an app locally\", \"$0 dev src/service.ts\"]]\n\t});\n\tentry = Option.String({ name: \"entry\" });\n\tname = Option.String(\"--name\", { description: \"Override the root node's name — the dev instance's application name.\" });\n\tfresh = Option.Boolean(\"--fresh\", false, { description: \"Destroy the dev stack and wipe the dev state directory before starting.\" });\n\tasync execute() {\n\t\treturn 0;\n\t}\n};\nvar LogCommand = class extends Command {\n\tstatic paths = [[\"log\"]];\n\tstatic usage = Command.Usage({\n\t\tdescription: \"Tail the merged logs of the locally-running application whose root node is <entry>'s default export.\",\n\t\texamples: [[\"Tail every service\", \"$0 log src/service.ts\"], [\"Tail one service\", \"$0 log src/service.ts catalog.service\"]]\n\t});\n\tentry = Option.String({ name: \"entry\" });\n\taddress = Option.String({\n\t\tname: \"address\",\n\t\trequired: false\n\t});\n\tname = Option.String(\"--name\", { description: \"Override the root node's name — the dev instance's application name.\" });\n\ttail = Option.String(\"--tail\", { description: `How many trailing history lines to show before live output (default ${String(DEFAULT_LOG_TAIL)}).` });\n\tasync execute() {\n\t\treturn 0;\n\t}\n};\nfunction buildCli() {\n\treturn Cli.from([\n\t\tDeployCommand,\n\t\tDestroyCommand,\n\t\tDevCommand,\n\t\tLogCommand\n\t], {\n\t\tbinaryName: BINARY_NAME,\n\t\tbinaryLabel: \"The prisma-composer deploy CLI\"\n\t});\n}\n/** Thrown internally when the user explicitly asked for `--help`/`-h` — run() prints it to stdout and exits 0; not a usage error. */\nvar HelpRequested = class extends Error {};\n/** Duck-typed: clipanion's UnknownSyntaxError isn't re-exported, so match its name + clipanion.type discriminator (mirrors prisma-next's migration-cli.ts). */\nfunction isUnknownSyntaxError(error) {\n\tif (!(error instanceof Error) || error.name !== \"UnknownSyntaxError\") return false;\n\tconst meta = error.clipanion;\n\treturn typeof meta === \"object\" && meta !== null && meta.type === \"none\";\n}\n/** `log`'s default backlog: an empty screen reads as broken, so show a little recent history before going live. */\nconst DEFAULT_LOG_TAIL = 20;\n/** Exported for direct testing (main.test.ts) — not part of the package's public barrel (see index.ts). */\nfunction parseArgs(argv) {\n\tconst cli = buildCli();\n\tlet command;\n\ttry {\n\t\tcommand = cli.process([...argv]);\n\t} catch (error) {\n\t\tif (isUnknownSyntaxError(error) || error instanceof UsageError) throw new UsageError(cli.usage(null, { detailed: true }));\n\t\tthrow error;\n\t}\n\tif (command instanceof DeployCommand || command instanceof DestroyCommand) return {\n\t\tcommand: command.action,\n\t\tentry: command.entry,\n\t\tname: command.name,\n\t\tstage: command.stage,\n\t\tproduction: command.production,\n\t\tfresh: false\n\t};\n\tif (command instanceof DevCommand) return {\n\t\tcommand: \"dev\",\n\t\tentry: command.entry,\n\t\tname: command.name,\n\t\tstage: void 0,\n\t\tproduction: false,\n\t\tfresh: command.fresh\n\t};\n\tif (command instanceof LogCommand) {\n\t\tconst tail = command.tail === void 0 ? DEFAULT_LOG_TAIL : Number.parseInt(command.tail, 10);\n\t\tif (Number.isNaN(tail) || tail < 0) throw new UsageError(\"`--tail` must be a non-negative integer.\");\n\t\treturn {\n\t\t\tcommand: \"log\",\n\t\t\tentry: command.entry,\n\t\t\tname: command.name,\n\t\t\tstage: void 0,\n\t\t\tproduction: false,\n\t\t\tfresh: false,\n\t\t\taddress: command.address,\n\t\t\ttail\n\t\t};\n\t}\n\tif (argv.includes(\"--help\") || argv.includes(\"-h\")) throw new HelpRequested(cli.usage(null, { detailed: true }));\n\tthrow new UsageError(cli.usage(null, { detailed: true }));\n}\n/**\n* Renders a deploy/destroy operation failure the way run() always has: an\n* alchemy exit becomes the two console.error hint lines and the child's own\n* status (the documented ADR-0044 child-status exception); everything else\n* rethrows the structured failure so cli.ts renders its envelope.\n*/\nfunction renderDeployDestroyFailure(failure) {\n\tconst status = renderChildStatusHints(failure);\n\tif (status !== void 0) return status;\n\tthrow failure;\n}\n/** Runs the full pipeline; returns the process exit code. */\nasync function run(argv, deps = {}) {\n\tlet args;\n\ttry {\n\t\targs = parseArgs(argv);\n\t} catch (error) {\n\t\tif (error instanceof HelpRequested) {\n\t\t\tconsole.log(error.message);\n\t\t\treturn 0;\n\t\t}\n\t\tthrow error;\n\t}\n\tif (args.command === \"dev\") return runDev(args, deps);\n\tif (args.command === \"log\") return runLog({\n\t\tentry: args.entry,\n\t\tname: args.name,\n\t\taddress: args.address,\n\t\ttail: args.tail ?? DEFAULT_LOG_TAIL\n\t}, { config: deps.config });\n\tif (args.command === \"deploy\") {\n\t\tif (args.production) throw new CliStructuredError(\"DEPLOY.FLAG_INVALID\", \"--production is only valid with `destroy`.\", { fix: \"`deploy` targets production by default (omit --stage).\" });\n\t\tconst result = await deployWithDeps({\n\t\t\tentry: args.entry,\n\t\t\tname: args.name,\n\t\t\tstage: args.stage\n\t\t}, deps);\n\t\tif (result.ok) return 0;\n\t\treturn renderDeployDestroyFailure(result.failure);\n\t}\n\tif (args.stage !== void 0 && args.production) throw new CliStructuredError(\"DEPLOY.TARGET_CONFLICT\", \"Pass either --stage <name> or --production to `destroy`, not both.\");\n\tif (args.stage === void 0 && !args.production) throw new CliStructuredError(\"DEPLOY.TARGET_MISSING\", \"`destroy` requires an explicit target.\", { fix: \"Pass --stage <name> to tear down a branch environment, or --production to tear down the production environment.\" });\n\tconst target = args.stage !== void 0 ? {\n\t\tkind: \"stage\",\n\t\tstage: args.stage\n\t} : { kind: \"production\" };\n\tconst result = await destroyWithDeps({\n\t\tentry: args.entry,\n\t\tname: args.name,\n\t\ttarget,\n\t\tonEvent: (event) => {\n\t\t\tif (event.kind === \"no-local-deploy-state\") console.warn(`\\nNo prior deploy state under ${event.cwd} — if you deployed from a different directory, run destroy from there; otherwise this is a no-op.`);\n\t\t}\n\t}, deps);\n\tif (result.ok) return 0;\n\treturn renderDeployDestroyFailure(result.failure);\n}\n//#endregion\n//#region src/cli.ts\n/** Printed for a non-structured escape — by the shared base-type rules that is a bug, not a user failure. */\nconst REPORT_HINT = \"This is a bug in prisma-composer, not in your app — please report it: https://github.com/prisma/composer/issues\";\n/**\n* Run the `prisma-composer` CLI end to end: dispatch `argv`, map errors to exit\n* codes — usage errors and structured failures exit 2 (expected failures),\n* anything else is a bug and exits 1 with a report hint. Shared by this\n* package's `bin` and the unscoped `prisma-composer` launcher.\n*/\nasync function cli(argv = process.argv.slice(2)) {\n\ttry {\n\t\tprocess.exitCode = await run(argv);\n\t} catch (error) {\n\t\tif (error instanceof UsageError) {\n\t\t\tconsole.error(error.message);\n\t\t\tprocess.exitCode = 2;\n\t\t\treturn;\n\t\t}\n\t\tif (CliStructuredError.is(error)) {\n\t\t\tconsole.error(renderErrorEnvelope(error.toEnvelope()));\n\t\t\tprocess.exitCode = 2;\n\t\t\treturn;\n\t\t}\n\t\tconsole.error(`Error: ${error instanceof Error ? error.message : String(error)}`);\n\t\tconsole.error(REPORT_HINT);\n\t\tprocess.exitCode = 1;\n\t}\n}\n//#endregion\nexport { run as n, cli as t };\n\n//# sourceMappingURL=cli-M2oUU0IV.mjs.map"],"mappings":";;;;;;;;AASA,eAAe,YAAY,OAAO,MAAM;CACvC,MAAM,MAAM,MAAM,OAAO,QAAQ,IAAI;CACrC,IAAI;CACJ,IAAI;EACH,WAAW,MAAM,OAAO;CACzB,SAAS,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m.mjs";
|
package/dist/config.d.mts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { D as PreflightInput, F as containerEnv, I as containerEnvVarName, L as defineConfig, M as StateDescriptor, N as TeardownInput, O as PrismaAppConfig, R as deserializeContainers, _ as LocalTargetProvidersInput, c as DEV_DIR, f as ExtensionDescriptor, g as LocalTargetEmulatorsInput, h as LocalTargetDescriptor, m as LocalTargetAttachment, o as ContainerDescriptor, p as LocalTargetAttachInput, s as ContainerInstance, v as LocateContainerInput, w as NodeDescriptor, z as isBuildOnlyExtension } from "./app-config-
|
|
2
|
-
import "./config-
|
|
1
|
+
import { D as PreflightInput, F as containerEnv, I as containerEnvVarName, L as defineConfig, M as StateDescriptor, N as TeardownInput, O as PrismaAppConfig, R as deserializeContainers, _ as LocalTargetProvidersInput, c as DEV_DIR, f as ExtensionDescriptor, g as LocalTargetEmulatorsInput, h as LocalTargetDescriptor, m as LocalTargetAttachment, o as ContainerDescriptor, p as LocalTargetAttachInput, s as ContainerInstance, v as LocateContainerInput, w as NodeDescriptor, z as isBuildOnlyExtension } from "./app-config-CFsSXEVj-B242oUnm.mjs";
|
|
2
|
+
import "./config-ku5b_2YD.mjs";
|
|
3
3
|
export { type ContainerDescriptor, type ContainerInstance, DEV_DIR, ExtensionDescriptor, LocalTargetAttachInput, LocalTargetAttachment, LocalTargetDescriptor, LocalTargetEmulatorsInput, LocalTargetProvidersInput, type LocateContainerInput, NodeDescriptor, PreflightInput, PrismaAppConfig, StateDescriptor, TeardownInput, containerEnv, containerEnvVarName, defineConfig, deserializeContainers, isBuildOnlyExtension };
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { a as CliStructuredError } from "./shared-CCaR42wo-BvegvmA_.mjs";
|
|
2
|
+
import * as fs from "node:fs";
|
|
3
|
+
import * as path from "node:path";
|
|
4
|
+
import { spawnSync } from "node:child_process";
|
|
5
|
+
//#region ../../0-framework/3-tooling/cli/dist/run-alchemy-hghRtddF.mjs
|
|
6
|
+
/**
|
|
7
|
+
* Pipeline step 7 (deploy-cli.md § The pipeline; design-notes.md's "Driving
|
|
8
|
+
* Alchemy" call): shell out to the generated stack file. Resolves the
|
|
9
|
+
* workspace's own installed `alchemy` bin (walking up `node_modules/.bin`
|
|
10
|
+
* from the generated file's package dir) rather than going through
|
|
11
|
+
* `bunx`/`npx`, so this works the same under node and bun — the resolved
|
|
12
|
+
* bin's own launcher (`alchemy/bin/cli.js`) does its own node/bun dispatch
|
|
13
|
+
* from there, driven by the env it inherits.
|
|
14
|
+
*/
|
|
15
|
+
/** Walks up from `startDir` looking for `node_modules/.bin/alchemy`. */
|
|
16
|
+
function resolveAlchemyBin(startDir) {
|
|
17
|
+
let dir = startDir;
|
|
18
|
+
while (true) {
|
|
19
|
+
const candidate = path.join(dir, "node_modules", ".bin", "alchemy");
|
|
20
|
+
if (fs.existsSync(candidate)) return candidate;
|
|
21
|
+
const parent = path.dirname(dir);
|
|
22
|
+
if (parent === dir) throw new CliStructuredError("DEPLOY.ALCHEMY_BIN_MISSING", `Could not find an installed \`alchemy\` bin above "${startDir}".`, { fix: "Add \"alchemy\" as a dependency of your app." });
|
|
23
|
+
dir = parent;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
/** Runs `alchemy deploy|destroy <stack file> --yes --stage <stage>`, inheriting stdio + env, plus every extension's resolved container. */
|
|
27
|
+
function runAlchemy(input) {
|
|
28
|
+
const result = spawnSync(resolveAlchemyBin(input.cwd), [
|
|
29
|
+
input.command,
|
|
30
|
+
input.stackFileRelativePath,
|
|
31
|
+
"--yes",
|
|
32
|
+
"--stage",
|
|
33
|
+
input.stage
|
|
34
|
+
], {
|
|
35
|
+
cwd: input.cwd,
|
|
36
|
+
stdio: "inherit",
|
|
37
|
+
env: {
|
|
38
|
+
...input.env ?? process.env,
|
|
39
|
+
...input.containerEnv
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
if (result.error !== void 0) throw result.error;
|
|
43
|
+
return result.status ?? 1;
|
|
44
|
+
}
|
|
45
|
+
//#endregion
|
|
46
|
+
//#region ../../0-framework/1-core/core/dist/container-transport-DKmKg5JQ.mjs
|
|
47
|
+
/** '@prisma/composer-prisma-cloud' → 'PRISMA_COMPOSER_CONTAINER_PRISMA_COMPOSER_PRISMA_CLOUD' */
|
|
48
|
+
function containerEnvVarName(extensionId) {
|
|
49
|
+
return `PRISMA_COMPOSER_CONTAINER_${extensionId.toUpperCase().replace(/[^A-Z0-9]+/g, "_").replace(/^_+|_+$/g, "")}`;
|
|
50
|
+
}
|
|
51
|
+
function collisionError(a, b, varName) {
|
|
52
|
+
return /* @__PURE__ */ new Error(`Extension ids "${a}" and "${b}" both mangle to the container transport variable "${varName}" — rename one of the extensions.`);
|
|
53
|
+
}
|
|
54
|
+
function emptySerializeError(extensionId) {
|
|
55
|
+
return /* @__PURE__ */ new Error(`Extension "${extensionId}"'s container instance serialized to an empty string — ContainerInstance.serialize() must return a non-empty string.`);
|
|
56
|
+
}
|
|
57
|
+
/** The env entries the CLI sets on the alchemy process: `{ [containerEnvVarName(id)]: instance.serialize() }` for every resolved instance. */
|
|
58
|
+
function containerEnv(instances) {
|
|
59
|
+
const env = {};
|
|
60
|
+
const ownerByVarName = /* @__PURE__ */ new Map();
|
|
61
|
+
for (const [extensionId, instance] of instances) {
|
|
62
|
+
const varName = containerEnvVarName(extensionId);
|
|
63
|
+
const owner = ownerByVarName.get(varName);
|
|
64
|
+
if (owner !== void 0) throw collisionError(owner, extensionId, varName);
|
|
65
|
+
ownerByVarName.set(varName, extensionId);
|
|
66
|
+
const serialized = instance.serialize();
|
|
67
|
+
if (serialized.length === 0) throw emptySerializeError(extensionId);
|
|
68
|
+
env[varName] = serialized;
|
|
69
|
+
}
|
|
70
|
+
return env;
|
|
71
|
+
}
|
|
72
|
+
//#endregion
|
|
73
|
+
export { runAlchemy as n, containerEnv as t };
|
|
74
|
+
|
|
75
|
+
//# sourceMappingURL=container-transport-DKmKg5JQ-BMRhx5w-.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"container-transport-DKmKg5JQ-BMRhx5w-.mjs","names":[],"sources":["../../../0-framework/3-tooling/cli/dist/run-alchemy-hghRtddF.mjs","../../../0-framework/1-core/core/dist/container-transport-DKmKg5JQ.mjs"],"sourcesContent":["import { CliStructuredError } from \"@internal/foundation/errors\";\nimport * as fs from \"node:fs\";\nimport * as path from \"node:path\";\nimport { spawnSync } from \"node:child_process\";\n//#region src/run-alchemy.ts\n/**\n* Pipeline step 7 (deploy-cli.md § The pipeline; design-notes.md's \"Driving\n* Alchemy\" call): shell out to the generated stack file. Resolves the\n* workspace's own installed `alchemy` bin (walking up `node_modules/.bin`\n* from the generated file's package dir) rather than going through\n* `bunx`/`npx`, so this works the same under node and bun — the resolved\n* bin's own launcher (`alchemy/bin/cli.js`) does its own node/bun dispatch\n* from there, driven by the env it inherits.\n*/\n/** Walks up from `startDir` looking for `node_modules/.bin/alchemy`. */\nfunction resolveAlchemyBin(startDir) {\n\tlet dir = startDir;\n\twhile (true) {\n\t\tconst candidate = path.join(dir, \"node_modules\", \".bin\", \"alchemy\");\n\t\tif (fs.existsSync(candidate)) return candidate;\n\t\tconst parent = path.dirname(dir);\n\t\tif (parent === dir) throw new CliStructuredError(\"DEPLOY.ALCHEMY_BIN_MISSING\", `Could not find an installed \\`alchemy\\` bin above \"${startDir}\".`, { fix: \"Add \\\"alchemy\\\" as a dependency of your app.\" });\n\t\tdir = parent;\n\t}\n}\n/** Runs `alchemy deploy|destroy <stack file> --yes --stage <stage>`, inheriting stdio + env, plus every extension's resolved container. */\nfunction runAlchemy(input) {\n\tconst result = spawnSync(resolveAlchemyBin(input.cwd), [\n\t\tinput.command,\n\t\tinput.stackFileRelativePath,\n\t\t\"--yes\",\n\t\t\"--stage\",\n\t\tinput.stage\n\t], {\n\t\tcwd: input.cwd,\n\t\tstdio: \"inherit\",\n\t\tenv: {\n\t\t\t...input.env ?? process.env,\n\t\t\t...input.containerEnv\n\t\t}\n\t});\n\tif (result.error !== void 0) throw result.error;\n\treturn result.status ?? 1;\n}\n//#endregion\nexport { runAlchemy as n, resolveAlchemyBin as t };\n\n//# sourceMappingURL=run-alchemy-hghRtddF.mjs.map","//#region src/container-transport.ts\n/** '@prisma/composer-prisma-cloud' → 'PRISMA_COMPOSER_CONTAINER_PRISMA_COMPOSER_PRISMA_CLOUD' */\nfunction containerEnvVarName(extensionId) {\n\treturn `PRISMA_COMPOSER_CONTAINER_${extensionId.toUpperCase().replace(/[^A-Z0-9]+/g, \"_\").replace(/^_+|_+$/g, \"\")}`;\n}\nfunction collisionError(a, b, varName) {\n\treturn /* @__PURE__ */ new Error(`Extension ids \"${a}\" and \"${b}\" both mangle to the container transport variable \"${varName}\" — rename one of the extensions.`);\n}\nfunction emptySerializeError(extensionId) {\n\treturn /* @__PURE__ */ new Error(`Extension \"${extensionId}\"'s container instance serialized to an empty string — ContainerInstance.serialize() must return a non-empty string.`);\n}\n/** The env entries the CLI sets on the alchemy process: `{ [containerEnvVarName(id)]: instance.serialize() }` for every resolved instance. */\nfunction containerEnv(instances) {\n\tconst env = {};\n\tconst ownerByVarName = /* @__PURE__ */ new Map();\n\tfor (const [extensionId, instance] of instances) {\n\t\tconst varName = containerEnvVarName(extensionId);\n\t\tconst owner = ownerByVarName.get(varName);\n\t\tif (owner !== void 0) throw collisionError(owner, extensionId, varName);\n\t\townerByVarName.set(varName, extensionId);\n\t\tconst serialized = instance.serialize();\n\t\tif (serialized.length === 0) throw emptySerializeError(extensionId);\n\t\tenv[varName] = serialized;\n\t}\n\treturn env;\n}\n/**\n* The alchemy-process side: for each extension with a container descriptor\n* whose var is present in `env`, call its deserialize. Absent var → no entry.\n*/\nfunction deserializeContainers(extensions, env) {\n\tconst instances = /* @__PURE__ */ new Map();\n\tfor (const extension of extensions) {\n\t\tconst descriptor = extension.container;\n\t\tif (descriptor === void 0) continue;\n\t\tconst serialized = env[containerEnvVarName(extension.id)];\n\t\tif (serialized === void 0) continue;\n\t\tinstances.set(extension.id, descriptor.deserialize(serialized));\n\t}\n\treturn instances;\n}\n//#endregion\nexport { containerEnvVarName as n, deserializeContainers as r, containerEnv as t };\n\n//# sourceMappingURL=container-transport-DKmKg5JQ.mjs.map"],"mappings":";;;;;;;;;;;;;;;AAeA,SAAS,kBAAkB,UAAU;CACpC,IAAI,MAAM;CACV,OAAO,MAAM;EACZ,MAAM,YAAY,KAAK,KAAK,KAAK,gBAAgB,QAAQ,SAAS;EAClE,IAAI,GAAG,WAAW,SAAS,GAAG,OAAO;EACrC,MAAM,SAAS,KAAK,QAAQ,GAAG;EAC/B,IAAI,WAAW,KAAK,MAAM,IAAI,mBAAmB,8BAA8B,sDAAsD,SAAS,KAAK,EAAE,KAAK,+CAA+C,CAAC;EAC1M,MAAM;CACP;AACD;;AAEA,SAAS,WAAW,OAAO;CAC1B,MAAM,SAAS,UAAU,kBAAkB,MAAM,GAAG,GAAG;EACtD,MAAM;EACN,MAAM;EACN;EACA;EACA,MAAM;CACP,GAAG;EACF,KAAK,MAAM;EACX,OAAO;EACP,KAAK;GACJ,GAAG,MAAM,OAAO,QAAQ;GACxB,GAAG,MAAM;EACV;CACD,CAAC;CACD,IAAI,OAAO,UAAU,KAAK,GAAG,MAAM,OAAO;CAC1C,OAAO,OAAO,UAAU;AACzB;;;;ACzCA,SAAS,oBAAoB,aAAa;CACzC,OAAO,6BAA6B,YAAY,YAAY,CAAC,CAAC,QAAQ,eAAe,GAAG,CAAC,CAAC,QAAQ,YAAY,EAAE;AACjH;AACA,SAAS,eAAe,GAAG,GAAG,SAAS;CACtC,uBAAuB,IAAI,MAAM,kBAAkB,EAAE,SAAS,EAAE,qDAAqD,QAAQ,kCAAkC;AAChK;AACA,SAAS,oBAAoB,aAAa;CACzC,uBAAuB,IAAI,MAAM,cAAc,YAAY,qHAAqH;AACjL;;AAEA,SAAS,aAAa,WAAW;CAChC,MAAM,MAAM,CAAC;CACb,MAAM,iCAAiC,IAAI,IAAI;CAC/C,KAAK,MAAM,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