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

Function printCurrentSelection

packages/cli/src/commands/preview.ts:362–450  ·  view source on GitHub ↗
(
  projectDir: string,
  startPort: number,
  json: boolean,
  preferredPort?: number,
)

Source from the content-addressed store, hash-verified

360}
361
362async function printCurrentSelection(
363 projectDir: string,
364 startPort: number,
365 json: boolean,
366 preferredPort?: number,
367): Promise<void> {
368 const {
369 AmbiguousPreviewServerError,
370 PreviewServerPortMismatchError,
371 fetchStudioSelection,
372 findPreviewServerForProject,
373 } = await import("../utils/studioSelectionClient.js");
374 let server: Awaited<ReturnType<typeof findPreviewServerForProject>>;
375 try {
376 server = await findPreviewServerForProject(
377 projectDir,
378 startPort,
379 undefined,
380 undefined,
381 preferredPort === undefined ? undefined : { preferredPort },
382 );
383 } catch (err) {
384 if (err instanceof AmbiguousPreviewServerError) {
385 printSelectionFailure("ambiguous-preview-server", err.message, json);
386 return;
387 }
388 if (err instanceof PreviewServerPortMismatchError) {
389 printSelectionFailure("preview-port-mismatch", err.message, json);
390 return;
391 }
392 throw err;
393 }
394 if (!server) {
395 printSelectionFailure(
396 "preview-not-running",
397 "No running Studio preview found for this project. Start one with: npx hyperframes preview",
398 json,
399 );
400 return;
401 }
402
403 let response: Awaited<ReturnType<typeof fetchStudioSelection>>;
404 try {
405 response = await fetchStudioSelection(server);
406 } catch (err) {
407 printSelectionFailure("selection-unavailable", errorMessage(err), json);
408 return;
409 }
410
411 if (!response.selection) {
412 printSelectionFailure(
413 "no-selection",
414 "Studio is running, but no element is selected. Select an element in Studio and rerun this command.",
415 json,
416 );
417 return;
418 }
419

Callers 1

runFunction · 0.85

Calls 6

printSelectionFailureFunction · 0.85
fetchStudioSelectionFunction · 0.85
errorMessageFunction · 0.85
absolutePreviewUrlFunction · 0.85
previewServerPayloadFunction · 0.85

Tested by

no test coverage detected