aws-cdk-lib
Version:
Version 2 of the AWS Cloud Development Kit library
2 lines (1 loc) • 2.27 kB
JavaScript
;var _a;Object.defineProperty(exports,"__esModule",{value:!0}),exports.attachCustomSynthesis=exports.App=void 0;const jsiiDeprecationWarnings=require("../../.warnings.jsii.js"),JSII_RTTI_SYMBOL_1=Symbol.for("jsii.rtti"),cxapi=require("../../cx-api"),fs=require("fs-extra"),private_context_1=require("./private/private-context"),synthesis_1=require("./private/synthesis"),stage_1=require("./stage"),APP_SYMBOL=Symbol.for("@aws-cdk/core.App");class App extends stage_1.Stage{constructor(props={}){super(void 0,"",{outdir:props.outdir??process.env[cxapi.OUTDIR_ENV]});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()),this._treeMetadata=props.treeMetadata??!0}static isApp(obj){return APP_SYMBOL in obj}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.70.0"};function attachCustomSynthesis(construct,synthesis){synthesis_1.addCustomSynthesis(construct,synthesis)}exports.attachCustomSynthesis=attachCustomSynthesis;