@catladder/cli
Version:
Panter cli tool for cloud CI/CD and DevOps
23 lines • 1.35 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.resolveAllReferencesOnce = void 0;
const VariableValueContainingReferences_1 = require("./VariableValueContainingReferences");
const resolveReferencesOnce_1 = require("./resolveReferencesOnce");
const resolveAllReferencesOnce = async (values, getEnvVars) => {
const allReferences = Object.values(values).flatMap((value) => value === null || value === void 0 ? void 0 : value.parts.filter((part) => part instanceof VariableValueContainingReferences_1.VariableReference));
const allComponentsUnique = Array.from(new Set(allReferences.map((reference) => reference.componentName)));
const allEnvVarsInComponents = Object.fromEntries(await Promise.all(allComponentsUnique.map(async (componentName) => [
componentName,
await getEnvVars(componentName),
])));
return Object.fromEntries(Object.entries(values).map(([key, value]) => [
key,
value !== null && value !== undefined
? (0, resolveReferencesOnce_1.resolveReferencesOnce)(value, ({ componentName, variableName }) => {
return allEnvVarsInComponents[componentName][variableName];
})
: value,
]));
};
exports.resolveAllReferencesOnce = resolveAllReferencesOnce;
//# sourceMappingURL=resolveAllReferencesOnce.js.map