Open rikbrowning opened 8 years ago
It is! Check out https://github.com/PolymerElements/generator-polymer-init-custom-build for an example of a custom polymer-cli generator. Our generation logic is built off of yeoman, and if I remember correctly all you need to be loaded automatically is to make sure your template name starts with polymer-init-
all these generators are just Yeoman generators and therefore can be extended and composed. How easily depends on what you want to do. Checkout the following https://www.youtube.com/watch?v=A_OEdyhgnKc&list=PLOU2XLYxmsII5c3Mgw6fNYCzaWrsM3sMN (Polycast on building a CLI generator) Ps the prefix is `generator-polymer-init
Thanks for the extra info and links @OrenBochman!
@FredKSchott I know you can compose those generators, but what if you need access to the props defined in that generator? Would be very useful to have access to the name.
@rikbrowning I'm not sure I'm following, can you give me an example of what you'd like to do with your generator, that you can't currently do?
The example I just had was to create a company element generator. The issue was I wanted to use the polymer element generator with just a few extra files that we require. So I could use composition which works until you need access to the name or description property of the polymer element which is only available in the polymer generator.
What I ended up doing was extending the Polymer Element Generator class, now to get access to that I had to reference the Polymer-CLI package which means that my very light weight generator now has a huge dependency to pull in all to get access to the name/description of the element.
Is there a better way to handle this? Even if the generators were in their own separate packages it would make my solution a lot nicer and allow others to easily extend it as well.
Ah, got it. Yea, we could definitely pull those out into separate libraries. We probably won't be able to prioritize this for a while though, so for now I would suggest just copying the generator out of the CLI and into your own project. It's not perfect, but it'll let you do what you want today without needing to pull in the entire CLI as a dependency.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
I am currently trying to extend both the app and element generators, I want everything those generators give but to simply add a few custom files. Currently the only nice way I have found to do this is to have a dependency on polymer-cli which feels like I am getting the jungle when all I want is a banana. I did try composing my generators of the built-in generators but the issue is that I would like to use the props that are defined in the prompting priority so I have ended up extending the actual classes to get access to those props.
Is there any intention to make it easier to extend the built-in generators?