24 lines
639 B
TypeScript
24 lines
639 B
TypeScript
import { ComposeStack } from "./components/mod.ts";
|
|
import { ComposeSpecification } from "./compose-schema.ts";
|
|
|
|
const deployments: ComposeStack[] = [];
|
|
|
|
export function registerDeployment(stack: ComposeStack) {
|
|
deployments.push(stack);
|
|
}
|
|
|
|
export function getStacks(): Record<string, ComposeSpecification> {
|
|
const stacks: Record<string, ComposeSpecification> = {};
|
|
for (const stack of deployments) {
|
|
stacks[stack.name] = stack.toComposeFile();
|
|
}
|
|
return stacks;
|
|
}
|
|
|
|
globalThis.addEventListener("unload", () => {
|
|
if (deployments.length > 0) {
|
|
// Print stacks
|
|
console.log(JSON.stringify(getStacks(), null, 2));
|
|
}
|
|
});
|