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

Prettier runs too late and causes conflicts during re-generation #7172

Closed
gmarziou opened this issue Feb 25, 2018 · 8 comments
Closed

Prettier runs too late and causes conflicts during re-generation #7172

gmarziou opened this issue Feb 25, 2018 · 8 comments
Assignees
Projects
Milestone

Comments

@gmarziou
Copy link
Contributor

Currently, prettier runs after code generation.

Due to this, when re-generating an entity or an app, yeoman shows many conflicts (~25% of generated files) only due to reformatting that runs later.

I don't know enough yeoman to say whether it is easy to run prettier after template rendering and before yeoman compares file contents.

@gmarziou gmarziou added the v5 label Feb 25, 2018
@deepu105
Copy link
Member

I was also thinking about doing that and I guess it should be possible using the yeoman pipe feature. I'll look into this later

@gmarziou
Copy link
Contributor Author

gmarziou commented Mar 9, 2018

I have something starting to work by using yeoman registerTransformStream(), for now it only uses default settings, I must pass it our configuration

gmarziou@b88051b

@gmarziou gmarziou self-assigned this Mar 9, 2018
@deepu105
Copy link
Member

deepu105 commented Mar 9, 2018 via email

@deepu105 deepu105 added this to In progress in JHipster 5 Mar 9, 2018
@gmarziou
Copy link
Contributor Author

gmarziou commented Mar 9, 2018

Yes I used gulp-filter, I also used gulp-prettier but I had to modify its code a little so finally I rewrote it as a short inner function

@gmarziou
Copy link
Contributor Author

gmarziou commented Mar 9, 2018

@deepu105 there's a bootstrap issue here: .prettierrc is generated from an EJS template, so on first generation it does not exist yet and on next generations it exists but could have been customized by user with merge conflicts.

I don't know what I could do with yeoman's in-memory filesystem.

A simple approach could be to define our .prettierrc file as a plain file not a template and that user's configuration file is ignored during generation.

@gmarziou
Copy link
Contributor Author

gmarziou commented Mar 9, 2018

I could not find a way to specify a configuration file path through API so I may do the reverse: defining options in a variable and generating the .prettierrc file from it.

@deepu105
Copy link
Member

deepu105 commented Mar 9, 2018 via email

@gmarziou
Copy link
Contributor Author

gmarziou commented Mar 9, 2018

Here it is, I added it only to app generator.

JHipster 5 automation moved this from In progress to Done Mar 11, 2018
@jdubois jdubois added this to the 5.0.0-beta.0 milestone Apr 3, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
JHipster 5
  
Done
Development

No branches or pull requests

3 participants