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

Function installItem

packages/cli/src/registry/installer.ts:69–94  ·  view source on GitHub ↗
(
  item: RegistryItem,
  options: InstallOptions,
)

Source from the content-addressed store, hash-verified

67 * parallel and writing it to its validated target path.
68 */
69export async function installItem(
70 item: RegistryItem,
71 options: InstallOptions,
72): Promise<InstallResult> {
73 const baseUrl = options.baseUrl ?? DEFAULT_REGISTRY_URL;
74 const destDir = resolve(options.destDir);
75
76 // Validate all targets up-front so a malformed item fails before any write.
77 for (const file of item.files) {
78 assertSafeTarget(destDir, file.target);
79 }
80
81 const written = await Promise.all(
82 item.files.map(async (file: FileTarget) => {
83 const destPath = resolve(destDir, file.target);
84 await fetchItemFile(item, file, destPath, baseUrl);
85 if (isInstalledRegistryBlockComposition(item, file)) {
86 const source = readFileSync(destPath, "utf-8");
87 writeFileSync(destPath, addRegistryItemMarker(source, item), "utf-8");
88 }
89 return destPath;
90 }),
91 );
92
93 return { written };
94}

Callers 3

installAllFunction · 0.85
fetchRemoteTemplateFunction · 0.85
installRegistryBlockFunction · 0.85

Calls 5

resolveFunction · 0.85
assertSafeTargetFunction · 0.85
fetchItemFileFunction · 0.85
addRegistryItemMarkerFunction · 0.85

Tested by

no test coverage detected