@@ -14,53 +14,63 @@ program
1414 . option ( '-m, --models <path>' , 'Model dizininin yolu' )
1515 . option ( '-o, --output <path>' , 'Çıktı dizininin yolu' )
1616 . option ( '-c, --content <path>' , 'İçerik dizininin yolu' )
17+ . option ( '-l, --lint' , 'Tip tanımlarını lint et ve formatla' )
1718 . option ( '-d, --debug' , 'Debug modunda çalıştır' )
1819 . parse ( process . argv ) ;
1920
20- const options = program . opts ( ) ;
21+ async function main ( ) {
22+ const options = program . opts ( ) ;
2123
22- try {
23- // Komut satırı argümanlarını mutlak yola çevir
24- const resolvedOptions = {
25- modelsDir : options . models ? path . resolve ( process . cwd ( ) , options . models ) : undefined ,
26- outputDir : options . output ? path . resolve ( process . cwd ( ) , options . output ) : undefined ,
27- contentDir : options . content ? path . resolve ( process . cwd ( ) , options . content ) : undefined ,
28- } ;
24+ try {
25+ // Komut satırı argümanlarını mutlak yola çevir
26+ const resolvedOptions = {
27+ modelsDir : options . models ? path . resolve ( process . cwd ( ) , options . models ) : undefined ,
28+ outputDir : options . output ? path . resolve ( process . cwd ( ) , options . output ) : undefined ,
29+ contentDir : options . content ? path . resolve ( process . cwd ( ) , options . content ) : undefined ,
30+ lint : options . lint ,
31+ } ;
2932
30- if ( options . debug ) {
31- console . log ( 'CLI Options:' , options ) ;
32- console . log ( 'Resolved Options:' , resolvedOptions ) ;
33- }
34-
35- // Eğer komut satırı argümanları verilmemişse, config dosyasını kullan
36- const generator = new ContentrainTypesGenerator ( resolvedOptions ) ;
33+ if ( options . debug ) {
34+ console . log ( 'CLI Options:' , options ) ;
35+ console . log ( 'Resolved Options:' , resolvedOptions ) ;
36+ }
3737
38- if ( options . debug ) {
39- console . log ( 'Generator Configuration:' , {
40- modelsDir : generator . getConfig ( ) . modelsDir ,
41- contentDir : generator . getConfig ( ) . contentDir ,
42- outputDir : generator . getConfig ( ) . outputDir ,
43- } ) ;
44- }
38+ // Eğer komut satırı argümanları verilmemişse, config dosyasını kullan
39+ const generator = new ContentrainTypesGenerator ( resolvedOptions ) ;
4540
46- generator . generate ( ) ;
47- }
48- catch ( error : unknown ) {
49- if ( options . debug ) {
50- if ( error instanceof Error ) {
51- console . error ( '❌ Hata detayları:' , {
52- message : error . message ,
53- cause : error . cause ,
54- stack : error . stack ,
41+ if ( options . debug ) {
42+ console . log ( 'Generator Configuration:' , {
43+ modelsDir : generator . getConfig ( ) . modelsDir ,
44+ contentDir : generator . getConfig ( ) . contentDir ,
45+ outputDir : generator . getConfig ( ) . outputDir ,
5546 } ) ;
5647 }
48+
49+ await generator . generate ( ) ;
50+ }
51+ catch ( error : unknown ) {
52+ if ( options . debug ) {
53+ if ( error instanceof Error ) {
54+ console . error ( '❌ Hata detayları:' , {
55+ message : error . message ,
56+ cause : error . cause ,
57+ stack : error . stack ,
58+ } ) ;
59+ }
60+ else {
61+ console . error ( '❌ Hata detayları:' , error ) ;
62+ }
63+ }
5764 else {
58- console . error ( '❌ Hata detayları:' , error ) ;
65+ console . error ( '❌ Tip tanımları oluşturulurken hata:' , error instanceof Error ? error . message : String ( error ) ) ;
66+ console . error ( 'Daha fazla detay için -d veya --debug seçeneğini kullanın' ) ;
5967 }
68+ process . exit ( 1 ) ;
6069 }
61- else {
62- console . error ( '❌ Tip tanımları oluşturulurken hata:' , error instanceof Error ? error . message : String ( error ) ) ;
63- console . error ( 'Daha fazla detay için -d veya --debug seçeneğini kullanın' ) ;
64- }
65- process . exit ( 1 ) ;
6670}
71+
72+ // Ana fonksiyonu çalıştır
73+ main ( ) . catch ( ( error ) => {
74+ console . error ( '❌ Beklenmeyen hata:' , error ) ;
75+ process . exit ( 1 ) ;
76+ } ) ;
0 commit comments