forked from citrix-research/js-signals
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Gruntfile.js
114 lines (105 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
module.exports = function (grunt) {
var props = grunt.file.readJSON('build/build.properties.json');
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
buildnumber: {
package : {}
},
clean: {
dist: [props.dir.dist + '/*'],
'closure-compiler': [props.dir.dist + '/' + props.names.dist_min + '.report.txt']
},
copy: {
main: {
src: props.dir.src + '/wrapper.js',
dest: props.dir.dist + '/' + props.names.dist
}
},
'string-replace': {
main: {
files: [{
src: props.dir.dist + '/' + props.names.dist,
dest: props.dir.dist + '/' + props.names.dist
}],
options: {
replacements: [{
pattern: '//::LICENSE:://',
replacement: grunt.file.read(props.dir.src + '/license.txt')
},
{
pattern: '//::SIGNAL_BINDING_JS:://',
replacement: grunt.file.read(props.dir.src + '/SignalBinding.js')
},
{
pattern: '//::SIGNAL_JS:://',
replacement: grunt.file.read(props.dir.src + '/Signal.js')
},
// version number, build number/date should come after other replaces
{
pattern: new RegExp('::VERSION_NUMBER::', 'gi'), // Replace all ocurrencies
replacement: '<%= pkg.version %>'
},
{
pattern: '::BUILD_NUMBER::',
replacement: '<%= pkg.build %>'
},
{
pattern: '::BUILD_DATE::',
replacement: grunt.template.today("yyyy/mm/dd hh:MM TT")
}]
}
}
},
'closure-compiler': {
frontend: {
closurePath: 'build/closure-compiler',
js: props.dir.dist + '/' + props.names.dist,
jsOutputFile: props.dir.dist + '/' + props.names.dist_min,
options: {
compilation_level: 'SIMPLE_OPTIMIZATIONS',
externs: [
'externs.js'
]
}
}
},
jshint: {
files: [ props.dir.dist + '/' + props.names.dist ]
},
jsdoc : {
dist : {
src: [ props.dir.src + '/Signal*.js' ],
options: {
destination: "<%= pkg.directories.doc %>",
template : "node_modules/grunt-jsdoc/node_modules/ink-docstrap/template",
configure : "node_modules/grunt-jsdoc/node_modules/ink-docstrap/template/jsdoc.conf.json"
}
}
}
});
grunt.loadNpmTasks('grunt-build-number');
grunt.loadNpmTasks('grunt-contrib-clean');
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.loadNpmTasks('grunt-string-replace');
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-closure-compiler');
grunt.loadNpmTasks('grunt-jsdoc');
grunt.registerTask('update-pkg', function(){
grunt.config.set('pkg', grunt.file.readJSON('package.json'));
});
grunt.registerTask('compile-done', function(){
grunt.log.writeln('%s built.', props.names.dist);
});
grunt.registerTask('build-done', function(){
grunt.log.writeln('Build complete.', props.names.dist);
});
grunt.registerTask('compile', function(){
grunt.log.writeln('Building %s..', props.names.dist);
grunt.task.run(['buildnumber', 'update-pkg', 'clean:dist', 'copy:main', 'string-replace:main', 'compile-done']);
});
grunt.registerTask('minify', function(){
grunt.task.run(['closure-compiler', 'clean:closure-compiler']);
});
grunt.registerTask('build', ['compile', 'jshint', 'minify', 'build-done']);
grunt.registerTask('deploy', ['build', 'jsdoc']);
};