Skip to content

Commit

Permalink
[BUGFIX beta] fail builds in ember-cli when ember-cli-shims isn't met
Browse files Browse the repository at this point in the history
fixes #4044

(cherry picked from commit 3454fe5)
  • Loading branch information
Stanley Stuart authored and bmac committed Jan 12, 2016
1 parent d22a033 commit ef48cfd
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 9 deletions.
39 changes: 30 additions & 9 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
'use strict';

var path = require('path');
var SilentError = require('silent-error');

module.exports = {
name: 'ember-data',
Expand All @@ -21,21 +22,41 @@ module.exports = {

init: function() {
var bowerDeps = this.project.bowerDependencies();
var VersionChecker = require('ember-cli-version-checker');

var checker = new VersionChecker(this);
var shims = checker.for('ember-cli-shims', 'bower');

var semver = require('semver');
var version = require('./package').version;

if (process.env.EMBER_DATA_SKIP_VERSION_CHECKING_DO_NOT_USE_THIS_ENV_VARIABLE) {
// Skip for node tests as we can't currently override the version of ember-cli-shims
// before the test helpers run.
return;
}

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.');
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;
} else {
this._forceBowerUsage = false;
}

var VersionChecker = require('ember-cli-version-checker');
var emberDataBower = checker.for('ember-data', 'bower');

var checker = new VersionChecker(this);
var dep = checker.for('ember-cli-shims', 'bower');
if (!shims.satisfies('< 0.1.0') && emberDataBower.satisfies('< 2.3.0-beta.3')) {
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.satisfies('>= 0.1.0') && emberDataBower.satisfies('>= 2.3.0-beta.3')) {
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.');
}

if (!dep.satisfies('>= 0.1.0')) {
this._warn('Using a version of ember-cli-shims prior to 0.1.0 will cause errors while loading Ember Data 2.3+. Please update ember-cli-shims from ' + dep.version + ' to 0.1.0.');
} else {
// NPM only, but ember-cli-shims does not match
if (!shims.satisfies('>= 0.1.0') && semver.satisfies(version, '^2.3.0-beta.3')) {
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
2 changes: 2 additions & 0 deletions node-tests/nodetest-runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ var Promise = require('ember-cli/lib/ext/promise');
var rimraf = require('rimraf');
var mochaOnlyDetector = require('mocha-only-detector');

process.env.EMBER_DATA_SKIP_VERSION_CHECKING_DO_NOT_USE_THIS_ENV_VARIABLE = true;

if (process.env.EOLNEWLINE) {
require('os').EOL = '\n';
}
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
"ember-cli-version-checker": "^1.1.4",
"ember-inflector": "^1.9.4",
"inflection": "^1.8.0",
"semver": "^5.1.0",
"silent-error": "^1.0.0"
},
"devDependencies": {
Expand Down

0 comments on commit ef48cfd

Please sign in to comment.