From 446d65f7ebbb6b34a3dc50c24a5d992889d581a1 Mon Sep 17 00:00:00 2001 From: Robert Jackson Date: Mon, 14 Dec 2015 15:39:37 -0500 Subject: [PATCH] [BUGFIX beta] Use `bower` version of ember-data if present. In order to keep backwards compat, we must honor the version of ember-data that is present in `bower.json` (even though it is not needed). This is due to the fact that many people update the `package.json` and `bower.json` versions of Ember Data completely independently. If `bower.json` includes `ember-data` a warning will be issued, and that version will be used. --- index.js | 40 ++++++++++++++++++++++++++++++++++++++++ package.json | 2 +- 2 files changed, 41 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index 38deac39edc..baae5a6815e 100644 --- a/index.js +++ b/index.js @@ -4,10 +4,50 @@ module.exports = { name: 'ember-data', + _warn: function(message) { + var chalk = require('chalk'); + var warning = chalk.yellow('WARNING: ' + message); + + if (this.ui && this.ui.writeWarnLine) { + this.ui.writeWarnLine(message); + } else if (this.ui) { + this.ui.writeLine(warning); + } else { + console.log(warning); + } + }, + + init: function() { + var bowerDeps = this.project.bowerDependencies(); + + 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._forceBowerUsage = true; + } else { + this._forceBowerUsage = false; + } + }, + treeForAddon: function(dir) { + if (this._forceBowerUsage) { + // Fakes an empty broccoli tree + return { inputTree: dir, rebuild: function() { return []; } }; + } + var version = require('./lib/version'); var merge = require('broccoli-merge-trees'); return this._super.treeForAddon.call(this, merge([version(), dir])); + }, + + included: function(app) { + this._super.included.apply(this, arguments); + + if (this._forceBowerUsage) { + this.app.import({ + development: app.bowerDirectory + '/ember-data/ember-data.js', + production: app.bowerDirectory + '/ember-data/ember-data.prod.js' + }); + } } }; diff --git a/package.json b/package.json index f41d413d282..c82c3073dd1 100644 --- a/package.json +++ b/package.json @@ -15,7 +15,6 @@ "bower": "bower install", "production": "ember build --environment=production" }, - "repository": "", "engines": { "node": ">= 0.10.0" }, @@ -24,6 +23,7 @@ "dependencies": { "broccoli-file-creator": "^1.0.0", "broccoli-merge-trees": "^1.0.0", + "chalk": "^1.1.1", "ember-cli-babel": "^5.1.3" }, "devDependencies": {