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

[Requests] - Don't override existing - Generate Only Entity/Dto/Create #103

Open
ragokan opened this issue Mar 31, 2022 · 3 comments
Open
Labels
wontfix This will not be worked on

Comments

@ragokan
Copy link

ragokan commented Mar 31, 2022

Hello, firstly I would like to say thank you for this amazing package. It saved a lot of time for me. Because I am using it currently, I would like to suggest/request two features.

1: Don't override if file exists

  • When it is generated, sometimes we do changes such as adding validator decorators. Especially when I use outputToNestJsResourceStructure = "true", I do add validators. It would be good if this package does not do anything if there is any file on that location. ( as an option )

2: Select what is going to be generated. For example only generate Entity and Create Dto

@chocovish
Copy link

another idea could be checking if file exists on that path and has some other annotations then generate classes with those existing annotations.

@ragokan
Copy link
Author

ragokan commented Apr 16, 2022

another idea could be checking if file exists on that path and has some other annotations then generate classes with those existing annotations.

This is actually better but I don't know if it is harder to do.

@benkroeger
Copy link
Member

not overriding existing files could lead to inconsistent behaviour. esp. when we import that existing file in another newly generated file to reuse its generated contents.

What I found to work great for me is to have generators produce code in a separate folder (e.g. src/generated) and import DTOs in my nest modules:

// src/my-module/dto/input/create-foo.input.ts
import { CreateFooInput as GeneratedCreateFooInput } from 'src/generated';

export CreateFooInput extends GeneratedCreateFooInput {
// add custom props here
}

This way you can always generate all the things - and only import what you need - and even make modifications.
Also see MappedTypes if you want to exclude generated props or merge classes

@benkroeger benkroeger added the wontfix This will not be worked on label May 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
wontfix This will not be worked on
Development

No branches or pull requests

3 participants