UNPKG

@webda/shell

Version:

Deploy a Webda app or configure it

41 lines 1.34 kB
import { WebdaError } from "@webda/core"; import * as merge from "merge"; import { Deployer } from "./deployer.js"; /** * Run a list of Deployer * * @WebdaDeployer WebdaDeployer/ChainDeployer */ export default class ChainDeployer extends Deployer { /** * * @returns current chain */ getChain() { if (typeof this.resources.chain === "string") { return this.resources.chain.split(","); } return this.resources.chain || []; } /** * Deploy each deployer from the chain, adding any results sent by previous * deployers to the next one */ async deploy() { let deployers = this.getChain(); deployers.forEach(d => { if (!this.manager.deployersDefinition[d.toLowerCase()]) { throw new WebdaError.CodeError("DEPLOYER_UNKNOWN", "Deployer " + d + " is unknown"); } }); // Duplicate object let resources = JSON.parse(JSON.stringify(this.resources)); // Run all deployers one after the other for (let i in deployers) { let result = (await this.manager.run(deployers[i], resources)) || {}; resources = merge.recursive(resources, this.replaceVariables(result)); } } } export { ChainDeployer }; //# sourceMappingURL=chaindeployer.js.map