@@ -16,7 +16,6 @@ import { resolve, dirname, join } from 'node:path';
1616import { spawn } from 'node:child_process' ;
1717import { cpus } from 'node:os' ;
1818import { fileURLToPath } from 'node:url' ;
19- import { get as httpsGet } from 'node:https' ;
2019const __filename = fileURLToPath ( import . meta. url ) ;
2120const __dirname = dirname ( __filename ) ;
2221
@@ -437,51 +436,6 @@ function generateBranchIndex(branch, results, repoRoot) {
437436 writeFileSync ( join ( indexDir , 'index.html' ) , html ) ;
438437}
439438
440- function fetchUrl ( url ) {
441- return new Promise ( ( resolve , reject ) => {
442- httpsGet ( url , ( res ) => {
443- if ( res . statusCode >= 300 && res . statusCode < 400 && res . headers . location ) {
444- fetchUrl ( res . headers . location ) . then ( resolve , reject ) ;
445- return ;
446- }
447- if ( res . statusCode !== 200 ) {
448- res . resume ( ) ;
449- reject ( new Error ( `HTTP ${ res . statusCode } ` ) ) ;
450- return ;
451- }
452- let data = '' ;
453- res . on ( 'data' , ( chunk ) => { data += chunk ; } ) ;
454- res . on ( 'end' , ( ) => resolve ( data ) ) ;
455- res . on ( 'error' , reject ) ;
456- } ) . on ( 'error' , reject ) ;
457- } ) ;
458- }
459-
460- async function updateRootIndex ( branch , repoRoot ) {
461- const isPR = branch . startsWith ( 'pr-' ) ;
462- const indexFile = isPR ? 'pulls.html' : 'index.html' ;
463- const indexPath = join ( repoRoot , 'titles-generated' , indexFile ) ;
464- const url = `${ PAGES_BASE } /${ indexFile } ` ;
465-
466- // Fetch existing index from GitHub Pages
467- try {
468- const data = await fetchUrl ( url ) ;
469- writeFileSync ( indexPath , data ) ;
470- } catch {
471- // If fetch fails, create a minimal file
472- writeFileSync ( indexPath , '<html><body><ul>\n</ul></body></html>' ) ;
473- }
474-
475- const content = readFileSync ( indexPath , 'utf8' ) ;
476- const link = `./${ branch } /index.html` ;
477- if ( ! content . includes ( link ) ) {
478- console . log ( `Building root index for ${ branch } in titles-generated/${ indexFile } ...` ) ;
479- const entry = `<li><a href=${ link } >${ branch } </a></li>` ;
480- const updated = content . replace ( '</ul>' , `${ entry } \n</ul>` ) ;
481- writeFileSync ( indexPath , updated ) ;
482- }
483- }
484-
485439// ── Summary output ───────────────────────────────────────────────────────────
486440
487441function printFailedTitle ( r ) {
@@ -653,9 +607,6 @@ async function main() {
653607 // Generate branch index HTML (only for passed titles)
654608 generateBranchIndex ( args . branch , buildResults , repoRoot ) ;
655609
656- // Update root index
657- await updateRootIndex ( args . branch , repoRoot ) ;
658-
659610 // Run lychee link validation
660611 console . log ( '\nRunning link validation (lychee)...' ) ;
661612 const lycheeResult = await runLychee ( repoRoot , args . branch , args . verbose ) ;
@@ -664,20 +615,22 @@ async function main() {
664615 }
665616
666617 // Run CQA content quality assessment
667- // Skip when CQA_RUNNING env is set (CQA-14 recursion guard)
668- const cqaResult = ( process . env . CQA_RUNNING )
669- ? { status : 'skipped' , duration : 0 , output : '' , stats : { total : 0 , pass : 0 , fail : 0 } }
670- : await ( async ( ) => {
671- console . log ( '\nRunning CQA content quality assessment...' ) ;
672- return runCqa ( repoRoot , args . verbose ) ;
673- } ) ( ) ;
618+ let cqaResult ;
619+ if ( process . env . CQA_RUNNING ) {
620+ cqaResult = { status : 'skipped' , duration : 0 , output : '' , stats : { total : 0 , pass : 0 , fail : 0 } } ;
621+ } else {
622+ // Write preliminary report so CQA-14 can read lychee results without rebuilding
623+ const pendingCqa = { status : 'pending' , duration : 0 , output : '' , stats : { total : 0 , pass : 0 , fail : 0 } } ;
624+ writeReport ( args . branch , buildResults , lycheeResult , pendingCqa , args . jobs , 0 , repoRoot ) ;
625+
626+ console . log ( '\nRunning CQA content quality assessment...' ) ;
627+ process . env . CQA_RUNNING = '1' ;
628+ cqaResult = await runCqa ( repoRoot , args . verbose ) ;
629+ delete process . env . CQA_RUNNING ;
630+ }
674631
675632 const totalDuration = Math . round ( ( Date . now ( ) - totalStart ) / 1000 ) ;
676-
677- // Print summary
678633 printSummary ( buildResults , lycheeResult , cqaResult , patterns , totalDuration ) ;
679-
680- // Write JSON report
681634 writeReport ( args . branch , buildResults , lycheeResult , cqaResult , args . jobs , totalDuration , repoRoot ) ;
682635
683636 // Exit with error if any builds, lychee, or CQA failed
0 commit comments