Closed m4b closed 9 years ago
Hey @m4b thanks for the PR!
One of the things we're trying to avoid is maintaining our own set of templates. At the moment, we copy the source from the starter kit or the seed-element and use their exact templates. In the future I hope to move this over to using git submodules even. The reasoning behind this is to keep us in sync with those projects without having to patch up a bunch of template files or look for differences.
Having said that, I'm wondering if you can use the templates from app/templates/polymer-starter-kit as the basis for your generator.
For sure, fair enough (although it makes doing something like <title><% projectName %></title>
much more complicated if the html template is coming from a git repo, I should think?)
I will look into using the starter kit template, but I imagine a strip()
function will have to be created that deletes nodes to create something similar to the index in the bare starter kit.
This also still suffers from poor encapsulation, because the strip function would still have to have knowledge of what the template is/looks like, in order to delete the nodes. In the case of a simple index file, it might be best just to maintain its template, since it's fairly small, and the generator then doesn't have to add stripping functionality and have knowledge of the upstream index, etc.
But on hindsight, it was kind of dumb to not use the starter-kits files like bower.json
; I will correct that; I'll have to look into accessing another generator's template files though, haven't done that, but it's probably easy?
In terms of commits, do you want all the future commits on this PR to be squashed except for the latest one, so if or when this PR is merged, it's a single commit, or are you OK with more than one commit message on this PR?
I will look into using the starter kit template, but I imagine a strip() function will have to be created that deletes nodes to create something similar to the index in the bare starter kit.
I guess if the index file is simple enough we could maybe just have that be its own template file... we do have something kinda similar for the yo polymer:el
subgenerator.
You can keep committing to this PR if you'd like and feel free to rebase to combine commits as well. When it reaches a state where we're happy with it I can do a squash merge.
One sec, found a minor bug, where a spurious project-name directory is created inside of the project; doesn't cause problems, just an annoyance. Squashing commits now and pushing. Ready for review now.
@robdodson I updated the PR to remove all of the blank
template files except a very simple index.html
file; the rest of the files come from the app
generator's template.
I'll be in absentia for a week or so, starting tomorrow, so if you want any more changes, might have to wait a bit.
@m4b thanks for doing that and sorry for the delay on my part. I've been preparing for a talk that I have to give today so have neglected Github a bit. I'll try to review this week.
@robdodson yea, no worries! And have fun at your talk :)
Hey @m4b, I chatted a bit with @addyosmani about this and I think this would probably be better off as a separate generator. I'd really like to keep the current generator as closely attached to Polymer Starter Kit and seed-element as possible and I don't quite feel like the blank generator fits in. But I really appreciate you taking the time to work on it, and hopefully you can just turn this PR into its own generator.
just turn this PR into its own generator.
:+1:
Summary
Implemented a 'blank' generator, with a required project name, for creating a baseline polymer project; includes
--use-wct
,--skip-install
,--skip-install-message
, and--test-element
optional args; eventually, this entire generator should probably merged into an optional arg in the default generator, i.e., something likeyo polymer:app sweet-project --blank
.I also added a basic test, to check if files are created correctly.
Using a similar template to the starter-kit is probably a DRY violation, but it was an easy modification to create the desired behavior.
Rationale:
I find myself quickly wanting a 'blank' polymer project, but with the starter-kit's nice build system. To that end, I typically do three things:
This PR does all 3 above, and optionally adds a test-element and/or web component testing.