(args: ProgressArgs)
| 16 | } |
| 17 | |
| 18 | export async function runProgress(args: ProgressArgs): Promise<void> { |
| 19 | const stack = requireStack(args.stackName); |
| 20 | |
| 21 | // Allow callers to pass either the full ARN or the renderId/exec name. |
| 22 | // The state machine ARN is on the stack, so deriving the execution ARN |
| 23 | // from a bare name is a deterministic suffix swap. |
| 24 | const executionArn = args.target.startsWith("arn:") |
| 25 | ? args.target |
| 26 | : executionArnFromName(stack.stateMachineArn, args.target); |
| 27 | |
| 28 | // Dynamic-import the SDK so tsup keeps it out of the static-import head |
| 29 | // of the CLI bundle. See sites.ts loadSDK() for the full rationale. |
| 30 | const { getRenderProgress } = await import("@hyperframes/aws-lambda/sdk"); |
| 31 | const progress = await getRenderProgress({ |
| 32 | executionArn, |
| 33 | region: stack.region, |
| 34 | defaultMemorySizeMb: stack.lambdaMemoryMb, |
| 35 | }); |
| 36 | |
| 37 | if (args.json) { |
| 38 | console.log(JSON.stringify(progress, null, 2)); |
| 39 | return; |
| 40 | } |
| 41 | |
| 42 | const pct = Math.round(progress.overallProgress * 100); |
| 43 | console.log(`${c.dim("Status:")} ${statusColor(progress.status)}`); |
| 44 | console.log(`${c.dim("Progress:")} ${pct}%`); |
| 45 | console.log( |
| 46 | `${c.dim("Frames:")} ${progress.framesRendered}${progress.totalFrames === null ? "" : ` / ${progress.totalFrames}`}`, |
| 47 | ); |
| 48 | console.log(`${c.dim("Lambdas:")} ${progress.lambdasInvoked}`); |
| 49 | console.log( |
| 50 | `${c.dim("Cost:")} ${progress.costs.displayCost} (Lambda $${progress.costs.breakdown.lambdaUsd.toFixed(4)} + SFN $${progress.costs.breakdown.stepFunctionsUsd.toFixed(4)})`, |
| 51 | ); |
| 52 | if (progress.outputFile) { |
| 53 | console.log(`${c.dim("Output:")} ${progress.outputFile.s3Uri}`); |
| 54 | } |
| 55 | if (progress.errors.length > 0) { |
| 56 | console.log(); |
| 57 | console.log(c.error("Errors:")); |
| 58 | for (const err of progress.errors) { |
| 59 | console.log(` ${c.dim(err.state)}: ${err.error} — ${err.cause}`); |
| 60 | } |
| 61 | } |
| 62 | if (progress.fatalErrorEncountered) { |
| 63 | process.exitCode = 1; |
| 64 | } |
| 65 | } |
| 66 | |
| 67 | function executionArnFromName(stateMachineArn: string, name: string): string { |
| 68 | // `arn:aws:states:<region>:<account>:stateMachine:<sm-name>` → |
nothing calls this directly
no test coverage detected