UNPKG

aws-cdk-lib

Version:

Version 2 of the AWS Cloud Development Kit library

2 lines (1 loc) 2.63 kB
"use strict";var _a;Object.defineProperty(exports,"__esModule",{value:!0}),exports.App=void 0,exports.attachCustomSynthesis=attachCustomSynthesis;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-extra");return fs=()=>tmp,tmp},private_context_1=()=>{var tmp=require("./private/private-context");return private_context_1=()=>tmp,tmp},synthesis_1=()=>{var tmp=require("./private/synthesis");return synthesis_1=()=>tmp,tmp},stage_1=()=>{var tmp=require("./stage");return stage_1=()=>tmp,tmp},cxapi=()=>{var tmp=require("../../cx-api");return cxapi=()=>tmp,tmp};const APP_SYMBOL=Symbol.for("@aws-cdk/core.App");class App extends stage_1().Stage{static isApp(obj){return APP_SYMBOL in obj}constructor(props={}){super(void 0,"",{outdir:props.outdir??process.env[cxapi().OUTDIR_ENV],policyValidationBeta1:props.policyValidationBeta1});try{jsiiDeprecationWarnings().aws_cdk_lib_AppProps(props)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,App),error}Object.defineProperty(this,APP_SYMBOL,{value:!0}),this.loadContext(props.context,props.postCliContext),props.stackTraces===!1&&this.node.setContext(cxapi().DISABLE_METADATA_STACK_TRACE,!0),props.defaultStackSynthesizer&&this.node.setContext(private_context_1().PRIVATE_CONTEXT_DEFAULT_STACK_SYNTHESIZER,props.defaultStackSynthesizer);const analyticsReporting=props.analyticsReporting??props.runtimeInfo;analyticsReporting!==void 0&&this.node.setContext(cxapi().ANALYTICS_REPORTING_ENABLED_CONTEXT,analyticsReporting),(props.autoSynth??cxapi().OUTDIR_ENV in process.env)&&process.once("beforeExit",()=>this.synth({errorOnDuplicateSynth:!1})),this._treeMetadata=props.treeMetadata??!0}loadContext(defaults={},final={}){for(const[k,v]of Object.entries(defaults))this.node.setContext(k,v);const context={...this.readContextFromEnvironment(),...this.readContextFromTempFile()};for(const[k,v]of Object.entries(context))this.node.setContext(k,v);for(const[k,v]of Object.entries(final))this.node.setContext(k,v)}readContextFromTempFile(){const location=process.env[cxapi().CONTEXT_OVERFLOW_LOCATION_ENV];return location?fs().readJSONSync(location):{}}readContextFromEnvironment(){const contextJson=process.env[cxapi().CONTEXT_ENV];return contextJson?JSON.parse(contextJson):{}}}exports.App=App,_a=JSII_RTTI_SYMBOL_1,App[_a]={fqn:"aws-cdk-lib.App",version:"2.185.0"};function attachCustomSynthesis(construct,synthesis){(0,synthesis_1().addCustomSynthesis)(construct,synthesis)}