Search code examples
polymercommand-line-interfacepolymer-cli

Flag for init polymer cli?


I looked at the help for init for the new Polymer CLI for but I could not see any flags to reduce the number of bower packages downloaded, especially if the init is for a new element, I would not really need paper-ripple by default or if I need it, I can add it later. Any ideas?


Solution

  • paper-ripple is a transitive dependency of iron-component-page, which is in the element template's default devDependencies. The iron-component-page is intended for the element's demo page, which would make sense if you were going to publish this element standalone.

    The ElementGenerator simply copies files from its template directory, so you could just modify that directory in your installation, removing dependencies from bower.json as desired.

    On my machine, I removed all dependencies from /usr/local/lib/node_modules/polymer-cli/lib/init/element/templates/bower.json so that it looks like this:

    {
      "name": "<%= name %>",
    <% if (description) { -%>  "description": "<%= description %>",
    <% } -%>
      "main": "<%= name %>.html"
    }
    

    Now, the element generator outputs this:

    $ polymer init element
    info:    Running template element
    ? Element name x-bar
    ? Brief description of the element
       create bower.json
       create demo/index.html
       create index.html
       create README.md
       create x-bar.html
       create test/x-bar_test.html
    
    Project generated!
    Installing dependencies...
    
    
    I'm all done. Running bower install for you to install the required dependencies. If this fails, try running the command yourself.
    
    
    
    Setup Complete!
    Check out your new project README for information about what to do next.