({
appRoot,
target,
root,
requiredFile,
missingMessage,
assetKey,
})
| 63 | } |
| 64 | |
| 65 | async 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 | |
| 107 | export async function collectWebAssets({ appRoot, target }) { |
| 108 | const buildCommand = |
no test coverage detected