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

Refactor blueprint #377

Closed
wants to merge 1 commit into from
Closed

Refactor blueprint #377

wants to merge 1 commit into from

Conversation

MajorBreakfast
Copy link
Contributor

See discussion below.

};

return blueprint.install(cwd, locals, options.dryRun);
Copy link
Contributor

Choose a reason for hiding this comment

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

This change seems to be a step in the wrong direction.

I would prefer to have a blueprint object and a fileinfo object that encapsulates this complexity and clearly explains intent.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It doesn't hold any state?

Copy link
Contributor

Choose a reason for hiding this comment

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

it encapsulates complexity, and maintains the blueprint sessions state.

Churn for the sake of churn really causes a lot of un-needed noise.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

What session state? The blueprint is a folder with a bunch of files. I'd really like to keep it that simple.

I rewrote it because I didn't understand the old version. Isn't it much easier to understand now?

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't believe so.

State includes dependency instances. Entities should not have explicit dependencies on there collaborators, this just becomes unmaintainable. A solution for this is injected a dependency during entity construction. Then these collaborator instances are available at runtime, following this approach continues to decouple our project and also simplify testing.

When fixing something, the smallest amount of refactoring to facilitate the fix is appropriate, or submit a refactoring first.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hmm I don't get it. What dependencies are you talking about. Could you explain this in simpler terms? What do you mean by a collaborator?

My concept:
Tell blueprint task the blueprint folder -> prompts user if there are conflicts -> copies files into cwd

I don't care whether we use this version. Main problems with the old one are:

  • It's output doesn't go through ui all the time Edit: Patched in ui.prompt with inquirer #411
  • It's output is verbose even if --verbose wasn't specified
  • It's code is twice as long and complicated as it needs to be

Copy link
Contributor

Choose a reason for hiding this comment

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

checkout the command refactor to see what i mean by collaborator. As that is finished I'll update the arch doc accordingly.

I believe the code can be improved, but I also believe you have not noticed all the functionality. Such as: Prompting the user each question first, and later batch applying.

Additionally a Blueprint is a "real thing", it has collaborators, it carries the state of the current session. Additionally, we plan to use this constructor for our generators.

I am very fine with improving the current constructs, but not to disembody them.

@MajorBreakfast MajorBreakfast changed the title Refactored blueprint, ui.prompt uses inquirer Refactor blueprint Apr 22, 2014
@MajorBreakfast
Copy link
Contributor Author

#411 now fixes the tests on windows an pimps ui.prompt(). So that's no longer part of this PR. But I still think that the blueprint code needs some love. Before I continue its refactoring, though, I want to discuss it some more first.

#377 (comment) pretty much summarizes of what I think of the current blueprint implementation.

The flow I describe there:

  • Tell blueprint task the blueprint folder
  • Then: Prompt user to resove conflicts
  • Then: Copy files into cwd

I want some convincing comments on why moving all blueprint related stuff into the install-blueprint task isn't sensible. I think that lib/blueprint.js and lib/models/file-info.js are a mess :)

@MajorBreakfast
Copy link
Contributor Author

I'm closing this.

We plan to unify generators with the blueprint. The blueprint we have now would then only become another generator. #351

@MajorBreakfast MajorBreakfast deleted the blueprint branch May 1, 2014 07:54
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

2 participants