forked from emberjs/data
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
68 lines (53 loc) · 1.86 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
/* jshint node: true */
'use strict';
var path = require('path');
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;
}
var VersionChecker = require('ember-cli-version-checker');
var checker = new VersionChecker(this);
var dep = checker.for('ember-cli-shims', 'bower');
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.');
}
},
blueprintsPath: function() {
return path.join(__dirname, 'blueprints');
},
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'
});
}
}
};