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

Provide documentation on how to extend schematics #2470

Open
1 task done
hcharley opened this issue Sep 22, 2022 · 5 comments
Open
1 task done

Provide documentation on how to extend schematics #2470

hcharley opened this issue Sep 22, 2022 · 5 comments
Labels

Comments

@hcharley
Copy link

Is there an existing issue that is already proposing this?

  • I have searched the existing issues

Is your feature request related to a problem? Please describe it

I'm currently unsure how to extend schematics to include my own spin on how I create resources, so it would be great to help people like me out with an example of how to do so.

Describe the solution you'd like

Documentation on how to extend schematics, like @nestjs/schematics:resource.

Teachability, documentation, adoption, migration strategy

No response

What is the motivation / use case for changing the behavior?

I like to add MikroORM decorators to resources, use both resolvers and controllers at the same time, and other organization-specific code styles that would be nice to automate adding without having to rewrite and maintain everything.

@micalevisk
Copy link
Member

micalevisk commented Sep 22, 2022

I guess you could search on how to extends Angular schematics

Then use the -c option of NestJS CLI or define the collection field on your nest-cli.json file

@hcharley
Copy link
Author

Thanks for the advice. I have searched on how to extend schematics, but I did it through a search of Nx schematics.

Honestly, it's all a bit confusing because Nx schematics are maybe called Nx generators, and Angular schematics are called Angular schematics. And the documentation seems a bit spread out.

But you're right, I could do more research to figure it out. I just thought that with a popular project like this, it might be helpful to folks. Partly I wanted to create this ticket to document that this is a possibility to those that come behind.

Here's an idea now that my gears are turning: what if this project had a schematic for creating a schematic that extended one of the available schematics? Kind of meta, but it would be cool imho.

@micalevisk
Copy link
Member

micalevisk commented Sep 22, 2022

I agree that having that covered at the docs would be pretty good to the NestJS ecosystem.

If I recall correctly, I manage to extend the @nestjs/schematics collection with no much worries but I didn't have that project anymore to share with you :/ I'll try again in the future.


what if this project had a schematic for creating a schematic that extended one of the available schematics?

sounds good to me.

EDIT: actually, that schematics will be another nodejs project, so having some generator for it in @nestjs/cli (as nest g <foo>) doesn't make much sense. We could have a boilerplate repository tho

@jmcdo29
Copy link
Member

jmcdo29 commented Sep 22, 2022

For a nice reference, I extend the schematics in nest-commander a bit to create @Command() classes

@kamilmysliwiec kamilmysliwiec transferred this issue from nestjs/schematics Sep 23, 2022
@soydev019
Copy link

Do we have any updates ? I would like to have my own templates/schematics using @nestjs/cli but couldn't reach my goal with the current informations I found. I will need a clear documentation on the exact process if possible please

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants