MCPcopy Create free account
hub / github.com/MoonshotAI/kimi-code / collectAssetRoot

Function collectAssetRoot

apps/kimi-code/scripts/native/web-assets.mjs:65–105  ·  view source on GitHub ↗
({
  appRoot,
  target,
  root,
  requiredFile,
  missingMessage,
  assetKey,
})

Source from the content-addressed store, hash-verified

63}
64
65async function collectAssetRoot({
66 appRoot,
67 target,
68 root,
69 requiredFile,
70 missingMessage,
71 assetKey,
72}) {
73 const assetRoot = resolve(appRoot, ...root.split('/'));
74 await assertBuiltAssetRoot({ assetRoot, requiredFile, message: missingMessage });
75
76 const files = (await listFiles(assetRoot)).sort((a, b) => a.localeCompare(b));
77 const manifestFiles = [];
78 const assets = {};
79
80 for (const file of files) {
81 if (!existsSync(file)) continue;
82 const bytes = await readFile(file);
83 const relativePath = toPosixPath(relative(assetRoot, file));
84 const key = assetKey(target, relativePath);
85 manifestFiles.push({
86 assetKey: key,
87 relativePath,
88 sha256: sha256(bytes),
89 });
90 assets[key] = file;
91 }
92
93 const manifest = {
94 version: WEB_ASSET_MANIFEST_VERSION,
95 target,
96 root,
97 files: manifestFiles,
98 };
99
100 return {
101 manifest,
102 manifestJson: `${JSON.stringify(manifest, null, 2)}\n`,
103 assets,
104 };
105}
106
107export async function collectWebAssets({ appRoot, target }) {
108 const buildCommand =

Callers 1

collectWebAssetsFunction · 0.85

Calls 7

assertBuiltAssetRootFunction · 0.85
listFilesFunction · 0.70
toPosixPathFunction · 0.70
sha256Function · 0.70
resolveFunction · 0.50
readFileFunction · 0.50
pushMethod · 0.45

Tested by

no test coverage detected