@@ -183,7 +183,7 @@ export default class ServiceGenerator {
183183
184184 // 生成枚举翻译
185185 const enums = filter ( interfaceTPConfigs , ( item ) => item . isEnum ) ;
186- if ( ! isEmpty ( enums ) ) {
186+ if ( ! this . config . isOnlyGenTypeScriptType && ! isEmpty ( enums ) ) {
187187 this . genFileFromTemplate (
188188 `${ displayEnumLabelFileName } .ts` ,
189189 TypescriptFileType . displayEnumLabel ,
@@ -200,7 +200,11 @@ export default class ServiceGenerator {
200200 ( item ) => ! item . isEnum
201201 ) ;
202202 // 生成 type 翻译
203- if ( this . config . isDisplayTypeLabel && ! isEmpty ( displayTypeLabels ) ) {
203+ if (
204+ ! this . config . isOnlyGenTypeScriptType &&
205+ this . config . isDisplayTypeLabel &&
206+ ! isEmpty ( displayTypeLabels )
207+ ) {
204208 this . genFileFromTemplate (
205209 `${ displayTypeLabelFileName } .ts` ,
206210 TypescriptFileType . displayTypeLabel ,
@@ -212,30 +216,38 @@ export default class ServiceGenerator {
212216 ) ;
213217 }
214218
215- const prettierError = [ ] ;
216-
217- // 生成 service controller 文件
218- this . getServiceTPConfigs ( ) . forEach ( ( tp ) => {
219- const hasError = this . genFileFromTemplate (
220- getFinalFileName ( `${ tp . className } .ts` ) ,
221- TypescriptFileType . serviceController ,
222- {
223- namespace : this . config . namespace ,
224- requestOptionsType : this . config . requestOptionsType ,
225- requestImportStatement : this . config . requestImportStatement ,
226- interfaceFileName : interfaceFileName ,
227- ...tp ,
228- }
229- ) ;
219+ if ( ! this . config . isOnlyGenTypeScriptType ) {
220+ const prettierError = [ ] ;
221+
222+ // 生成 service controller 文件
223+ this . getServiceTPConfigs ( ) . forEach ( ( tp ) => {
224+ const hasError = this . genFileFromTemplate (
225+ getFinalFileName ( `${ tp . className } .ts` ) ,
226+ TypescriptFileType . serviceController ,
227+ {
228+ namespace : this . config . namespace ,
229+ requestOptionsType : this . config . requestOptionsType ,
230+ requestImportStatement : this . config . requestImportStatement ,
231+ interfaceFileName : interfaceFileName ,
232+ ...tp ,
233+ }
234+ ) ;
230235
231- prettierError . push ( hasError ) ;
232- } ) ;
236+ prettierError . push ( hasError ) ;
237+ } ) ;
233238
234- if ( prettierError . includes ( true ) ) {
235- log ( '🚥 格式化失败,请检查 service controller 文件内可能存在的语法错误' ) ;
239+ if ( prettierError . includes ( true ) ) {
240+ log (
241+ '🚥 格式化失败,请检查 service controller 文件内可能存在的语法错误'
242+ ) ;
243+ }
236244 }
237245
238- if ( this . config . isGenJsonSchemas && ! isEmpty ( this . schemaList ) ) {
246+ if (
247+ ! this . config . isOnlyGenTypeScriptType &&
248+ this . config . isGenJsonSchemas &&
249+ ! isEmpty ( this . schemaList )
250+ ) {
239251 // 处理重复的 schemaName
240252 handleDuplicateTypeNames ( this . schemaList ) ;
241253 // 生成 schema 文件
@@ -257,12 +269,17 @@ export default class ServiceGenerator {
257269 namespace : this . config . namespace ,
258270 interfaceFileName : interfaceFileName ,
259271 isGenJsonSchemas :
260- this . config . isGenJsonSchemas && ! isEmpty ( this . schemaList ) ,
272+ ! this . config . isOnlyGenTypeScriptType &&
273+ this . config . isGenJsonSchemas &&
274+ ! isEmpty ( this . schemaList ) ,
261275 schemaFileName : schemaFileName ,
262- isDisplayEnumLabel : ! isEmpty ( enums ) ,
276+ isDisplayEnumLabel :
277+ ! this . config . isOnlyGenTypeScriptType && ! isEmpty ( enums ) ,
263278 displayEnumLabelFileName : displayEnumLabelFileName ,
264279 isDisplayTypeLabel :
265- this . config . isDisplayTypeLabel && ! isEmpty ( displayTypeLabels ) ,
280+ ! this . config . isOnlyGenTypeScriptType &&
281+ this . config . isDisplayTypeLabel &&
282+ ! isEmpty ( displayTypeLabels ) ,
266283 displayTypeLabelFileName : displayTypeLabelFileName ,
267284 }
268285 ) ;
0 commit comments