1- import fs from 'fs' ;
2- import path from ' path' ;
1+ import fs from "fs" ;
2+ import path from " path" ;
33
44interface DocsConfig {
55 navigation : {
@@ -24,32 +24,40 @@ interface DocsConfig {
2424
2525function extractAllPages ( config : DocsConfig ) : Set < string > {
2626 const pages = new Set < string > ( ) ;
27-
28- function processPages ( pageList : Array < string | { group : string ; pages : string [ ] | Array < string | { group : string ; pages : string [ ] } > } > ) : void {
27+
28+ function processPages (
29+ pageList : Array <
30+ | string
31+ | {
32+ group : string ;
33+ pages : string [ ] | Array < string | { group : string ; pages : string [ ] } > ;
34+ }
35+ > ,
36+ ) : void {
2937 for ( const item of pageList ) {
30- if ( typeof item === ' string' ) {
38+ if ( typeof item === " string" ) {
3139 pages . add ( item ) ;
3240 } else if ( item . group && item . pages ) {
3341 processPages ( item . pages as any ) ;
3442 }
3543 }
3644 }
37-
45+
3846 for ( const tab of config . navigation . tabs ) {
3947 if ( tab . pages ) {
4048 processPages ( tab . pages as any ) ;
4149 }
42-
50+
4351 if ( tab . groups ) {
4452 for ( const group of tab . groups ) {
4553 processPages ( group . pages as any ) ;
4654 }
4755 }
48-
56+
4957 if ( tab . versions ) {
5058 for ( const version of tab . versions ) {
5159 if ( version . openapi ) {
52- pages . add ( version . openapi . replace ( / ^ \/ / , '' ) ) ;
60+ pages . add ( version . openapi . replace ( / ^ \/ / , "" ) ) ;
5361 }
5462 if ( version . groups ) {
5563 for ( const group of version . groups ) {
@@ -59,17 +67,17 @@ function extractAllPages(config: DocsConfig): Set<string> {
5967 }
6068 }
6169 }
62-
70+
6371 return pages ;
6472}
6573
6674function validatePageExists ( pagePath : string ) : boolean {
6775 // Check if the path already has a file extension (.json, .mdx, etc.)
6876 const ext = path . extname ( pagePath ) ;
69- if ( ext === ' .json' || ext === ' .mdx' ) {
77+ if ( ext === " .json" || ext === " .mdx" ) {
7078 return fs . existsSync ( pagePath ) ;
7179 }
72-
80+
7381 // Otherwise check for .mdx or .json extensions
7482 const mdxPath = `${ pagePath } .mdx` ;
7583
@@ -78,40 +86,41 @@ function validatePageExists(pagePath: string): boolean {
7886
7987async function main ( ) : Promise < void > {
8088 try {
81- const docsConfig : DocsConfig = JSON . parse ( fs . readFileSync ( 'docs.json' , 'utf8' ) ) ;
89+ const docsConfig : DocsConfig = JSON . parse (
90+ fs . readFileSync ( "docs.json" , "utf8" ) ,
91+ ) ;
8292 const allPages = extractAllPages ( docsConfig ) ;
83-
93+
8494 console . log ( `Found ${ allPages . size } page references in docs.json` ) ;
85-
95+
8696 const missingPages : string [ ] = [ ] ;
8797 const existingPages : string [ ] = [ ] ;
88-
98+
8999 for ( const page of allPages ) {
90100 if ( validatePageExists ( page ) ) {
91101 existingPages . push ( page ) ;
92102 } else {
93103 missingPages . push ( page ) ;
94104 }
95105 }
96-
106+
97107 console . log ( `✅ ${ existingPages . length } pages found` ) ;
98-
108+
99109 if ( missingPages . length > 0 ) {
100110 console . error ( `❌ ${ missingPages . length } missing pages:` ) ;
101111 for ( const page of missingPages . sort ( ) ) {
102112 console . error ( ` - ${ page } ` ) ;
103113 }
104114 process . exit ( 1 ) ;
105115 } else {
106- console . log ( ' 🎉 All pages referenced in docs.json exist!' ) ;
116+ console . log ( " 🎉 All pages referenced in docs.json exist!" ) ;
107117 }
108-
109118 } catch ( error ) {
110- console . error ( ' Error validating docs:' , error ) ;
119+ console . error ( " Error validating docs:" , error ) ;
111120 process . exit ( 1 ) ;
112121 }
113122}
114123
115124if ( require . main === module ) {
116125 main ( ) ;
117- }
126+ }
0 commit comments