-
Notifications
You must be signed in to change notification settings - Fork 7
/
Gruntfile.js
147 lines (120 loc) · 3.82 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
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', 'test/*.js'],
complexity: ['index.js', 'test/*.js'],
test: ['test/*.js'],
src: ['index.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(),
// up version, tag & commit
bump: configs.bump({
pushTo: '[email protected]:dalekjs/dalek-cli.git',
files: ['package.json', 'CONTRIBUTORS.md', 'CHANGELOG.md']
}),
// generate contributors file
contributors: configs.contributors,
// 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 - Cli',
desc: 'DalekJS - Documentation - Cli',
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: './'
}
},
// 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/index_js'
],
files: [
'report.history.json',
'files/index_js/report.history.json',
'files/index_js/report.history.json'
]
}
},
// prepare files & folders for coverage
prepareCoverage: {
options: {
folders: ['coverage', 'report', 'report/coverage'],
pattern: '[require("fs").realpathSync(__dirname + "/../index.js")]'
}
},
// archive docs
archive: {
options: {
files: ['cli.html']
}
},
// release canary version
'release-canary': {
options: {
files: []
}
}
});
// load 3rd party tasks
require('load-grunt-tasks')(grunt);
grunt.loadTasks('./node_modules/dalek-build-tools/tasks');
grunt.loadNpmTasks('grunt-documantix');
// 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']);
};