-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathGruntfile.js
258 lines (241 loc) · 8.37 KB
/
Gruntfile.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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
/*
If you are new to grunt, be sure to examine the list of grunt.
registerTasks at the bottom of the page. Once defined, a
registered tasks can be used within other task definitions.
************************************************
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Most of the grunt tasks (watch/concat/test) rely
on an external file that designates the order in
which to load files. That is located in
client/client-files-config.js.
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
************************************************
When adding a Backbone View that will be extended into other
views, it must be added to goldstone/client/js/ and explicitly
added to karma.conf.js. If it is added into goldstone/client/js/
views it may not be concatenated in the proper order to be
available for extending. Adding it properly to karma.conf.js is
also required to make sure it is loaded into memory for the
headless browser testing.
*/
module.exports = function(grunt) {
// load up all of the necessary grunt plugins
grunt.loadNpmTasks('grunt-casperjs');
grunt.loadNpmTasks('grunt-contrib-clean');
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-contrib-sass');
grunt.loadNpmTasks('grunt-express-server');
grunt.loadNpmTasks('grunt-focus');
grunt.loadNpmTasks('grunt-karma');
grunt.loadNpmTasks('grunt-mocha');
grunt.loadNpmTasks('grunt-notify');
grunt.loadNpmTasks('grunt-po2json');
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
// list of files for concatenation order / watching / linting, etc
var clientIncludeOrder = require('./client/client-files-config.js');
// grunt setup
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
// messages to display as OS X notifications
notify: {
concat_message: {
options: {
message: "Client concat is finished"
}
},
concat_message_lib: {
options: {
message: "Lib concat is finished"
}
},
scss: {
options: {
message: "SASS/CSS compile complete"
}
},
pojson: {
options: {
message: ".po > json conversion complete"
}
},
compliance: {
options: {
message: "Compliance tasks complete"
}
},
topology: {
options: {
message: "Topology tasks complete"
}
}
},
// linting
jshint: {
gruntfile: 'Gruntfile.js',
karmaConfig: 'karma.conf.js',
client: clientIncludeOrder.clientWildcards,
test: [clientIncludeOrder.test, clientIncludeOrder.e2e],
addons: clientIncludeOrder.jshintAddons,
options: {
elision: true
}
},
// karma headless browser unit/integration test runner
karma: {
options: {
configFile: 'karma.conf.js'
},
// Single-run configuration for development
single: {
singleRun: true
}
},
// casperjs headless browser e2e test runner
casperjs: {
options: {},
e2e: {
files: {
'results/casper': clientIncludeOrder.e2e
}
}
},
// transpile sass > css
sass: {
dev: {
options: {
compass: false,
lineNumbers: false,
style: 'compact',
noCache: true
},
files: [{
expand: true,
src: clientIncludeOrder.scssDark,
dest: clientIncludeOrder.cssDark,
ext: '.css'
}, {
expand: true,
src: clientIncludeOrder.scssLight,
dest: clientIncludeOrder.cssLight,
ext: '.css'
}]
}
},
// changes to the designated files kick off tasks as a result
watch: {
client: {
files: clientIncludeOrder.clientWildcards,
tasks: ['c', 'lint']
},
lib: {
files: clientIncludeOrder.lib,
tasks: ['clib']
},
gruntfile: {
files: ['Gruntfile.js', 'karma.conf.js'],
tasks: ['jshint:gruntfile', 'jshint:karmaConfig', 'lint']
},
unitTests: {
files: clientIncludeOrder.testUnit,
tasks: ['lint', 'karma']
},
integrationTests: {
files: clientIncludeOrder.testIntegration,
tasks: ['lint', 'karma']
},
e2eTests: {
files: clientIncludeOrder.e2e,
tasks: ['e']
},
css: {
files: clientIncludeOrder.scssWatch,
tasks: ['scss']
},
po2json: {
files: clientIncludeOrder.poSourceFiles,
tasks: ['pojson']
},
// compliance and topology
addOnModuleTests: {
files: clientIncludeOrder.testAddons,
tasks: ['lint', 'karma']
},
compliance: {
files: clientIncludeOrder.complianceWatch,
tasks: ['concat:compliance', 'notify:compliance']
},
topology: {
files: clientIncludeOrder.topologyWatch,
tasks: ['concat:topology', 'notify:topology']
}
},
// start watch tasks that only observe the specified files
focus: {
dev: {
include: ['unitTests', 'integrationTests', 'client']
},
e2e: {
include: ['e2eTests']
}
},
// configure grunt-concat for JavaScript file combining
concat: {
options: {
separator: ';\n'
},
lib: {
nonull: true,
src: clientIncludeOrder.lib,
dest: clientIncludeOrder.libBundle,
stripBanners: true
},
clientjs: {
nonull: true,
src: clientIncludeOrder.clientWildcards,
dest: clientIncludeOrder.clientBundle
},
compliance: {
nonull: true,
options: {
separator: '\n'
},
src: clientIncludeOrder.complianceConcatWildcards,
dest: clientIncludeOrder.complianceConcatBundle
},
topology: {
nonull: true,
options: {
separator: '\n'
},
src: clientIncludeOrder.topologyConcatWildcards,
dest: clientIncludeOrder.topologyConcatBundle
}
},
// translate files from .po format to a Jed.js compatible json file
po2json: {
options: {
format: 'jed1.x',
singleFile: true
},
all: {
src: [clientIncludeOrder.poSourceFiles],
dest: clientIncludeOrder.poJsonDest
}
}
});
// Start watching and run tests when files change
grunt.registerTask('default', ['lint', 'karma', 'watch']);
grunt.registerTask('c', ['concat:clientjs', 'notify:concat_message']);
grunt.registerTask('casper', ['casperjs:e2e']);
grunt.registerTask('clib', ['concat:lib', 'notify:concat_message_lib']);
grunt.registerTask('e', ['casperjs:e2e']);
grunt.registerTask('lint', ['jshint']);
grunt.registerTask('lintAndTest', ['lint', 'test']);
grunt.registerTask('scss', ['sass:dev', 'notify:scss']);
grunt.registerTask('test', ['karma']);
grunt.registerTask('pojson', ['po2json', 'notify:pojson']);
};