(superblocks: SuperBlocks[], blockStructureDir: string)
| 362 | } |
| 363 | |
| 364 | function validateBlocks(superblocks: SuperBlocks[], blockStructureDir: string) { |
| 365 | const withSuperblockStructure = addSuperblockStructure(superblocks, true); |
| 366 | const blockInSuperblocks = withSuperblockStructure |
| 367 | .flatMap(({ blocks }) => blocks) |
| 368 | .map(b => b.dashedName); |
| 369 | for (const block of blockInSuperblocks) { |
| 370 | const blockPath = getBlockStructurePath(block); |
| 371 | if (!existsSync(blockPath)) { |
| 372 | throw Error( |
| 373 | `Block "${block}" is in a superblock, but has no block structure file at ${blockPath}` |
| 374 | ); |
| 375 | } |
| 376 | } |
| 377 | |
| 378 | const blockStructureFiles = readdirSync(blockStructureDir).map(file => |
| 379 | basename(file, '.json') |
| 380 | ); |
| 381 | |
| 382 | for (const block of blockStructureFiles) { |
| 383 | if (!blockInSuperblocks.includes(block)) { |
| 384 | throw Error( |
| 385 | `Block "${block}" has a structure file, ${getBlockStructurePath(block)}, but is not in a superblock` |
| 386 | ); |
| 387 | } |
| 388 | } |
| 389 | } |
| 390 | |
| 391 | export async function parseCurriculumStructure(filter?: Filter) { |
| 392 | const curriculum = getCurriculumStructure(); |
no test coverage detected