-
-
Notifications
You must be signed in to change notification settings - Fork 80
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
Added a check to enforce top-level dependency #290. #292
Added a check to enforce top-level dependency #290. #292
Conversation
index.js
Outdated
@@ -68,6 +68,15 @@ module.exports = { | |||
included: function() { | |||
this._super.included.apply(this, arguments); | |||
|
|||
let isApp = !this.project.isEmberCLIAddon(); | |||
|
|||
let hasEmberFetch = this.project.addons.map(addon => addon.name).includes('ember-fetch'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good, but there is a more concise API that could be used:
project.findAddonByName('ember-fetch')
https://github.com/ember-cli/ember-cli/blob/807f56e2e434f716757de02fd1f2c3251dadaf6f/lib/models/project.js#L634
I noticed this method was listed as private, but it's intent was to be public so I've fixed that:ember-cli/ember-cli#8621
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another approach, would be to do this work in the init()
would be via this.project.dependencies['ember-fetch']
This approach would allow us to disable nested ember-fetch
instances via isEnabled() { }
hook, whereas if isEnabled
returns false, we won't hit the included
hook.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good, but there is a more concise API that could be used:
project.findAddonByName('ember-fetch')
https://github.com/ember-cli/ember-cli/blob/807f56e2e434f716757de02fd1f2c3251dadaf6f/lib/models/project.js#L634I noticed this method was listed as private, but it's intent was to be public so I've fixed that:ember-cli/ember-cli#8621
I made the change to use findAddonByName
API for checking if addon exists. Also, updated the condition to check if the app has ember-cli-fastboot. If that addon exists and ember-fetch is not included throw the error.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another approach, would be to do this work in the
init()
would be viathis.project.dependencies['ember-fetch']
This approach would allow us to disable nested
ember-fetch
instances viaisEnabled() { }
hook, whereas ifisEnabled
returns false, we won't hit theincluded
hook.
I am just wondering, using above approeach and disabling nested fetch can have any side-effects.
@dnalagatla @stefanpenner |
@xg-wang, I agree. I will update the readme to make this the requirement. You are correct this issue is Fastboot specific and if apps are using fastboot, the ember-fetch as nested dependency fails to set up the fetch module. Apps not on fastboot, I think there should not be an issue. @stefanpenner @xg-wang |
776616f
to
11d9d7e
Compare
@dnalagatla Is this PR ready to merge? This requires a major bump that can go together with #348. |
This PR adds a check to enforce top-level dependency requirement for ember-fetch addon.