-
Notifications
You must be signed in to change notification settings - Fork 31
/
Jakefile
186 lines (152 loc) · 5.22 KB
/
Jakefile
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
var DOC_DIR = __dirname + '/doc/jsdoc/';
var LIB_DIR = __dirname + '/lib/';
var DIST_DIR = __dirname + '/dist/';
var JsDoc3_CONF = __dirname + '/doc/JsDocConf.json';
var JsDoc3_EXEC = __dirname + '/doc/jsdoc3/jsdoc';
var UI_FILES = {
mainline : {
conf : __dirname + '/apps/mainline/conf.json',
index : __dirname + '/apps/mainline/index.html',
app : __dirname + '/apps/mainline/app.js'
},
udp : {
conf : __dirname + '/apps/udp/conf.json',
index : __dirname + '/apps/udp/index.html',
app : __dirname + '/apps/udp/app.js'
},
xmpp : {
conf : __dirname + '/apps/xmpp/conf.json',
index : __dirname + '/apps/xmpp/index.html',
app : __dirname + '/apps/xmpp/app.js'
},
boilerplate : {
app : __dirname + '/apps/boilerplate/app.js'
}
};
var FS = require('fs');
var PATH = require('path');
var PROC = require('child_process');
var COLORS = require('colors');
var UI = require(__dirname + '/UI/generator');
// ------------ DEFAULT ------------
desc('Say Hello to Kadoh');
task('default', [], function() {
var logo =
' \n' +
' _/ _/ _/ _/_/ _/ _/ \n' +
' _/ _/ _/_/_/ _/_/_/ _/ _/ _/ _/ \n' +
' _/_/ _/ _/ _/ _/ _/ _/ _/_/_/_/ \n' +
' _/ _/ _/ _/ _/ _/ _/ _/ _/ _/ \n' +
' _/ _/ _/_/_/ _/_/_/ _/_/ _/ _/ \n' +
' ';
console.log(logo.yellow);
});
// ------------ TESTS ------------
namespace('test', function() {
desc('Testing in node');
task('node', ['default'], function(reporter) {
reporter = reporter || 'dot'
var mocha = PROC.spawn('mocha', ['--colors', '--reporter', reporter]);
mocha.stdout.pipe(process.stdout, { end: false });
mocha.stderr.pipe(process.stderr, { end: false });
}, true);
desc('Testing in the browser');
task('browser', ['default'], function() {
jake.Task['build:test'].execute();
var jasmine = require('jasmine-runner');
jasmine.run({
command : 'mon' ,
cwd : __dirname ,
args : []
});
});
});
// ------------ DOC ------------
desc('Generate documentation using JsDoc3');
task('doc', ['default'], function(){
console.log('[Doc] Purging the doc folder');
var rm = 'rm -rf '+DOC_DIR;
console.log(rm);
PROC.exec(rm, function (error, stdout, stderr) {
console.log('[Doc] ' + stdout);
console.error('[Doc] Error :' + stderr);
if (error !== null) {
console.error('[Doc] Error : ' + error);
}
});
console.log('[Doc] Generating documentation..');
var cmd = JsDoc3_EXEC+' --recurse '+LIB_DIR +' --destination '+DOC_DIR +' -c '+JsDoc3_CONF;
console.log(cmd);
PROC.exec(cmd, function (error, stdout, stderr) {
console.log('[Doc] ' + stdout);
console.error('[Doc] Error :' + stderr);
if (error !== null) {
console.error('[Doc] Error : ' + error);
}
});
});
// ------------ BUILD ------------
var checked = ' done ✓'.green + '\n';
desc('Building and minifing the embedded code');
task('build', ['default'], function() {
jake.Task['build:xmpp'].execute();
jake.Task['build:simudp'].execute();
});
namespace('build', function() {
function build(type, debug) {
return function() {
var browserify = require('browserify');
var tagify = require('tagify');
process.stdout.write('Building '+type);
var build = browserify({debug : debug});
build.use(tagify.flags([type, 'lawnchair']));
build.addEntry(LIB_DIR+'index-browserify.js');
fs.writeFileSync(
DIST_DIR+'KadOH.'+type+'.js',
build.bundle()
);
process.stdout.write(checked);
};
}
desc('Building the brower-side code with xmpp configuration');
task('xmpp', ['default'], build('xmpp', false));
desc('Building the brower-side code with simudp configuration');
task('simudp', ['default'], build('simudp', false));
});
// ------------ UI GENERATE ------------
namespace('generate', function() {
function generate(type) {
return function() {
process.stdout.write('Creating '+type+' UI');
fs.writeFileSync(
UI_FILES[type].index,
UI.generate(UI_FILES[type].conf)
);
process.stdout.write(checked);
}
}
desc('Generate the mainline proxy app UI');
task('mainline', ['default'], generate('mainline'));
desc('Generate the udp proxy app UI');
task('udp', ['default'], generate('udp'));
desc('Generate the xmpp app UI');
task('xmpp', ['default'], generate('xmpp'));
});
// ------------ RUN SERVER ------------
namespace('run', function() {
function run(type) {
return function(port) {
port = parseInt(port, 10) || 8080 ;
require(UI_FILES[type].app).server.listen(port);
console.log('Server running on http://localhost:'+port);
}
}
desc('Run the mainline proxy app server');
task('mainline', ['generate:mainline'], run('mainline'));
desc('Run the udp proxy app server');
task('udp', ['generate:udp'], run('udp'));
desc('Run the xmpp app server');
task('xmpp', ['generate:xmpp'], run('xmpp'));
desc('Run the boilerplate app server');
task('boilerplate', run('boilerplate'));
});