Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 104 lines (82 sloc) 2.871 kb
2cea6ae @josephg Added client stream tests, and fixed many many bugs.
josephg authored
1 {exec} = require 'child_process'
792f7b8 @my8bird Instead of using fixed path to coffee binary add the `node_modules/.b…
my8bird authored
2 fs = require 'fs'
3 path = require 'path'
4 os = require 'os'
2cea6ae @josephg Added client stream tests, and fixed many many bugs.
josephg authored
5
792f7b8 @my8bird Instead of using fixed path to coffee binary add the `node_modules/.b…
my8bird authored
6 # Gain access through PATH to all binaries added by `npm install`
7 npm_bin = path.resolve(path.join('node_modules', '.bin'))
8 path_sep = if os.platform() == 'win32' then ";" else ":"
9 process.env.PATH = "#{npm_bin}#{path_sep}#{process.env.PATH}"
9b60eed @my8bird do not depend on system wide installed coffee. Instead use the one n…
my8bird authored
10
2cea6ae @josephg Added client stream tests, and fixed many many bugs.
josephg authored
11 task 'test', 'Run all tests', ->
972c18c @josephg Updated sharejs to use socket.io 0.8
josephg authored
12 # run directly to get all the delicious output
27c3374 @wmertens Make the tests pass
wmertens authored
13 console.log 'Running tests... (is your webclient up-to-date?)'
972c18c @josephg Updated sharejs to use socket.io 0.8
josephg authored
14 exec 'nodeunit tests.coffee', (err, stdout, stderr) ->
15 throw err if err
2cea6ae @josephg Added client stream tests, and fixed many many bugs.
josephg authored
16
23ead4a @wmertens Only cake webclient is needed; updated webclient
wmertens authored
17 # This is only needed to be able to refer to the line numbers of crashes
2cea6ae @josephg Added client stream tests, and fixed many many bugs.
josephg authored
18 task 'build', 'Build the .js files', (options) ->
59198ee @my8bird Print out a message when building so that we know something did happe…
my8bird authored
19 console.log('Compiling Coffee from src to lib')
792f7b8 @my8bird Instead of using fixed path to coffee binary add the `node_modules/.b…
my8bird authored
20 exec "coffee --compile --bare --output lib/ src/", (err, stdout, stderr) ->
2cea6ae @josephg Added client stream tests, and fixed many many bugs.
josephg authored
21 throw err if err
22 console.log stdout + stderr
23
24 client = [
067329c @josephg Added closure compiler, and made the client build using it.
josephg authored
25 'client/web-prelude'
6eebcbe @josephg Made my own version of microevent in coffee. doc.subscribe -> doc.on …
josephg authored
26 'client/microevent'
b00f19f @josephg Fixed webclient build and fixed examples
josephg authored
27 'types/helpers'
2cea6ae @josephg Added client stream tests, and fixed many many bugs.
josephg authored
28 'types/text'
a33dc2a @josephg Lots of changes, adding a higher level text API for manipulating text…
josephg authored
29 'types/text-api'
a4ea236 @josephg Refactored client, splitting client.coffee out into 3 files
josephg authored
30 'client/doc'
31 'client/connection'
32 'client/index'
2cea6ae @josephg Added client stream tests, and fixed many many bugs.
josephg authored
33 ]
34
67483bc @josephg Added dead simple code to handle text areas in all browsers, O(N) wit…
josephg authored
35 extras = [
36 'client/ace'
0c09744 @espadrine CodeMirror editor: Example page.
espadrine authored
37 'client/cm'
67483bc @josephg Added dead simple code to handle text areas in all browsers, O(N) wit…
josephg authored
38 'client/textarea'
39 ]
40
6eebcbe @josephg Made my own version of microevent in coffee. doc.subscribe -> doc.on …
josephg authored
41 # Backticks
2cea6ae @josephg Added client stream tests, and fixed many many bugs.
josephg authored
42 e = (str, callback) ->
4ad2d16 @josephg Fixed issue #10 related to coffeescript 1.1.0
josephg authored
43 console.log str
2cea6ae @josephg Added client stream tests, and fixed many many bugs.
josephg authored
44 exec str, (err, stdout, stderr) ->
45 throw err if err
6eebcbe @josephg Made my own version of microevent in coffee. doc.subscribe -> doc.on …
josephg authored
46 out = stdout + stderr
47 console.log out if out != ''
2cea6ae @josephg Added client stream tests, and fixed many many bugs.
josephg authored
48 callback() if callback?
49
a4ea236 @josephg Refactored client, splitting client.coffee out into 3 files
josephg authored
50 makeUgly = (infile, outfile) ->
51 # Uglify compile the JS
0a0ca76 @josephg Switched to uglifyjs
josephg authored
52 source = fs.readFileSync infile, 'utf8'
067329c @josephg Added closure compiler, and made the client build using it.
josephg authored
53
0a0ca76 @josephg Switched to uglifyjs
josephg authored
54 {parser, uglify} = require 'uglify-js'
067329c @josephg Added closure compiler, and made the client build using it.
josephg authored
55
0a0ca76 @josephg Switched to uglifyjs
josephg authored
56 opts =
57 defines:
58 WEB: ['name', 'true']
067329c @josephg Added closure compiler, and made the client build using it.
josephg authored
59
0a0ca76 @josephg Switched to uglifyjs
josephg authored
60 ast = parser.parse source
ea68c10 @josephg Added uglify ast_lift_variables step
josephg authored
61 ast = uglify.ast_lift_variables ast
0a0ca76 @josephg Switched to uglifyjs
josephg authored
62 ast = uglify.ast_mangle ast, opts
63 ast = uglify.ast_squeeze ast
64 code = uglify.gen_code ast
067329c @josephg Added closure compiler, and made the client build using it.
josephg authored
65
0a0ca76 @josephg Switched to uglifyjs
josephg authored
66 smaller = Math.round((1 - (code.length / source.length)) * 100)
067329c @josephg Added closure compiler, and made the client build using it.
josephg authored
67
0a0ca76 @josephg Switched to uglifyjs
josephg authored
68 output = outfile
69 fs.writeFileSync output, code
70
a4ea236 @josephg Refactored client, splitting client.coffee out into 3 files
josephg authored
71 console.log "Uglified: #{smaller}% smaller (#{code.length} bytes} written to #{output}"
b09039f @josephg Added compiler warnings via closure
josephg authored
72
73 expandNames = (names) -> ("src/#{c}.coffee" for c in names).join ' '
74
a4ea236 @josephg Refactored client, splitting client.coffee out into 3 files
josephg authored
75 compile = (filenames, dest) ->
b09039f @josephg Added compiler warnings via closure
josephg authored
76 filenames = expandNames filenames
6eebcbe @josephg Made my own version of microevent in coffee. doc.subscribe -> doc.on …
josephg authored
77 # I would really rather do this in pure JS.
792f7b8 @my8bird Instead of using fixed path to coffee binary add the `node_modules/.b…
my8bird authored
78 e "coffee -j #{dest}.uncompressed.js -c #{filenames}", ->
a4ea236 @josephg Refactored client, splitting client.coffee out into 3 files
josephg authored
79 console.log "Uglifying #{dest}"
80 makeUgly "#{dest}.uncompressed.js", "#{dest}.js"
69d45ee @josephg Added separate closure compilation units, and moved the JSON type int…
josephg authored
81
82 buildtype = (name) ->
83 filenames = ['types/web-prelude', "types/#{name}"]
84
85 try
86 fs.statSync "src/types/#{name}-api.coffee"
87 filenames.push "types/#{name}-api"
88
a4ea236 @josephg Refactored client, splitting client.coffee out into 3 files
josephg authored
89 compile filenames, "webclient/#{name}"
69d45ee @josephg Added separate closure compilation units, and moved the JSON type int…
josephg authored
90
b09039f @josephg Added compiler warnings via closure
josephg authored
91 task 'webclient', 'Build the web client into one file', ->
a4ea236 @josephg Refactored client, splitting client.coffee out into 3 files
josephg authored
92 compile client, 'webclient/share'
69d45ee @josephg Added separate closure compilation units, and moved the JSON type int…
josephg authored
93 buildtype 'json'
94 buildtype 'text-tp2'
b09039f @josephg Added compiler warnings via closure
josephg authored
95
ca01cab @josephg Added more stuff to the README.
josephg authored
96 # TODO: This should also be closure compiled.
b09039f @josephg Added compiler warnings via closure
josephg authored
97 extrafiles = expandNames extras
792f7b8 @my8bird Instead of using fixed path to coffee binary add the `node_modules/.b…
my8bird authored
98 e "coffee --compile --output webclient/ #{extrafiles}", ->
082770d @josephg Renamed share-ace.js to ace.js. Fixed bugs share-ace.js
josephg authored
99 # For backwards compatibility. (The ace.js file used to be called share-ace.js)
100 e "cp webclient/ace.js webclient/share-ace.js"
ca01cab @josephg Added more stuff to the README.
josephg authored
101
b09039f @josephg Added compiler warnings via closure
josephg authored
102 #task 'lightwave', ->
103 # buildclosure ['client/web-prelude', 'client/microevent', 'types/text-tp2'], 'lightwave'
Something went wrong with that request. Please try again.