UNPKG

aws-cdk-lib

Version:

Version 2 of the AWS Cloud Development Kit library

3 lines (2 loc) 22.8 kB
"use strict";var __createBinding=exports&&exports.__createBinding||(Object.create?(function(o,m,k,k2){k2===void 0&&(k2=k);var desc=Object.getOwnPropertyDescriptor(m,k);(!desc||("get"in desc?!m.__esModule:desc.writable||desc.configurable))&&(desc={enumerable:!0,get:function(){return m[k]}}),Object.defineProperty(o,k2,desc)}):(function(o,m,k,k2){k2===void 0&&(k2=k),o[k2]=m[k]})),__setModuleDefault=exports&&exports.__setModuleDefault||(Object.create?(function(o,v){Object.defineProperty(o,"default",{enumerable:!0,value:v})}):function(o,v){o.default=v}),__runInitializers=exports&&exports.__runInitializers||function(thisArg,initializers,value){for(var useValue=arguments.length>2,i=0;i<initializers.length;i++)value=useValue?initializers[i].call(thisArg,value):initializers[i].call(thisArg);return useValue?value:void 0},__esDecorate=exports&&exports.__esDecorate||function(ctor,descriptorIn,decorators,contextIn,initializers,extraInitializers){function accept(f){if(f!==void 0&&typeof f!="function")throw new TypeError("Function expected");return f}for(var kind=contextIn.kind,key=kind==="getter"?"get":kind==="setter"?"set":"value",target=!descriptorIn&&ctor?contextIn.static?ctor:ctor.prototype:null,descriptor=descriptorIn||(target?Object.getOwnPropertyDescriptor(target,contextIn.name):{}),_,done=!1,i=decorators.length-1;i>=0;i--){var context={};for(var p in contextIn)context[p]=p==="access"?{}:contextIn[p];for(var p in contextIn.access)context.access[p]=contextIn.access[p];context.addInitializer=function(f){if(done)throw new TypeError("Cannot add initializers after decoration has completed");extraInitializers.push(accept(f||null))};var result=(0,decorators[i])(kind==="accessor"?{get:descriptor.get,set:descriptor.set}:descriptor[key],context);if(kind==="accessor"){if(result===void 0)continue;if(result===null||typeof result!="object")throw new TypeError("Object expected");(_=accept(result.get))&&(descriptor.get=_),(_=accept(result.set))&&(descriptor.set=_),(_=accept(result.init))&&initializers.unshift(_)}else(_=accept(result))&&(kind==="field"?initializers.unshift(_):descriptor[key]=_)}target&&Object.defineProperty(target,contextIn.name,descriptor),done=!0},__importStar=exports&&exports.__importStar||(function(){var ownKeys=function(o){return ownKeys=Object.getOwnPropertyNames||function(o2){var ar=[];for(var k in o2)Object.prototype.hasOwnProperty.call(o2,k)&&(ar[ar.length]=k);return ar},ownKeys(o)};return function(mod){if(mod&&mod.__esModule)return mod;var result={};if(mod!=null)for(var k=ownKeys(mod),i=0;i<k.length;i++)k[i]!=="default"&&__createBinding(result,mod,k[i]);return __setModuleDefault(result,mod),result}})(),__addDisposableResource=exports&&exports.__addDisposableResource||function(env,value,async){if(value!=null){if(typeof value!="object"&&typeof value!="function")throw new TypeError("Object expected.");var dispose,inner;if(async){if(!Symbol.asyncDispose)throw new TypeError("Symbol.asyncDispose is not defined.");dispose=value[Symbol.asyncDispose]}if(dispose===void 0){if(!Symbol.dispose)throw new TypeError("Symbol.dispose is not defined.");dispose=value[Symbol.dispose],async&&(inner=dispose)}if(typeof dispose!="function")throw new TypeError("Object not disposable.");inner&&(dispose=function(){try{inner.call(this)}catch(e){return Promise.reject(e)}}),env.stack.push({value,dispose,async})}else async&&env.stack.push({async:!0});return value},__disposeResources=exports&&exports.__disposeResources||(function(SuppressedError2){return function(env){function fail(e){env.error=env.hasError?new SuppressedError2(e,env.error,"An error was suppressed during disposal."):e,env.hasError=!0}var r,s=0;function next(){for(;r=env.stack.pop();)try{if(!r.async&&s===1)return s=0,env.stack.push(r),Promise.resolve().then(next);if(r.dispose){var result=r.dispose.call(r.value);if(r.async)return s|=2,Promise.resolve(result).then(next,function(e){return fail(e),next()})}else s|=1}catch(e){fail(e)}if(s===1)return env.hasError?Promise.reject(env.error):Promise.resolve();if(env.hasError)throw env.error}return next()}})(typeof SuppressedError=="function"?SuppressedError:function(error,suppressed,message){var e=new Error(message);return e.name="SuppressedError",e.error=error,e.suppressed=suppressed,e});Object.defineProperty(exports,"__esModule",{value:!0}),exports.Bundling=void 0;var fs=()=>{var tmp=__importStar(require("fs"));return fs=()=>tmp,tmp},os=()=>{var tmp=__importStar(require("os"));return os=()=>tmp,tmp},path=()=>{var tmp=__importStar(require("path"));return path=()=>tmp,tmp},package_installation_1=()=>{var tmp=require("./package-installation");return package_installation_1=()=>tmp,tmp},package_manager_1=()=>{var tmp=require("./package-manager");return package_manager_1=()=>tmp,tmp},types_1=()=>{var tmp=require("./types");return types_1=()=>tmp,tmp},util_1=()=>{var tmp=require("./util");return util_1=()=>tmp,tmp},aws_lambda_1=()=>{var tmp=require("../../aws-lambda");return aws_lambda_1=()=>tmp,tmp},cdk=()=>{var tmp=__importStar(require("../../core"));return cdk=()=>tmp,tmp},core_1=()=>{var tmp=require("../../core");return core_1=()=>tmp,tmp},literal_string_1=()=>{var tmp=require("../../core/lib/private/literal-string");return literal_string_1=()=>tmp,tmp},perf_1=()=>{var tmp=require("../../core/lib/private/perf");return perf_1=()=>tmp,tmp},cx_api_1=()=>{var tmp=require("../../cx-api");return cx_api_1=()=>tmp,tmp};const ESBUILD_MAJOR_VERSION="0",ESBUILD_DEFAULT_VERSION="0.21";function pathEscapesRoot(relativePath){return path().isAbsolute(relativePath)||relativePath===".."||relativePath.startsWith(`..${path().sep}`)}let Bundling=(()=>{let _instanceExtraInitializers=[],_executeBundlingSteps_decorators;return class Bundling2{static{const _metadata=typeof Symbol=="function"&&Symbol.metadata?Object.create(null):void 0;_executeBundlingSteps_decorators=[(0,perf_1().profileFn)("NodejsFunction#tryBundle",{telemetry:!0})],__esDecorate(this,null,_executeBundlingSteps_decorators,{kind:"method",name:"executeBundlingSteps",static:!1,private:!1,access:{has:obj=>"executeBundlingSteps"in obj,get:obj=>obj.executeBundlingSteps},metadata:_metadata},null,_instanceExtraInitializers),_metadata&&Object.defineProperty(this,Symbol.metadata,{enumerable:!0,configurable:!0,writable:!0,value:_metadata})}props=__runInitializers(this,_instanceExtraInitializers);static bundle(scope,options){return aws_lambda_1().Code.fromAsset(options.projectRoot,{assetHash:options.assetHash,assetHashType:options.assetHash?cdk().AssetHashType.CUSTOM:cdk().AssetHashType.OUTPUT,bundling:new Bundling2(scope,options)})}static clearEsbuildInstallationCache(){this.esbuildInstallation=void 0}static clearTscInstallationCache(){this.tscInstallation=void 0}static esbuildInstallation;static tscInstallation;[cdk().PERF_BUNDLING_SRC_SYM]="NodejsFunction";image;entrypoint;command;volumes;volumesFrom;environment;workingDirectory;user;securityOpt;network;local;bundlingFileAccess;projectRoot;relativeEntryPath;relativeTsconfigPath;relativeDepsLockFilePath;externals;packageManager;constructor(scope,props){if(this.props=props,this.packageManager=package_manager_1().PackageManager.fromLockFile(props.depsLockFilePath,props.logLevel),Bundling2.esbuildInstallation=Bundling2.esbuildInstallation??package_installation_1().PackageInstallation.detect("esbuild"),Bundling2.tscInstallation=Bundling2.tscInstallation??package_installation_1().PackageInstallation.detect("typescript"),this.projectRoot=props.projectRoot,this.relativeEntryPath=path().relative(this.projectRoot,path().resolve(props.entry)),this.relativeDepsLockFilePath=path().relative(this.projectRoot,path().resolve(props.depsLockFilePath)),pathEscapesRoot(this.relativeEntryPath))throw new(core_1()).ValidationError((0,literal_string_1().lit)`PathNotUnderRoot`,`entryPath (${props.entry}) should be under projectRoot (${this.projectRoot})`,scope);if(pathEscapesRoot(this.relativeDepsLockFilePath))throw new(core_1()).ValidationError((0,literal_string_1().lit)`PathNotUnderRoot`,`depsLockFilePath (${props.depsLockFilePath}) should be under projectRoot (${this.projectRoot})`,scope);if(props.tsconfig&&(this.relativeTsconfigPath=path().relative(this.projectRoot,path().resolve(props.tsconfig))),props.preCompilation&&!/\.tsx?$/.test(props.entry))throw new(core_1()).ValidationError((0,literal_string_1().lit)`PreCompilationTypescriptFiles`,"preCompilation can only be used with typescript files",scope);if(props.format===types_1().OutputFormat.ESM&&!isEsmRuntime(props.runtime))throw new(core_1()).ValidationError((0,literal_string_1().lit)`ScriptModuleOutputFormatSupported`,`ECMAScript module output format is not supported by the ${props.runtime.name} runtime`,scope);const sdkV3Externals=cdk().FeatureFlags.of(scope).isEnabled(cx_api_1().LAMBDA_NODEJS_SDK_V3_EXCLUDE_SMITHY_PACKAGES)?["@aws-sdk/*","@smithy/*"]:["@aws-sdk/*"],isV2Runtime=(0,util_1().isSdkV2Runtime)(props.runtime),versionedExternals=isV2Runtime?["aws-sdk"]:sdkV3Externals,defaultExternals=props.runtime?.isVariable||props.bundleAwsSDK?[]:versionedExternals,externals=props.externalModules??defaultExternals;externals.length&&isV2Runtime&&cdk().Annotations.of(scope).addWarningV2("aws-cdk-lib/aws-lambda-nodejs:runtimeUpdateSdkV2Breakage","Be aware that the NodeJS runtime of Node 16 will be deprecated by Lambda on June 12, 2024. Lambda runtimes Node 18 and higher include SDKv3 and not SDKv2. Updating your Lambda runtime will require bundling the SDK, or updating all SDK calls in your handler code to use SDKv3 (which is not a trivial update). Please account for this added complexity and update as soon as possible."),isV2Runtime&&externals.some(pkgName=>pkgName.startsWith("@aws-sdk/"))?cdk().Annotations.of(scope).addWarningV2("@aws-cdk/aws-lambda-nodejs:sdkV3NotInRuntime","If you are relying on AWS SDK v3 to be present in the Lambda environment already, please explicitly configure a NodeJS runtime of Node 18 or higher."):!isV2Runtime&&externals.includes("aws-sdk")&&cdk().Annotations.of(scope).addWarningV2("@aws-cdk/aws-lambda-nodejs:sdkV2NotInRuntime","If you are relying on AWS SDK v2 to be present in the Lambda environment already, please explicitly configure a NodeJS runtime of Node 16 or lower."),externals.length&&props.runtime?.isVariable&&cdk().Annotations.of(scope).addWarningV2("@aws-cdk/aws-lambda-nodejs:variableRuntimeExternals","When using NODEJS_LATEST the runtime version may change as new runtimes are released, this may affect the availability of packages shipped with the environment. Ensure that any external dependencies are available through layers or specify a specific runtime version."),this.externals=[...externals,...props.nodeModules??[]];const shouldBuildImage=props.forceDockerBundling||!Bundling2.esbuildInstallation;if(shouldBuildImage&&props.dockerImage)this.image=props.dockerImage;else if(shouldBuildImage&&!props.dockerImage){const env_1={stack:[],error:void 0,hasError:!1};try{const _span=__addDisposableResource(env_1,(0,perf_1().profileSpan)(`bundle:${this[cdk().PERF_BUNDLING_SRC_SYM]}`,{telemetry:!0,skipCount:!0}),!1);this.image=cdk().DockerImage.fromBuild(path().join(__dirname,"docker"),{buildArgs:{...props.buildArgs??{},IMAGE:props.runtime.bundlingImage.image,ESBUILD_VERSION:props.esbuildVersion??ESBUILD_DEFAULT_VERSION},platform:props.architecture.dockerPlatform,network:props.network})}catch(e_1){env_1.error=e_1,env_1.hasError=!0}finally{__disposeResources(env_1)}}else this.image=cdk().DockerImage.fromRegistry("dummy");const bundlingCommand=this.createBundlingCommand(scope,{inputDir:cdk().AssetStaging.BUNDLING_INPUT_DIR,outputDir:cdk().AssetStaging.BUNDLING_OUTPUT_DIR,esbuildRunner:"esbuild",tscRunner:"tsc",osPlatform:"linux"});this.command=props.command??["bash","-c",bundlingCommand],this.environment=props.environment,this.workingDirectory=props.workingDirectory??"/",this.entrypoint=props.entrypoint,this.volumes=props.volumes,this.volumesFrom=props.volumesFrom,this.user=props.user,this.securityOpt=props.securityOpt,this.network=props.network,this.bundlingFileAccess=props.bundlingFileAccess,props.forceDockerBundling||(this.local=this.getLocalBundlingProvider(scope))}buildEsbuildArgs(scope,inputDir,outputDir,pathJoin){if(this.props.sourceMap===!1&&this.props.sourceMapMode)throw new(core_1()).ValidationError((0,literal_string_1().lit)`SourceMapModeCannotSource`,"sourceMapMode cannot be used when sourceMap is false",scope);const sourceMapEnabled=this.props.sourceMapMode??this.props.sourceMap,sourceMapValue=(this.props.sourceMapMode??types_1().SourceMapMode.DEFAULT)===types_1().SourceMapMode.DEFAULT?"":`=${this.props.sourceMapMode}`,sourcesContent=this.props.sourcesContent??!0,outFile=this.props.format===types_1().OutputFormat.ESM?"index.mjs":"index.js";return[`--target=${this.props.target??toTarget(scope,this.props.runtime)}`,"--platform=node",...this.props.format?[`--format=${this.props.format}`]:[],`--outfile=${pathJoin(outputDir,outFile)}`,...this.props.minify?["--minify"]:[],...sourceMapEnabled?[`--sourcemap${sourceMapValue}`]:[],...sourcesContent?[]:[`--sources-content=${sourcesContent}`],...this.externals.map(external=>`--external:${external}`),...Object.entries(this.props.loader??{}).map(([ext,name])=>`--loader:${ext}=${name}`),...Object.entries(this.props.define??{}).map(([key,value])=>`--define:${key}=${value}`),...this.props.logLevel?[`--log-level=${this.props.logLevel}`]:[],...this.props.keepNames?["--keep-names"]:[],...this.relativeTsconfigPath?[`--tsconfig=${pathJoin(inputDir,this.relativeTsconfigPath)}`]:[],...this.props.metafile?[`--metafile=${pathJoin(outputDir,"index.meta.json")}`]:[],...this.props.banner?[`--banner:js=${this.props.banner}`]:[],...this.props.footer?[`--footer:js=${this.props.footer}`]:[],...this.props.mainFields?[`--main-fields=${this.props.mainFields.join(",")}`]:[],...this.props.inject?this.props.inject.map(i=>`--inject:${i}`):[]]}createBundlingCommand(scope,options){const pathJoin=osPathJoin(options.osPlatform),osCommand=new OsCommand(options.osPlatform),steps=this.createBundlingSteps(scope,{inputDir:options.inputDir,outputDir:options.outputDir,pathJoin,esbuildRunner:[options.esbuildRunner],tscRunner:options.tscRunner?[options.tscRunner]:void 0,createFileOps:deps=>this.dockerFileOps(osCommand,pathJoin,options,deps)});return stepsToPosixShellCommand(steps)}dockerFileOps(osCommand,pathJoin,options,deps){const lockFilePath=pathJoin(options.inputDir,this.relativeDepsLockFilePath??this.packageManager.lockFile),isPnpm=this.packageManager.lockFile===package_manager_1().LockFile.PNPM,isBun=this.packageManager.lockFile===package_manager_1().LockFile.BUN_LOCK||this.packageManager.lockFile===package_manager_1().LockFile.BUN;return[{type:"shell",commands:[chain([isPnpm?osCommand.write(pathJoin(options.outputDir,"pnpm-workspace.yaml"),""):"",osCommand.writeJson(pathJoin(options.outputDir,"package.json"),{dependencies:deps.dependencies}),osCommand.copy(lockFilePath,pathJoin(options.outputDir,this.packageManager.lockFile)),osCommand.changeDirectory(options.outputDir),this.packageManager.installCommand.join(" "),isPnpm?osCommand.remove(pathJoin(options.outputDir,"node_modules",".modules.yaml"),!0):"",isBun?osCommand.removeDir(pathJoin(options.outputDir,"node_modules",".cache")):""])]}]}localFileOps(outputDir,deps){const lockFilePath=path().join(this.projectRoot,this.relativeDepsLockFilePath??this.packageManager.lockFile),isPnpm=this.packageManager.lockFile===package_manager_1().LockFile.PNPM,isBun=this.packageManager.lockFile===package_manager_1().LockFile.BUN_LOCK||this.packageManager.lockFile===package_manager_1().LockFile.BUN,steps=[];return steps.push({type:"callback",operation:()=>{isPnpm&&fs().writeFileSync(path().join(outputDir,"pnpm-workspace.yaml"),""),fs().writeFileSync(path().join(outputDir,"package.json"),JSON.stringify({dependencies:deps.dependencies})),fs().copyFileSync(lockFilePath,path().join(outputDir,this.packageManager.lockFile))}}),steps.push({type:"spawn",command:[...this.packageManager.installCommand],cwd:outputDir}),isPnpm&&steps.push({type:"callback",operation:()=>{const modulesYaml=path().join(outputDir,"node_modules",".modules.yaml");fs().existsSync(modulesYaml)&&fs().rmSync(modulesYaml,{force:!0})}}),isBun&&steps.push({type:"callback",operation:()=>{const cacheDir=path().join(outputDir,"node_modules",".cache");fs().existsSync(cacheDir)&&fs().rmSync(cacheDir,{recursive:!0,force:!0})}}),steps}getLocalBundlingProvider(scope){const cwd=this.projectRoot;return{tryBundle:outputDir=>{if(!Bundling2.esbuildInstallation)return process.stderr.write(`esbuild cannot run locally. Switching to Docker bundling. `),!1;if(!Bundling2.esbuildInstallation.version.startsWith(`${ESBUILD_MAJOR_VERSION}.`))throw new(core_1()).ValidationError((0,literal_string_1().lit)`ExpectedEsbuildVersion`,`Expected esbuild version ${ESBUILD_MAJOR_VERSION}.x but got ${Bundling2.esbuildInstallation.version}`,scope);const esbuild=Bundling2.esbuildInstallation,tsc=Bundling2.tscInstallation,steps=this.createBundlingSteps(scope,{inputDir:cwd,outputDir,pathJoin:(...args)=>path().join(...args),esbuildRunner:esbuild.isWorkspacePackage?this.packageManager.runBinCommand("esbuild"):["esbuild"],tscRunner:tsc&&(tsc.isWorkspacePackage?this.packageManager.runBinCommand("tsc"):["tsc"]),createFileOps:deps=>this.localFileOps(outputDir,deps)});return this.executeBundlingSteps(scope,steps),!0}}}createBundlingSteps(scope,options){const steps=[];let entryPath=options.pathJoin(options.inputDir,this.relativeEntryPath);const beforeBundling=this.props.commandHooks?.beforeBundling(options.inputDir,options.outputDir)??[];if(beforeBundling.length&&steps.push({type:"shell",commands:beforeBundling}),this.props.preCompilation){const tsconfig=this.props.tsconfig??(0,util_1().findUp)("tsconfig.json",path().dirname(this.props.entry));if(!tsconfig)throw new(core_1()).ValidationError((0,literal_string_1().lit)`CannotFindTsconfigJsonPre`,"Cannot find a `tsconfig.json` but `preCompilation` is set to `true`, please specify it via `tsconfig`",scope);const compilerOptionsArray=(0,util_1().getTsconfigCompilerOptionsArray)(tsconfig);options.tscRunner&&steps.push({type:"spawn",command:[...options.tscRunner,entryPath,...compilerOptionsArray]}),entryPath=entryPath.replace(/\.ts(x?)$/,".js$1")}const esbuildArgs=[...this.buildEsbuildArgs(scope,options.inputDir,options.outputDir,options.pathJoin),...this.props.esbuildArgs?toCliArgsArray(this.props.esbuildArgs):[]];if(steps.push({type:"spawn",command:[...options.esbuildRunner,"--bundle",entryPath,...esbuildArgs]}),this.props.nodeModules){const pkgPath=(0,util_1().findUp)("package.json",path().dirname(this.props.entry));if(!pkgPath)throw new(core_1()).ValidationError((0,literal_string_1().lit)`CannotFindPackageJsonProject`,"Cannot find a `package.json` in this project. Using `nodeModules` requires a `package.json`.",scope);const beforeInstall=this.props.commandHooks?.beforeInstall(options.inputDir,options.outputDir)??[];beforeInstall.length&&steps.push({type:"shell",commands:beforeInstall});const dependencies=(0,util_1().extractDependencies)(pkgPath,this.props.nodeModules);steps.push(...options.createFileOps({dependencies}))}const afterBundling=this.props.commandHooks?.afterBundling(options.inputDir,options.outputDir)??[];return afterBundling.length&&steps.push({type:"shell",commands:afterBundling}),steps}executeBundlingSteps(scope,steps){const cwd=this.projectRoot,isWindows=os().platform()==="win32",environment=this.props.environment??{},execOptions={env:{...process.env,...environment},stdio:["ignore",process.stderr,"inherit"],cwd};for(const step of steps)switch(step.type){case"shell":for(const cmd of step.commands)isWindows?(0,util_1().exec)(process.env.COMSPEC??"cmd",["/c",cmd],{...execOptions,windowsVerbatimArguments:!0}):(0,util_1().exec)("bash",["-c",cmd],execOptions);break;case"spawn":isWindows?(0,util_1().exec)("powershell.exe",["-NoProfile","-Command",`& ${step.command.map(powershellEscape).join(" ")}`],{...execOptions,cwd:step.cwd??cwd}):(0,util_1().exec)(step.command[0],step.command.slice(1),{...execOptions,cwd:step.cwd??cwd});break;case"callback":try{step.operation()}catch(err){throw new(core_1()).ValidationError((0,literal_string_1().lit)`LocalBundlingFileOperationFailed`,`Local bundling file operation failed: ${err instanceof Error?err.message:String(err)}`,scope)}break}}}})();exports.Bundling=Bundling;function stepsToPosixShellCommand(steps){const commands=[];for(const step of steps)switch(step.type){case"shell":commands.push(...step.commands);break;case"spawn":commands.push(preparePosixShellCommand(step.command));break;case"callback":throw new(core_1()).AssumptionError((0,literal_string_1().lit)`CallbackNotRenderable`,"callback steps cannot be rendered to a shell command")}return chain(commands)}class OsCommand{osPlatform;constructor(osPlatform){this.osPlatform=osPlatform}write(filePath,data){return this.osPlatform==="win32"?data?`echo ^${data}^ > "${filePath}"`:`echo. > "${filePath}"`:`echo ${posixShellEscape(data)} > ${posixShellEscape(filePath)}`}writeJson(filePath,data){const stringifiedData=JSON.stringify(data);return this.write(filePath,stringifiedData)}copy(src,dest){return this.osPlatform==="win32"?`copy "${src}" "${dest}"`:`cp ${posixShellEscape(src)} ${posixShellEscape(dest)}`}changeDirectory(dir){return`cd "${dir}"`}remove(filePath,force=!1){return this.osPlatform==="win32"?`del "${filePath}"`:`rm ${(force?["-f"]:[]).join(" ")} "${filePath}"`}removeDir(dir){return this.osPlatform==="win32"?`rmdir /s /q "${dir}"`:`rm -rf "${dir}"`}}function preparePosixShellCommand(argv){return argv.map(posixShellEscape).join(" ")}function posixShellEscape(arg){return"'"+arg.replace(/'/g,"'\\''")+"'"}function powershellEscape(arg){return"'"+arg.replace(/'/g,"''")+"'"}function chain(commands){return commands.filter(c=>!!c).join(" && ")}function osPathJoin(platform){return function(...paths){const joined=path().join(...paths);return os().platform()==="win32"&&platform!=="win32"?joined.replace(/\\/g,"/"):joined}}function toTarget(scope,runtime){const match=runtime.name.match(/nodejs(\d+)/);if(!match)throw new(core_1()).ValidationError((0,literal_string_1().lit)`CannotExtractVersionRuntime`,"Cannot extract version from runtime.",scope);return`node${match[1]}`}function toCliArgsArray(esbuildArgs){const args=[],reSpecifiedKeys=["--alias","--drop","--pure","--log-override","--out-extension"];for(const[key,value]of Object.entries(esbuildArgs))value===!0||value===""?args.push(key):reSpecifiedKeys.includes(key)?args.push(`${key}:${value}`):value&&args.push(`${key}=${value}`);return args}function isEsmRuntime(runtime){return![aws_lambda_1().Runtime.NODEJS,aws_lambda_1().Runtime.NODEJS_4_3,aws_lambda_1().Runtime.NODEJS_6_10,aws_lambda_1().Runtime.NODEJS_8_10,aws_lambda_1().Runtime.NODEJS_10_X,aws_lambda_1().Runtime.NODEJS_12_X].some(r=>r.family===runtime.family&&r.name===runtime.name)}