(args: Partial<DeployArgs> = {})
| 34 | const DEFAULT_CONCURRENCY = 8; |
| 35 | |
| 36 | export async function runDeploy(args: Partial<DeployArgs> = {}): Promise<void> { |
| 37 | const resolved: DeployArgs = { |
| 38 | stackName: args.stackName ?? DEFAULT_STACK_NAME, |
| 39 | region: args.region ?? process.env.AWS_REGION ?? DEFAULT_REGION, |
| 40 | awsProfile: args.awsProfile ?? process.env.AWS_PROFILE, |
| 41 | reservedConcurrency: args.reservedConcurrency ?? DEFAULT_CONCURRENCY, |
| 42 | chromeSource: args.chromeSource ?? "sparticuz", |
| 43 | lambdaMemoryMb: args.lambdaMemoryMb ?? DEFAULT_MEMORY_MB, |
| 44 | skipBuild: args.skipBuild ?? false, |
| 45 | }; |
| 46 | |
| 47 | const root = repoRoot(); |
| 48 | // Locate the SAM template up-front so users get a fast, clear error |
| 49 | // (not an opaque `sam deploy` failure) when this isn't a checkout. |
| 50 | locateSamTemplate(root); |
| 51 | |
| 52 | if (!resolved.skipBuild) { |
| 53 | console.log(c.dim("→ Building handler ZIP")); |
| 54 | buildHandlerZip(root); |
| 55 | } else { |
| 56 | const zip = join(root, "packages", "aws-lambda", "dist", "handler.zip"); |
| 57 | if (!existsSync(zip)) { |
| 58 | throw new Error( |
| 59 | `--skip-build set but ${zip} does not exist. Run \`bun run --cwd packages/aws-lambda build:zip\` first or drop --skip-build.`, |
| 60 | ); |
| 61 | } |
| 62 | } |
| 63 | |
| 64 | console.log(c.dim(`→ sam deploy (stack=${resolved.stackName} region=${resolved.region})`)); |
| 65 | samDeploy({ |
| 66 | repoRoot: root, |
| 67 | stackName: resolved.stackName, |
| 68 | region: resolved.region, |
| 69 | awsProfile: resolved.awsProfile, |
| 70 | reservedConcurrency: resolved.reservedConcurrency, |
| 71 | lambdaMemoryMb: resolved.lambdaMemoryMb, |
| 72 | chromeSource: resolved.chromeSource, |
| 73 | }); |
| 74 | |
| 75 | console.log(c.dim("→ Reading stack outputs")); |
| 76 | const outputs = fetchStackOutputs({ |
| 77 | stackName: resolved.stackName, |
| 78 | region: resolved.region, |
| 79 | awsProfile: resolved.awsProfile, |
| 80 | }); |
| 81 | |
| 82 | const statePath = writeStackOutputs({ |
| 83 | stackName: resolved.stackName, |
| 84 | region: resolved.region, |
| 85 | bucketName: outputs.bucketName, |
| 86 | stateMachineArn: outputs.stateMachineArn, |
| 87 | functionName: outputs.functionName, |
| 88 | lambdaMemoryMb: resolved.lambdaMemoryMb, |
| 89 | deployedAt: new Date().toISOString(), |
| 90 | }); |
| 91 | |
| 92 | console.log(); |
| 93 | console.log(c.success("Stack deployed.")); |
nothing calls this directly
no test coverage detected