forked from pouchdb-community/ember-pouch
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
81 lines (66 loc) · 2.61 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
69
70
71
72
73
74
75
76
77
78
79
80
81
/* eslint-env node */
'use strict';
var path = require('path');
var stew = require('broccoli-stew');
var writeFile = require('broccoli-file-creator');
var version = require('./package.json').version;
module.exports = {
name: 'ember-pouch',
init: function() {
this._super.init && this._super.init.apply(this, arguments);
var bowerDeps = this.project.bowerDependencies();
if (bowerDeps['pouchdb']) {this.ui.writeWarnLine('Please remove `pouchdb` from `bower.json`. As of ember-pouch 4.2.0, only the NPM package is needed.');}
if (bowerDeps['relational-pouch']) {this.ui.writeWarnLine('Please remove `relational-pouch` from `bower.json`. As of ember-pouch 4.2.0, only the NPM package is needed.');}
if (bowerDeps['pouchdb-find']) {this.ui.writeWarnLine('Please remove `pouchdb-find` from `bower.json`. As of ember-pouch 4.2.0, only the NPM package is needed.');}
},
treeForVendor: function() {
var pouchdb = stew.find(path.join(path.dirname(require.resolve('pouchdb')), '..', 'dist'), {
destDir: 'pouchdb',
files: ['pouchdb.js']
});
var relationalPouch = stew.find(path.join(path.dirname(require.resolve('relational-pouch')), '..', 'dist'), {
destDir: 'pouchdb',
files: ['pouchdb.relational-pouch.js']
});
var pouchdbFind = stew.find(path.join(path.dirname(require.resolve('pouchdb')), '..', 'dist'), {
destDir: 'pouchdb',
files: ['pouchdb.find.js']
});
var shims = stew.find(__dirname + '/vendor/pouchdb', {
destDir: 'pouchdb',
files: ['shims.js']
});
var content = "Ember.libraries.register('Ember Pouch', '" + version + "');";
var registerVersionTree = writeFile(
'ember-pouch/register-version.js',
content
);
return stew.find([
pouchdb,
relationalPouch,
pouchdbFind,
shims,
registerVersionTree
]);
},
included(app) {
this._super.included.apply(this, arguments);
// see: https://github.com/ember-cli/ember-cli/issues/3718
if (typeof app.import !== 'function' && app.app) {
app = app.app;
}
app.import('vendor/pouchdb/pouchdb.js');
app.import('vendor/pouchdb/pouchdb.relational-pouch.js');
app.import('vendor/pouchdb/pouchdb.find.js');
app.import('vendor/pouchdb/shims.js', {
exports: { 'pouchdb': [ 'default' ]}
});
app.import('vendor/ember-pouch/register-version.js');
let env = this.project.config(app.env);
if (env.emberpouch) {
if (env.emberpouch.hasOwnProperty('dontsavehasmany')) {
this.ui.writeWarnLine('The `dontsavehasmany` flag is no longer needed in `config/environment.js`');
}
}
}
};