This repository has been archived by the owner on Aug 28, 2023. It is now read-only.
forked from strophe/strophejs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Gruntfile.js
133 lines (118 loc) · 4.28 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
// Check for the name of the naturaldocs binary
var fs = require('fs');
if (fs.existsSync("/usr/bin/naturaldocs")) {
naturaldocs = "/usr/bin/naturaldocs";
} else if (fs.existsSync("/usr/lib/bin/natural_docs")) {
naturaldocs = "/usr/lib/bin/natural_docs";
} else {
naturaldocs = "NaturalDocs";
}
module.exports = function(grunt){
var pkg = grunt.file.readJSON('package.json');
grunt.initConfig({
pkg: pkg,
clean: {
"prepare-doc": ["<%= natural_docs.docs.inputs[0] %>", "<%= natural_docs.docs.project %>"],
"doc": ["<%= natural_docs.docs.output %>"],
"prepare-release": ["strophejs-<%= pkg.version %>"],
"release": ["strophejs-<%= pkg.version %>.zip", "strophejs-<%= pkg.version %>.tar.gz"],
"js": ["<%= concat.dist.dest %>", "strophe.min.js"]
},
qunit: {
all: {
options: {
urls: [
'http://localhost:8000/tests/strophe.html',
]
}
}
},
concat: {
dist: {
src: ['src/base64.js', "src/sha1.js", "src/md5.js", "src/core.js", "src/bosh.js", "src/websocket.js" ],
dest: '<%= pkg.name %>'
},
options: {
process: function(src){
return src.replace('@VERSION@', pkg.version);
}
}
},
copy: {
"prepare-release": {
files:[
{
expand: true,
src:['<%= concat.dist.dest %>', 'strophe.min.js', 'LICENSE.txt', 'README.txt',
'contrib/**', 'examples/**', 'plugins/**', 'tests/**', 'doc/**'],
dest:"strophejs-<%= pkg.version %>"
}
]
},
"prepare-doc": {
files:[
{
src:['<%= concat.dist.dest %>'],
dest:"<%= natural_docs.docs.inputs[0] %>"
}
]
}
},
jshint: {
files: ['Gruntfile.js', 'src/*.js'],
},
shell: {
tar: {
command: 'tar czf strophejs-<%= pkg.version %>.tar.gz strophejs-<%= pkg.version %>',
options: { failOnError: true }
},
zip: {
command: 'zip -qr strophejs-<%= pkg.version %>.zip strophejs-<%= pkg.version %>',
options: { failOnError: true }
}
},
uglify: {
options: {
banner: '/*! <%= pkg.name %> v<%= pkg.version %> - built on <%= grunt.template.today("dd-mm-yyyy") %> */\n'
},
dist: {
files: { 'strophe.min.js': ['<%= concat.dist.dest %>'] }
}
},
watch: {
files: ['<%= jshint.files %>'],
tasks: ['concat', 'uglify']
},
natural_docs: {
docs: {
bin: naturaldocs,
inputs: [ "doc-tmp/" ],
project: "ndproj",
output: "doc"
},
},
mkdir: {
"prepare-doc": {
options: {
create: ["<%= natural_docs.docs.project %>", "<%= natural_docs.docs.output %>"]
}
},
},
});
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.loadNpmTasks("grunt-contrib-uglify");
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks("grunt-contrib-concat");
grunt.loadNpmTasks("grunt-contrib-clean");
grunt.loadNpmTasks('grunt-shell');
grunt.loadNpmTasks('grunt-natural-docs');
grunt.loadNpmTasks('grunt-mkdir');
grunt.loadNpmTasks('grunt-contrib-qunit');
grunt.registerTask("default", ["jshint", "min"]);
grunt.registerTask("min", ["concat", "uglify"]);
grunt.registerTask("prepare-release", ["copy:prepare-release"]);
grunt.registerTask("doc", ["concat", "copy:prepare-doc", "mkdir:prepare-doc", "natural_docs"]);
grunt.registerTask("release", ["default", "doc", "copy:prepare-release", "shell:tar", "shell:zip"]);
grunt.registerTask("all", ["release", "clean"]);
};