-
Notifications
You must be signed in to change notification settings - Fork 8
/
Gruntfile.js
154 lines (125 loc) · 4.17 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
module.exports = function(grunt) {
'use strict';
// check task runtime
require('time-grunt')(grunt);
// load generic configs
var configs = require('dalek-build-tools');
// set maintainability index lower for large grunt functions
configs.complexity.generic.options.maintainability = 56;
configs.complexity.generic.options.cyclomatic = 15;
configs.complexity.generic.options.halstead = 35;
// 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', 'tasks/*.js', 'test/*.js'],
complexity: ['tasks/*.js'],
test: ['test/*.js'],
src: ['tasks/*.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 - Grunt',
desc: 'DalekJS - Documentation - Grunt',
docs: true
}
},
src: ['tasks/dalekjs.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/grunt-dalek.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/coverage',
'report/complexity',
'report/complexity/files',
'report/complexity/files/tasks',
'report/complexity/files/tasks/dalekjs_js'
],
files: [
'report.history.json',
'files/tasks/report.history.json',
'files/tasks/dalekjs_js/report.history.json'
]
}
},
// prepare files & folders for coverage
prepareCoverage: {
options: {
folders: ['coverage', 'report', 'report/coverage'],
pattern: '[require("fs").realpathSync(__dirname + "/../tasks/dalekjs.js")]'
}
},
// list requires that need to be changed
// for generating a canary build
'release-canary': {
options: {
files: ['tasks/dalekjs.js']
}
},
// archives the docs if a new version appears
archive: {
options: {
file: 'grunt.html'
}
}
});
// 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', 'documantix', 'includereplace', 'concurrent:docs', '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']);
};