@terraforge/core 0.0.7 → 0.0.8
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/index.js +42 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -186,6 +186,40 @@ var findInputDeps = (props) => {
|
|
|
186
186
|
find(props);
|
|
187
187
|
return deps;
|
|
188
188
|
};
|
|
189
|
+
var formatPath = (path) => {
|
|
190
|
+
if (path.length === 0) {
|
|
191
|
+
return "<root>";
|
|
192
|
+
}
|
|
193
|
+
return path.map((part) => {
|
|
194
|
+
if (typeof part === "number") {
|
|
195
|
+
return `[${part}]`;
|
|
196
|
+
}
|
|
197
|
+
return `.${part}`;
|
|
198
|
+
}).join("").replace(/^\./, "");
|
|
199
|
+
};
|
|
200
|
+
var findInputDepsWithPaths = (props) => {
|
|
201
|
+
const deps = [];
|
|
202
|
+
const find = (value, path) => {
|
|
203
|
+
if (value instanceof Output) {
|
|
204
|
+
for (const meta of value.dependencies) {
|
|
205
|
+
deps.push({
|
|
206
|
+
meta,
|
|
207
|
+
path: formatPath(path)
|
|
208
|
+
});
|
|
209
|
+
}
|
|
210
|
+
return;
|
|
211
|
+
}
|
|
212
|
+
if (Array.isArray(value)) {
|
|
213
|
+
value.map((item, index) => find(item, [...path, index]));
|
|
214
|
+
return;
|
|
215
|
+
}
|
|
216
|
+
if (value?.constructor === Object) {
|
|
217
|
+
Object.entries(value).map(([key, item]) => find(item, [...path, key]));
|
|
218
|
+
}
|
|
219
|
+
};
|
|
220
|
+
find(props, []);
|
|
221
|
+
return deps;
|
|
222
|
+
};
|
|
189
223
|
var resolveInputs = async (inputs) => {
|
|
190
224
|
const unresolved = [];
|
|
191
225
|
const find = (props, parent, key) => {
|
|
@@ -1103,6 +1137,14 @@ var deployApp = async (app, opt) => {
|
|
|
1103
1137
|
for (const node of stack.nodes) {
|
|
1104
1138
|
const meta = getMeta(node);
|
|
1105
1139
|
const dependencies = [...meta.dependencies];
|
|
1140
|
+
for (let i = 0; i < dependencies.length; i++) {
|
|
1141
|
+
if (!dependencies[i]) {
|
|
1142
|
+
const depPaths = findInputDepsWithPaths(meta.input).map((dep) => `${dep.path} -> ${dep.meta?.urn ?? "undefined"}`).join(", ");
|
|
1143
|
+
throw new Error(
|
|
1144
|
+
`Resource ${meta.urn} has an undefined dependency at index ${i}. Check inputs for missing/undefined Output references. ` + (depPaths ? `Dependency sources: ${depPaths}` : "")
|
|
1145
|
+
);
|
|
1146
|
+
}
|
|
1147
|
+
}
|
|
1106
1148
|
const partialNewResourceState = {
|
|
1107
1149
|
dependencies,
|
|
1108
1150
|
lifecycle: isResource(node) ? {
|