@@ -286,8 +286,6 @@ async function main() {
286286 ! excludedPaths . some ( excluded => file . includes ( excluded ) )
287287 ) ;
288288
289- console . log ( `📄 Found ${ filteredFiles . length } documentation files\n` ) ;
290-
291289 const brokenLinks = [ ] ;
292290 const externalLinks = [ ] ;
293291 let totalLinks = 0 ;
@@ -325,56 +323,54 @@ async function main() {
325323 }
326324
327325 // Check for orphaned pages
328- console . log ( '🔍 Checking for orphaned pages (not in docs.json)...\n' ) ;
329326 const docsJson = loadDocsJson ( ) ;
330327 const orphanedPages = findOrphanedPages ( filteredFiles , docsJson ) ;
331328
332329 // Check redirects
333- console . log ( '🔍 Checking redirects in docs.json...\n' ) ;
334330 const redirects = extractRedirects ( docsJson ) ;
335331 const redirectIssues = validateRedirects ( redirects ) ;
336332
337- // Display results
338- if ( brokenLinks . length === 0 ) {
339- console . log ( '✅ No broken internal links found!\n' ) ;
333+ // Calculate total issues for summary header
334+ const totalIssues = brokenLinks . length + orphanedPages . length + redirectIssues . length ;
335+
336+ // Print summary header first
337+ if ( totalIssues === 0 ) {
338+ console . log ( '✅ No issues found!\n' ) ;
340339 } else {
341- console . log ( `❌ Found ${ brokenLinks . length } broken internal links :\n` ) ;
342-
343- brokenLinks . forEach ( ( { file , url , line , type , triedPaths } ) => {
344- console . log ( `📄 ${ file } : ${ line } ` ) ;
345- console . log ( ` 🔗 Broken link: ${ url } ` ) ;
346- console . log ( ` 📍 Type: ${ type } ` ) ;
347- if ( triedPaths ) {
348- console . log ( ` 🔍 Tried paths:` ) ;
349- triedPaths . slice ( 0 , 2 ) . forEach ( p => {
350- console . log ( ` - ${ path . relative ( process . cwd ( ) , p ) } ` ) ;
351- } ) ;
352- }
353- console . log ( '' ) ;
340+ console . log ( `❌ Found ${ totalIssues } issue(s) :\n` ) ;
341+ console . log ( ` • ${ brokenLinks . length } broken link(s)` ) ;
342+ console . log ( ` • ${ orphanedPages . length } orphaned page(s)` ) ;
343+ console . log ( ` • ${ redirectIssues . length } invalid redirect(s)\n ` ) ;
344+ }
345+
346+ // Display broken links details
347+ if ( brokenLinks . length > 0 ) {
348+ console . log ( '─' . repeat ( 40 ) ) ;
349+ console . log ( 'BROKEN LINKS:\n' ) ;
350+ brokenLinks . forEach ( ( { file , url , line } ) => {
351+ console . log ( ` 📄 ${ file } : ${ line } ` ) ;
352+ console . log ( ` ${ url } \n` ) ;
354353 } ) ;
355354 }
356355
357- // Display orphaned pages
358- if ( orphanedPages . length === 0 ) {
359- console . log ( '✅ No orphaned pages found!\n' ) ;
360- } else {
361- console . log ( `⚠️ Found ${ orphanedPages . length } orphaned pages (exist but not in docs.json):\n` ) ;
356+ // Display orphaned pages details
357+ if ( orphanedPages . length > 0 ) {
358+ console . log ( '─' . repeat ( 40 ) ) ;
359+ console . log ( 'ORPHANED PAGES (not in docs.json):\n' ) ;
362360 orphanedPages . forEach ( page => {
363361 console . log ( ` 📄 ${ page } .mdx` ) ;
364362 } ) ;
365- console . log ( '\n💡 These pages exist but are not linked in docs.json navigation.\n ' ) ;
363+ console . log ( '' ) ;
366364 }
367365
368- // Display redirect issues
369- if ( redirectIssues . length === 0 ) {
370- console . log ( '✅ All redirects are valid!\n' ) ;
371- } else {
372- console . log ( `❌ Found ${ redirectIssues . length } invalid redirects in docs.json:\n` ) ;
366+ // Display redirect issues details
367+ if ( redirectIssues . length > 0 ) {
368+ console . log ( '─' . repeat ( 40 ) ) ;
369+ console . log ( 'INVALID REDIRECTS:\n' ) ;
373370 redirectIssues . forEach ( ( { source, destination, issue } ) => {
374371 console . log ( ` 🔀 ${ source } → ${ destination } ` ) ;
375- console . log ( ` ❌ ${ issue } \n` ) ;
372+ console . log ( ` ${ issue } \n` ) ;
376373 } ) ;
377- console . log ( '💡 When moving pages, ensure redirect destinations exist.\n' ) ;
378374 }
379375
380376 // Check external links if requested
@@ -402,20 +398,8 @@ async function main() {
402398 }
403399 }
404400
405- // Summary
406- console . log ( '─' . repeat ( 60 ) ) ;
407- console . log ( `Total links checked: ${ totalLinks } ` ) ;
408- console . log ( `Broken internal links: ${ brokenLinks . length } ` ) ;
409- console . log ( `Orphaned pages: ${ orphanedPages . length } ` ) ;
410- console . log ( `Invalid redirects: ${ redirectIssues . length } ` ) ;
411- if ( CHECK_EXTERNAL ) {
412- console . log ( `External links checked: ${ externalLinks . length } ` ) ;
413- }
414- console . log ( '─' . repeat ( 60 ) ) ;
415-
416401 // Exit with error if issues found
417- const hasIssues = brokenLinks . length > 0 || orphanedPages . length > 0 || redirectIssues . length > 0 ;
418- process . exit ( hasIssues ? 1 : 0 ) ;
402+ process . exit ( totalIssues > 0 ? 1 : 0 ) ;
419403}
420404
421405main ( ) ;
0 commit comments