Skip to content

Commit

Permalink
chore(internals): rename getVersion to getEngineVersion (#14054)
Browse files Browse the repository at this point in the history
  • Loading branch information
jkomyno committed Jun 29, 2022
1 parent e28f8a0 commit 33ab40e
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 18 deletions.
6 changes: 3 additions & 3 deletions packages/cli/src/Version.ts
Expand Up @@ -8,9 +8,9 @@ import {
format,
formatTable,
getConfig,
getEngineVersion,
getSchema,
getSchemaPath,
getVersion,
HelpError,
isError,
loadEnvFile,
Expand Down Expand Up @@ -136,12 +136,12 @@ export class Version implements Command {
const envVar = engineEnvVarMap[binaryName]
const pathFromEnv = process.env[envVar]
if (pathFromEnv && fs.existsSync(pathFromEnv)) {
const version = await getVersion(pathFromEnv, binaryName)
const version = await getEngineVersion(pathFromEnv, binaryName)
return { version, path: pathFromEnv, fromEnvVar: envVar }
}

const binaryPath = await resolveBinary(binaryName)
const version = await getVersion(binaryPath, binaryName)
const version = await getEngineVersion(binaryPath, binaryName)
return { path: binaryPath, version }
}

Expand Down
6 changes: 3 additions & 3 deletions packages/client/src/generation/generateClient.ts
@@ -1,7 +1,7 @@
import { BinaryType } from '@prisma/fetch-engine'
import type { BinaryPaths, DataSource, DMMF, GeneratorConfig } from '@prisma/generator-helper'
import type { Platform } from '@prisma/internals'
import { ClientEngineType, getClientEngineType, getVersion } from '@prisma/internals'
import { ClientEngineType, getClientEngineType, getEngineVersion } from '@prisma/internals'
import copy from '@timsuchanek/copy'
import chalk from 'chalk'
import fs from 'fs'
Expand Down Expand Up @@ -291,8 +291,8 @@ export async function generateClient(options: GenerateClientOptions): Promise<vo
clientEngineType === ClientEngineType.Binary ? BinaryType.queryEngine : BinaryType.libqueryEngine
// They must have an equal size now, let's check for the hash
const [sourceVersion, targetVersion] = await Promise.all([
getVersion(filePath, binaryName).catch(() => null),
getVersion(target, binaryName).catch(() => null),
getEngineVersion(filePath, binaryName).catch(() => null),
getEngineVersion(target, binaryName).catch(() => null),
])

if (sourceVersion && targetVersion && sourceVersion === targetVersion) {
Expand Down
@@ -1,32 +1,32 @@
import { enginesVersion, getCliQueryEngineBinaryType } from '@prisma/engines'

import { BinaryType, getVersion } from '../..'
import { BinaryType, getEngineVersion } from '../..'

const testIf = (condition: boolean) => (condition ? test : test.skip)
const useNodeAPI = getCliQueryEngineBinaryType() === BinaryType.libqueryEngine

describe('getVersion', () => {
describe('getEngineVersion', () => {
test('Introspection Engine', async () => {
const introspectionEngineVersion = await getVersion(undefined, BinaryType.introspectionEngine)
const introspectionEngineVersion = await getEngineVersion(undefined, BinaryType.introspectionEngine)
expect(introspectionEngineVersion.split(' ')[1]).toMatch(enginesVersion)
})

test('Migration Engine', async () => {
const migrationEngineVersion = await getVersion(undefined, BinaryType.migrationEngine)
const migrationEngineVersion = await getEngineVersion(undefined, BinaryType.migrationEngine)
expect(migrationEngineVersion.split(' ')[1]).toMatch(enginesVersion)
})

test('Prisma Fmt', async () => {
const prismaFmtVersion = await getVersion(undefined, BinaryType.prismaFmt)
const prismaFmtVersion = await getEngineVersion(undefined, BinaryType.prismaFmt)
expect(prismaFmtVersion.split(' ')[1]).toMatch(enginesVersion)
})

testIf(!useNodeAPI)('Query Engine', async () => {
const queryEngineVersion = await getVersion(undefined, BinaryType.queryEngine)
const queryEngineVersion = await getEngineVersion(undefined, BinaryType.queryEngine)
expect(queryEngineVersion.split(' ')[1]).toMatch(enginesVersion)
})
testIf(useNodeAPI)('Query Engine (Node-API)', async () => {
const libqueryEngineVersion = await getVersion(undefined, BinaryType.libqueryEngine)
const libqueryEngineVersion = await getEngineVersion(undefined, BinaryType.libqueryEngine)
expect(libqueryEngineVersion.split(' ')[1]).toMatch(enginesVersion)
})
})
@@ -1,4 +1,3 @@
import Debug from '@prisma/debug'
import type { NodeAPILibraryTypes } from '@prisma/engine-core'
import { getCliQueryEngineBinaryType } from '@prisma/engines'
import { BinaryType } from '@prisma/fetch-engine'
Expand All @@ -8,11 +7,9 @@ import execa from 'execa'
import { resolveBinary } from '../resolveBinary'
import { load } from '../utils/load'

const debug = Debug('prisma:getVersion')

const MAX_BUFFER = 1_000_000_000

export async function getVersion(enginePath?: string, binaryName?: BinaryType): Promise<string> {
export async function getEngineVersion(enginePath?: string, binaryName?: BinaryType): Promise<string> {
if (!binaryName) {
binaryName = getCliQueryEngineBinaryType()
}
Expand Down
2 changes: 1 addition & 1 deletion packages/internals/src/engine-commands/index.ts
Expand Up @@ -3,4 +3,4 @@ export type { ConfigMetaFormat } from './getConfig'
export { getConfig } from './getConfig'
export type { GetDMMFOptions } from './getDmmf'
export { getDMMF } from './getDmmf'
export { getVersion } from './getVersion'
export { getEngineVersion } from './getEngineVersion'

0 comments on commit 33ab40e

Please sign in to comment.