From 1ec76055c1a5c0f720f6be97c2fa70394cbb0b48 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 73a55573..66173c50 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 c4541c52..9f1ba347 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