From 2c8a0dba070daaff0e62f008d3324bd92baec234 Mon Sep 17 00:00:00 2001 From: Alon Amster Date: Thu, 15 Jan 2015 07:12:35 +0200 Subject: [PATCH 1/2] Added the ability to include devDependencies in GitHub Pages. Fixes #61 --- gh/index.js | 9 ++++++++- gh/templates/gp.sh | 10 ++++++++++ readme.md | 2 ++ 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/gh/index.js b/gh/index.js index 14ab84a..ff0f32f 100644 --- a/gh/index.js +++ b/gh/index.js @@ -23,12 +23,19 @@ module.exports = yeoman.generators.Base.extend({ name: 'elementName', message: 'What is your element\'s name', default: defaultName + }, + { + name: 'includeDevDeps', + message: 'Would you like to include the devDependencies from your bower.json file?', + type: 'confirm', + default: false } ]; this.prompt(prompts, function (props) { this.ghUser = props.ghUser; this.elementName = props.elementName; + this.includeDevDeps = props.includeDevDeps ? 'yes' : 'no'; done(); }.bind(this)); @@ -44,7 +51,7 @@ module.exports = yeoman.generators.Base.extend({ return this.log(err); } - var gp = spawn('sh', ['gp.sh', this.ghUser, this.elementName], {cwd: dest}); + var gp = spawn('sh', ['gp.sh', this.ghUser, this.elementName, this.includeDevDeps], {cwd: dest}); gp.stdout.on('data', function (data) { this.log(data.toString()); diff --git a/gh/templates/gp.sh b/gh/templates/gp.sh index f8498b2..72ef2f5 100644 --- a/gh/templates/gp.sh +++ b/gh/templates/gp.sh @@ -7,6 +7,7 @@ # Run in a clean directory passing in a GitHub org and repo name org=$1 repo=$2 +getdevdeps=$3 # make folder (same as input, no checking!) mkdir $repo @@ -26,6 +27,15 @@ bower install --config.directory="components" $org/$repo#master # redirect by default to the component folder echo "" >index.html + +# install the project's dev dependencies +if [ "$getdevdeps" = "yes" ] +then + cd components/$repo + bower install --config.directory="../" + cd ../../ +fi + # send it all to github git add -A . git commit -am 'seed gh-pages' diff --git a/readme.md b/readme.md index 035b38b..0debbfa 100644 --- a/readme.md +++ b/readme.md @@ -91,6 +91,8 @@ yo polymer:seed x-foo ### Gh Generates a Github pages branch for your [seed-element](#seed). +If your documentation or demo pages have dependencies declared as devDependencies in bower.json, you can include them in the Github pages branch by answering _yes_ to the relevant question. + Example: ```bash cd components/x-foo From 05278fa74d8f45225ca9e7f979f27b3a78ce65ae Mon Sep 17 00:00:00 2001 From: Alon Amster Date: Thu, 29 Jan 2015 21:05:08 +0200 Subject: [PATCH 2/2] Added a command line option to ignore dev dependencies. Off by default. --- gh/index.js | 15 ++++++++------- readme.md | 4 +++- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/gh/index.js b/gh/index.js index ff0f32f..2768030 100644 --- a/gh/index.js +++ b/gh/index.js @@ -7,6 +7,14 @@ var spawn = require('child_process').spawn; var rimraf = require('rimraf'); module.exports = yeoman.generators.Base.extend({ + constructor: function () { + yeoman.generators.Base.apply(this, arguments); + this.option('nodevdeps', { + desc: 'Whether devDependencies should be installed in the gh-pages branch', + default: false + }); + this.includeDevDeps = this.options.nodevdeps ? 'no' : 'yes'; + }, askFor: function () { var done = this.async(); @@ -23,19 +31,12 @@ module.exports = yeoman.generators.Base.extend({ name: 'elementName', message: 'What is your element\'s name', default: defaultName - }, - { - name: 'includeDevDeps', - message: 'Would you like to include the devDependencies from your bower.json file?', - type: 'confirm', - default: false } ]; this.prompt(prompts, function (props) { this.ghUser = props.ghUser; this.elementName = props.elementName; - this.includeDevDeps = props.includeDevDeps ? 'yes' : 'no'; done(); }.bind(this)); diff --git a/readme.md b/readme.md index 0debbfa..c744106 100644 --- a/readme.md +++ b/readme.md @@ -91,7 +91,7 @@ yo polymer:seed x-foo ### Gh Generates a Github pages branch for your [seed-element](#seed). -If your documentation or demo pages have dependencies declared as devDependencies in bower.json, you can include them in the Github pages branch by answering _yes_ to the relevant question. +If your documentation or demo pages have dependencies declared as devDependencies in `bower.json`, they will be included in your GitHub pages branch. Example: ```bash @@ -99,6 +99,8 @@ cd components/x-foo yo polymer:gh ``` +If, for some reason, you don't want the devDependencies, use the `--nodevdeps` option. + ## Testing The project generated by `yo polymer` contains support for [web-component-tester](https://github.com/Polymer/web-component-tester). The following commands are included: