@@ -45,7 +45,7 @@ export class NestiaSdkApplication {
45
45
await validate ( "sdk" ) ( this . config . output ) ;
46
46
await validate ( "e2e" ) ( this . config . e2e ) ;
47
47
48
- title ( "Nestia E2E Generator" ) ;
48
+ print_title ( "Nestia E2E Generator" ) ;
49
49
await this . generate (
50
50
"e2e" ,
51
51
( config ) => config ,
@@ -69,7 +69,7 @@ export class NestiaSdkApplication {
69
69
"Error on NestiaApplication.sdk(): output directory does not exists." ,
70
70
) ;
71
71
72
- title ( "Nestia SDK Generator" ) ;
72
+ print_title ( "Nestia SDK Generator" ) ;
73
73
await this . generate ( "sdk" , ( config ) => config , SdkGenerator . generate ) ;
74
74
}
75
75
@@ -89,7 +89,7 @@ export class NestiaSdkApplication {
89
89
"Error on NestiaApplication.swagger(): output directory does not exists." ,
90
90
) ;
91
91
92
- title ( "Nestia Swagger Generator" ) ;
92
+ print_title ( "Nestia Swagger Generator" ) ;
93
93
await this . generate (
94
94
"swagger" ,
95
95
( config ) => config . swagger ! ,
@@ -112,6 +112,7 @@ export class NestiaSdkApplication {
112
112
input : await ConfigAnalyzer . input ( this . config ) ,
113
113
checker : null ! ,
114
114
errors : [ ] ,
115
+ warnings : [ ] ,
115
116
} ;
116
117
117
118
console . log ( "Analyzing reflections" ) ;
@@ -170,9 +171,10 @@ export class NestiaSdkApplication {
170
171
171
172
// REPORT ERRORS
172
173
if ( project . errors . length ) {
173
- report_errors ( project . errors ) ;
174
+ report_errors ( "error" ) ( project . errors ) ;
174
175
process . exit ( - 1 ) ;
175
176
}
177
+ if ( project . warnings . length ) report_errors ( "warning" ) ( project . warnings ) ;
176
178
177
179
// FIND IMPLICIT TYPES
178
180
const implicit : IRoute [ ] = routeList . filter ( is_implicit_return_typed ) ;
@@ -195,7 +197,7 @@ export class NestiaSdkApplication {
195
197
}
196
198
}
197
199
198
- const title = ( str : string ) : void => {
200
+ const print_title = ( str : string ) : void => {
199
201
console . log ( "-----------------------------------------------------------" ) ;
200
202
console . log ( ` ${ str } ` ) ;
201
203
console . log ( "-----------------------------------------------------------" ) ;
@@ -217,30 +219,45 @@ const is_implicit_return_typed = (route: IRoute): boolean => {
217
219
return true ;
218
220
} ;
219
221
220
- const report_errors = ( errors : IErrorReport [ ] ) : void => {
221
- // key: file
222
- // key: controller
223
- // key: function
224
- // value: message
225
- const map : Map < string , Map < string , Map < string , Set < string > > > > = new Map ( ) ;
226
- for ( const e of errors ) {
227
- const file = MapUtil . take ( map , e . file , ( ) => new Map ( ) ) ;
228
- const controller = MapUtil . take ( file , e . controller , ( ) => new Map ( ) ) ;
229
- const func = MapUtil . take ( controller , e . function , ( ) => new Set ( ) ) ;
230
- func . add ( e . message ) ;
231
- }
222
+ const report_errors =
223
+ ( type : "error" | "warning" ) =>
224
+ ( errors : IErrorReport [ ] ) : void => {
225
+ // key: file
226
+ // key: controller
227
+ // key: function
228
+ // value: message
229
+ const map : Map <
230
+ string ,
231
+ Map < string , Map < string , Set < string > > >
232
+ > = new Map ( ) ;
233
+ for ( const e of errors ) {
234
+ const file = MapUtil . take ( map , e . file , ( ) => new Map ( ) ) ;
235
+ const controller = MapUtil . take (
236
+ file ,
237
+ e . controller ,
238
+ ( ) => new Map ( ) ,
239
+ ) ;
240
+ const func = MapUtil . take ( controller , e . function , ( ) => new Set ( ) ) ;
241
+ func . add ( e . message ) ;
242
+ }
232
243
233
- console . log ( "" ) ;
234
- title ( "Nestia Error Report" ) ;
235
- for ( const [ file , cMap ] of map ) {
236
- for ( const [ controller , fMap ] of cMap )
237
- for ( const [ func , messages ] of fMap ) {
238
- const location : string = path . relative ( process . cwd ( ) , file ) ;
239
- console . log ( `${ location } - error on ${ controller } .${ func } ()` ) ;
240
- for ( const msg of messages ) console . log ( ` - ${ msg } ` ) ;
241
- console . log ( "" ) ;
242
- }
243
- }
244
- } ;
244
+ console . log ( "" ) ;
245
+ print_title ( `Nestia ${ type [ 0 ] . toUpperCase ( ) } ${ type . slice ( 1 ) } Report` ) ;
246
+ for ( const [ file , cMap ] of map ) {
247
+ for ( const [ controller , fMap ] of cMap )
248
+ for ( const [ func , messages ] of fMap ) {
249
+ const location : string = path . relative ( process . cwd ( ) , file ) ;
250
+ console . log (
251
+ `${ location } - ${
252
+ func !== null
253
+ ? `${ controller } .${ func } ()`
254
+ : controller
255
+ } `,
256
+ ) ;
257
+ for ( const msg of messages ) console . log ( ` - ${ msg } ` ) ;
258
+ console . log ( "" ) ;
259
+ }
260
+ }
261
+ } ;
245
262
246
263
const VARIABLE = / [ a - z A - Z _ $ 0 - 9 ] / ;
0 commit comments