import Debug from '@prisma/debug' ; import type { NodeAPILibraryTypes } from '@prisma/engine-core' ; import { getCliQueryEngineBinaryType } from '@prisma/engines' ; import { BinaryType } from '@prisma/fetch-engine' ; import { isNodeAPISupported } from '@prisma/get-platform' ; import execa from 'execa' ; import { resolveBinary } from '../resolveBinary' ; import { load } from '../utils/load' ; const debug = Debug ( 'prisma:getVersion' ) ; const MAX_BUFFER = 1000000000 ; export async function getVersion ( enginePath ? , binaryName ? ) { if ( ! binaryName ) { binaryName = getCliQueryEngineBinaryType ( ) ; } enginePath = await resolveBinary ( binaryName , enginePath ) ; if ( binaryName === BinaryType . libqueryEngine ) { await isNodeAPISupported ( ) ; const QE = load < NodeAPILibraryTypes . Library > ( enginePath ) ; return `libquery-engine ${ QE . version ( ) . commit }` ; } else { const result = await execa ( enginePath , [ '--version' ] , { maxBuffer : MAX_BUFFER , } ) ; return result . stdout ; } }