forked from Kurento/kurento-client-js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Gruntfile.js
232 lines (209 loc) · 5.76 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
/*
* (C) Copyright 2014-2015 Kurento (http://kurento.org/)
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the GNU Lesser General Public License
* (LGPL) version 2.1 which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-2.1.html
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
*/
module.exports = function (grunt) {
var DIST_DIR = 'dist';
var pkg = grunt.file.readJSON('package.json');
const PKG_BROWSER = 'lib/browser.js';
var bower = {
TOKEN: process.env.TOKEN,
repository: 'git://github.com/Kurento/<%= pkg.name %>-bower.git'
};
// Project configuration.
grunt.initConfig({
pkg: pkg,
bower: bower,
// Plugins configuration
clean: {
generated_code: DIST_DIR,
coverage: 'lib-cov',
generated_doc: '<%= jsdoc.all.dest %>'
},
// Generate documentation
jsdoc: {
all: {
src: [
'README.md',
'lib/**/*.js',
'node_modules/kurento-client-core/lib/**/*.js',
'node_modules/kurento-client-elements/lib/**/*.js',
'node_modules/kurento-client-filters/lib/**/*.js',
'test/*.js'
],
dest: 'doc/jsdoc'
}
},
// Generate instrumented version for coverage analisis
jscoverage: {
all: {
expand: true,
cwd: 'lib/',
src: ['**/*.js'],
dest: 'lib-cov/'
}
},
// Generate browser versions and mapping debug file
browserify: {
options: {
alias: [
'<%= pkg.main %>:<%= pkg.name %>',
'async',
'es6-promise',
'inherits',
'kurento-client-core',
'kurento-client-elements',
'kurento-client-filters',
'promisecallback'
]
},
coverage: {
src: PKG_BROWSER,
dest: DIST_DIR + '/<%= pkg.name %>.cov.js'
},
'standard': {
src: PKG_BROWSER,
dest: DIST_DIR + '/<%= pkg.name %>.js'
},
'minified': {
src: PKG_BROWSER,
dest: DIST_DIR + '/<%= pkg.name %>.min.js',
options: {
browserifyOptions: {
debug: true
},
plugin: [
['minifyify', {
compressPath: DIST_DIR,
map: '<%= pkg.name %>.map',
output: DIST_DIR + '/<%= pkg.name %>.map'
}]
]
}
}
},
// Generate bower.json file from package.json data
sync: {
bower: {
options: {
sync: [
'name', 'description', 'license', 'keywords', 'homepage',
'repository'
],
overrides: {
authors: (pkg.author ? [pkg.author] : []).concat(pkg.contributors || []),
main: 'js/<%= pkg.name %>.js'
}
}
}
},
// Publish / update package info in Bower
shell: {
bower: {
command: [
'curl -X DELETE "https://bower.herokuapp.com/packages/<%= pkg.name %>?auth_token=<%= bower.TOKEN %>"',
'node_modules/.bin/bower register <%= pkg.name %> <%= bower.repository %>',
'node_modules/.bin/bower cache clean'
].join('&&')
},
'pre-coverage': {
command: [
'rm -rf lib_orig',
'mv lib lib_orig',
'mv lib-cov lib'
].join('&&')
},
'post-coverage': {
command: [
'rm -rf lib',
'mv lib_orig lib'
].join('&&')
}
},
// githooks configuration
githooks: {
all: {
'pre-commit': 'jsbeautifier:git-pre-commit'
}
},
jsbeautifier: {
options: {
js: {
braceStyle: "collapse",
breakChainedMethods: false,
e4x: false,
evalCode: false,
indentChar: " ",
indentLevel: 0,
indentSize: 2,
indentWithTabs: false,
jslintHappy: true,
keepArrayIndentation: false,
keepFunctionIndentation: false,
maxPreserveNewlines: 2,
preserveNewlines: true,
spaceBeforeConditional: true,
spaceInParen: false,
unescapeStrings: false,
wrapLineLength: 80
}
},
"default": {
src: ["lib/**/*.js", "*.js", "test/*.js", "test_reconnect/*.js",
"scripts/*.js"
]
},
"git-pre-commit": {
src: ["lib/**/*.js", "*.js", "test/*.js", "test_reconnect/*.js",
"scripts/*.js"
],
options: {
mode: "VERIFY_ONLY"
}
}
},
jshint: {
all: ['lib/**/*.js', "test/*.js"],
options: {
"curly": true,
"indent": 2,
"unused": true,
"undef": true,
"camelcase": false,
"newcap": true,
"node": true,
"browser": true
}
}
});
// Load plugins
grunt.loadNpmTasks('grunt-browserify');
grunt.loadNpmTasks('grunt-contrib-clean');
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.loadNpmTasks('grunt-jscoverage');
grunt.loadNpmTasks('grunt-jsdoc');
grunt.loadNpmTasks('grunt-npm2bower-sync');
grunt.loadNpmTasks('grunt-shell');
grunt.loadNpmTasks('grunt-githooks');
grunt.loadNpmTasks('grunt-jsbeautifier');
grunt.loadNpmTasks('grunt-contrib-jshint');
// Alias tasks
grunt.registerTask('default', ['clean', 'jsdoc', 'browserify',
'jsbeautifier:git-pre-commit'
]);
grunt.registerTask('bower', ['sync:bower', 'shell:bower']);
grunt.registerTask('coverage', [
'jscoverage',
'shell:pre-coverage', 'browserify:coverage', 'shell:post-coverage'
]);
};