-
Notifications
You must be signed in to change notification settings - Fork 1
/
Gruntfile.js
232 lines (211 loc) · 6.43 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
'use strict';
//var path = require('path');
module.exports = function (grunt) {
var path = require('path');
/**
* Gets the index.html file from the code coverage folder.
*
* @param {!string} folder The path to the code coverage folder.
*/
function getCoverageReport (folder) {
var reports = grunt.file.expand(folder + '*/index.html');
if (reports && reports.length > 0) {
return reports[0];
}
return '';
}
// Load grunt tasks automatically
require('load-grunt-tasks')(grunt);
// Time how long tasks take. Can help when optimizing build times
require('time-grunt')(grunt);
// Project configuration.
grunt.initConfig({
src: {
jshint: {
files: [
'modules/**/*.js',
'Gruntfile.js',
'!modules/**/*.tpl.js'
]
},
bowerrc: grunt.file.readJSON('.bowerrc'),
tmpMod: '.tmp/modules'
},
// Empties folders to start fresh
clean: {
coverage: '.reports/coverage',
test: '.reports/test',
jshint: '.reports/jshint',
bower: ['<%= src.bowerrc.directory %>'],
node_modules: ['node_modules'],
docs: ['.dist/docs']
},
open: {
coverage: {
path: function () {
return path.join(__dirname, getCoverageReport('.reports/coverage/'));
}
}
},
// Make sure code styles are up to par and there are no obvious mistakes
jshint: {
options: {
jshintrc: true,
reporter: require('jshint-stylish')
},
test: {
src: '<%= src.jshint.files %>'
},
jslint: {
options: {
reporter: 'jslint',
reporterOutput: '.reports/lint/jshint.xml'
},
files: {
src: '<%= src.jshint.files %>'
}
},
checkstyle: {
options: {
reporter: 'checkstyle',
reporterOutput: '.reports/lint/jshint_checkstyle.xml'
},
files: {
src: '<%= src.jshint.files %>'
}
}
},
html2js: {
modules: {
options: {
module: null, // no bundle module for all the html2js templates
base: 'modules'
},
files: [
{
expand: true,
cwd: 'modules/',
src: ['**/*.html'],
ext: '.tpl.js',
dest: 'modules/'
}
]
}
},
karma: {
unit: {
configFile: 'test/karma.conf.js'
},
chrome: {
configFile: 'test/karma.conf.js',
logLevel: 'DEBUG',
detectBrowsers: {
enabled: false
}
},
ci: {
configFile: 'test/karma.conf.js',
colors: false,
reporters: ['mocha', 'junit'],
junitReporter: {
outputFile: '.reports/tests/baboon-client.xml',
suite: 'baboon_client'
}
},
debug: {
configFile: 'test/karma.conf.js',
singleRun: false,
detectBrowsers: {
enabled: false
}
},
coverage: {
configFile: 'test/karma.coverage.conf.js',
colors: false
},
cobertura: {
configFile: 'test/karma.coverage.conf.js',
colors: false,
coverageReporter: {
type: 'cobertura',
dir: '.reports/coverage'
}
}
},
changelog: {
options: {
}
},
bump: {
options: {
files: ['package.json', 'bower.json'],
commitFiles: ['.'],
commitMessage: 'chore: release v%VERSION%',
push: false
}
},
ngdocs: {
options: {
dest: '.dist/docs',
html5Mode: false,
navTemplate: 'docs/html/nav.html',
title: 'baboon client',
image: 'docs/img/baboon.png'
},
api: {
src: ['modules/**/*.js', '!modules/**/*.spec.js', '!modules/**/*.tpl.js', 'docs/content/api/*.ngdoc'],
title: 'API Reference'
}
}
});
grunt.registerTask('move-doc', function () {
grunt.file.copy('./.dist/docs/index.html', 'example/views/doc/index.html');
grunt.file.delete('./.dist/docs/index.html');
});
grunt.registerTask('doc', ['clean:docs', 'ngdocs', 'move-doc']);
grunt.registerTask('git:commitHook', 'Install git commit hook', function () {
grunt.file.copy('validate-commit-msg.js', '.git/hooks/commit-msg');
require('fs').chmodSync('.git/hooks/commit-msg', '0755');
grunt.log.ok('Registered git hook: commit-msg');
});
grunt.registerTask('lint', [
'newer:jshint:test'
]);
grunt.registerTask('build', [
'newer:html2js'
]);
grunt.registerTask('test', [
'git:commitHook',
'build',
'lint',
'karma:unit'
]);
grunt.registerTask('cover', [
'build',
'clean:coverage',
'lint',
'karma:coverage',
'open:coverage'
]);
grunt.registerTask('ci', [
'clean:coverage',
'clean:test',
'clean:jshint',
'html2js',
'jshint:test',
'jshint:checkstyle',
'karma:ci',
'karma:coverage',
'karma:cobertura'
]);
grunt.registerTask('release', 'Bump version, update changelog and tag version', function (version) {
grunt.task.run([
'bump:' + (version || 'patch') + ':bump-only',
'build',
'changelog',
'bump-commit'
]);
});
// Default task.
grunt.registerTask('default', ['test']);
};