forked from Kurento/kurento-utils-js
-
Notifications
You must be signed in to change notification settings - Fork 7
/
Gruntfile.js
227 lines (202 loc) · 5.6 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
/*
* (C) Copyright 2014 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');
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 %>'
},
githooks: {
all: {
'pre-commit': 'jsbeautifier:git-pre-commit'
}
},
// Generate documentation
jsdoc: {
all: {
src: ['package.json', 'README.md', 'lib/**/*.js', 'test/*.js'],
dest: 'doc/jsdoc'
}
},
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", "scripts/*.js"]
},
"git-pre-commit": {
src: ["lib/**/*.js", "*.js", "test/*.js", "scripts/*.js"],
options: {
mode: "VERIFY_ONLY"
}
}
},
// Generate instrumented version for coverage analisis
jscoverage: {
all: {
expand: true,
cwd: 'lib/',
src: ['**/*.js'],
dest: 'lib-cov/'
}
},
jshint: {
all: ['lib/**/*.js', "test/*.js"],
options: {
"curly": true,
"indent": 2,
"unused": true,
"undef": true,
"camelcase": false,
"newcap": true,
"node": true,
"browser": true
}
},
// Generate browser versions and mapping debug file
browserify: {
options: {
transform: ['browserify-optional']
},
require: {
src: 'lib/browser.js',
dest: DIST_DIR + '/<%= pkg.name %>_require.js'
},
standalone: {
src: 'lib/browser.js',
dest: DIST_DIR + '/<%= pkg.name %>.js',
options: {
browserifyOptions: {
standalone: '<%= pkg.name %>'
}
}
},
coverage: {
src: 'lib-cov/browser.js',
dest: DIST_DIR + '/<%= pkg.name %>.cov.js',
options: {
browserifyOptions: {
standalone: '<%= pkg.name %>'
}
}
},
'require minified': {
src: 'lib/browser.js',
dest: DIST_DIR + '/<%= pkg.name %>_require.min.js',
options: {
browserifyOptions: {
debug: true
},
plugin: [
['minifyify', {
compressPath: DIST_DIR,
map: '<%= pkg.name %>.map'
}]
]
}
},
'standalone minified': {
src: 'lib/browser.js',
dest: DIST_DIR + '/<%= pkg.name %>.min.js',
options: {
browserifyOptions: {
debug: true,
standalone: '<%= pkg.name %>'
},
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('&&')
}
}
});
// Load plugins
grunt.loadNpmTasks('grunt-browserify');
grunt.loadNpmTasks('grunt-contrib-clean');
grunt.loadNpmTasks('grunt-githooks');
grunt.loadNpmTasks('grunt-jsbeautifier');
grunt.loadNpmTasks('grunt-jscoverage');
grunt.loadNpmTasks('grunt-jsdoc');
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-npm2bower-sync');
grunt.loadNpmTasks('grunt-shell');
// Alias tasks
grunt.registerTask('default', ['clean', 'jsdoc', 'browserify',
'jsbeautifier:git-pre-commit'
]);
grunt.registerTask('bower', ['sync:bower', 'shell:bower']);
grunt.registerTask('coverage', ['clean:coverage', 'jscoverage',
'browserify:coverage'
]);
};