forked from emberjs/list-view
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Brocfile.js
115 lines (97 loc) · 2.82 KB
/
Brocfile.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
114
115
var concat = require('broccoli-concat');
var env = process.env.EMBER_ENV;
var es6 = require('broccoli-es6-module-transpiler');
var jshint = require('broccoli-jshint');
var merge = require('broccoli-merge-trees');
var moveFile = require('broccoli-file-mover');
var wrap = require('broccoli-wrap');
var uglify = require('broccoli-uglify-js');
var es3SafeRecast = require('broccoli-es3-safe-recast');
var pickFiles = require('broccoli-static-compiler');
var version = require('./lib/calculate_version');
var replace = require('broccoli-string-replace');
function testTree(libTree, packageName){
var test = pickFiles('packages/' + packageName + '/tests', {
srcDir: '/',
files: [ '**/*.js' ],
destDir: '/'
});
var jshinted = jshint(libTree);
jshinted = wrap(jshinted, {
wrapper: [ "if (!QUnit.urlParams.nojshint) {\n", "\n}"]
});
return merge([jshinted, test]);
}
var testRunner = pickFiles('tests', {
srcDir: '/',
inputFiles: [ '**/*' ],
destDir: '/'
});
var bower = pickFiles('bower_components', {
srcDir: '/',
inputFiles: [ '**/*' ],
destDir: '/bower_components'
});
var listViewFiles = pickFiles('packages/list-view/lib', {
srcDir: '/',
files: [ '**/*.js' ],
destDir: '/list-view'
});
listViewFiles = es6(listViewFiles, {moduleName: true});
if (env === 'production'){ listViewFiles = es3SafeRecast(listViewFiles); }
var testFiles = testTree(listViewFiles, 'list-view');
var loaderJS = pickFiles('bower_components/loader.js', {
srcDir: '/',
files: [ 'loader.js' ],
destDir: '/'
});
var licenseJS = pickFiles('generators', {
srcDir: '/',
files: [ 'LICENSE' ],
destDir: '/'
});
var globalBuild = concat(merge([listViewFiles, loaderJS]), {
inputFiles: ['loader.js', '**/*.js'],
outputFile: '/list-view.js'
});
globalBuild = wrap(globalBuild, {
wrapper: [ "(function(global){\n", "\n requireModule('list-view/main');\n})(this);"]
});
testFiles = concat(testFiles, {
inputFiles: ['test_helper.js', '**/*.js'],
wrapInEval: true,
wrapInFunction: true,
outputFile: '/tests.js'
});
globalBuild = concat(merge([globalBuild, licenseJS]), {
inputFiles: ['LICENSE', 'list-view.js'],
outputFile: '/list-view.js'
});
//var bowerShimFiles = pickFiles(__dirname, {
// srcDir: '/',
// files: ['bower.json', 'package.json'],
// destDir: '/'
//});
var distTree = merge([
globalBuild,
testFiles,
testRunner,
bower,
//bowerShimFiles
]);
if (env === 'production') {
var uglified = uglify(globalBuild, { mangle: true });
var uglified = concat(merge([uglified, licenseJS]), {
inputFiles: ['LICENSE', 'list-view.js'],
outputFile: '/list-view.min.js'
});
distTree = merge([uglified, distTree]);
}
distTree = replace(distTree, {
files: [ 'list-view.js', 'list-view.min.js' ],
pattern: {
match: /VERSION_STRING_PLACEHOLDER/g,
replacement: version()
}
});
module.exports = distTree;