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

Function printCurrentContext

packages/cli/src/commands/preview.ts:462–620  ·  view source on GitHub ↗
(
  projectDir: string,
  startPort: number,
  options: { json: boolean; fields?: string; detail?: string; preferredPort?: number },
)

Source from the content-addressed store, hash-verified

460}
461
462async function printCurrentContext(
463 projectDir: string,
464 startPort: number,
465 options: { json: boolean; fields?: string; detail?: string; preferredPort?: number },
466): Promise<void> {
467 let fields: ContextField[];
468 try {
469 fields = parseContextFields(options.fields);
470 } catch (err) {
471 printSelectionFailure("invalid-context-fields", errorMessage(err), options.json);
472 return;
473 }
474 const fullDetail = options.detail === "full";
475 if (options.detail !== undefined && !["compact", "full"].includes(options.detail)) {
476 printSelectionFailure(
477 "invalid-context-detail",
478 "--context-detail must be compact or full",
479 options.json,
480 );
481 return;
482 }
483
484 const {
485 AmbiguousPreviewServerError,
486 PreviewServerPortMismatchError,
487 fetchStudioLint,
488 fetchStudioSelection,
489 findPreviewServerForProject,
490 } = await import("../utils/studioSelectionClient.js");
491 let server: Awaited<ReturnType<typeof findPreviewServerForProject>>;
492 try {
493 server = await findPreviewServerForProject(
494 projectDir,
495 startPort,
496 undefined,
497 undefined,
498 options.preferredPort === undefined ? undefined : { preferredPort: options.preferredPort },
499 );
500 } catch (err) {
501 if (err instanceof AmbiguousPreviewServerError) {
502 printSelectionFailure("ambiguous-preview-server", err.message, options.json);
503 return;
504 }
505 if (err instanceof PreviewServerPortMismatchError) {
506 printSelectionFailure("preview-port-mismatch", err.message, options.json);
507 return;
508 }
509 throw err;
510 }
511 if (!server) {
512 printSelectionFailure(
513 "preview-not-running",
514 "No running Studio preview found for this project. Start one with: npx hyperframes preview",
515 options.json,
516 );
517 return;
518 }
519

Callers 1

runFunction · 0.85

Calls 13

parseContextFieldsFunction · 0.85
printSelectionFailureFunction · 0.85
errorMessageFunction · 0.85
contextIncludesFunction · 0.85
fetchStudioSelectionFunction · 0.85
fetchStudioLintFunction · 0.85
absolutePreviewUrlFunction · 0.85
compactSelectionPayloadFunction · 0.85
countLintFindingsFunction · 0.85
previewServerPayloadFunction · 0.85
addContextErrorFunction · 0.85

Tested by

no test coverage detected