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

Function resolveProjectInput

packages/cli/src/commands/cloud/render.ts:345–366  ·  view source on GitHub ↗
(opts: {
  dir: string | undefined;
  assetId: string | undefined;
  url: string | undefined;
})

Source from the content-addressed store, hash-verified

343
344// fallow-ignore-next-line complexity
345function resolveProjectInput(opts: {
346 dir: string | undefined;
347 assetId: string | undefined;
348 url: string | undefined;
349}): ProjectInputSource {
350 // Count every source the user explicitly supplied. The positional
351 // `dir` defaults to `undefined` when omitted (not to "."), so we
352 // can detect "user actually typed something" vs. "default to cwd".
353 const explicit = {
354 dir: opts.dir !== undefined && opts.dir !== "",
355 assetId: opts.assetId !== undefined && opts.assetId !== "",
356 url: opts.url !== undefined && opts.url !== "",
357 };
358 const count = Number(explicit.dir) + Number(explicit.assetId) + Number(explicit.url);
359 if (count > 1) {
360 errorBox("Conflicting inputs", "Pass only one of: project dir, --asset-id, --url.");
361 process.exit(1);
362 }
363 if (explicit.assetId) return { kind: "asset_id", assetId: opts.assetId };
364 if (explicit.url) return { kind: "url", url: opts.url };
365 return { kind: "dir", dir: opts.dir ?? "." };
366}
367
368/**
369 * Resolve the aspect ratio for the submit body, validating local inputs.

Callers 1

runFunction · 0.85

Calls 1

errorBoxFunction · 0.85

Tested by

no test coverage detected