Skip to content

Commit

Permalink
feat(prisma): upgrade to [email protected] (#506)
Browse files Browse the repository at this point in the history
  • Loading branch information
steebchen authored Jul 7, 2021
1 parent f0ef28d commit 91e1064
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 20 deletions.
4 changes: 2 additions & 2 deletions binaries/binaries.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ import (
)

// PrismaVersion is a hardcoded version of the Prisma CLI.
const PrismaVersion = "2.23.0"
const PrismaVersion = "2.26.0"

// EngineVersion is a hardcoded version of the Prisma Engine.
// The versions can be found under https://github.com/prisma/prisma-engine/commits/master.
const EngineVersion = "adf5e8cba3daf12d456d911d72b6e9418681b28b"
const EngineVersion = "9b816b3aa13cc270074f172f30d6eda8a8ce867d"

// PrismaURL points to an S3 bucket URL where the CLI binaries are stored.
var PrismaURL = "https://prisma-photongo.s3-eu-west-1.amazonaws.com/%s-%s-%s.gz"
Expand Down
6 changes: 2 additions & 4 deletions engine/request.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,8 @@ import (
"github.com/prisma/prisma-client-go/runtime/types"
)

var internalUpdateNotFoundMessage = "Error occurred during query execution:\nInterpretationError(\"Error for binding" +
" \\'0\\'\", Some(QueryGraphBuilderError(RecordNotFound(\"Record to update not found.\"))))"
var internalDeleteNotFoundMessage = "Error occurred during query execution:\nInterpretationError(\"Error for binding" +
" \\'0\\'\", Some(QueryGraphBuilderError(RecordNotFound(\"Record to delete does not exist.\"))))"
var internalUpdateNotFoundMessage = "Error occurred during query execution:\nInterpretationError(\"Error for binding '0'\", Some(QueryGraphBuilderError(RecordNotFound(\"Record to update not found.\"))))"
var internalDeleteNotFoundMessage = "Error occurred during query execution:\nInterpretationError(\"Error for binding '0'\", Some(QueryGraphBuilderError(RecordNotFound(\"Record to delete does not exist.\"))))"

// Do sends the http Request to the query engine and unmarshals the response
func (e *QueryEngine) Do(ctx context.Context, payload interface{}, v interface{}) error {
Expand Down
17 changes: 9 additions & 8 deletions generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func reply(w io.Writer, data interface{}) error {
func invokePrisma() error {
reader := bufio.NewReader(os.Stdin)

if logger.Enabled {
if logger.Enabled || writeDebugFile {
dir, _ := os.Getwd()
log.Printf("current working dir: %s", dir)
}
Expand All @@ -51,18 +51,18 @@ func invokePrisma() error {
return fmt.Errorf("could not read bytes from stdin: %w", err)
}

if writeDebugFile {
if err := ioutil.WriteFile("dmmf.json", content, 0600); err != nil {
log.Print(err)
}
}

var input jsonrpc.Request

if err := json.Unmarshal(content, &input); err != nil {
return fmt.Errorf("could not open stdin %w", err)
}

if writeDebugFile {
if err := ioutil.WriteFile("dmmf.json", content, 0644); err != nil {
log.Print(err)
}
}

var response interface{}

switch input.Method {
Expand All @@ -80,7 +80,8 @@ func invokePrisma() error {
var params generator.Root

if err := json.Unmarshal(input.Params, &params); err != nil {
return fmt.Errorf("could not unmarshal params into generator.Root type %w", err)
dir, _ := os.Getwd()
return fmt.Errorf("could not unmarshal params into generator.Root type at %s: %w", dir, err)
}

if err := generator.Run(&params); err != nil {
Expand Down
15 changes: 10 additions & 5 deletions generator/generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,20 @@ type Config struct {
// Generator describes a generator defined in the Prisma schema.
type Generator struct {
// Output holds the file path of where the client gets generated in.
Output *Value `json:"output"`
Name types.String `json:"name"`
Provider *Value `json:"provider"`
Config Config `json:"config"`
BinaryTargets []string `json:"binaryTargets"`
Output *Value `json:"output"`
Name types.String `json:"name"`
Provider *Value `json:"provider"`
Config Config `json:"config"`
BinaryTargets []BinaryTarget `json:"binaryTargets"`
// PinnedBinaryTarget (optional)
PinnedBinaryTarget string `json:"pinnedBinaryTarget"`
}

type BinaryTarget struct {
FromEnvVar string `json:"fromEnvVar"`
Value string `json:"value"`
}

type Value struct {
FromEnvVar string `json:"fromEnvVar"`
Value types.String `json:"value"`
Expand Down
6 changes: 5 additions & 1 deletion generator/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,11 @@ func addDefaults(input *Root) {
func Run(input *Root) error {
addDefaults(input)

targets := input.Generator.BinaryTargets
var targets []string

for _, target := range input.Generator.BinaryTargets {
targets = append(targets, target.Value)
}

targets = add(targets, "native")
targets = add(targets, "linux")
Expand Down

0 comments on commit 91e1064

Please sign in to comment.