-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathGruntfile.js
169 lines (164 loc) · 5.64 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
'use strict';
var fs = require('fs');
module.exports = function (grunt) {
// load grunt tasks
require('load-grunt-tasks')(grunt);
// Project configuration.
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
jshint_files_to_test: ['Gruntfile.js', 'lib/**/*.js', 'test/**/*.js'],
banner: '/*!\n' +
' * <%= pkg.title || pkg.name %> - v<%= pkg.version %> - <%= grunt.template.today("yyyy-mm-dd") %>\n' +
'<%= pkg.homepage ? " * " + pkg.homepage + "\\n" : "" %>' +
' *\n' +
' * Copyright (c) <%= grunt.template.today("yyyy") %> <%= pkg.author.name %>\n' +
' * Licensed <%= _.map(pkg.licenses, "type").join(", ") %>\n' +
' */\n\n',
// Before generating any new files, remove any previously-created files.
clean: {
jasmine: ['build/reports/jasmine'],
coverage: ['build/coverage'],
dist: ['dist']
},
concat: {
options: {
stripBanners: true,
banner: '<%= banner %>'
},
dist: {
src: [
'lib/revalidator.js',
'node_modules/async/lib/async.js',
'lib/<%= pkg.name %>.js'
],
dest: '<%= pkg.name %>.js'
}
},
uglify: {
options: {
banner: '<%= banner %>',
sourceMap: true
},
dist: {
src: ['<%= concat.dist.dest %>'],
dest: '<%= pkg.name %>.min.js'
}
},
compress: {
main: {
options: {
mode: 'zip',
archive: 'dist/<%= pkg.name %>.zip'
},
src: ['dist/<%= pkg.name %>.js', 'dist/<%= pkg.name %>.min.js']
}
},
jshint: {
options: {
jshintrc: true
},
test: '<%= jshint_files_to_test %>',
jslint: {
options: {
reporter: 'jslint',
reporterOutput: 'build/reports/jshint.xml'
},
files: {
src: '<%= jshint_files_to_test %>'
}
},
checkstyle: {
options: {
reporter: 'checkstyle',
reporterOutput: 'build/reports/jshint_checkstyle.xml'
},
files: {
src: '<%= jshint_files_to_test %>'
}
}
},
bgShell: {
coverage: {
cmd: 'node node_modules/istanbul/lib/cli.js cover --dir build/coverage node_modules/jasmine/bin/jasmine.js -- JASMINE_CONFIG_PATH=test/jasmine.json'
},
cobertura: {
cmd: 'node node_modules/istanbul/lib/cli.js report --root build/coverage --dir build/coverage/cobertura cobertura'
}
},
open: {
file: {
path: 'build/coverage/lcov-report/index.html'
}
},
jasmine_nodejs: {
options: {
specNameSuffix: 'spec.js', // also accepts an array
reporters: {
console: {
cleanStack: 1,
verbosity: 3,
listStyle: 'indent'
}
}
},
test: {
specs: ['test/**']
},
ci: {
specs: ['test/**'],
options: {
reporters: {
junit: {
savePath: './build/reports/jasmine/'
},
console: {
cleanStack: 1,
verbosity: 3,
listStyle: 'indent',
activity: false
}
}
}
}
},
conventionalChangelog: {
options: {
changelogOpts: {
preset: 'angular'
}
},
release: {
src: 'CHANGELOG.md'
}
},
bump: {
options: {
files: ['package.json', 'bower.json'],
updateConfigs: ['pkg'],
commitFiles: ['-a'],
commitMessage: 'chore: release v%VERSION%',
push: false
}
}
});
// Register tasks.
grunt.registerTask('git:commitHook', 'Install git commit hook', function () {
grunt.file.copy('validate-commit-msg.js', '.git/hooks/commit-msg');
fs.chmodSync('.git/hooks/commit-msg', '0755');
grunt.log.ok('Registered git hook: commit-msg');
});
grunt.registerTask('test', ['git:commitHook', 'clean:jasmine', 'jshint:test', 'jasmine_nodejs:test']);
grunt.registerTask('cover', ['clean:coverage', 'jshint:test', 'bgShell:coverage', 'open']);
grunt.registerTask('build', ['test', 'concat', 'uglify']);
grunt.registerTask('ci', ['clean:coverage', 'clean:jasmine', 'jshint:jslint', 'jshint:checkstyle', 'bgShell:coverage', 'bgShell:cobertura', 'jasmine_nodejs:ci']);
grunt.registerTask('release', 'Bump version, update changelog and tag version', function (version) {
grunt.task.run([
'bump:' + (version || 'patch') + ':bump-only',
'build',
'conventionalChangelog:release',
'bump-commit'
]);
});
// Default task.
grunt.registerTask('default', ['build']);
};