1
- import type { Result } from 'neverthrow'
2
1
import type { DtsGenerationConfig , DtsGenerationOption } from './types'
3
2
import { rm , mkdir } from 'node:fs/promises'
4
3
import { join , relative , dirname } from 'node:path'
5
- import { err , ok } from 'neverthrow'
6
4
import { config } from './config'
7
5
import { writeToFile , getAllTypeScriptFiles , checkIsolatedDeclarations , formatDeclarations } from './utils'
8
6
import { extractTypeFromSource , extractConfigTypeFromSource , extractIndexTypeFromSource } from './extract'
@@ -17,15 +15,15 @@ export async function generateDeclarationsFromFiles(options: DtsGenerationConfig
17
15
}
18
16
19
17
if ( options . clean ) {
20
- console . log ( 'Cleaning output directory...' )
18
+ // console.log('Cleaning output directory...')
21
19
await rm ( options . outdir , { recursive : true , force : true } )
22
20
}
23
21
24
22
const files = await getAllTypeScriptFiles ( options . root )
25
- console . log ( 'Found the following TypeScript files:' , files )
23
+ // console.log('Found the following TypeScript files:', files)
26
24
27
25
for ( const file of files ) {
28
- console . log ( `Processing file: ${ file } ` )
26
+ // console.log(`Processing file: ${file}`)
29
27
const fileDeclarations = await extractTypeFromSource ( file )
30
28
31
29
if ( fileDeclarations ) {
@@ -38,13 +36,13 @@ export async function generateDeclarationsFromFiles(options: DtsGenerationConfig
38
36
// Write the declarations without additional formatting
39
37
await writeToFile ( outputPath , fileDeclarations )
40
38
41
- console . log ( `Generated ${ outputPath } ` )
39
+ // console.log(`Generated ${outputPath}`)
42
40
} else {
43
41
console . warn ( `No declarations extracted for ${ file } ` )
44
42
}
45
43
}
46
44
47
- console . log ( 'Declaration file generation complete' )
45
+ // console.log('Declaration file generation complete')
48
46
} catch ( error ) {
49
47
console . error ( 'Error generating declarations:' , error )
50
48
}
@@ -53,11 +51,3 @@ export async function generateDeclarationsFromFiles(options: DtsGenerationConfig
53
51
export async function generate ( options ?: DtsGenerationOption ) : Promise < void > {
54
52
await generateDeclarationsFromFiles ( { ...config , ...options } )
55
53
}
56
-
57
- function validateOptions ( options : unknown ) : Result < DtsGenerationOption , Error > {
58
- if ( typeof options === 'object' && options !== null ) {
59
- return ok ( options as DtsGenerationOption )
60
- }
61
-
62
- return err ( new Error ( 'Invalid options' ) )
63
- }
0 commit comments