@@ -114,21 +114,18 @@ export class EnhancerGenerator {
114
114
115
115
if ( this . needsLogicalClient ) {
116
116
prismaTypesFixed = true ;
117
- resultPrismaTypeImport = `${ LOGICAL_CLIENT_GENERATION_PATH } /index-fixed ` ;
117
+ resultPrismaTypeImport = `${ LOGICAL_CLIENT_GENERATION_PATH } /index` ;
118
118
const result = await this . generateLogicalPrisma ( ) ;
119
119
dmmf = result . dmmf ;
120
120
}
121
121
122
122
// reexport PrismaClient types (original or fixed)
123
- const modelsDts = this . project . createSourceFile (
124
- path . join ( this . outDir , 'models.d. ts' ) ,
123
+ const modelsTs = this . project . createSourceFile (
124
+ path . join ( this . outDir , 'models.ts' ) ,
125
125
`export * from '${ resultPrismaTypeImport } ';` ,
126
126
{ overwrite : true }
127
127
) ;
128
- await modelsDts . save ( ) ;
129
-
130
- // reexport values from the original PrismaClient (enums, etc.)
131
- fs . writeFileSync ( path . join ( this . outDir , 'models.js' ) , `module.exports = require('${ prismaImport } ');` ) ;
128
+ await modelsTs . save ( ) ;
132
129
133
130
const authDecl = getAuthDecl ( getDataModelAndTypeDefs ( this . model ) ) ;
134
131
const authTypes = authDecl ? generateAuthType ( this . model , authDecl ) : '' ;
177
174
return {
178
175
dmmf,
179
176
newPrismaClientDtsPath : prismaTypesFixed
180
- ? path . resolve ( this . outDir , LOGICAL_CLIENT_GENERATION_PATH , 'index-fixed .d.ts' )
177
+ ? path . resolve ( this . outDir , LOGICAL_CLIENT_GENERATION_PATH , 'index.d.ts' )
181
178
: undefined ,
182
179
} ;
183
180
}
@@ -457,7 +454,7 @@ export type Enhanced<Client> =
457
454
}
458
455
459
456
private async processClientTypes ( prismaClientDir : string ) {
460
- // make necessary updates to the generated `index.d.ts` file and save it as `index-fixed.d.ts`
457
+ // make necessary updates to the generated `index.d.ts` file and overwrite it
461
458
const project = new Project ( ) ;
462
459
const sf = project . addSourceFileAtPath ( path . join ( prismaClientDir , 'index.d.ts' ) ) ;
463
460
@@ -473,7 +470,6 @@ export type Enhanced<Client> =
473
470
} ) ;
474
471
475
472
// transform index.d.ts and save it into a new file (better perf than in-line editing)
476
-
477
473
const sfNew = project . createSourceFile ( path . join ( prismaClientDir , 'index-fixed.d.ts' ) , undefined , {
478
474
overwrite : true ,
479
475
} ) ;
@@ -483,7 +479,7 @@ export type Enhanced<Client> =
483
479
this . generateExtraTypes ( sfNew ) ;
484
480
485
481
sfNew . formatText ( ) ;
486
- await sfNew . save ( ) ;
482
+ await sfNew . copyImmediately ( sf . getFilePath ( ) , { overwrite : true } ) ;
487
483
}
488
484
489
485
private transformPrismaTypes ( sf : SourceFile , sfNew : SourceFile , delegateInfo : DelegateInfo ) {
0 commit comments