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

[ENHANCEMENT] Prevent addon generation in existing ember-cli project #3433

Merged
merged 1 commit into from
Mar 18, 2015

Conversation

cbrock
Copy link

@cbrock cbrock commented Mar 5, 2015

This fixes #3411.

This commit prevents addon generation if the current project is an existing ember-cli project.

Any thoughts or feedback are welcome.

@rwjblue
Copy link
Member

rwjblue commented Mar 6, 2015

Can you implement normalizeEntityName in the addon blueprint instead? Basically like: https://github.com/ember-cli/ember-cli/blob/master/blueprints/component/index.js#L33-L41

@rwjblue
Copy link
Member

rwjblue commented Mar 8, 2015

@cbrock - Any updates?

@cbrock
Copy link
Author

cbrock commented Mar 9, 2015

@rwjblue I should have time this week to pick this back up and address your comment. I appreciate the feedback - thanks!

@cbrock
Copy link
Author

cbrock commented Mar 12, 2015

@rwjblue I could use a little guidance on your previous comment.

My interpretation is that by implementing normalizeEntityName in the addon blueprint, we would throw if the current project is an ember-cli project, perhaps by importing lib/models/project and using isEmberCLIProject()?

I apologize for my ignorance, but I'm happy to implement the change if you're able to help me understand a bit better.

@cbrock
Copy link
Author

cbrock commented Mar 16, 2015

@rwjblue I'd love to have another go at this. Any chance you could provide some clarification, per my comment above?

@rwjblue
Copy link
Member

rwjblue commented Mar 16, 2015

From the context of a blueprint instance, the project instance is set at this.project here just before normalizeEntityName is called here. That means that you can do something like the following:

normalizeEntityName: function() {
  if (this.project.isEmberCLIProject()) {
    throw new SilentError('You cannot run the addon blueprint from within an `ember-cli` project.');
  }
}

Then, we need to test the blueprints normalizeEntityName method (in a unit test) like the component blueprint tests here.

@cbrock cbrock force-pushed the prevent-addon-in-existing-project branch from 0b768ca to 2bc210a Compare March 17, 2015 04:58
@cbrock
Copy link
Author

cbrock commented Mar 17, 2015

@rwjblue Thanks for pointing me in the right direction.

One thing to note, without actually returning entityName from normalizeEntityName, I was seeing Cannot call method 'replace' of undefined errors in the generate acceptance tests.

Because of that, I added a 'keeps existing behavior by calling Blueprint.normalizeEntityName' test, per the component blueprint test. Let me know if that should be handled differently (or not at all).

Again, thanks for the clarification!

@cbrock cbrock force-pushed the prevent-addon-in-existing-project branch from 2bc210a to 40d53ab Compare March 17, 2015 18:48
@cbrock cbrock force-pushed the prevent-addon-in-existing-project branch from 40d53ab to 715a4e4 Compare March 17, 2015 18:52
@stefanpenner
Copy link
Contributor

@rwjblue r?

@rwjblue
Copy link
Member

rwjblue commented Mar 18, 2015

AWESOME, thank you @cbrock!

rwjblue added a commit that referenced this pull request Mar 18, 2015
[ENHANCEMENT] Prevent addon generation in existing ember-cli project
@rwjblue rwjblue merged commit de07190 into ember-cli:master Mar 18, 2015
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.

Check if creating addon in existing ember-cli project
3 participants