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

Function run

packages/cli/src/commands/lambda.ts:194–417  ·  view source on GitHub ↗
({ args })

Source from the content-addressed store, hash-verified

192 json: { type: "boolean", description: "Emit machine-readable JSON" },
193 },
194 async run({ args }) {
195 const subcommand = args.subcommand;
196 if (!subcommand) {
197 console.log(HELP);
198 return;
199 }
200
201 const stackName =
202 (args["stack-name"] as string | undefined) ??
203 // Lazy-imported so the dispatcher doesn't pull state.ts (and its
204 // node:fs deps) on every CLI invocation — only on lambda runs.
205 (await import("./lambda/state.js")).DEFAULT_STACK_NAME;
206
207 // Apply --profile globally before any AWS-SDK / `aws` / `sam` call runs.
208 // The AWS SDK + the SAM CLI both read AWS_PROFILE from the environment,
209 // so setting it here threads the value through render / progress / sites
210 // (which don't take an explicit awsProfile arg) without each subverb
211 // having to know about it. Region gets the same treatment so the SDK
212 // clients constructed inside the SDK pick it up too.
213 const profileFlag = args.profile as string | undefined;
214 if (profileFlag) process.env.AWS_PROFILE = profileFlag;
215 const regionFlag = args.region as string | undefined;
216 if (regionFlag) process.env.AWS_REGION = regionFlag;
217
218 // The lambda subverbs dynamic-import `@hyperframes/aws-lambda` at call
219 // time. We keep aws-lambda as a workspace devDependency (not a runtime
220 // dep) so the published CLI install stays small for users who don't
221 // deploy to Lambda. Subverbs other than `policies` need aws-lambda;
222 // catch the missing-module error here and turn it into a friendly hint.
223 const verbsNeedingSDK = new Set([
224 "deploy",
225 "sites",
226 "render",
227 "render-batch",
228 "progress",
229 "destroy",
230 ]);
231 if (verbsNeedingSDK.has(subcommand)) {
232 try {
233 await import("@hyperframes/aws-lambda/sdk");
234 } catch (err) {
235 if ((err as NodeJS.ErrnoException).code === "ERR_MODULE_NOT_FOUND") {
236 console.error(
237 `${c.error("@hyperframes/aws-lambda is not installed.")} The ${c.accent(`hyperframes lambda ${subcommand}`)} command needs it at runtime.\n` +
238 `Install it alongside the CLI:\n` +
239 ` ${c.accent("npm install -g @hyperframes/aws-lambda")}\n` +
240 `Or, for an opt-in dev setup:\n` +
241 ` ${c.accent("npm install @hyperframes/aws-lambda")}`,
242 );
243 process.exit(1);
244 }
245 throw err;
246 }
247 }
248
249 switch (subcommand) {
250 case "deploy": {
251 const { runDeploy } = await import("./lambda/deploy.js");

Callers

nothing calls this directly

Calls 15

parseChromeSourceFunction · 0.85
runSitesCreateFunction · 0.85
runPoliciesFunction · 0.85
errorMethod · 0.80
runDeployFunction · 0.70
parsePositiveIntFunction · 0.70
parseIntFlagFunction · 0.70
runRenderFunction · 0.70
parseOutputResolutionFunction · 0.70
parseFormatFunction · 0.70
parseCodecFunction · 0.70
parseQualityFunction · 0.70

Tested by

no test coverage detected