-
Notifications
You must be signed in to change notification settings - Fork 7
/
Gruntfile.js
executable file
·172 lines (144 loc) · 5.04 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
module.exports = function(grunt) {
'use strict';
// check task runtime
require('time-grunt')(grunt);
// load generic configs
var configs = require('dalek-build-tools');
// project config
grunt.initConfig({
// load module meta data
pkg: grunt.file.readJSON('package.json'),
// define a src set of files for other tasks
src: {
lint: ['Gruntfile.js', 'index.js', 'lib/**/*.js', 'test/*.js'],
complexity: ['index.js', 'lib/**/*.js'],
test: ['test/*.js'],
src: ['index.js', 'lib/**/*.js']
},
// clean automatically generated helper files & docs
clean: configs.clean,
// speed up build by defining concurrent tasks
concurrent: configs.concurrent,
// linting
jshint: configs.jshint,
// testing
mochaTest: configs.mocha,
// code metrics
complexity: configs.complexity,
plato: configs.plato(grunt.file.readJSON('.jshintrc')),
// api docs
yuidoc: configs.yuidocs(),
// user docs
documantix: {
options: {
header: 'dalekjs/dalekjs.com/master/assets/header.html',
footer: 'dalekjs/dalekjs.com/master/assets/footer.html',
target: 'report/docs',
vars: {
title: 'DalekJS - Documentation - Driver',
desc: 'DalekJS - Documentation - Driver',
docs: true
}
},
src: ['index.js']
},
// add current timestamp to the html document
includereplace: {
dist: {
options: {
globals: {
timestamp: '<%= grunt.template.today("dddd, mmmm dS, yyyy, h:MM:ss TT") %>'
},
},
src: 'report/docs/*.html',
dest: './'
}
},
// up version, tag & commit
bump: configs.bump({
pushTo: '[email protected]:dalekjs/dalek-driver-native.git',
files: ['package.json', 'CONTRIBUTORS.md', 'CHANGELOG.md']
}),
// generate contributors file
contributors: configs.contributors,
// compress artifacts
compress: configs.compress,
// prepare files for grunt-plato to
// avoid error messages (weird issue...)
preparePlato: {
options: {
folders: [
'coverage',
'report',
'report/complexity',
'report/complexity/files',
'report/complexity/files/test',
'report/complexity/files/index_js',
'report/complexity/files/lib_commands_cookie_js',
'report/complexity/files/lib_commands_element_js',
'report/complexity/files/lib_commands_execute_js',
'report/complexity/files/lib_commands_frame_js',
'report/complexity/files/lib_commands_page_js',
'report/complexity/files/lib_commands_screenshot_js',
'report/complexity/files/lib_commands_window_js',
'report/complexity/files/lib_commands_url_js'
],
files: [
'report.history.json',
'files/report.history.json',
'files/index_js/report.history.json',
'files/lib_commands_cookie_js/report.history.json',
'files/lib_commands_element_js/report.history.json',
'files/lib_commands_execute_js/report.history.json',
'files/lib_commands_frame_js/report.history.json',
'files/lib_commands_page_js/report.history.json',
'files/lib_commands_screenshot_js/report.history.json',
'files/lib_commands_url_js/report.history.json',
'files/lib_commands_window_js/report.history.json'
]
}
},
// prepare files & folders for coverage
prepareCoverage: {
options: {
folders: ['coverage', 'report', 'report/coverage'],
pattern: '[require("fs").realpathSync(__dirname + "/../index.js"), require("fs").realpathSync(__dirname + "/../lib/")]'
}
},
// archive docs
archive: {
options: {
files: ['drivernative.html']
}
},
// release canary version
'release-canary': {
options: {
files: ['index.js']
}
},
watch: {
scripts: {
files: ['lib/**/*.js', 'test/**/*.js'],
tasks: ['lint', 'mochaTest'],
options: {
atBegin: true
}
}
}
});
// load 3rd party tasks
require('load-grunt-tasks')(grunt);
grunt.loadTasks('./node_modules/dalek-build-tools/tasks');
// define runner tasks
grunt.registerTask('lint', 'jshint');
// split test & docs for speed
grunt.registerTask('test', ['clean:coverage', 'prepareCoverage', 'concurrent:test', 'generateCoverageBadge']);
grunt.registerTask('docs', ['clean:reportZip', 'clean:report', 'preparePlato', 'concurrent:docs', 'documantix', 'includereplace', 'compress']);
// release tasks
grunt.registerTask('releasePatch', ['test', 'bump-only:patch', 'contributors', 'changelog', 'bump-commit']);
grunt.registerTask('releaseMinor', ['test', 'bump-only:minor', 'contributors', 'changelog', 'bump-commit']);
grunt.registerTask('releaseMajor', ['test', 'bump-only:major', 'contributors', 'changelog', 'bump-commit']);
// clean, test, generate docs (the CI task)
grunt.registerTask('all', ['clean', 'test', 'docs']);
};