Skip to content

Commit

Permalink
Bump yeoman-generator to v1.0 (#249)
Browse files Browse the repository at this point in the history
* Use yarn

* Bump to yeoman-generator 1.0
  • Loading branch information
SBoudrias committed Dec 25, 2016
1 parent d778d42 commit 7ec1c65
Show file tree
Hide file tree
Showing 19 changed files with 3,954 additions and 159 deletions.
4 changes: 3 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,7 @@ sudo: false
language: node_js
node_js:
- 4
- 5
- 6
- node
cache:
yarn: true
8 changes: 3 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,10 @@ $ npm publish
First of all, make sure you're comfortable with [Yeoman composability](http://yeoman.io/authoring/composability.html) feature. Then in your own generator:

```js
module.exports = generators.Base.extend({
module.exports = Generator.extend({
default: function () {
this.composeWith('node:app', {
options: {/* provide the options you want */}
}, {
local: require.resolve('generator-node/generators/app')
this.composeWith(require.resolve('generator-node/generators/app'), {
/* provide the options you want */
});
}
});
Expand Down
108 changes: 38 additions & 70 deletions generators/app/index.js
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
'use strict';
var _ = require('lodash');
var extend = _.merge;
var generators = require('yeoman-generator');
var Generator = require('yeoman-generator');
var parseAuthor = require('parse-author');
var githubUsername = require('github-username');
var path = require('path');
var askName = require('inquirer-npm-name');

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

this.option('travis', {
type: Boolean,
required: false,
defaults: true,
default: true,
desc: 'Include travis config'
});

this.option('boilerplate', {
type: Boolean,
required: false,
defaults: true,
default: true,
desc: 'Include boilerplate files'
});

Expand All @@ -34,7 +34,7 @@ module.exports = generators.Base.extend({
this.option('cli', {
type: Boolean,
required: false,
defaults: false,
default: false,
desc: 'Add a CLI'
});

Expand All @@ -47,14 +47,14 @@ module.exports = generators.Base.extend({
this.option('gulp', {
type: Boolean,
required: false,
defaults: true,
default: true,
desc: 'Include or not a gulpfile.js'
});

this.option('license', {
type: Boolean,
required: false,
defaults: true,
default: true,
desc: 'Include a license'
});

Expand All @@ -73,7 +73,7 @@ module.exports = generators.Base.extend({
this.option('projectRoot', {
type: String,
required: false,
defaults: 'lib',
default: 'lib',
desc: 'Relative path to the project code root'
});

Expand Down Expand Up @@ -237,91 +237,59 @@ module.exports = generators.Base.extend({

default: function () {
if (this.options.travis) {
this.composeWith('travis', {}, {
local: require.resolve('generator-travis/generators/app')
});
this.composeWith(require.resolve('generator-travis/generators/app'));
}

this.composeWith('node:editorconfig', {}, {
local: require.resolve('../editorconfig')
});
this.composeWith(require.resolve('../editorconfig'));

this.composeWith('node:eslint', {
options: {
es2015: this.props.babel
}
}, {
local: require.resolve('../eslint')
this.composeWith(require.resolve('../eslint'), {
es2015: this.props.babel
});

this.composeWith('node:git', {
options: {
name: this.props.name,
githubAccount: this.props.githubAccount
}
}, {
local: require.resolve('../git')
this.composeWith(require.resolve('../git'), {
name: this.props.name,
githubAccount: this.props.githubAccount
});

if (this.options.gulp) {
this.composeWith('node:gulp', {
options: {
coveralls: this.props.includeCoveralls,
babel: this.props.babel,
projectRoot: this.options.projectRoot,
cli: this.options.cli
}
}, {
local: require.resolve('../gulp')
this.composeWith(require.resolve('../gulp'), {
coveralls: this.props.includeCoveralls,
babel: this.props.babel,
projectRoot: this.options.projectRoot,
cli: this.options.cli
});
}

if (this.options.boilerplate) {
this.composeWith('node:boilerplate', {
options: {
name: this.props.name,
babel: this.props.babel
}
}, {
local: require.resolve('../boilerplate')
this.composeWith(require.resolve('../boilerplate'), {
name: this.props.name,
babel: this.props.babel
});
}

if (this.options.cli) {
this.composeWith('node:cli', {
options: {
babel: this.props.babel
}
}, {
local: require.resolve('../cli')
this.composeWith(require.resolve('../cli'), {
babel: this.props.babel
});
}

if (this.options.license && !this.pkg.license) {
this.composeWith('license', {
options: {
name: this.props.authorName,
email: this.props.authorEmail,
website: this.props.authorUrl
}
}, {
local: require.resolve('generator-license/app')
this.composeWith(require.resolve('generator-license/app'), {
name: this.props.authorName,
email: this.props.authorEmail,
website: this.props.authorUrl
});
}

if (!this.fs.exists(this.destinationPath('README.md'))) {
this.composeWith('node:readme', {
options: {
name: this.props.name,
description: this.props.description,
githubAccount: this.props.githubAccount,
authorName: this.props.authorName,
authorUrl: this.props.authorUrl,
coveralls: this.props.includeCoveralls,
content: this.options.readme
}
}, {
local: require.resolve('../readme')
this.composeWith(require.resolve('../readme'), {
name: this.props.name,
description: this.props.description,
githubAccount: this.props.githubAccount,
authorName: this.props.authorName,
authorUrl: this.props.authorUrl,
coveralls: this.props.includeCoveralls,
content: this.options.readme
});
}
},
Expand Down
11 changes: 6 additions & 5 deletions generators/boilerplate/index.js
Original file line number Diff line number Diff line change
@@ -1,26 +1,27 @@
'use strict';
var _ = require('lodash');
var generators = require('yeoman-generator');
var Generator = require('yeoman-generator');

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

this.option('generateInto', {
type: String,
required: false,
defaults: '',
default: '',
desc: 'Relocate the location of the generated files.'
});

this.option('name', {
type: String,
required: true,
desc: 'The new module name.'
});

this.option('babel', {
required: false,
defaults: false,
default: false,
desc: 'Compile ES2015 using Babel'
});
},
Expand Down
6 changes: 3 additions & 3 deletions generators/cli/index.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
'use strict';
var _ = require('lodash');
var extend = _.merge;
var generators = require('yeoman-generator');
var Generator = require('yeoman-generator');

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

this.option('generateInto', {
type: String,
Expand Down
6 changes: 3 additions & 3 deletions generators/editorconfig/index.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
'use strict';
var generators = require('yeoman-generator');
var Generator = require('yeoman-generator');

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

this.option('generateInto', {
type: String,
Expand Down
6 changes: 3 additions & 3 deletions generators/eslint/index.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
'use strict';
var generators = require('yeoman-generator');
var Generator = require('yeoman-generator');
var extend = require('lodash').merge;

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

this.option('generateInto', {
type: String,
Expand Down
6 changes: 3 additions & 3 deletions generators/git/index.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
'use strict';
var generators = require('yeoman-generator');
var Generator = require('yeoman-generator');
var originUrl = require('git-remote-origin-url');

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

this.option('generateInto', {
type: String,
Expand Down
6 changes: 3 additions & 3 deletions generators/gulp/index.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
'use strict';
var path = require('path');
var extend = require('lodash').merge;
var generators = require('yeoman-generator');
var Generator = require('yeoman-generator');

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

this.option('generateInto', {
type: String,
Expand Down
6 changes: 3 additions & 3 deletions generators/readme/index.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
'use strict';
var _ = require('lodash');
var generators = require('yeoman-generator');
var Generator = require('yeoman-generator');

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

this.option('generateInto', {
type: String,
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"inquirer-npm-name": "^2.0.0",
"lodash": "^4.3.0",
"parse-author": "^1.0.0",
"yeoman-generator": "^0.24.1"
"yeoman-generator": "^1.0.1"
},
"devDependencies": {
"eslint": "^3.8.1",
Expand Down
18 changes: 7 additions & 11 deletions test/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,11 @@ describe('node:app', function () {
authorName: 'The Yeoman Team',
authorEmail: 'hi@yeoman.io',
authorUrl: 'http://yeoman.io',
keywords: ['foo', 'bar']
keywords: ['foo', 'bar'],
babel: true
};
return helpers.run(path.join(__dirname, '../generators/app'))
.withPrompts(this.answers)
.toPromise();
.withPrompts(this.answers);
});

it('creates files', function () {
Expand Down Expand Up @@ -108,8 +108,7 @@ describe('node:app', function () {
.on('ready', function (gen) {
gen.fs.writeJSON(gen.destinationPath('package.json'), this.pkg);
gen.fs.write(gen.destinationPath('README.md'), 'foo');
}.bind(this))
.toPromise();
}.bind(this));
});

it('extends package.json keys with missing ones', function () {
Expand All @@ -125,8 +124,7 @@ describe('node:app', function () {
describe('--no-travis', function () {
before(function () {
return helpers.run(path.join(__dirname, '../generators/app'))
.withOptions({travis: false})
.toPromise();
.withOptions({travis: false});
});

it('skip .travis.yml', function () {
Expand All @@ -137,8 +135,7 @@ describe('node:app', function () {
describe('--no-babel', function () {
before(function () {
return helpers.run(path.join(__dirname, '../generators/app'))
.withOptions({babel: false})
.toPromise();
.withOptions({babel: false});
});

it('skip .bablerc', function () {
Expand All @@ -156,8 +153,7 @@ describe('node:app', function () {
describe('--projectRoot', function () {
before(function () {
return helpers.run(path.join(__dirname, '../generators/app'))
.withOptions({projectRoot: 'generators', babel: false})
.toPromise();
.withOptions({projectRoot: 'generators', babel: false});
});

it('include the raw files', function () {
Expand Down

0 comments on commit 7ec1c65

Please sign in to comment.