Skip to content

Commit

Permalink
More updates to the gulp subgenerator and tests
Browse files Browse the repository at this point in the history
Made the subgenerator properly scaffold a gulpfile and packages now and
updated the tests accordingly for the gulpfile and moved most of the
small tests into a boilerplate test file. Also updated the gulpfile at
the root directory to look for JS errors in the generated gulpfiles and
run a singular test task so even when there are errors it will actually
fail. Neat.

Also updated yeoman-generator to a newer version (0.20.1) for some
templating goodness.
  • Loading branch information
sondr3 committed May 17, 2015
1 parent d314beb commit 24ad2df
Show file tree
Hide file tree
Showing 13 changed files with 584 additions and 402 deletions.
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# .gitignore for jekyllized projects
# Folders that shouldn't be tracked
node_modules/
temp/
coverage/
.envrc
.coveralls.yml
test/test-*/
test/tmp/
npm-shrinkwrap.json

# Ignore hidden folders
# This takes care of .tmp, .sass-cache, and many others
Expand Down
84 changes: 57 additions & 27 deletions generators/gulp/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,34 +5,31 @@ var chalk = require('chalk');
var generators = require('yeoman-generator');

module.exports = generators.Base.extend({
prompting: function() {
var done = this.async();
constructor: function() {
generators.Base.apply(this, arguments);

var prompts = [{
type: 'list',
name: 'uploading',
message: 'How would you like to host/upload your site?',
choices: [{
name: 'Amazon S3',
value: 'amazonS3'
}, {
name: 'Rsync',
value: 'rsync'
}, {
name: 'GitHub Pages',
value: 'ghpages'
}, {
name: 'None',
value: 'noUpload'
}]
}];
this.option('amazonS3', {
type: Boolean,
name: 'amazonS3',
desc: 'Do you want to upload to Amazon S3?'
});

this.prompt(prompts, function(props) {
this.props = _.extend(this.props, props);
this.config.set(this.props);
this.option('rsync', {
type: Boolean,
name: 'rsync',
desc: 'Do you want to upload to Rsync?'
});

done();
}.bind(this));
this.option('ghpages', {
type: Boolean,
name: 'ghPages',
desc: 'Do you want to upload to GitHub Pages?'
});
this.option('noUpload', {
type: Boolean,
name: 'noUpload',
desc: 'No uploading'
});
},

writing: {
Expand Down Expand Up @@ -72,15 +69,48 @@ module.exports = generators.Base.extend({
'trash': '^1.4.0'
});

if (this.options.amazonS3) {
pkg.devDependencies['gulp-awspublish'] = '^0.1.0';
pkg.devDependencies['gulp-awspublish-router'] = '^0.1.0';
pkg.devDependencies['concurrent-transform'] = '^1.0.0';
}

if (this.options.rsync) {
pkg.devDependencies['gulp-rsync'] = '^0.0.2';
}

if (this.options.ghPages) {
pkg.devDependencies['gulp-gh-pages'] = '^0.4.0';
}

this.fs.writeJSON(this.destinationPath('package.json'), pkg);
},

gulpfile: function() {

this.fs.copyTpl(
this.templatePath('gulpfile.js'),
this.destinationPath('gulpfile.js')
this.destinationPath('gulpfile.js'),
{
amazonS3: this.options.amazonS3,
rsync: this.options.rsync,
ghPages: this.options.ghPages,
noUpload: this.options.noUpload
}
);

if (this.options.amazonS3) {
this.fs.copyTpl(
this.templatePath('aws-credentials.json'),
this.destinationPath('aws-credentials.json')
);
}

if (this.options.rsync) {
this.fs.copyTpl(
this.templatePath('rsync-credentials.json'),
this.destinationPath('rsync-credentials.json')
);
}
}
}
});
9 changes: 4 additions & 5 deletions generators/gulp/templates/aws-credentials.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{
"key": "<%= amazonKey %>",
"secret": "<%= amazonSecret %>",
"bucket": "<%= amazonBucket %>",
"region": "us-west-1",
"distributionId": "<%= amazonDistID %>"
"key": "AWS KEY GOES HERE",
"secret": "AWS SECRET GOES HERE",
"bucket": "www.example.org",
"region": "us-west-1"
}
Loading

0 comments on commit 24ad2df

Please sign in to comment.