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

ES6, new way to extend YO generator #161

Open
wants to merge 10 commits into
base: master
Choose a base branch
from

Conversation

maustand
Copy link
Collaborator

Hi @diegohaz

This commit has a lots of changes..

I have updated all the dependencies again.
I changed all the generator code to es6 ( changing var to let and consts )
I put eslint and the last but one , i have updated the way that you create yeoman generators because you was using YO 0.24.1 and i updated for the last one..

Please you can review the code the code and do the merge...

Important:

Tests are not working, even running npm test in a fresh clone..

I am trying to fix it... meanwhile you can take a look :

screenshot from 2018-03-13 10-03-44

Regards

Mauricio Stand and others added 5 commits October 24, 2017 19:10
…package.json that it would be

generate for the this generator. This dependencies are working perfect in the project that the generator creates.

.ignore: i added a few files that it should be ignored.

Note:

The next dependencies are breaking the tests and/or it would have to do a few changes in the templetes
for using it because of the new versions have a new approach for use it.
In this way, dont update the next dependencies :

babel-jest
jest-cli
mockgoose
- eslint added to the main project. eslint config file added and removed from the package.json
- main project es6 implemented ( changed vars for consts, let and es6 literal objects and functions )
- Main project tests and generator template were broken because the new version of Yeoman has a different way to extend the generator and spawnCommand was moved to another path.
- blueBird promises removed.. Now we are going to use js native promises.

Note:
Main project tests have been fixed but output tests are broken. Probably it is happening because the dependecies update ( new way to use them, ect .)
Copy link
Owner

@diegohaz diegohaz left a comment

Choose a reason for hiding this comment

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

Thank you very much, @maustand. That's an awesome work.

I made some suggestions on code.

Most of the errors on tests seems to be related to mockgoose. Also, [email protected] has broken some of the mongoose plugins we are using, see diegohaz/mongoose-keywords#12. I think they've fixed it on v5.0.10. Not sure.

const recast = require('recast');
const reservedWords = require('reserved-words');

module.exports = class extends generator {
Copy link
Owner

Choose a reason for hiding this comment

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

Since generator is a class, let's make it capitalized: Generator

this.props.lower = lowerCase(this.props.camel);
this.props.lowers = lowerCase(this.props.camels);
this.props.start = upperFirst(this.props.lower);
this.props.starts = upperFirst(this.props.lowers);
Copy link
Owner

Choose a reason for hiding this comment

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

Does that pass eslint? I don't think we need those alignments.

Copy link
Collaborator Author

@maustand maustand Mar 14, 2018

Choose a reason for hiding this comment

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

we can create our custom rules...
Currently i am using eslint recommend, but we could use another rules about indentation, spaces, ect..

feel free to modify it.

}) : [];
this.props.modelFields.split(',').map((field) => {
return field.trim();
}) : [];
Copy link
Owner

Choose a reason for hiding this comment

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

Shorten:
this.props.modelFields.split(',').map(field => field.trim())

const copyTpl = this.fs.copyTpl.bind(this.fs);
const tPath = this.templatePath.bind(this);
const dPath = this.destinationPath.bind(this);
const filepath = (filename) => {
return path.join(props.dir, props.kebab, filename);
};
Copy link
Owner

Choose a reason for hiding this comment

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

I think we can make it shorter too: filename => path.join(...)

module.exports = yeoman.Base.extend({
prompting: function () {
var that = this;
module.exports = class extends generator {
Copy link
Owner

Choose a reason for hiding this comment

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

Generator

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I changed this.. probably i forgot to do it in this file...

@@ -147,15 +160,15 @@ module.exports = yeoman.Base.extend({
tPath('api/password-reset'),
dPath(props.srcDir + '/' + props.apiDir + '/password-reset'),
props
);
);
Copy link
Owner

Choose a reason for hiding this comment

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

Is that space needed?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

No.

@maustand
Copy link
Collaborator Author

maustand commented Mar 14, 2018

@diegohaz In general i did not modify the code in order to avoid problems.
just i have changed the code in cases that it was impossible to avoid it, just like Yeoman.. becasue they changed the way to extend the generator..

By the way, we should find a way to have the dependencies of the output in a only one place..
Currently we have to update the dependencies of the generator and output as well...
So i updated the generator but i did not do it in the package.json of the output...

So i should change this files in my fork or it is automatic ??

let me know.

@diegohaz
Copy link
Owner

diegohaz commented Mar 14, 2018

@maustand It's not automatic. You should make the changes in your fork.

The package.json problem is really annoying. I'll try to think in another solution. In the meanwhile, we'll still need to update both package.json.

@diegohaz
Copy link
Owner

diegohaz commented Mar 23, 2018

@maustand, I fixed tests on the branch https://github.com/diegohaz/rest/tree/maustand-master (tried to push to your repo, but I guess you've created the PR without allowing changes, so I don't have access. In this case, you need to merge https://github.com/diegohaz/rest.git maustand-master into your local branch and push it).

I needed to downgrade Mongoose and Mockgoose. It seems to not be an easy migration, so let's try to upgrade them alter in another PR.

And, for some reason, coverage reports are empty (for the generator). I'm not sure why. Maybe upgrading some gulp plugin caused this.

@coveralls
Copy link

Coverage Status

Coverage decreased (-100.0%) to 0.0% when pulling efab27d on maustand:master into c190f5d on diegohaz:master.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants