Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adapt changes of yeoman generator 1.0.0 #170

Merged
merged 23 commits into from
Dec 9, 2016
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
"extends": "eslint:recommended",
"env": {
"node": true,
"mocha": true
"mocha": true,
"es6": true
},
"rules": {
"array-bracket-spacing": [
Expand Down
52 changes: 23 additions & 29 deletions app/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict';
var path = require('path');
var generators = require('yeoman-generator');
var Generator = require('yeoman-generator');
var askName = require('inquirer-npm-name');
var _ = require('lodash');
var extend = require('deep-extend');
Expand All @@ -12,12 +12,12 @@ function makeGeneratorName(name) {
return name;
}

module.exports = generators.Base.extend({
initializing: function () {
module.exports = class extends Generator {
initializing() {
this.props = {};
},
}

prompting: function () {
prompting() {
return askName({
name: 'name',
message: 'Your generator name',
Expand All @@ -29,9 +29,9 @@ module.exports = generators.Base.extend({
}, this).then(function (props) {
this.props.name = props.name;
}.bind(this));
},
}

default: function () {
default() {
if (path.basename(this.destinationPath()) !== this.props.name) {
this.log(
'Your generator must be inside a folder named ' + this.props.name + '\n' +
Expand All @@ -43,30 +43,24 @@ module.exports = generators.Base.extend({

var readmeTpl = _.template(this.fs.read(this.templatePath('README.md')));

this.composeWith('node:app', {
options: {
babel: false,
boilerplate: false,
name: this.props.name,
projectRoot: 'generators',
skipInstall: this.options.skipInstall,
readme: readmeTpl({
generatorName: this.props.name,
yoName: this.props.name.replace('generator-', '')
})
}
}, {
local: require('generator-node').app
this.composeWith(require.resolve('generator-node/generators/app'), {
babel: false,
boilerplate: false,
name: this.props.name,
projectRoot: 'generators',
skipInstall: this.options.skipInstall,
readme: readmeTpl({
generatorName: this.props.name,
yoName: this.props.name.replace('generator-', '')
})
});

this.composeWith('generator:subgenerator', {
this.composeWith(require.resolve('../subgenerator'), {
arguments: ['app']
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs to be the name of the argument you want to pass in. It's treated the same as an option now.

{namespace: 'app'}

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. Tried that too. Doesn’t work as well :(
Pushed that for you one minute ago.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops. Missed one line. It does work.

}, {
local: require.resolve('../subgenerator')
});
},
}

writing: function () {
writing() {
var pkg = this.fs.readJSON(this.destinationPath('package.json'), {});
extend(pkg, {
dependencies: {
Expand All @@ -83,9 +77,9 @@ module.exports = generators.Base.extend({
pkg.keywords.push('yeoman-generator');

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

install: function () {
install() {
this.installDependencies({bower: false});
}
});
};
38 changes: 19 additions & 19 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,29 +25,29 @@
"node": ">=4.0.0"
},
"dependencies": {
"chalk": "^1.0.0",
"deep-extend": "^0.4.0",
"generator-node": "^1.7.0",
"chalk": "^1.1.3",
"deep-extend": "^0.4.1",
"generator-node": "^1.12.1",
"inquirer-npm-name": "^2.0.0",
"lodash": "^4.6.1",
"lodash": "^4.17.2",
"mkdirp": "^0.5.1",
"superb": "^1.0.0",
"yeoman-generator": "^0.23.3",
"yosay": "^1.0.2"
"superb": "^1.3.0",
"yeoman-generator": "yeoman/generator#bump-version-for-updating-generator-generator",
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to change this when v1.0.0 is released.

"yosay": "^1.2.1"
},
"devDependencies": {
"gulp": "^3.6.0",
"gulp-coveralls": "^0.1.0",
"gulp-eslint": "^2.0.0",
"gulp-exclude-gitignore": "^1.0.0",
"gulp-istanbul": "^0.10.3",
"gulp-mocha": "^2.0.0",
"gulp-nsp": "^2.1.0",
"gulp-plumber": "^1.0.0",
"mocha": "^2.2.5",
"mockery": "^1.4.0",
"yeoman-assert": "^2.0.0",
"yeoman-test": "^1.0.0",
"gulp": "^3.9.1",
"gulp-coveralls": "^0.1.4",
"gulp-eslint": "^3.0.1",
"gulp-exclude-gitignore": "^1.1.1",
"gulp-istanbul": "^1.1.1",
"gulp-mocha": "^3.0.1",
"gulp-nsp": "^2.4.2",
"gulp-plumber": "^1.1.0",
"mocha": "^3.2.0",
"mockery": "^2.0.0",
"yeoman-assert": "^2.2.1",
"yeoman-test": "^1.6.0",
"pinkie-promise": "^2.0.1"
},
"license": "MIT"
Expand Down
22 changes: 11 additions & 11 deletions subgenerator/index.js
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
'use strict';
var path = require('path');
var generators = require('yeoman-generator');
var Generator = require('yeoman-generator');
var superb = require('superb');

module.exports = generators.Base.extend({
constructor: function () {
generators.Base.apply(this, arguments);
module.exports = class extends Generator {
constructor(args, opts) {
super(args, opts);

this.argument('namespace', {
type: String,
required: true,
description: 'Generator namespace'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Old error, but that key as always been desc instead of the full description.

});
},
}

writing: function () {
writing() {
var generatorName = this.fs.readJSON(this.destinationPath('package.json')).name;

this.fs.copyTpl(
this.templatePath('index.js'),
this.destinationPath(path.join('generators', this.namespace, 'index.js')),
this.destinationPath(path.join('generators', this.options.namespace, 'index.js')),
{
// Escape apostrophes from superb to not conflict with JS strings
superb: superb().replace('\'', '\\\''),
Expand All @@ -29,16 +29,16 @@ module.exports = generators.Base.extend({

this.fs.copy(
this.templatePath('templates/**'),
this.destinationPath(path.join('generators', this.namespace, 'templates'))
this.destinationPath(path.join('generators', this.options.namespace, 'templates'))
);

this.fs.copyTpl(
this.templatePath('test.js'),
this.destinationPath('test/' + this.namespace + '.js'),
this.destinationPath('test/' + this.options.namespace + '.js'),
{
namespace: this.namespace,
namespace: this.options.namespace,
generatorName: generatorName
}
);
}
});
};