Skip to content

Commit

Permalink
Add subgenerator for Bower
Browse files Browse the repository at this point in the history
So it now generates everything you actually need for it to properly
configure everything. Updated the tests and such accordingly.
  • Loading branch information
sondr3 committed Jul 1, 2015
1 parent 9b99b28 commit 9278f73
Show file tree
Hide file tree
Showing 9 changed files with 117 additions and 0 deletions.
10 changes: 10 additions & 0 deletions generators/app/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,16 @@ module.exports = generators.Base.extend({
local: require.resolve('../boilerplate')
});

this.composeWith('jekyllized:bower', {
options: {
projectName: this.props.projectName,
authorName: this.props.authorName,
authorEmail: this.props.authorEmail
}
}, {
local: require.resolve('../bower')
});

this.composeWith('jekyllized:gulp', {
options: {
uploading: this.props.uploading
Expand Down
44 changes: 44 additions & 0 deletions generators/bower/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
'use strict';

var generators = require('yeoman-generator');

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

this.option('projectName', {
type: String,
required: true,
desc: 'Project name'
});

this.option('authorName', {
type: String,
required: true,
desc: 'Author name'
});

this.option('authorEmail', {
type: String,
required: true,
desc: 'Author email'
});
},

configuring: function() {
this.fs.copyTpl(
this.templatePath('bower.json'),
this.destinationPath('bower.json'),
{
projectName: this.options.projectName,
authorName: this.options.authorName,
authorEmail: this.options.authorEmail
}
);

this.fs.copy(
this.templatePath('bowerrc'),
this.destinationPath('.bowerrc')
);
}
});
17 changes: 17 additions & 0 deletions generators/bower/templates/bower.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"name": "<%= projectName %>",
"version": "0.0.0",
"authors": [
"<%= authorName %> <<%= authorEmail %>>"
],
"license": "MIT",
"ignore": [
"**/.*",
"node_modules",
"bower_components",
"test",
"tests"
],
"dependencies": {
}
}
4 changes: 4 additions & 0 deletions generators/bower/templates/bowerrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"directory": "bower_components",
"analytics": false
}
1 change: 1 addition & 0 deletions generators/gulp/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ module.exports = generators.Base.extend({
pkg.devDependencies = pkg.devDependencies || {};
_.extend(pkg.devDependencies, {
'babel': '^5.6.8',
'bower': '^1.4.1',
'browser-sync': '^2.7.12',
'del': '^1.1.1',
'gulp': 'git://github.com/gulpjs/gulp.git#4.0',
Expand Down
1 change: 1 addition & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
module.exports = {
app: require.resolve('./generators/app'),
boilerplate: require.resolve('./generators/boilerplate'),
bower: require.resolve('./generators/bower'),
gulp: require.resolve('./generators/gulp'),
jekyll: require.resolve('./generators/jekyll')
};
3 changes: 3 additions & 0 deletions test/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,11 @@ describe('jekyllized:app', function() {
'.jscsrc',
'.gitignore',
'.gitattributes',
'.bowerrc',
'bower.json',
'package.json',
'gulpfile.babel.js',
'README.md',
'_config.yml',
'_config.build.yml',
'Gemfile'
Expand Down
36 changes: 36 additions & 0 deletions test/bower.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
'use strict';

var path = require ('path');
var assert = require('yeoman-assert');
var helpers = require('yeoman-generator').test;

describe('jekyllized:bower', function() {
before(function(done) {
this.options = {
projectName: 'jekyllized',
authorName: 'Ola Nordmann',
authorEmail: '[email protected]'
};
helpers.run(path.join(__dirname, '../generators/bower'))
.inDir(path.join(__dirname, 'tmp/bower'))
.withOptions(this.options)
.on('end', done);
});

it('creates .bowerrc', function() {
assert.file('.bowerrc');
});

it('creates bower.json', function() {
assert.file('bower.json');
});

it('bower.json contains correct info', function() {
var expected = [
['bower.json', '"name": "jekyllized"'],
['bower.json', '"Ola Nordmann <[email protected]>"']
];

assert.fileContent(expected);
});
});
1 change: 1 addition & 0 deletions test/gulp.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ describe('jekyllized:gulp', function() {
var expected = [
['package.json', '"babel": "^5.6.8"'],
['package.json', '"browser-sync": "^2.7.12"'],
['package.json', '"bower": "^1.4.1"'],
['package.json', '"del": "^1.1.1"'],
['package.json', '"gulp": "git://github.com/gulpjs/gulp.git#4.0"'],
['package.json', '"gulp-autoprefixer": "^2.0.0"'],
Expand Down

0 comments on commit 9278f73

Please sign in to comment.