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 the detection / warnings around ember-cli-shims. #4860

Merged
merged 1 commit into from
Mar 14, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,25 +58,30 @@ module.exports = {
return;
}

var hasShims = !!shims;
var shimsHasEmberDataShims = hasShims && shims.satisfies('< 0.1.0');
var emberDataNPMWithShimsIncluded = semver.satisfies(version, '^2.3.0-beta.3');

if (bowerDeps['ember-data']) {
this._warn('Please remove `ember-data` from `bower.json`. As of Ember Data 2.3.0, only the NPM package is needed. If you need an ' +
'earlier version of ember-data (< 2.3.0), you can leave this unchanged for now, but we strongly suggest you upgrade your version of Ember Data ' +
'as soon as possible.');
this._forceBowerUsage = true;

var emberDataBower = checker.for('ember-data', 'bower');
var emberDataBowerWithShimsIncluded = emberDataBower.satisifies('>= 2.3.0-beta.3');

if (shims && shims.version && !shims.satisfies('< 0.1.0') && emberDataBower.satisfies('< 2.3.0-beta.3')) {
if (hasShims && !shimsHasEmberDataShims && !emberDataBowerWithShimsIncluded) {
throw new SilentError('Using a version of ember-cli-shims greater than or equal to 0.1.0 will cause errors while loading Ember Data < 2.3.0-beta.3 Please update ember-cli-shims from ' + shims.version + ' to 0.0.6');
}

if (shims && shims.version && !shims.satisfies('>= 0.1.0') && emberDataBower.satisfies('>= 2.3.0-beta.3')) {
if (hasShims && shimsHasEmberDataShims && !emberDataBowerWithShimsIncluded) {
throw new SilentError('Using a version of ember-cli-shims prior to 0.1.0 will cause errors while loading Ember Data 2.3.0-beta.3+. Please update ember-cli-shims from ' + shims.version + ' to 0.1.0.');
}

} else {
// NPM only, but ember-cli-shims does not match
if (shims && shims.version && !shims.satisfies('>= 0.1.0') && semver.satisfies(version, '^2.3.0-beta.3')) {
if (hasShims && shimsHasEmberDataShims && emberDataNPMWithShimsIncluded) {
throw new SilentError('Using a version of ember-cli-shims prior to 0.1.0 will cause errors while loading Ember Data 2.3.0-beta.3+. Please update ember-cli-shims from ' + shims.version + ' to 0.1.0.');
}
}
Expand Down