(root = repositoryRoot)
| 54 | } |
| 55 | |
| 56 | export async function checkPackageDocs(root = repositoryRoot) { |
| 57 | const documentPaths = [ |
| 58 | 'README.md', |
| 59 | 'packages/rxjs/README.md', |
| 60 | 'packages/rxjs/MIGRATION.md', |
| 61 | 'packages/rxjs/CONTRIBUTING.md', |
| 62 | ...(await markdownFiles(root, 'packages/rxjs/docs')), |
| 63 | 'packages/observable-polyfill/README.md', |
| 64 | 'packages/observable-polyfill/test/wpt/README.md', |
| 65 | 'packages/test/README.md', |
| 66 | 'packages/migrate/README.md', |
| 67 | ...(await markdownFiles(root, 'packages/migrate/docs')), |
| 68 | ...(await markdownFiles(root, 'packages/migrate/skill')), |
| 69 | ]; |
| 70 | const documents = await Promise.all( |
| 71 | documentPaths.map(async (documentPath) => [documentPath, await readFile(path.join(root, documentPath), 'utf8')]) |
| 72 | ); |
| 73 | const manifestEntries = await Promise.all( |
| 74 | Object.keys(packageRequirements).map(async (manifestPath) => [ |
| 75 | manifestPath, |
| 76 | JSON.parse(await readFile(path.join(root, manifestPath), 'utf8')), |
| 77 | ]) |
| 78 | ); |
| 79 | const existingPaths = new Set(await allPaths(root)); |
| 80 | const errors = auditPackageDocs({ documents, existingPaths, manifests: Object.fromEntries(manifestEntries) }); |
| 81 | if (errors.length > 0) throw new Error(`Package documentation check failed:\n- ${errors.join('\n- ')}`); |
| 82 | } |
| 83 | |
| 84 | async function markdownFiles(root, relativeDirectory) { |
| 85 | const entries = await readdir(path.join(root, relativeDirectory), { withFileTypes: true }); |
no test coverage detected