MCPcopy Create free account
hub / github.com/heygen-com/hyperframes / runRenderBatch

Function runRenderBatch

packages/cli/src/commands/lambda/render-batch.ts:156–334  ·  view source on GitHub ↗
(args: RenderBatchArgs)

Source from the content-addressed store, hash-verified

154 */
155// fallow-ignore-next-line complexity
156export async function runRenderBatch(args: RenderBatchArgs): Promise<void> {
157 const projectDir = resolvePath(args.projectDir);
158 const stack = requireStack(args.stackName);
159
160 const batchPath = resolvePath(args.batch);
161 if (!existsSync(batchPath)) {
162 errorBox("Batch file not found", `No such file: ${batchPath}`);
163 process.exit(1);
164 }
165 const entries = parseBatchFile(batchPath);
166 if (entries.length === 0) {
167 errorBox("Empty batch", `${batchPath} contains zero entries (every line was blank).`);
168 process.exit(1);
169 }
170
171 warnOnDimensionMismatch({
172 projectDir,
173 cliWidth: args.width,
174 cliHeight: args.height,
175 outputResolution: args.outputResolution,
176 quiet: args.json,
177 });
178
179 // Pre-validate every entry's variables against the composition's
180 // schema. Mismatches print as warnings; strict mode aborts before any
181 // AWS call. Schema is loaded once and reused across entries — a 10k-row
182 // batch with the per-entry parser would do 10k readFile + DOM parses.
183 //
184 // In strict mode we accumulate every failing entry first, then exit
185 // once with the full list. The naive "exit on first failure" pattern
186 // would force the caller to fix-one → re-run × N times on a batch with
187 // N broken rows.
188 const schema = loadProjectVariableSchema(join(projectDir, "index.html"));
189 const strict = args.strictVariables ?? false;
190 let hadStrictIssue = false;
191 for (const { entry, lineNumber } of entries) {
192 if (!entry.variables || Object.keys(entry.variables).length === 0) continue;
193 const issues = validateVariablesAgainstSchema(entry.variables, schema);
194 if (issues.length === 0) continue;
195 if (!args.json) {
196 console.log("");
197 console.log(c.dim(`Batch entry on line ${lineNumber}:`));
198 }
199 // Pass strict: false here so the helper just prints; we own the
200 // single exit-at-end below.
201 reportVariableIssues(issues, { strict: false, quiet: args.json });
202 if (strict) hadStrictIssue = true;
203 }
204 if (hadStrictIssue) {
205 errorBox(
206 "Variable validation failed",
207 "Aborting batch due to variable issues in one or more entries (--strict-variables mode).",
208 );
209 process.exit(1);
210 }
211
212 const config: SerializableDistributedRenderConfig = {
213 fps: args.fps,

Callers

nothing calls this directly

Calls 12

requireStackFunction · 0.85
errorBoxFunction · 0.85
warnOnDimensionMismatchFunction · 0.85
reportVariableIssuesFunction · 0.85
runWithConcurrencyLimitFunction · 0.85
errorMethod · 0.80
parseBatchFileFunction · 0.70
loadSDKFunction · 0.70
deploySiteFunction · 0.50

Tested by

no test coverage detected