From 7285c16fa21ce26af60b9b59409ea2f4104cab87 Mon Sep 17 00:00:00 2001 From: steebchen Date: Sat, 11 Nov 2023 22:26:38 +0700 Subject: [PATCH] feat(generator): warn on prisma version mismatch --- generator/generator.go | 12 +++++++----- generator/run.go | 4 ++++ 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/generator/generator.go b/generator/generator.go index 73a55573a..66173c507 100644 --- a/generator/generator.go +++ b/generator/generator.go @@ -14,11 +14,13 @@ import ( // Root describes the generator output root. type Root struct { - Generator Generator `json:"generator"` - OtherGenerators []Generator `json:"otherGenerators"` - SchemaPath string `json:"schemaPath"` - DMMF dmmf.Document `json:"DMMF"` - Datasources []Datasource `json:"datasources"` + Generator Generator `json:"generator"` + OtherGenerators []Generator `json:"otherGenerators"` + SchemaPath string `json:"schemaPath"` + // Version contains the version hash of the Prisma engine + Version string `json:"version"` + DMMF dmmf.Document `json:"DMMF"` + Datasources []Datasource `json:"datasources"` // Datamodel provides the raw string of the Prisma datamodel. Datamodel string `json:"datamodel"` // BinaryPaths (optional) diff --git a/generator/run.go b/generator/run.go index c4541c521..9fdc04448 100644 --- a/generator/run.go +++ b/generator/run.go @@ -40,6 +40,10 @@ func addDefaults(input *Root) { func Run(input *Root) error { addDefaults(input) + if input.Version == binaries.EngineVersion { + fmt.Printf("\nwarning: prisma CLI version mismatch detected. CLI version: %s, internal version: %s (%s); please see https://github.com/steebchen/prisma-client-go/issues/1099 for details\n\n", input.Version, binaries.EngineVersion, binaries.PrismaVersion) + } + if input.Generator.Config.DisableGitignore != "true" && input.Generator.Config.DisableGoBinaries != "true" { logger.Debug.Printf("writing gitignore file") // generate a gitignore into the folder