Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

blitz generate page … creates file with raw comment #4223

Open
tordans opened this issue Sep 26, 2023 · 4 comments
Open

blitz generate page … creates file with raw comment #4223

tordans opened this issue Sep 26, 2023 · 4 comments

Comments

@tordans
Copy link
Contributor

tordans commented Sep 26, 2023

What is the problem?

A newly generated template looks like this …

export function RegionForm<S extends z.ZodType<any, any>>(props: FormProps<S>) {
  return (
    <Form<S> {...props}>
      <LabeledTextField
        name="slug"
        label="Slug"
        placeholder="Slug"
        type="text"
      />
      {/* template: <__component__ name="__fieldName__" label="__Field_Name__" placeholder="__Field_Name__"  type="__inputType__" /> */}
    </Form>
  );
}

The part {/* template: <__component__ name="__fieldName__" label="__Field_Name__" placeholder="__Field_Name__" type="__inputType__" /> */} should either be transformed … or not be there.

It looks like this is the comment that is visible here https://github.com/blitz-js/blitz/blob/main/packages/generator/templates/form/__ModelName__Form.tsx#L11

Paste all your error logs here:

Paste all relevant code snippets here:

What are detailed steps to reproduce this?

  1. blitz generate all region slug:string:unique shortName:string name:string public:boolean=false
  2. Open the file src/regions/components/RegionForm.tsx

Run blitz -v and paste the output here:

Blitz version: 2.0.0-beta.33 (global)
Blitz version: 2.0.0-beta.33 (local)
macOS Ventura | darwin-arm64 | Node: v18.16.1


 Package manager: npm

  System:
    OS: macOS 13.6
    CPU: (8) arm64 Apple M1
    Memory: 106.03 MB / 16.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 18.16.1 - ~/.nvm/versions/node/v18.16.1/bin/node
    Yarn: Not Found
    npm: 9.5.1 - ~/.nvm/versions/node/v18.16.1/bin/npm
  npmPackages:
    @blitzjs/auth: 2.0.0-beta.33 => 2.0.0-beta.33
    @blitzjs/next: 2.0.0-beta.33 => 2.0.0-beta.33
    @blitzjs/rpc: 2.0.0-beta.33 => 2.0.0-beta.33
    @prisma/client: 5.2.0 => 5.2.0
    blitz: 2.0.0-beta.33 => 2.0.0-beta.33
    next: 13.4.5 => 13.4.5
    prisma: 5.2.0 => 5.2.0
    react: 18.2.0 => 18.2.0
    react-dom: 18.2.0 => 18.2.0
    typescript: ^4.8.4 => 4.9.5

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

No response

@tordans tordans added kind/bug Something isn't working status/triage labels Sep 26, 2023
@tordans
Copy link
Contributor Author

tordans commented Sep 26, 2023

Addition:

Same issue on the Schema (eg src/regions/schemas.ts), which says // template: __fieldName__: z.__zodType__(),

@siddhsuresh
Copy link
Member

Hey @tordans it's meant to be there, the generator uses those comments to know where to update the file, if you choose to run the generate command again on the same modal with new fields.

@tordans
Copy link
Contributor Author

tordans commented Sep 26, 2023

@siddhsuresh oh, I see. Did not understand it as such. Can this be any text? Or could we prefix it with a more descriptive line? "Keep the following line so blitz generate can update the form later."

@siddhsuresh
Copy link
Member

siddhsuresh commented Oct 3, 2023

Hey @tordans We could improve this comment, we just use regex matching to find this and replace. Would you be interested in working on this?

@siddhsuresh siddhsuresh added kind/bad-experience scope/generator status/ready-to-work-on This issue is up for grabs and removed kind/bug Something isn't working labels Oct 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants