1 | #!/usr/bin/env node
|
2 |
|
3 | /**
|
4 | * Socket.IO client
|
5 | *
|
6 | * @author Guillermo Rauch <guillermo@learnboost.com>
|
7 | * @license The MIT license.
|
8 | * @copyright Copyright (c) 2010 LearnBoost <dev@learnboost.com>
|
9 | */
|
10 |
|
11 | /*
|
12 | * This file will help you take all the Socket.IO client files and build socket.io.js.
|
13 | * You can later use Google Closure Compiler on it.
|
14 | */
|
15 |
|
16 | var fs = require('fs'),
|
17 | io = require('../lib/io'),
|
18 | jsp = require('../lib/vendor/uglifyjs/lib/parse-js'),
|
19 | pro = require("../lib/vendor/uglifyjs/lib/process"),
|
20 | ast,
|
21 | files = [
|
22 | 'io.js',
|
23 | 'util.js',
|
24 | 'events.js',
|
25 | 'json.js',
|
26 | 'parser.js',
|
27 | 'transport.js',
|
28 | 'transports/xhr.js',
|
29 | 'transports/xhr-polling.js',
|
30 | 'transports/jsonp-polling.js',
|
31 | 'transports/websocket.js',
|
32 | 'transports/htmlfile.js',
|
33 | 'namespace.js',
|
34 | 'socket.js'
|
35 | ],
|
36 | content = "/** Socket.IO "+ io.version +" - Built with build.js */\n",
|
37 | license = "/* Socket.IO.min "+ io.version +" @author Guillermo Rauch <guillermo@learnboost.com>, @license The MIT license., @copyright Copyright (c) 2010 LearnBoost <dev@learnboost.com> */\n";
|
38 |
|
39 | console.log('Reading files…');
|
40 |
|
41 | files.forEach(function(file){
|
42 | var path = __dirname + '/../lib/' + file;
|
43 | console.log(' + ' + path);
|
44 | content += fs.readFileSync(path) + "\n";
|
45 | });
|
46 |
|
47 | console.log('Generating…');
|
48 |
|
49 | fs.write(fs.openSync(__dirname + '/../dist/socket.io.js', 'w'), content, 0, 'utf8');
|
50 | console.log(' + ' + __dirname + '/../dist/socket.io.js');
|
51 |
|
52 | console.log('Uglyfying…');
|
53 | ast = jsp.parse(content);
|
54 | ast = pro.ast_mangle(ast); // get a new AST with mangled names
|
55 | ast = pro.ast_squeeze(ast);
|
56 | fs.write(fs.openSync(__dirname + '/../dist/socket.io.min.js', 'w'), license + pro.gen_code(ast), 0, 'utf8');
|
57 | console.log(' + ' + __dirname + '/../dist/socket.io.min.js');
|
58 |
|
59 | console.log('All done!');
|