forked from Kurento/kurento-jsonrpc-js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Gruntfile.js
157 lines (138 loc) · 3.58 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
/*
* (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, 'src'],
generated_doc: '<%= jsdoc.all.dest %>'
},
// Generate documentation
jsdoc:
{
all:
{
src: ['README.md', 'lib/**/*.js', 'test/*.js'],
dest: 'doc/jsdoc'
}
},
// Generate browser versions and mapping debug file
browserify:
{
require:
{
src: '<%= pkg.main %>',
dest: DIST_DIR+'/<%= pkg.name %>_require.js'
},
standalone:
{
src: '<%= pkg.main %>',
dest: DIST_DIR+'/<%= pkg.name %>.js',
options:
{
bundleOptions: {
standalone: 'RpcBuilder'
}
}
},
'require minified':
{
src: '<%= pkg.main %>',
dest: DIST_DIR+'/<%= pkg.name %>_require.min.js',
options:
{
debug: true,
plugin: [
['minifyify',
{
compressPath: DIST_DIR,
map: '<%= pkg.name %>.map'
}]
]
}
},
'standalone minified':
{
src: '<%= pkg.main %>',
dest: DIST_DIR+'/<%= pkg.name %>.min.js',
options:
{
debug: true,
bundleOptions: {
standalone: 'RpcBuilder'
},
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 || [])
}
}
}
},
// 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-jsdoc');
grunt.loadNpmTasks('grunt-npm2bower-sync');
grunt.loadNpmTasks('grunt-shell');
// Alias tasks
grunt.registerTask('default', ['clean', 'jsdoc', 'browserify']);
grunt.registerTask('bower', ['sync:bower', 'shell:bower']);
};