UNPKG

aws-cdk-lib

Version:

Version 2 of the AWS Cloud Development Kit library

2 lines (1 loc) 2.85 kB
"use strict";var _a;Object.defineProperty(exports,"__esModule",{value:!0}),exports.StageDeployment=void 0;const jsiiDeprecationWarnings=require("../../../.warnings.jsii.js"),JSII_RTTI_SYMBOL_1=Symbol.for("jsii.rtti"),stack_deployment_1=require("./stack-deployment"),cloud_assembly_internals_1=require("../private/cloud-assembly-internals"),construct_internals_1=require("../private/construct-internals");class StageDeployment{constructor(stacks,props={}){this.stacks=stacks,this.stageName=props.stageName??"",this.pre=props.pre??[],this.post=props.post??[],this.stackSteps=props.stackSteps??[]}static fromStage(stage,props={}){try{jsiiDeprecationWarnings.aws_cdk_lib_Stage(stage),jsiiDeprecationWarnings.aws_cdk_lib_pipelines_StageDeploymentProps(props)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,this.fromStage),error}const assembly=construct_internals_1.pipelineSynth(stage);if(assembly.stacks.length===0)throw new Error(`The given Stage construct ('${stage.node.path}') should contain at least one Stack`);const stepFromArtifact=new Map;for(const artifact of assembly.stacks){const step=stack_deployment_1.StackDeployment.fromArtifact(artifact);stepFromArtifact.set(artifact,step)}if(props.stackSteps)for(const stackstep of props.stackSteps){const stackArtifact=assembly.getStackArtifact(stackstep.stack.artifactId),thisStep=stepFromArtifact.get(stackArtifact);if(!thisStep)throw new Error("Logic error: we just added a step for this artifact but it disappeared.");thisStep.addStackSteps(stackstep.pre??[],stackstep.changeSet??[],stackstep.post??[])}for(const artifact of assembly.stacks){const thisStep=stepFromArtifact.get(artifact);if(!thisStep)throw new Error("Logic error: we just added a step for this artifact but it disappeared.");const stackDependencies=artifact.dependencies.filter(cloud_assembly_internals_1.isStackArtifact);for(const dep of stackDependencies){const depStep=stepFromArtifact.get(dep);if(!depStep)throw new Error(`Stack '${artifact.id}' depends on stack not found in same Stage: '${dep.id}'`);thisStep.addStackDependency(depStep)}}return new StageDeployment(Array.from(stepFromArtifact.values()),{stageName:stage.stageName,...props})}addPre(...steps){try{jsiiDeprecationWarnings.aws_cdk_lib_pipelines_Step(steps)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,this.addPre),error}this.pre.push(...steps)}addPost(...steps){try{jsiiDeprecationWarnings.aws_cdk_lib_pipelines_Step(steps)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,this.addPost),error}this.post.push(...steps)}}exports.StageDeployment=StageDeployment,_a=JSII_RTTI_SYMBOL_1,StageDeployment[_a]={fqn:"aws-cdk-lib.pipelines.StageDeployment",version:"2.70.0"};