11#!/usr/bin/env bun
22
3- import fs from "fs/promises" ;
4- import path from "path" ;
5- import { fileURLToPath } from "url" ;
3+ import fs from "node: fs/promises" ;
4+ import path from "node: path" ;
5+ import { fileURLToPath } from "node: url" ;
66import yaml from "yaml" ;
77
88const __dirname = path . dirname ( fileURLToPath ( import . meta. url ) ) ;
@@ -20,7 +20,7 @@ interface PackageInfo {
2020async function ensureDir ( dir : string ) : Promise < void > {
2121 try {
2222 await fs . mkdir ( dir , { recursive : true } ) ;
23- } catch ( e ) {
23+ } catch ( _e ) {
2424 // Directory exists
2525 }
2626}
@@ -40,15 +40,15 @@ async function getClientPackages(): Promise<PackageInfo[]> {
4040 description : pkg . description || "" ,
4141 version : pkg . version ,
4242 } ) ;
43- } catch ( e ) {
43+ } catch ( _e ) {
4444 // Not a package directory
4545 }
4646 }
4747
4848 return packages ;
4949}
5050
51- function createFrontmatter ( data : Record < string , any > ) : string {
51+ function createFrontmatter ( data : Record < string , unknown > ) : string {
5252 return `---\n${ yaml . stringify ( data ) . trim ( ) } \n---` ;
5353}
5454
@@ -74,7 +74,7 @@ ${pkg.description}
7474
7575- Version: ${ pkg . version }
7676- [View Documentation](./${ pkg . dir } )
77- `
77+ ` ,
7878 )
7979 . join ( "\n" ) }
8080
@@ -145,30 +145,30 @@ import { /* exports */ } from "${pkg.name}";
145145 "programs" ,
146146 ] ;
147147
148- for ( const module of modules ) {
149- const moduleDir = path . join ( srcDir , module ) ;
150- const moduleOutDir = path . join ( outDir , module ) ;
148+ for ( const m of modules ) {
149+ const moduleDir = path . join ( srcDir , m ) ;
150+ const moduleOutDir = path . join ( outDir , m ) ;
151151
152152 try {
153153 const files = await fs . readdir ( moduleDir ) ;
154154 const tsFiles = files . filter (
155- ( f ) => f . endsWith ( ".ts" ) && f !== "index.ts"
155+ ( f ) => f . endsWith ( ".ts" ) && f !== "index.ts" ,
156156 ) ;
157157
158158 if ( tsFiles . length > 0 ) {
159159 await ensureDir ( moduleOutDir ) ;
160160
161161 // Generate module index
162162 const moduleFrontmatter = createFrontmatter ( {
163- title : module . charAt ( 0 ) . toUpperCase ( ) + module . slice ( 1 ) ,
164- description : `${ module } for ${ pkg . name } ` ,
163+ title : m . charAt ( 0 ) . toUpperCase ( ) + m . slice ( 1 ) ,
164+ description : `${ m } for ${ pkg . name } ` ,
165165 } ) ;
166166
167167 const moduleContent = `${ moduleFrontmatter }
168168
169- # ${ module . charAt ( 0 ) . toUpperCase ( ) + module . slice ( 1 ) }
169+ # ${ m . charAt ( 0 ) . toUpperCase ( ) + m . slice ( 1 ) }
170170
171- ## Available ${ module . charAt ( 0 ) . toUpperCase ( ) + module . slice ( 1 ) }
171+ ## Available ${ m . charAt ( 0 ) . toUpperCase ( ) + m . slice ( 1 ) }
172172
173173${ tsFiles
174174 . map ( ( file ) => {
@@ -205,21 +205,21 @@ For detailed type information, please refer to the source code or use your IDE's
205205
206206 await fs . writeFile (
207207 path . join ( moduleOutDir , `${ name } .mdx` ) ,
208- fileContent
208+ fileContent ,
209209 ) ;
210210 }
211211 }
212- } catch ( e ) {
212+ } catch ( _e ) {
213213 // Module doesn't exist
214214 }
215215 }
216216
217217 // Generate meta.json
218218 const availableModules : string [ ] = [ ] ;
219- for ( const module of modules ) {
219+ for ( const mod of modules ) {
220220 try {
221- await fs . access ( path . join ( outDir , module ) ) ;
222- availableModules . push ( module ) ;
221+ await fs . access ( path . join ( outDir , mod ) ) ;
222+ availableModules . push ( mod ) ;
223223 } catch {
224224 // Module doesn't exist
225225 }
@@ -232,7 +232,7 @@ For detailed type information, please refer to the source code or use your IDE's
232232
233233 await fs . writeFile (
234234 path . join ( outDir , "meta.json" ) ,
235- JSON . stringify ( metaContent , null , 2 )
235+ JSON . stringify ( metaContent , null , 2 ) ,
236236 ) ;
237237}
238238
@@ -254,4 +254,4 @@ async function main(): Promise<void> {
254254 console . log ( "API documentation generated successfully!" ) ;
255255}
256256
257- main ( ) . catch ( console . error ) ;
257+ main ( ) . catch ( console . error ) ;
0 commit comments