[bugfix] Allow VersionChecker to work with Projects #51
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There are two main use cases for VersionChecker today:
These use cases are currently intermingled in the VersionChecker API, which causes some confusing behavior:
When passing an Addon to a VersionChecker:
Checking an NPM dependency will check the addon's
package.json
directly, but checking a Bower dependency will check the root Project'sbower.json
. There is no way to check the root Project's NPM dependencies.Attempting to use
forEmber
will attempt to check the Addon's version ofember-source
(which shouldn't exist), and if it is not found will attempt to check the Bower dependencies of the root Project. This forking of behavior is confusing because it correctly detects the version of Ember for users who are still using Bower, but will not for users who switch toember-source
.The "fix" for this is to use
_findHost
to find the root EmberApp and to pass that to VersionChecker instead, but this breaks as described below and is still confusing (why can I even callforEmber
on a VersionChecker for a parent addon when it has this behavior?)When passing a Project to a VersionChecker:
project
property which is a Project.When passing an EmberApp to a VersionChecker:
undefined
root, but will correctly check Bower dependencies. This generally works, but breaks when usingyarn link
because NPM's module resolution defaults to the addon which is using VersionChecker rather than the Project root.This PR proposes that we should clarify the API by enforcing that users explicitly pass the thing they are trying to check the version of, either an Addon or a root Project, to VersionChecker:
We would do this by first allowing VersionChecker to accept a Project directly (as this PR does), adding deprecations, and allowing users to switch over to the new usage style, then creating a new major version.