-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathember-cli-build.js
113 lines (98 loc) · 3.77 KB
/
ember-cli-build.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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
/*jshint node:true*/
/* global require, module */
var EmberApp = require('ember-cli/lib/broccoli/ember-app');
var fs = require('fs');
var libxml = require("libxmljs");
var env = require('./config/environment.js')();
function createIfNotExists(directory, callback) {
fs.stat(directory, function(err) {
// Check if error defined and the error code is "not exists"
if (err && err.code === 'ENOENT') {
// Create the directory, call the callback.
fs.mkdir(directory, callback);
} else {
// just in case there was a different error:
callback(err);
}
callback();
});
}
// Update cordova version to match APP.version from config
var cordovaCfgXml = fs.readFileSync("cordova/TEMPLATE-config.xml");
var cordovaCfg = libxml.parseXml(cordovaCfgXml);
cordovaCfg.root().attr("version").value(env.APP.version);
cordovaCfg.get("/n:widget/n:name", { n:"http://www.w3.org/ns/widgets"} ).text(env.APP.name);
cordovaCfg.get("/n:widget/n:description", { n:"http://www.w3.org/ns/widgets"} ).text(env.APP.description);
var author = cordovaCfg.get("/n:widget/n:author", { n:"http://www.w3.org/ns/widgets"});
author.text(env.APP.author.name);
author.attr("email").value(env.APP.author.email);
author.attr("href").value(env.APP.author.website);
fs.writeFileSync("cordova/config.xml", cordovaCfg.toString());
// Create an index of books available at build-time
var booksDir = 'public/content/books';
createIfNotExists(booksDir, () => {
var bookList = fs.readdirSync(booksDir).map(dir => {
var bookDir = `${booksDir}/${dir}`;
if (!fs.statSync(bookDir).isDirectory()) {
// TODO: filter out nulls
return;
}
// TODO: catch exceptions and filter out invalid JSON
return JSON.parse(fs.readFileSync(bookDir + '/book.json'));
}).filter(e => e);
fs.writeFileSync(`${booksDir}/index.json`, JSON.stringify(bookList));
});
module.exports = function(defaults) {
var app = new EmberApp(defaults, {
minifyJS: {
enabled: false
},
minifyCSS: {
enabled: false
},
fingerprint: {
exclude: ['content/courses', 'content/books']
},
jscsOptions: {
enabled: true
},
sassOptions: {
includePaths: [
'bower_components/bootstrap-sass/assets/stylesheets',
'bower_components/bootstrap-material-design/sass'
]
}
});
// var course = new Funnel('bower_components', {
// include: ['funzo-*/**'],
// destDir: 'courses/'
// });
// var books = new Funnel('bower_components', {
// include: ['books/**'],
// destDir: ''
// });
// app.import('bower_components/materialize/dist/css/materialize.css');
app.import('bower_components/tincan/build/tincan.js');
// app.import('bower_components/Materialize/dist/js/materialize.js');
app.import('bower_components/bootstrap/dist/js/bootstrap.js');
app.import('bower_components/bootstrap-material-design/dist/js/material.js');
app.import('bower_components/bootstrap-material-design/dist/js/ripples.js');
app.import('bower_components/h5p-standalone/dist/js/h5p-standalone-main.js');
app.import('bower_components/velocity/velocity.js');
app.import('vendor/aes.js');
// Use `app.import` to add additional libraries to the generated
// output files.
//
// If you need to use different assets in different
// environments, specify an object as the first parameter. That
// object's keys should be the environment name and the values
// should be the asset to use in that environment.
//
// If the library that you are including contains AMD or ES6
// modules that you would like to import into your application
// please specify an object with the list of modules as keys
// along with the exports of each module as its value.
// return app.toTree();
return app.toTree();
// return mergeTrees([app.toTree(), course]);
};