@prisma/composer-cli 0.25.0 → 0.26.0-dev.2
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/composer-config-CY9fET8H-KpGjlYgO.mjs +432 -0
- package/dist/composer-config-CY9fET8H-KpGjlYgO.mjs.map +1 -0
- package/dist/{pipeline-C7gNjMzJ-CMqZQxqM.mjs → container-transport-HcvNOGZL-CHqecFc7.mjs} +109 -322
- package/dist/container-transport-HcvNOGZL-CHqecFc7.mjs.map +1 -0
- package/dist/{execute-deploy-destroy-CvKCwVkD-B3vcxYJF.mjs → execute-deploy-destroy-c0eko3AO-9npuGXd3.mjs} +108 -85
- package/dist/execute-deploy-destroy-c0eko3AO-9npuGXd3.mjs.map +1 -0
- package/dist/{execute-dev-BLCK5wF7-CuzMSK7T.mjs → execute-dev-BICPaq1g-CSoZJuhB.mjs} +162 -132
- package/dist/execute-dev-BICPaq1g-CSoZJuhB.mjs.map +1 -0
- package/dist/{family-B1RaH4f8-ChoTnv3A.d.mts → family-CgeZQdNg-gH8LuqqL.d.mts} +136 -172
- package/dist/family-CgeZQdNg-gH8LuqqL.d.mts.map +1 -0
- package/dist/family.d.mts +4 -39
- package/dist/family.d.mts.map +1 -1
- package/dist/family.mjs +49 -551
- package/dist/family.mjs.map +1 -1
- package/dist/generate-dev-stack-BUadNY_w-DF_lHVaP.mjs +87 -0
- package/dist/generate-dev-stack-BUadNY_w-DF_lHVaP.mjs.map +1 -0
- package/dist/run-alchemy-BEvB2sYQ-BgV2deuO.mjs +154 -0
- package/dist/run-alchemy-BEvB2sYQ-BgV2deuO.mjs.map +1 -0
- package/dist/testing.d.mts +24 -24
- package/dist/testing.d.mts.map +1 -1
- package/dist/testing.mjs +17 -45
- package/dist/testing.mjs.map +1 -1
- package/package.json +7 -11
- package/src/exports/testing.ts +5 -3
- package/dist/bin.mjs +0 -1040
- package/dist/bin.mjs.map +0 -1
- package/dist/container-transport-HcvNOGZL-CIoZc7Rs.mjs +0 -34
- package/dist/container-transport-HcvNOGZL-CIoZc7Rs.mjs.map +0 -1
- package/dist/execute-deploy-destroy-CvKCwVkD-B3vcxYJF.mjs.map +0 -1
- package/dist/execute-deploy-destroy-CvKCwVkD-DCufHnkW.mjs +0 -528
- package/dist/execute-deploy-destroy-CvKCwVkD-DCufHnkW.mjs.map +0 -1
- package/dist/execute-dev-BLCK5wF7-B-fG_E31.mjs +0 -2011
- package/dist/execute-dev-BLCK5wF7-B-fG_E31.mjs.map +0 -1
- package/dist/execute-dev-BLCK5wF7-CuzMSK7T.mjs.map +0 -1
- package/dist/execute-log-B_zCJ17b-BrLUt7vo.mjs +0 -157
- package/dist/execute-log-B_zCJ17b-BrLUt7vo.mjs.map +0 -1
- package/dist/execute-log-B_zCJ17b-C4a0uxJj.mjs +0 -158
- package/dist/execute-log-B_zCJ17b-C4a0uxJj.mjs.map +0 -1
- package/dist/family-B1RaH4f8-ChoTnv3A.d.mts.map +0 -1
- package/dist/local-target-BOGjATc2.mjs +0 -68
- package/dist/local-target-BOGjATc2.mjs.map +0 -1
- package/dist/local-target-hoEGqgVA.mjs +0 -68
- package/dist/local-target-hoEGqgVA.mjs.map +0 -1
- package/dist/pipeline-C7gNjMzJ-CMqZQxqM.mjs.map +0 -1
- package/dist/pipeline-C7gNjMzJ-CixaMvnR.mjs +0 -1205
- package/dist/pipeline-C7gNjMzJ-CixaMvnR.mjs.map +0 -1
- package/dist/result-B874OKwb.mjs +0 -383
- package/dist/result-B874OKwb.mjs.map +0 -1
- package/dist/result-sR7PBi61.mjs +0 -229
- package/dist/result-sR7PBi61.mjs.map +0 -1
- package/dist/run-alchemy-pANK8XNX-BH1wC0r6.mjs +0 -99
- package/dist/run-alchemy-pANK8XNX-BH1wC0r6.mjs.map +0 -1
- package/dist/run-alchemy-pANK8XNX-XcCQncKN.mjs +0 -99
- package/dist/run-alchemy-pANK8XNX-XcCQncKN.mjs.map +0 -1
- package/dist/shared-BTnATsqm-BH4axbJg.mjs +0 -158
- package/dist/shared-BTnATsqm-BH4axbJg.mjs.map +0 -1
|
@@ -1,10 +1,57 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { a as CliStructuredError, l as InternalError, n as configFileMissing, t as checkComposerConfig, u as blindCast } from "./composer-config-CY9fET8H-KpGjlYgO.mjs";
|
|
2
2
|
import * as mod from "node:module";
|
|
3
3
|
import * as fs from "node:fs";
|
|
4
4
|
import { existsSync } from "node:fs";
|
|
5
5
|
import * as path from "node:path";
|
|
6
6
|
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
7
|
-
|
|
7
|
+
//#region ../../0-framework/3-tooling/assemble/dist/index.mjs
|
|
8
|
+
/**
|
|
9
|
+
* A user-facing assembly failure, structured at origin (base-type rule 6):
|
|
10
|
+
* a `CliStructuredError` whose code names which way assembly went wrong.
|
|
11
|
+
* This package's second consumer is the programmatic deploy API, not just
|
|
12
|
+
* the CLI — hosts branch on `error.code`, the CLI renders the envelope.
|
|
13
|
+
*/
|
|
14
|
+
var AssembleError = class extends CliStructuredError {
|
|
15
|
+
constructor(code, summary, options) {
|
|
16
|
+
super(code, summary, options);
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* The registry route for one service's build: extension by
|
|
21
|
+
* `build.extension`, node descriptor by `build.type`, kind must be "build".
|
|
22
|
+
* The CLI's coverage validation reports the same misses earlier with the
|
|
23
|
+
* config fix; these errors are the backstop for programmatic callers.
|
|
24
|
+
*/
|
|
25
|
+
function buildDescriptorAssemble(config, node, address, cwd) {
|
|
26
|
+
const { extension, type } = node.build;
|
|
27
|
+
const extensionDescriptor = config.extensions.find((candidate) => candidate.id === extension);
|
|
28
|
+
if (extensionDescriptor === void 0) throw new AssembleError("ASSEMBLE.EXTENSION_MISSING", `No extension "${extension}" is configured (needed by service "${node.name}"'s build).`, { fix: "Add it to `extensions` in the `composer` section of prisma.config.ts." });
|
|
29
|
+
const nodeDescriptor = extensionDescriptor.nodes[type];
|
|
30
|
+
if (nodeDescriptor === void 0) throw new AssembleError("ASSEMBLE.DESCRIPTOR_MISSING", `Extension "${extension}" has no descriptor for build type "${type}".`, { why: `Known types: ${Object.keys(extensionDescriptor.nodes).join(", ")}.` });
|
|
31
|
+
if (nodeDescriptor.kind !== "build") throw new AssembleError("ASSEMBLE.DESCRIPTOR_KIND_MISMATCH", `Extension "${extension}"'s descriptor for type "${type}" is a "${nodeDescriptor.kind}" descriptor.`, { why: "Assembling a service build needs a \"build\" descriptor." });
|
|
32
|
+
return nodeDescriptor.assemble({
|
|
33
|
+
build: node.build,
|
|
34
|
+
address,
|
|
35
|
+
cwd
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
async function assembleServices(graph, config, cwd, run) {
|
|
39
|
+
const runAssembler = run ?? ((node, address, nodeCwd) => buildDescriptorAssemble(config, node, address, nodeCwd));
|
|
40
|
+
const serviceNodes = graph.nodes.filter((n) => n.node.kind === "service");
|
|
41
|
+
if (serviceNodes.length === 0) throw new AssembleError("ASSEMBLE.SERVICE_MISSING", "The loaded graph has no service to assemble.");
|
|
42
|
+
const bundles = {};
|
|
43
|
+
for (const { id, node } of serviceNodes) try {
|
|
44
|
+
bundles[id] = await runAssembler(node, id, cwd);
|
|
45
|
+
} catch (error) {
|
|
46
|
+
if (CliStructuredError.is(error)) throw error;
|
|
47
|
+
throw new AssembleError("ASSEMBLE.BUILD_FAILED", error instanceof Error ? error.message : String(error), {
|
|
48
|
+
meta: { address: id },
|
|
49
|
+
cause: error
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
return { bundles };
|
|
53
|
+
}
|
|
54
|
+
//#endregion
|
|
8
55
|
//#region ../../0-framework/1-core/core/dist/graph-BfKAg2Ap.mjs
|
|
9
56
|
/** The reserved name of a resource's single anonymous output port. Rejected as a user-declared port name (node.ts). */
|
|
10
57
|
const RESOURCE_OUT_PORT = "$out";
|
|
@@ -661,7 +708,7 @@ function Load(root, opts) {
|
|
|
661
708
|
}
|
|
662
709
|
blindCast(Symbol.for("prisma:secret-box"));
|
|
663
710
|
//#endregion
|
|
664
|
-
//#region ../../0-framework/3-tooling/cli/dist/
|
|
711
|
+
//#region ../../0-framework/3-tooling/cli/dist/pipeline-DYvl561J.mjs
|
|
665
712
|
/**
|
|
666
713
|
* Synchronous Node resolve hook so that entry modules may import relative
|
|
667
714
|
* files using the specifier forms TypeScript accepts by default —
|
|
@@ -805,291 +852,10 @@ async function loadEntry(entryArg, cwd) {
|
|
|
805
852
|
root: blindCast(root)
|
|
806
853
|
};
|
|
807
854
|
}
|
|
808
|
-
//#endregion
|
|
809
|
-
//#region ../../0-framework/3-tooling/assemble/dist/index.mjs
|
|
810
|
-
/**
|
|
811
|
-
* A user-facing assembly failure, structured at origin (base-type rule 6):
|
|
812
|
-
* a `CliStructuredError` whose code names which way assembly went wrong.
|
|
813
|
-
* This package's second consumer is the programmatic deploy API, not just
|
|
814
|
-
* the CLI — hosts branch on `error.code`, the CLI renders the envelope.
|
|
815
|
-
*/
|
|
816
|
-
var AssembleError = class extends CliStructuredError {
|
|
817
|
-
constructor(code, summary, options) {
|
|
818
|
-
super(code, summary, options);
|
|
819
|
-
}
|
|
820
|
-
};
|
|
821
|
-
/**
|
|
822
|
-
* The registry route for one service's build: extension by
|
|
823
|
-
* `build.extension`, node descriptor by `build.type`, kind must be "build".
|
|
824
|
-
* The CLI's coverage validation reports the same misses earlier with the
|
|
825
|
-
* config fix; these errors are the backstop for programmatic callers.
|
|
826
|
-
*/
|
|
827
|
-
function buildDescriptorAssemble(config, node, address, cwd) {
|
|
828
|
-
const { extension, type } = node.build;
|
|
829
|
-
const extensionDescriptor = config.extensions.find((candidate) => candidate.id === extension);
|
|
830
|
-
if (extensionDescriptor === void 0) throw new AssembleError("ASSEMBLE.EXTENSION_MISSING", `No extension "${extension}" is configured (needed by service "${node.name}"'s build).`, { fix: "Add it to prisma-composer.config.ts's `extensions`." });
|
|
831
|
-
const nodeDescriptor = extensionDescriptor.nodes[type];
|
|
832
|
-
if (nodeDescriptor === void 0) throw new AssembleError("ASSEMBLE.DESCRIPTOR_MISSING", `Extension "${extension}" has no descriptor for build type "${type}".`, { why: `Known types: ${Object.keys(extensionDescriptor.nodes).join(", ")}.` });
|
|
833
|
-
if (nodeDescriptor.kind !== "build") throw new AssembleError("ASSEMBLE.DESCRIPTOR_KIND_MISMATCH", `Extension "${extension}"'s descriptor for type "${type}" is a "${nodeDescriptor.kind}" descriptor.`, { why: "Assembling a service build needs a \"build\" descriptor." });
|
|
834
|
-
return nodeDescriptor.assemble({
|
|
835
|
-
build: node.build,
|
|
836
|
-
address,
|
|
837
|
-
cwd
|
|
838
|
-
});
|
|
839
|
-
}
|
|
840
|
-
async function assembleServices(graph, config, cwd, run) {
|
|
841
|
-
const runAssembler = run ?? ((node, address, nodeCwd) => buildDescriptorAssemble(config, node, address, nodeCwd));
|
|
842
|
-
const serviceNodes = graph.nodes.filter((n) => n.node.kind === "service");
|
|
843
|
-
if (serviceNodes.length === 0) throw new AssembleError("ASSEMBLE.SERVICE_MISSING", "The loaded graph has no service to assemble.");
|
|
844
|
-
const bundles = {};
|
|
845
|
-
for (const { id, node } of serviceNodes) try {
|
|
846
|
-
bundles[id] = await runAssembler(node, id, cwd);
|
|
847
|
-
} catch (error) {
|
|
848
|
-
if (CliStructuredError.is(error)) throw error;
|
|
849
|
-
throw new AssembleError("ASSEMBLE.BUILD_FAILED", error instanceof Error ? error.message : String(error), {
|
|
850
|
-
meta: { address: id },
|
|
851
|
-
cause: error
|
|
852
|
-
});
|
|
853
|
-
}
|
|
854
|
-
return { bundles };
|
|
855
|
-
}
|
|
856
|
-
//#endregion
|
|
857
|
-
//#region ../../0-framework/3-tooling/cli/dist/pipeline-C7gNjMzJ.mjs
|
|
858
|
-
/**
|
|
859
|
-
* Pipeline step: find and load `prisma-composer.config.ts` (ADR-0017) — the ONE
|
|
860
|
-
* file that imports control-plane code. Discovery is the standard walk-up
|
|
861
|
-
* from the deploy entry's directory (mirrors prisma/orm's config-loader);
|
|
862
|
-
* loading is c12 with that explicit path (rc/global/package.json lookups
|
|
863
|
-
* disabled), so the config file's own static imports resolve from the app
|
|
864
|
-
* root by whatever package manager runs — no specifier construction, no
|
|
865
|
-
* anchoring.
|
|
866
|
-
*
|
|
867
|
-
* Two shapes of the same machinery:
|
|
868
|
-
*
|
|
869
|
-
* loadAppConfigDiagnostics — returns the evaluated value together with
|
|
870
|
-
* EVERY problem found, and never throws. This is the shape the engine
|
|
871
|
-
* command family consumes: the engine renders diagnostics itself and
|
|
872
|
-
* decides per command whether a broken section is fatal, so a loader that
|
|
873
|
-
* threw on the first bad field would both hide the rest and bypass that
|
|
874
|
-
* rendering.
|
|
875
|
-
*
|
|
876
|
-
* loadAppConfig — the same load, throwing its first diagnostic. The
|
|
877
|
-
* clipanion CLI still runs on it; it goes when clipanion does.
|
|
878
|
-
*/
|
|
879
|
-
/**
|
|
880
|
-
* Accepted config file names, in precedence order: when several sit in one
|
|
881
|
-
* directory the first one found wins. The JavaScript spellings exist so a
|
|
882
|
-
* project whose own TypeScript build would otherwise compile the config file
|
|
883
|
-
* (no `include`, a `rootDir`, `module: commonjs`) can keep it out of that
|
|
884
|
-
* build's sight.
|
|
885
|
-
*/
|
|
886
|
-
const CONFIG_FILENAMES = [
|
|
887
|
-
"prisma-composer.config.ts",
|
|
888
|
-
"prisma-composer.config.mts",
|
|
889
|
-
"prisma-composer.config.mjs",
|
|
890
|
-
"prisma-composer.config.js"
|
|
891
|
-
];
|
|
892
|
-
/** The canonical spelling, used in messages and docs. */
|
|
893
|
-
const CONFIG_FILENAME = CONFIG_FILENAMES[0];
|
|
894
|
-
/** The accepted spellings as one glob-like string for messages. */
|
|
895
|
-
const CONFIG_FILENAME_PATTERN = "prisma-composer.config.{ts,mts,mjs,js}";
|
|
896
|
-
/** Walks UP from the entry file's directory looking for one of CONFIG_FILENAMES; undefined when the walk hits the filesystem root. */
|
|
897
|
-
function findConfigPathForEntry(entryPath) {
|
|
898
|
-
let current = path.dirname(path.resolve(entryPath));
|
|
899
|
-
while (true) {
|
|
900
|
-
for (const filename of CONFIG_FILENAMES) {
|
|
901
|
-
const candidate = path.join(current, filename);
|
|
902
|
-
if (fs.existsSync(candidate)) return candidate;
|
|
903
|
-
}
|
|
904
|
-
const parent = path.dirname(current);
|
|
905
|
-
if (parent === current) return void 0;
|
|
906
|
-
current = parent;
|
|
907
|
-
}
|
|
908
|
-
}
|
|
909
|
-
function missingConfigError(entryPath) {
|
|
910
|
-
const searchedFrom = path.dirname(path.resolve(entryPath));
|
|
911
|
-
return new CliStructuredError("CONFIG.FILE_MISSING", `No ${CONFIG_FILENAME_PATTERN} found walking up from "${searchedFrom}".`, {
|
|
912
|
-
why: "The deploy needs the app's config file.",
|
|
913
|
-
fix: "Create one next to (or above) the entry, default-exporting defineConfig({ extensions: [...], state: ... }) from '@prisma/composer/config'.",
|
|
914
|
-
where: { path: searchedFrom }
|
|
915
|
-
});
|
|
916
|
-
}
|
|
917
|
-
function fieldError(configPath, field, requirement) {
|
|
918
|
-
return new CliStructuredError("CONFIG.FIELD_INVALID", `${path.basename(configPath)}: \`${field}\` ${requirement}.`, {
|
|
919
|
-
fix: "See defineConfig() in '@prisma/composer/config'.",
|
|
920
|
-
meta: { field }
|
|
921
|
-
});
|
|
922
|
-
}
|
|
923
|
-
function isRecord(value) {
|
|
924
|
-
return typeof value === "object" && value !== null;
|
|
925
|
-
}
|
|
926
|
-
/**
|
|
927
|
-
* Field-by-field validation of the loaded default export — deliberately no
|
|
928
|
-
* schema library: each check is a structured error naming the offending field.
|
|
929
|
-
*
|
|
930
|
-
* Collects rather than throws, so one bad config reports every bad field
|
|
931
|
-
* instead of only the first. The `extensions` and `state` checks are
|
|
932
|
-
* independent, and within `extensions` each entry is judged on its own; a
|
|
933
|
-
* field whose own shape check already failed is not probed further, because
|
|
934
|
-
* anything derived from it would be noise rather than a second finding.
|
|
935
|
-
*/
|
|
936
|
-
function configShapeDiagnostics(loaded, configPath) {
|
|
937
|
-
if (!isRecord(loaded) || Object.keys(loaded).length === 0) return [new CliStructuredError("CONFIG.EXPORT_INVALID", `"${configPath}" exported no config.`, {
|
|
938
|
-
fix: "It must default-export defineConfig({ extensions: [...], state: ... }) from '@prisma/composer/config'.",
|
|
939
|
-
where: { path: configPath }
|
|
940
|
-
})];
|
|
941
|
-
const diagnostics = [];
|
|
942
|
-
const extensions = loaded["extensions"];
|
|
943
|
-
if (!Array.isArray(extensions)) diagnostics.push(fieldError(configPath, "extensions", "must be an array"));
|
|
944
|
-
else {
|
|
945
|
-
const seen = /* @__PURE__ */ new Set();
|
|
946
|
-
for (const [index, entry] of extensions.entries()) {
|
|
947
|
-
if (!isRecord(entry)) {
|
|
948
|
-
diagnostics.push(fieldError(configPath, `extensions[${index}]`, "must be an extension descriptor object"));
|
|
949
|
-
continue;
|
|
950
|
-
}
|
|
951
|
-
const id = entry["id"];
|
|
952
|
-
if (typeof id !== "string" || id.length === 0) diagnostics.push(fieldError(configPath, `extensions[${index}].id`, "must be a non-empty string (the extension package name)"));
|
|
953
|
-
else if (seen.has(id)) diagnostics.push(new CliStructuredError("CONFIG.EXTENSION_DUPLICATE", `${path.basename(configPath)}: extension "${id}" is listed more than once in \`extensions\`.`));
|
|
954
|
-
else seen.add(id);
|
|
955
|
-
if (!isRecord(entry["nodes"])) diagnostics.push(fieldError(configPath, `extensions[${index}].nodes`, "must be an object (the node-ID → control registry)"));
|
|
956
|
-
}
|
|
957
|
-
}
|
|
958
|
-
const state = loaded["state"];
|
|
959
|
-
if (!isRecord(state) || typeof state["extension"] !== "string" || typeof state["create"] !== "function") diagnostics.push(fieldError(configPath, "state", "must be a state descriptor (e.g. prismaState())"));
|
|
960
|
-
return diagnostics;
|
|
961
|
-
}
|
|
962
|
-
/** The throwing form of configShapeDiagnostics: raises the first finding, returns the same object typed. Used by the clipanion pipeline. */
|
|
963
|
-
function validateConfigShape(loaded, configPath) {
|
|
964
|
-
const [first] = configShapeDiagnostics(loaded, configPath);
|
|
965
|
-
if (first !== void 0) throw first;
|
|
966
|
-
return blindCast(loaded);
|
|
967
|
-
}
|
|
968
|
-
/**
|
|
969
|
-
* Evaluates `configPath` with c12 (explicit file; rc / global-rc /
|
|
970
|
-
* package.json lookups disabled). `verifySamePath` runs the same-file check
|
|
971
|
-
* against the discovered path — see loadAppConfigDiagnostics for when it does
|
|
972
|
-
* not apply.
|
|
973
|
-
*/
|
|
974
|
-
async function evaluateConfig(configPath, verifySamePath) {
|
|
975
|
-
let result;
|
|
976
|
-
try {
|
|
977
|
-
result = await c12.loadConfig({
|
|
978
|
-
name: "prisma-composer",
|
|
979
|
-
configFile: configPath,
|
|
980
|
-
cwd: path.dirname(configPath),
|
|
981
|
-
rcFile: false,
|
|
982
|
-
globalRc: false,
|
|
983
|
-
packageJson: false
|
|
984
|
-
});
|
|
985
|
-
} catch (error) {
|
|
986
|
-
return {
|
|
987
|
-
value: void 0,
|
|
988
|
-
diagnostics: [new CliStructuredError("CONFIG.EVALUATION_FAILED", `Evaluating "${configPath}" failed: ${error instanceof Error ? error.message : String(error)}`, {
|
|
989
|
-
where: { path: configPath },
|
|
990
|
-
cause: error
|
|
991
|
-
})]
|
|
992
|
-
};
|
|
993
|
-
}
|
|
994
|
-
const loadedFile = result.configFile;
|
|
995
|
-
if (verifySamePath && (typeof loadedFile !== "string" || fs.realpathSync(loadedFile) !== fs.realpathSync(configPath))) return {
|
|
996
|
-
value: result.config,
|
|
997
|
-
diagnostics: [new CliStructuredError("CONFIG.PATH_MISMATCH", `Config loading resolved "${String(loadedFile)}" instead of the discovered "${configPath}".`, {
|
|
998
|
-
why: "Refusing to deploy against a different file.",
|
|
999
|
-
where: { path: configPath }
|
|
1000
|
-
})]
|
|
1001
|
-
};
|
|
1002
|
-
return {
|
|
1003
|
-
value: result.config,
|
|
1004
|
-
diagnostics: configShapeDiagnostics(result.config, configPath)
|
|
1005
|
-
};
|
|
1006
|
-
}
|
|
1007
|
-
/**
|
|
1008
|
-
* The front of every config load, shared by the throwing and the
|
|
1009
|
-
* diagnostics-list shapes: verify the installed tree can evaluate a config at
|
|
1010
|
-
* all, then settle which file to load — the section's path, or the
|
|
1011
|
-
* entry-anchored walk.
|
|
1012
|
-
*
|
|
1013
|
-
* The effect-resolution check comes first because evaluating a config imports
|
|
1014
|
-
* alchemy's provider tree: in a tree where alchemy resolves an `effect` we did
|
|
1015
|
-
* not pin, nothing downstream can load, so the dependency conflict is the
|
|
1016
|
-
* finding with the fix in it and every later failure is its symptom.
|
|
1017
|
-
*/
|
|
1018
|
-
function configSource(request) {
|
|
1019
|
-
const resolvedEntry = path.resolve(request.entryPath);
|
|
1020
|
-
const effectConflict = effectResolutionDiagnostic(request.cwd ?? path.dirname(resolvedEntry));
|
|
1021
|
-
if (effectConflict !== void 0) return {
|
|
1022
|
-
ok: false,
|
|
1023
|
-
path: void 0,
|
|
1024
|
-
diagnostic: effectConflict
|
|
1025
|
-
};
|
|
1026
|
-
if (request.configPath === void 0) {
|
|
1027
|
-
const discovered = findConfigPathForEntry(resolvedEntry);
|
|
1028
|
-
return discovered === void 0 ? {
|
|
1029
|
-
ok: false,
|
|
1030
|
-
path: void 0,
|
|
1031
|
-
diagnostic: missingConfigError(resolvedEntry)
|
|
1032
|
-
} : {
|
|
1033
|
-
ok: true,
|
|
1034
|
-
path: discovered,
|
|
1035
|
-
explicit: false
|
|
1036
|
-
};
|
|
1037
|
-
}
|
|
1038
|
-
const configPath = request.configPath;
|
|
1039
|
-
if (!path.isAbsolute(configPath)) return {
|
|
1040
|
-
ok: false,
|
|
1041
|
-
path: configPath,
|
|
1042
|
-
diagnostic: new CliStructuredError("CONFIG.PATH_NOT_ABSOLUTE", `The \`composer\` config section's configPath must arrive absolute, and "${configPath}" is relative.`, {
|
|
1043
|
-
why: "The section validator resolves a relative configPath against the config file that declared it; a relative value here means that resolution was skipped.",
|
|
1044
|
-
fix: "Run the configPath through the composer section validator, or resolve it against its declaring file before constructing the load request.",
|
|
1045
|
-
where: { path: configPath }
|
|
1046
|
-
})
|
|
1047
|
-
};
|
|
1048
|
-
if (!fs.existsSync(configPath)) return {
|
|
1049
|
-
ok: false,
|
|
1050
|
-
path: configPath,
|
|
1051
|
-
diagnostic: new CliStructuredError("CONFIG.FILE_MISSING", `The \`composer\` config section points at "${configPath}", which does not exist.`, {
|
|
1052
|
-
why: "An explicit configPath is used as given — there is no walk to fall back on.",
|
|
1053
|
-
fix: "Correct `configPath` in the `composer` section of prisma.config.ts, or remove it to search upward from the entry.",
|
|
1054
|
-
where: { path: configPath }
|
|
1055
|
-
})
|
|
1056
|
-
};
|
|
1057
|
-
return {
|
|
1058
|
-
ok: true,
|
|
1059
|
-
path: configPath,
|
|
1060
|
-
explicit: true
|
|
1061
|
-
};
|
|
1062
|
-
}
|
|
1063
|
-
/**
|
|
1064
|
-
* The throwing form of that front, for the pipeline: the file the load will
|
|
1065
|
-
* use, or the finding raised. `explicit` says the section named the file,
|
|
1066
|
-
* which is what retires the same-file check for that case.
|
|
1067
|
-
*/
|
|
1068
|
-
function resolveConfigFile(request) {
|
|
1069
|
-
const source = configSource(request);
|
|
1070
|
-
if (!source.ok) throw source.diagnostic;
|
|
1071
|
-
return {
|
|
1072
|
-
path: source.path,
|
|
1073
|
-
explicit: source.explicit
|
|
1074
|
-
};
|
|
1075
|
-
}
|
|
1076
|
-
/**
|
|
1077
|
-
* Loads + validates the config at `configPath`, throwing its first diagnostic.
|
|
1078
|
-
* The clipanion CLI's pipeline runs on this; it goes when clipanion does.
|
|
1079
|
-
*/
|
|
1080
|
-
async function loadAppConfig(configPath, verifySamePath = true) {
|
|
1081
|
-
const { value, diagnostics } = await evaluateConfig(configPath, verifySamePath);
|
|
1082
|
-
const [first] = diagnostics;
|
|
1083
|
-
if (first !== void 0) throw first;
|
|
1084
|
-
return {
|
|
1085
|
-
path: configPath,
|
|
1086
|
-
config: validateConfigShape(value, configPath)
|
|
1087
|
-
};
|
|
1088
|
-
}
|
|
1089
855
|
function lookup(extensions, extension, type, expectedKind, what) {
|
|
1090
856
|
const ext = extensions.get(extension);
|
|
1091
857
|
if (ext === void 0) throw new CliStructuredError("CONFIG.EXTENSION_MISSING", `No extension "${extension}" is configured (needed by ${what}).`, {
|
|
1092
|
-
fix:
|
|
858
|
+
fix: "Add it to `extensions` in the `composer` section of prisma.config.ts (import its /control entry and list its descriptor).",
|
|
1093
859
|
meta: {
|
|
1094
860
|
extension,
|
|
1095
861
|
type
|
|
@@ -1124,7 +890,7 @@ function validateRegistryCoverage(graph, config) {
|
|
|
1124
890
|
}
|
|
1125
891
|
/**
|
|
1126
892
|
* The shared prefix of `deploy`/`destroy`/`dev` (deploy-cli.md § The
|
|
1127
|
-
* pipeline; local-dev spec § 6):
|
|
893
|
+
* pipeline; local-dev spec § 6): entry load, Load,
|
|
1128
894
|
* registry coverage validation, name resolution, assemble. Deploy and dev
|
|
1129
895
|
* diverge after this — deploy resolves containers/preflight/stack file
|
|
1130
896
|
* against the hosted providers, dev against the local ones — so everything
|
|
@@ -1132,50 +898,41 @@ function validateRegistryCoverage(graph, config) {
|
|
|
1132
898
|
* `run()` (main.ts) and `runDev()` (dev/run-dev.ts), so the two pipelines
|
|
1133
899
|
* cannot drift.
|
|
1134
900
|
*/
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
cwd
|
|
901
|
+
function configError(findings, file) {
|
|
902
|
+
const [first] = findings;
|
|
903
|
+
return new CliStructuredError(first.code, first.summary, {
|
|
904
|
+
...first.why === void 0 ? {} : { why: first.why },
|
|
905
|
+
fix: first.fix,
|
|
906
|
+
where: { path: first.where ?? file },
|
|
907
|
+
meta: {
|
|
908
|
+
...first.field === void 0 ? {} : { field: first.field },
|
|
909
|
+
findings
|
|
910
|
+
}
|
|
1146
911
|
});
|
|
1147
|
-
return {
|
|
1148
|
-
configPath,
|
|
1149
|
-
config: deps.config ?? (await loadAppConfig(configPath, !explicit)).config
|
|
1150
|
-
};
|
|
1151
912
|
}
|
|
1152
913
|
/**
|
|
1153
|
-
*
|
|
1154
|
-
*
|
|
1155
|
-
* config and resolved name) to reach the already-running local instance; it
|
|
1156
|
-
* neither builds nor provisions, so it must not require the user's built
|
|
1157
|
-
* output the way the full pipeline does.
|
|
914
|
+
* Refuses a caller's config with the same findings, in the same order, as the CLI's section validator.
|
|
915
|
+
* The error is the first finding and carries all of them in `meta.findings`. Returns the config with `file` resolved against `cwd`.
|
|
1158
916
|
*/
|
|
1159
|
-
|
|
1160
|
-
const
|
|
1161
|
-
|
|
1162
|
-
const
|
|
1163
|
-
if (
|
|
917
|
+
function checkConfigSource(source, cwd) {
|
|
918
|
+
const file = path.resolve(cwd, source.file);
|
|
919
|
+
if (!fs.existsSync(file)) throw configError([configFileMissing(file)], file);
|
|
920
|
+
const checked = checkComposerConfig(source.value, file);
|
|
921
|
+
if (!checked.ok) throw configError(checked.findings, file);
|
|
1164
922
|
return {
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
name
|
|
923
|
+
value: checked.value,
|
|
924
|
+
file
|
|
1168
925
|
};
|
|
1169
926
|
}
|
|
1170
927
|
/**
|
|
1171
|
-
* Runs
|
|
1172
|
-
* resolution, and assemble — steps 1–6 of `run()`. `onAssembleError`, when
|
|
928
|
+
* Runs entry load, Load, registry coverage, name resolution, and assemble — steps 1–5 of `run()`. `onAssembleError`, when
|
|
1173
929
|
* given, lets a caller decorate an assemble failure with command-specific
|
|
1174
930
|
* guidance (destroy's "build first" hint) without this shared step knowing
|
|
1175
931
|
* about any one command.
|
|
1176
932
|
*/
|
|
1177
|
-
async function runPipeline(entry, overrideName, cwd, deps = {}, onAssembleError) {
|
|
1178
|
-
const
|
|
933
|
+
async function runPipeline(entry, overrideName, cwd, source, deps = {}, onAssembleError) {
|
|
934
|
+
const configSource = checkConfigSource(source, cwd);
|
|
935
|
+
const config = configSource.value;
|
|
1179
936
|
const entryModule = await loadEntry(entry, cwd);
|
|
1180
937
|
const graph = Load(entryModule.root);
|
|
1181
938
|
if (graph.root.node.kind !== "module") throw new CliStructuredError("COMPOSE.ROOT_NOT_MODULE", "The deploy root must be a module.", { fix: "Wrap your service, e.g. export default module('name', ({ provision }) => { provision(service); })." });
|
|
@@ -1190,8 +947,7 @@ async function runPipeline(entry, overrideName, cwd, deps = {}, onAssembleError)
|
|
|
1190
947
|
throw error;
|
|
1191
948
|
}
|
|
1192
949
|
return {
|
|
1193
|
-
|
|
1194
|
-
config,
|
|
950
|
+
configSource,
|
|
1195
951
|
entryModule,
|
|
1196
952
|
graph,
|
|
1197
953
|
name,
|
|
@@ -1199,6 +955,37 @@ async function runPipeline(entry, overrideName, cwd, deps = {}, onAssembleError)
|
|
|
1199
955
|
};
|
|
1200
956
|
}
|
|
1201
957
|
//#endregion
|
|
1202
|
-
|
|
958
|
+
//#region ../../0-framework/1-core/core/dist/container-transport-HcvNOGZL.mjs
|
|
959
|
+
/** '@prisma/composer-prisma-cloud' → 'PRISMA_COMPOSER_PRISMA_CLOUD': uppercased, every non-alphanumeric run replaced by one underscore. */
|
|
960
|
+
function envVarSafeExtensionId(extensionId) {
|
|
961
|
+
return extensionId.toUpperCase().replace(/[^A-Z0-9]+/g, "_").replace(/^_+|_+$/g, "");
|
|
962
|
+
}
|
|
963
|
+
/** '@prisma/composer-prisma-cloud' → 'PRISMA_COMPOSER_CONTAINER_PRISMA_COMPOSER_PRISMA_CLOUD' */
|
|
964
|
+
function containerEnvVarName(extensionId) {
|
|
965
|
+
return `PRISMA_COMPOSER_CONTAINER_${envVarSafeExtensionId(extensionId)}`;
|
|
966
|
+
}
|
|
967
|
+
function collisionError(a, b, varName) {
|
|
968
|
+
return /* @__PURE__ */ new Error(`Extension ids "${a}" and "${b}" both map to the container transport variable "${varName}" — rename one of the extensions.`);
|
|
969
|
+
}
|
|
970
|
+
function emptySerializeError(extensionId) {
|
|
971
|
+
return /* @__PURE__ */ new Error(`Extension "${extensionId}"'s container instance serialized to an empty string — ContainerInstance.serialize() must return a non-empty string.`);
|
|
972
|
+
}
|
|
973
|
+
/** The env entries the CLI sets on the alchemy process: `{ [containerEnvVarName(id)]: instance.serialize() }` for every resolved instance. */
|
|
974
|
+
function containerEnv(instances) {
|
|
975
|
+
const env = {};
|
|
976
|
+
const ownerByVarName = /* @__PURE__ */ new Map();
|
|
977
|
+
for (const [extensionId, instance] of instances) {
|
|
978
|
+
const varName = containerEnvVarName(extensionId);
|
|
979
|
+
const owner = ownerByVarName.get(varName);
|
|
980
|
+
if (owner !== void 0) throw collisionError(owner, extensionId, varName);
|
|
981
|
+
ownerByVarName.set(varName, extensionId);
|
|
982
|
+
const serialized = instance.serialize();
|
|
983
|
+
if (serialized.length === 0) throw emptySerializeError(extensionId);
|
|
984
|
+
env[varName] = serialized;
|
|
985
|
+
}
|
|
986
|
+
return env;
|
|
987
|
+
}
|
|
988
|
+
//#endregion
|
|
989
|
+
export { envVarSafeExtensionId as n, runPipeline as r, containerEnv as t };
|
|
1203
990
|
|
|
1204
|
-
//# sourceMappingURL=
|
|
991
|
+
//# sourceMappingURL=container-transport-HcvNOGZL-CHqecFc7.mjs.map
|