import Debug from '@prisma/debug' ; import { enginesVersion } from '@prisma/engines-version' ; import { generatorHandler } from '@prisma/generator-helper' ; import { parseEnvValue , ClientEngineType , getClientEngineType } from '@prisma/sdk' ; import { generateClient } from './generateClient' ; import { getDMMF } from './getDMMF' ; import { externalToInternalDmmf } from '../runtime/externalToInternalDmmf' ; const debug = Debug ( 'prisma:client:generator' ) ; const pkg = require ( '../../package.json' ) ; const clientVersion = pkg . version ; if ( process . argv [ 1 ] === __filename ) { generatorHandler ( { onManifest ( config ) { const requiredEngine = getClientEngineType ( config ) === ClientEngineType . Library ? 'libqueryEngine' : 'queryEngine' ; debug ( `requiredEngine: ${ requiredEngine }` ) ; return { defaultOutput : '.prisma/client' , prettyName : 'Prisma Client' , requiresEngines : [ requiredEngine ] , version : clientVersion , requiresEngineVersion : enginesVersion , } ; } , async onGenerate ( options ) { const outputDir = typeof options . generator . output === 'string' ? options . generator . output : parseEnvValue ( options . generator . output ! ) ; return generateClient ( { datamodel : options . datamodel , datamodelPath : options . schemaPath , binaryPaths : options . binaryPaths ! , datasources : options . datasources , outputDir , copyRuntime : Boolean ( options . generator . config . copyRuntime ) , dmmf : options . dmmf , generator : options . generator , engineVersion : options . version , clientVersion , transpile : true , activeProvider : options . datasources [ 0 ] ?. activeProvider , } ) ; } , } ) ; } export { getDMMF , externalToInternalDmmf } ;