(
block: BlockStructure,
{ superBlock, order }: { superBlock: SuperBlocks; order: number }
)
| 363 | } |
| 364 | |
| 365 | async processBlock( |
| 366 | block: BlockStructure, |
| 367 | { superBlock, order }: { superBlock: SuperBlocks; order: number } |
| 368 | ) { |
| 369 | const blockName = block.dashedName; |
| 370 | log(`Processing block ${blockName} in superblock ${superBlock}`); |
| 371 | |
| 372 | // Check if block directory exists |
| 373 | const blockContentDir = resolve(this.blockContentDir, blockName); |
| 374 | if (!existsSync(blockContentDir)) { |
| 375 | throw Error(`Block directory not found: ${blockContentDir}`); |
| 376 | } |
| 377 | |
| 378 | if (block.isUpcomingChange && !SHOW_UPCOMING_CHANGES) { |
| 379 | log(`Ignoring upcoming block ${blockName}`); |
| 380 | return null; |
| 381 | } |
| 382 | |
| 383 | const superOrder = getSuperOrder(superBlock); |
| 384 | if (superOrder === undefined) |
| 385 | throw Error(`Superblock not found: ${superBlock}`); |
| 386 | const meta = { |
| 387 | ...block, |
| 388 | superOrder, |
| 389 | superBlock, |
| 390 | order, |
| 391 | ...(block.chapter && { chapter: block.chapter }), |
| 392 | ...(block.module && { module: block.module }) |
| 393 | }; |
| 394 | const isAudited = isAuditedSuperBlock(this.lang, superBlock as SuperBlocks); |
| 395 | |
| 396 | // Read challenges from directory |
| 397 | const foundChallenges = await this.readBlockChallenges( |
| 398 | blockName, |
| 399 | meta, |
| 400 | isAudited |
| 401 | ); |
| 402 | log(`Found ${foundChallenges.length} challenge files in directory`); |
| 403 | |
| 404 | // Log found challenges |
| 405 | foundChallenges.forEach(challenge => { |
| 406 | log(`Found challenge: ${challenge.title} (${challenge.id})`); |
| 407 | }); |
| 408 | |
| 409 | const throwOnError = this.lang === 'english'; |
| 410 | // Validate challenges against meta |
| 411 | if (!this.skipValidation) |
| 412 | validateChallenges(foundChallenges, meta, throwOnError); |
| 413 | |
| 414 | // Build the block object |
| 415 | const blockResult = buildBlock(foundChallenges, meta); |
| 416 | |
| 417 | log( |
| 418 | `Completed block "${meta.dashedName}" with ${blockResult.challenges.length} challenges (${blockResult.challenges.filter(c => !c.missing).length} built successfully)` |
| 419 | ); |
| 420 | |
| 421 | return blockResult; |
| 422 | } |
no test coverage detected