blitz-js / blitz

⚡️ The Missing Fullstack Toolkit for Next.js

Home Page:https://Blitzjs.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

BlitzCliConfig does not work when blitz-server.ts is in /src/app directory

ReadB opened this issue · comments

What is the problem?

blitz-server.ts was moved from src/blitz-server.tsto src/app/blitz-server.ts some time between 2.0.0-beta.35 and v2.0.2

This causes the BlitzCliConfig to not function, tested using blitz generate command and codegen: { fieldTypeMap: {} } config.

Paste all your error logs here:

n/a

Paste all relevant code snippets here:

blitz-server.ts

import type { BlitzCliConfig } from "blitz"
///...
export const cliConfig: BlitzCliConfig = {
  codegen: {
    fieldTypeMap: {
      string: {
        component: "LabeledTextField",
        inputType: "text",
        zodType: "string",
        prismaType: "String",
      },
      boolean: {
        component: "LabeledBooleanField",
        inputType: "checkbox",
        zodType: "boolean",
        prismaType: "Boolean",
      },
    },
  },
}

What are detailed steps to reproduce this?

  1. Run blitz new app
  2. Run cd app
  3. Modify the BlitzCliConfig in src/app/blitz-server.ts as above
  4. Run blitz generate all test somestring:string someboolean:boolean
  5. Find src/app/tests/components/TestForm.tsx and observe the field someboolean is using the default LabeledTextField component instead of LabeledBooleanField

Moving src/app/blitz-server.ts back to the original src/blitz-server.ts location resolves the issue.

Run blitz -v and paste the output here:

Blitz version: 2.0.2 (global)
Blitz version: 2.0.2 (local)
Linux 5.19 | linux-x64 | Node: v18.18.2


 Package manager: npm

  System:
    OS: Linux 5.19 Ubuntu 22.04.3 LTS 22.04.3 LTS (Jammy Jellyfish)
    CPU: (8) x64 Intel(R) Core(TM) i7-6700 CPU @ 3.40GHz
    Memory: 8.99 GB / 15.50 GB
    Shell: 5.1.16 - /bin/bash
  Binaries:
    Node: 18.18.2 - ~/.nvm/versions/node/v18.18.2/bin/node
    Yarn: 1.22.19 - ~/.nvm/versions/node/v18.18.2/bin/yarn
    npm: 9.8.1 - ~/.nvm/versions/node/v18.18.2/bin/npm
  npmPackages:
    @blitzjs/auth: 2.0.2 => 2.0.2 
    @blitzjs/next: 2.0.2 => 2.0.2 
    @blitzjs/rpc: 2.0.2 => 2.0.2 
    @prisma/client: 5.4.2 => 5.4.2 
    blitz: 2.0.2 => 2.0.2 
    next: 13.5.4 => 13.5.4 
    prisma: 5.4.2 => 5.4.2 
    react: 18.2.0 => 18.2.0 
    react-dom: 18.2.0 => 18.2.0 
    typescript: 4.8.4 => 4.8.4 

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

No response

Thanks for the issue @ReadB! will be fixed in the upcoming patch