1
+ import { consola } from "consola" ;
1
2
import lodash from "lodash" ;
2
3
import * as typescript from "typescript" ;
3
4
import { CodeFormatter } from "./code-formatter.js" ;
@@ -12,7 +13,6 @@ import { JavascriptTranslator } from "./translators/javascript.js";
12
13
import { TypeNameFormatter } from "./type-name-formatter.js" ;
13
14
import { FileSystem } from "./util/file-system.js" ;
14
15
import { internalCase } from "./util/internal-case.js" ;
15
- import { Logger } from "./util/logger.js" ;
16
16
import { NameResolver } from "./util/name-resolver.js" ;
17
17
import { pascalCase } from "./util/pascal-case.js" ;
18
18
import { sortByProperty } from "./util/sort-by-property.js" ;
@@ -36,8 +36,6 @@ class CodeGenProcess {
36
36
swaggerSchemaResolver ;
37
37
/** @type {SchemaComponentsMap } */
38
38
schemaComponentsMap ;
39
- /** @type {Logger } */
40
- logger ;
41
39
/** @type {TypeNameFormatter } */
42
40
typeNameFormatter ;
43
41
/** @type {SchemaParserFabric } */
@@ -61,7 +59,6 @@ class CodeGenProcess {
61
59
*/
62
60
constructor ( config ) {
63
61
this . config = new CodeGenConfig ( config ) ;
64
- this . logger = new Logger ( this ) ;
65
62
this . fileSystem = new FileSystem ( this ) ;
66
63
this . schemaWalker = new SchemaWalker ( this ) ;
67
64
this . swaggerSchemaResolver = new SwaggerSchemaResolver ( this ) ;
@@ -72,7 +69,6 @@ class CodeGenProcess {
72
69
this . schemaParserFabric = new SchemaParserFabric ( this ) ;
73
70
this . schemaRoutes = new SchemaRoutes ( this ) ;
74
71
this . javascriptTranslator = new JavascriptTranslator ( this ) ;
75
- this . config . componentTypeNameResolver . logger = this . logger ;
76
72
}
77
73
78
74
async start ( ) {
@@ -95,7 +91,7 @@ class CodeGenProcess {
95
91
this . schemaWalker . addSchema ( "$usage" , swagger . usageSchema ) ;
96
92
this . schemaWalker . addSchema ( "$original" , swagger . originalSchema ) ;
97
93
98
- this . logger . event ( "start generating your typescript api" ) ;
94
+ consola . info ( "start generating your typescript api" ) ;
99
95
100
96
this . config . update (
101
97
this . config . hooks . onInit ( this . config , this ) || this . config ,
@@ -160,11 +156,11 @@ class CodeGenProcess {
160
156
161
157
if ( this . fileSystem . pathIsExist ( this . config . output ) ) {
162
158
if ( this . config . cleanOutput ) {
163
- this . logger . debug ( ` cleaning dir ${ this . config . output } ` ) ;
159
+ consola . debug ( " cleaning dir" , this . config . output ) ;
164
160
this . fileSystem . cleanDir ( this . config . output ) ;
165
161
}
166
162
} else {
167
- this . logger . debug (
163
+ consola . debug (
168
164
`path ${ this . config . output } is not exist. creating dir by this path` ,
169
165
) ;
170
166
this . fileSystem . createDir ( this . config . output ) ;
@@ -185,7 +181,7 @@ class CodeGenProcess {
185
181
withPrefix : true ,
186
182
} ) ;
187
183
188
- this . logger . success (
184
+ consola . success (
189
185
"api file" ,
190
186
`"${ file . fileName } ${ file . fileExtension } "` ,
191
187
`created in ${ this . config . output } ` ,
@@ -510,7 +506,7 @@ class CodeGenProcess {
510
506
const fileExtension = typescript . Extension . Ts ;
511
507
512
508
if ( configuration . translateToJavaScript ) {
513
- this . logger . debug ( "using js translator for" , fileName ) ;
509
+ consola . debug ( "using js translator for" , fileName ) ;
514
510
return await this . javascriptTranslator . translate ( {
515
511
fileName : fileName ,
516
512
fileExtension : fileExtension ,
@@ -519,15 +515,15 @@ class CodeGenProcess {
519
515
}
520
516
521
517
if ( configuration . customTranslator ) {
522
- this . logger . debug ( "using custom translator for" , fileName ) ;
518
+ consola . debug ( "using custom translator for" , fileName ) ;
523
519
return await configuration . customTranslator . translate ( {
524
520
fileName : fileName ,
525
521
fileExtension : fileExtension ,
526
522
fileContent : content ,
527
523
} ) ;
528
524
}
529
525
530
- this . logger . debug ( "generating output for" , `${ fileName } ${ fileExtension } ` ) ;
526
+ consola . debug ( "generating output for" , `${ fileName } ${ fileExtension } ` ) ;
531
527
532
528
return [
533
529
{
0 commit comments