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

[core] Creating a better Conflicter module #4

Open
SBoudrias opened this issue Aug 19, 2014 · 3 comments
Open

[core] Creating a better Conflicter module #4

SBoudrias opened this issue Aug 19, 2014 · 3 comments
Labels

Comments

@SBoudrias
Copy link
Member

What?

Yeoman uses a conflicter system to protect a user's files from unwanted modification.

Every time Yeoman write to a file inside the destination root, the conflict system kicks in an compare the old file with the new file. If there's line deleted, it will prompt the user and ask for resolution (overwrite, skip, display diff, overwrite this one and all next).

This is a very important part of our system because it secure the user and alert him when there's a risk a generator break something.

Issue

The conflicter system is pretty vital to Yeoman, but it is getting old and rusty. In short, it could be made way better!

Feature

The conflicter should be smarter. Right now each time a line is changed, it'll alert the user. For example, minor line changes (syntax) shouldn't display an alert - for example:

 {
   "files": [
-    "bar"
+    "bar",
+    "foo"
   ]
 }

Next on, the conflicter can throw when handling folders. This would be useful to let a user know a generator is going to overwrite a complete directory via a bulk task.

The system also need a good refactoring to keep clean code. And it would be awesome to be able to extract the conflicter in a standalone npm module that could be reused by other projects.

Any else you feel is missing!

Prior art

Find current module here: https://github.com/yeoman/generator/blob/master/lib/util/conflicter.js

Related issues

@jbnicolai
Copy link

@sindresorhus just tipped me on this issue. I'd be more than happy to take a tab at it!

@SBoudrias
Copy link
Member Author

@jbnicolai Still any interest in making this happens? (The system is very bad and start to hurt the kind of iteration we can made around it)

On a general comments, the general current API from the conflict is horrible. We shouldn't use events to communicate back and forth. I feel promises would make sense in this part of the api. Also, the bundling of conflicts make the API pretty weird (#add(), #resolve()), I don't think the conflicter should bother about ordering - consume data and answer.

Also, there's no good reason why the conflicter should handle user interactions. The conflicter should let you know if there's a conflict or not, what's the diff. Then the core system should consume the information, present to the user and take action. (this also mean we might want to make the conflicter sync as it won't need it to handle user interactions)

@sindresorhus
Copy link
Member

Agreed. The conflicter should be focused at handling conflicts with good hooks.

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

No branches or pull requests

3 participants