UNPKG

aws-cdk-lib

Version:

Version 2 of the AWS Cloud Development Kit library

7 lines (6 loc) 4.28 kB
"use strict";var __decorate=exports&&exports.__decorate||function(decorators,target,key,desc){var c=arguments.length,r=c<3?target:desc===null?desc=Object.getOwnPropertyDescriptor(target,key):desc,d;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(decorators,target,key,desc);else for(var i=decorators.length-1;i>=0;i--)(d=decorators[i])&&(r=(c<3?d(r):c>3?d(target,key,r):d(target,key))||r);return c>3&&r&&Object.defineProperty(target,key,r),r},_a;Object.defineProperty(exports,"__esModule",{value:!0}),exports.ProductStackHistory=void 0;var jsiiDeprecationWarnings=()=>{var tmp=require("../../.warnings.jsii.js");return jsiiDeprecationWarnings=()=>tmp,tmp};const JSII_RTTI_SYMBOL_1=Symbol.for("jsii.rtti");var fs=()=>{var tmp=require("fs");return fs=()=>tmp,tmp},path=()=>{var tmp=require("path");return path=()=>tmp,tmp},constructs_1=()=>{var tmp=require("constructs");return constructs_1=()=>tmp,tmp},cloudformation_template_1=()=>{var tmp=require("./cloudformation-template");return cloudformation_template_1=()=>tmp,tmp},common_1=()=>{var tmp=require("./common");return common_1=()=>tmp,tmp},core_1=()=>{var tmp=require("../../core");return core_1=()=>tmp,tmp},prop_injectable_1=()=>{var tmp=require("../../core/lib/prop-injectable");return prop_injectable_1=()=>tmp,tmp};let ProductStackHistory=class ProductStackHistory2 extends constructs_1().Construct{constructor(scope,id,props){super(scope,id);try{jsiiDeprecationWarnings().aws_cdk_lib_aws_servicecatalog_ProductStackHistoryProps(props)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,ProductStackHistory2),error}props.productStack._setParentProductStackHistory(this),this.props=props}currentVersion(){return{cloudFormationTemplate:cloudformation_template_1().CloudFormationTemplate.fromProductStack(this.props.productStack),productVersionName:this.props.currentVersionName,description:this.props.description}}versionFromSnapshot(productVersionName){const productStackSnapshotDirectory=this.props.directory||common_1().DEFAULT_PRODUCT_STACK_SNAPSHOT_DIRECTORY,templateFileKey=`${core_1().Names.uniqueId(this)}.${this.props.productStack.artifactId}.${productVersionName}.product.template.json`,templateFilePath=path().join(productStackSnapshotDirectory,templateFileKey);if(!fs().existsSync(templateFilePath))throw new(core_1()).ValidationError(`Template ${templateFileKey} cannot be found in ${productStackSnapshotDirectory}`,this);return{cloudFormationTemplate:cloudformation_template_1().CloudFormationTemplate.fromAsset(templateFilePath),productVersionName,description:this.props.description}}_writeTemplateToSnapshot(cfn){const productStackSnapshotDirectory=this.props.directory||common_1().DEFAULT_PRODUCT_STACK_SNAPSHOT_DIRECTORY;fs().existsSync(productStackSnapshotDirectory)||fs().mkdirSync(productStackSnapshotDirectory,{recursive:!0});const templateFileKey=`${core_1().Names.uniqueId(this)}.${this.props.productStack.artifactId}.${this.props.currentVersionName}.product.template.json`,templateFilePath=path().join(productStackSnapshotDirectory,templateFileKey);if(fs().existsSync(templateFilePath)&&fs().readFileSync(templateFilePath).toString()!==cfn&&this.props.currentVersionLocked)throw new(core_1()).ValidationError(`Template has changed for ProductStack Version ${this.props.currentVersionName}. ${this.props.currentVersionName} already exist in ${productStackSnapshotDirectory}. Since locked has been set to ${this.props.currentVersionLocked}, Either update the currentVersionName to deploy a new version or deploy the existing ProductStack snapshot. If ${this.props.currentVersionName} was unintentionally synthesized and not deployed, delete the corresponding version from ${productStackSnapshotDirectory} and redeploy.`,this);fs().writeFileSync(templateFilePath,cfn)}};exports.ProductStackHistory=ProductStackHistory,_a=JSII_RTTI_SYMBOL_1,ProductStackHistory[_a]={fqn:"aws-cdk-lib.aws_servicecatalog.ProductStackHistory",version:"2.211.0"},ProductStackHistory.PROPERTY_INJECTION_ID="aws-cdk-lib.aws-servicecatalog.ProductStackHistory",exports.ProductStackHistory=ProductStackHistory=__decorate([prop_injectable_1().propertyInjectable],ProductStackHistory);