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

Function localizeExternalAssets

packages/cli/src/utils/publishProject.ts:319–340  ·  view source on GitHub ↗
(
  absProjectDir: string,
  fileContents: Map<string, Buffer>,
)

Source from the content-addressed store, hash-verified

317 * rewrite the references so the published project is self-contained.
318 */
319export function localizeExternalAssets(
320 absProjectDir: string,
321 fileContents: Map<string, Buffer>,
322): number {
323 const ctx: ExternalAssetContext = {
324 absProjectDir,
325 fileContents,
326 externalMap: new Map(),
327 usedArchivePaths: new Set(),
328 };
329
330 for (const [entryPath, content] of [...fileContents.entries()]) {
331 if (entryPath.startsWith(EXT_ASSETS_PREFIX + "/")) continue;
332 if (entryPath.endsWith(".html") || entryPath.endsWith(".htm")) {
333 localizeHtmlEntry(ctx, entryPath, content);
334 } else if (entryPath.endsWith(".css")) {
335 localizeCssEntry(ctx, entryPath, content);
336 }
337 }
338
339 return ctx.externalMap.size;
340}
341
342export function createPublishArchive(projectDir: string): PublishArchiveResult {
343 const absProjectDir = resolve(projectDir);

Callers 2

createPublishArchiveFunction · 0.85

Calls 3

localizeHtmlEntryFunction · 0.85
localizeCssEntryFunction · 0.85
entriesMethod · 0.80

Tested by

no test coverage detected