blitz-js / legacy-framework

MIT License
3 stars 2 forks source link

Propagate `prisma generate` errors when using `blitz codegen` #218

Closed beerose closed 2 years ago

beerose commented 2 years ago

What is the problem?

Currently, if a user runs blitz codegen, and there there is Prisma installed, Blitz also runs primsa generate. If there are any errors during the prisma generate step, they aren't displayed in the terminal even when using DEBUG=blitz:*. This way some useful information returned from Prisma is omitted.

Relevant code: https://github.com/blitz-js/blitz/blob/canary/packages/cli/src/commands/codegen.ts#L32

Paste all your error logs here:

blitz codegen output:

✔ Generating route manifest
✖ Generating Prisma client

While prisma generate returns the following:

Error: 
You don't have any models defined in your schema.prisma, so nothing will be generated.
You can define a model like this:

model User {
  id    Int     @id @default(autoincrement())
  email String  @unique
  name  String?
}

More information in our documentation:
https://pris.ly/d/prisma-schema

Paste all relevant code snippets here:

n/a

What are detailed steps to reproduce this?

  1. Try to run blitz codegen without any models in schema.prisma (or schema.prisma containing some errors).

Run blitz -v and paste the output here:

macOS Big Sur | darwin-x64 | Node: v14.17.6

blitz: 0.41.1 (local)

  Package manager: yarn 
  System:
    OS: macOS 11.1
    CPU: (12) x64 Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
    Memory: 73.24 MB / 16.00 GB
    Shell: 5.0.11 - /usr/local/bin/bash
  Binaries:
    Node: 14.17.6 - /var/folders/xt/37ypr1bj3s565bjrdzx3znd00000gn/T/yarn--1635260280228-0.10240775555445136/node
    Yarn: 1.19.2 - /var/folders/xt/37ypr1bj3s565bjrdzx3znd00000gn/T/yarn--1635260280228-0.10240775555445136/yarn
    npm: 8.1.0 - ~/workspace/emojis/emojis-lib/bin/npm
    Watchman: Not Found
  npmPackages:
    @prisma/client: ^3.3.0 => 3.3.0 
    blitz: ^0.41.1 => 0.41.1 
    prisma: ^3.3.0 => 3.3.0 
    react: 17.0.2 => 17.0.2 
    react-dom: 17.0.2 => 17.0.2 
    typescript: 4.4.4 => 4.4.4 

Please include below any other applicable logs and screenshots that show your problem:

No response