Skip to content
Newer
Older
100644 222 lines (190 sloc) 7.64 KB
0b1a192 @assaf Started using Docco for documentation.
authored Dec 14, 2010
1 fs = require("fs")
2 path = require("path")
3 {spawn, exec} = require("child_process")
39a12a8 @assaf Removed CoffeeScript from runtime dependencies.
authored Dec 22, 2010
4 stdout = process.stdout
0b1a192 @assaf Started using Docco for documentation.
authored Dec 14, 2010
5
20f5cc9 @assaf Now using npm bundle to manage runtime/dev dependencies when working …
authored Jan 1, 2011
6 # Use executables installed with npm bundle.
7 process.env["PATH"] = "node_modules/.bin:#{process.env["PATH"]}"
8
0b1a192 @assaf Started using Docco for documentation.
authored Dec 14, 2010
9 # ANSI Terminal Colors.
10 bold = "\033[0;1m"
11 red = "\033[0;31m"
12 green = "\033[0;32m"
13 reset = "\033[0m"
14
15 # Log a message with a color.
16 log = (message, color, explanation) ->
17 console.log color + message + reset + ' ' + (explanation or '')
18
200f4f3 @assaf Brought back callback in runTests but fixed cake test to show vows
authored Jan 8, 2011
19 # Handle error and kill the process.
e05c3f6 @assaf Fixed lack of JavaScript source code: CoffeeScript moved to src,
authored Dec 21, 2010
20 onerror = (err)->
21 if err
39a12a8 @assaf Removed CoffeeScript from runtime dependencies.
authored Dec 23, 2010
22 process.stdout.write "#{red}#{err.stack}#{reset}\n"
20f5cc9 @assaf Now using npm bundle to manage runtime/dev dependencies when working …
authored Jan 1, 2011
23 process.exit -1
2f9b7ee @assaf First NPM release.
authored Dec 21, 2010
24
25
e05c3f6 @assaf Fixed lack of JavaScript source code: CoffeeScript moved to src,
authored Dec 22, 2010
26 ## Setup ##
2f9b7ee @assaf First NPM release.
authored Dec 21, 2010
27
28 # Setup development dependencies, not part of runtime dependencies.
29 task "setup", "Install development dependencies", ->
30 fs.readFile "package.json", "utf8", (err, package)->
6943caa @assaf Fixed cak setup to install all dependencies one by one and sequentially.
authored Aug 3, 2011
31 install = (dependencies, callback)->
32 if dep = dependencies.shift()
33 [name, version] = dep
34 log "Installing #{name} #{version}", green
35 exec "npm install \"#{name}@#{version}\"", (err)->
36 if err
37 onerror err
38 else
39 install dependencies, callback
40 else if callback
41 callback()
20f5cc9 @assaf Now using npm bundle to manage runtime/dev dependencies when working …
authored Jan 1, 2011
42
6943caa @assaf Fixed cak setup to install all dependencies one by one and sequentially.
authored Aug 4, 2011
43 json = JSON.parse(package)
44 log "Need runtime dependencies, installing into node_modules ...", green
45 dependencies = []
46 dependencies.push [name, version] for name, version of json.dependencies
47 install dependencies, ->
48 log "Need development dependencies, installing ...", green
49 dependencies = []
50 dependencies.push [name, version] for name, version of json.devDependencies
51 install dependencies
e05c3f6 @assaf Fixed lack of JavaScript source code: CoffeeScript moved to src,
authored Dec 22, 2010
52
32c3860 @assaf Added cake install
authored Feb 10, 2011
53 task "install", "Install Zombie in your local repository", ->
3aeae31 @assaf Browser.visit returns but no longer fails on errors.
authored Nov 18, 2011
54 generateMan (err)->
32c3860 @assaf Added cake install
authored Feb 11, 2011
55 onerror err
3aeae31 @assaf Browser.visit returns but no longer fails on errors.
authored Nov 18, 2011
56 log "Installing Zombie ...", green
57 exec "npm install", (err, stdout, stderr)->
58 process.stdout.write stderr
32c3860 @assaf Added cake install
authored Feb 11, 2011
59 onerror err
60
e05c3f6 @assaf Fixed lack of JavaScript source code: CoffeeScript moved to src,
authored Dec 22, 2010
61
20f5cc9 @assaf Now using npm bundle to manage runtime/dev dependencies when working …
authored Jan 1, 2011
62 clean = (callback)->
b1bfc13 @assaf Less verbose console.log.
authored Nov 19, 2011
63 exec "rm -rf build html man7", callback
20f5cc9 @assaf Now using npm bundle to manage runtime/dev dependencies when working …
authored Jan 1, 2011
64 task "clean", "Remove temporary files and such", -> clean onerror
e05c3f6 @assaf Fixed lack of JavaScript source code: CoffeeScript moved to src,
authored Dec 22, 2010
65
0b1a192 @assaf Started using Docco for documentation.
authored Dec 14, 2010
66
e05c3f6 @assaf Fixed lack of JavaScript source code: CoffeeScript moved to src,
authored Dec 22, 2010
67 ## Testing ##
2f9b7ee @assaf First NPM release.
authored Dec 21, 2010
68
e05c3f6 @assaf Fixed lack of JavaScript source code: CoffeeScript moved to src,
authored Dec 22, 2010
69 runTests = (callback)->
70 log "Running test suite ...", green
4582104 @assaf Express 1.0.7 request parsing under Node 0.3.7 still broken,
authored Feb 9, 2011
71 exec "vows --spec spec/*-spec.coffee", (err, stdout, stderr)->
39a12a8 @assaf Removed CoffeeScript from runtime dependencies.
authored Dec 23, 2010
72 process.stdout.write stdout
f4fb2ce @assaf Added site option allowing you to use visit with a relative path.
authored Nov 18, 2011
73 process.stderr.write stderr
200f4f3 @assaf Brought back callback in runTests but fixed cake test to show vows
authored Jan 9, 2011
74 callback err if callback
75 task "test", "Run all tests", ->
76 runTests (err)->
77 process.stdout.on "drain", -> process.exit -1 if err
e05c3f6 @assaf Fixed lack of JavaScript source code: CoffeeScript moved to src,
authored Dec 22, 2010
78
79
80 ## Documentation ##
2f9b7ee @assaf First NPM release.
authored Dec 21, 2010
81
82 # Markdown to HTML.
2b99178 @assaf Added subtitle to pages, changed tagline.
authored Dec 22, 2010
83 toHTML = (source, callback)->
2f9b7ee @assaf First NPM release.
authored Dec 21, 2010
84 target = "html/#{path.basename(source, ".md").toLowerCase()}.html"
51c0401 @assaf Fixed TOC, PDF header and added require("assert") to examples.
authored Dec 31, 2010
85 fs.readFile "doc/layout/main.html", "utf8", (err, layout)->
92ab434 @assaf Added documentation page for CSS selectors.
authored Dec 28, 2010
86 onerror err
87 fs.readFile source, "utf8", (err, text)->
e05c3f6 @assaf Fixed lack of JavaScript source code: CoffeeScript moved to src,
authored Dec 22, 2010
88 onerror err
92ab434 @assaf Added documentation page for CSS selectors.
authored Dec 28, 2010
89 log "Creating #{target}", green
90 exec "ronn --html #{source}", (err, stdout, stderr)->
e05c3f6 @assaf Fixed lack of JavaScript source code: CoffeeScript moved to src,
authored Dec 22, 2010
91 onerror err
92ab434 @assaf Added documentation page for CSS selectors.
authored Dec 28, 2010
92 [name, title] = stdout.match(/<h1>(.*)<\/h1>/)[1].split(" -- ")
93 name = name.replace(/\(\d\)/, "")
94 body = stdout.replace(/<h1>.*<\/h1>/, "")
95 html = layout.replace("{{body}}", body).replace(/{{title}}/g, title)
96 fs.writeFile target, html, "utf8", (err)->
97 callback err, target
cf1f734 @assaf Smarted Cakefile.
authored Dec 21, 2010
98
99 documentPages = (callback)->
8f851ca @assaf Added troublehsooting guide.
authored Dec 27, 2010
100 files = fs.readdirSync(".").filter((file)-> path.extname(file) == ".md").
101 concat(fs.readdirSync("doc").filter((file)-> path.extname(file) == ".md").map((file)-> "doc/#{file}"))
92ab434 @assaf Added documentation page for CSS selectors.
authored Dec 28, 2010
102 fs.mkdir "html", 0777, ->
103 convert = ->
104 if file = files.pop()
105 toHTML file, (err)->
106 onerror err
107 convert()
108 else
109 process.stdout.write "\n"
110 fs.readFile "html/readme.html", "utf8", (err, html)->
111 html = html.replace(/<h1>(.*)<\/h1>/, "<h1>Zombie.js</h1><b>$1</b>")
112 fs.writeFile "html/index.html", html, "utf8", onerror
113 fs.unlink "html/readme.html", onerror
51c0401 @assaf Fixed TOC, PDF header and added require("assert") to examples.
authored Dec 31, 2010
114 exec "cp -fr doc/css doc/images html/", callback
92ab434 @assaf Added documentation page for CSS selectors.
authored Dec 28, 2010
115 convert()
cf1f734 @assaf Smarted Cakefile.
authored Dec 22, 2010
116
117 documentSource = (callback)->
2f9b7ee @assaf First NPM release.
authored Dec 21, 2010
118 log "Documenting source files ...", green
3aeae31 @assaf Browser.visit returns but no longer fails on errors.
authored Nov 18, 2011
119 exec "docco lib/*.coffee lib/**/*.coffee", (err, stdout, stderr)->
a95a1c9 @assaf Cakefile now reports more of what's going on.
authored Dec 22, 2010
120 log stdout, green
e05c3f6 @assaf Fixed lack of JavaScript source code: CoffeeScript moved to src,
authored Dec 22, 2010
121 onerror err
a95a1c9 @assaf Cakefile now reports more of what's going on.
authored Dec 22, 2010
122 log "Copying to html/source", green
650947c @assaf Fixed documentation link.
authored Dec 21, 2010
123 exec "mkdir -p html && cp -rf docs/ html/source && rm -rf docs", callback
406ed04 @assaf Added doc:readme Cake task.
authored Dec 14, 2010
124
c59ef32 @assaf Fixed documentation link.
authored Dec 21, 2010
125 generateMan = (callback)->
8f851ca @assaf Added troublehsooting guide.
authored Dec 28, 2010
126 files = fs.readdirSync(".").filter((file)-> path.extname(file) == ".md").
127 concat(fs.readdirSync("doc").filter((file)-> path.extname(file) == ".md").map((file)-> "doc/#{file}"))
92ab434 @assaf Added documentation page for CSS selectors.
authored Dec 28, 2010
128 fs.mkdir "man7", 0777, (err)->
8f851ca @assaf Added troublehsooting guide.
authored Dec 28, 2010
129 log "Generating man file ...", green
130 convert = ->
131 if file = files.pop()
92ab434 @assaf Added documentation page for CSS selectors.
authored Dec 28, 2010
132 target = "man7/#{path.basename(file, ".md").toLowerCase()}.7"
8f851ca @assaf Added troublehsooting guide.
authored Dec 28, 2010
133 exec "ronn --roff #{file}", (err, stdout, stderr)->
134 onerror err
135 log "Creating #{target}", green
550bb16 @assaf Fixed the cake.
authored Jan 4, 2011
136 fs.writeFile target, stdout, "utf8", onerror
8f851ca @assaf Added troublehsooting guide.
authored Dec 28, 2010
137 convert()
138 else
92ab434 @assaf Added documentation page for CSS selectors.
authored Dec 28, 2010
139 exec "mv man7/readme.7 man7/zombie.7", onerror
8f851ca @assaf Added troublehsooting guide.
authored Dec 28, 2010
140 process.stdout.write "\n"
550bb16 @assaf Fixed the cake.
authored Jan 4, 2011
141 callback()
8f851ca @assaf Added troublehsooting guide.
authored Dec 28, 2010
142 convert()
c59ef32 @assaf Fixed documentation link.
authored Dec 22, 2010
143
71ad9f8 @assaf Added magical zombie girl and PDF.
authored Dec 30, 2010
144 generatePDF = (callback)->
145 log "Generating PDF documentation ...", green
146 files = "index api selectors troubleshoot".split(" ").map((f)-> "html/#{f}.html")
ca00211 @assaf Trying something else with wkhtmltopdf
authored Nov 2, 2011
147 options = "--disable-javascript --outline --print-media-type --title Zombie.js --header-html doc/layout/header.html --allow doc/images"
8750a5e @assaf Added credits linking to Github contribution page.
authored Jan 12, 2011
148 margins = "--margin-left 30 --margin-right 30 --margin-top 30 --margin-bottom 30 --header-spacing 5"
ca00211 @assaf Trying something else with wkhtmltopdf
authored Nov 2, 2011
149 outline = " --outline --outline-depth 2"
150 toc = "toc --disable-dotted-lines"
151 cover = "cover doc/layout/cover.html"
152 exec "wkhtmltopdf #{options} #{margins} #{cover} #{toc} #{files.join(" ")} html/zombie.pdf", callback
71ad9f8 @assaf Added magical zombie girl and PDF.
authored Dec 30, 2010
153
cf1f734 @assaf Smarted Cakefile.
authored Dec 22, 2010
154 generateDocs = (callback)->
155 log "Generating documentation ...", green
156 documentPages (err)->
e05c3f6 @assaf Fixed lack of JavaScript source code: CoffeeScript moved to src,
authored Dec 22, 2010
157 onerror err
cf1f734 @assaf Smarted Cakefile.
authored Dec 22, 2010
158 documentSource (err)->
e05c3f6 @assaf Fixed lack of JavaScript source code: CoffeeScript moved to src,
authored Dec 22, 2010
159 onerror err
71ad9f8 @assaf Added magical zombie girl and PDF.
authored Dec 30, 2010
160 generatePDF (err)->
161 onerror err
162 generateMan callback
163
2e14582 @assaf Added `querySelector` and `querySelectorAll` based on the [DOM
authored Dec 22, 2010
164 task "doc:pages", "Generate documentation for main pages", -> documentPages onerror
165 task "doc:source", "Generate documentation from source files", -> documentSource onerror
166 task "doc:man", "Generate man pages", -> generateMan onerror
8750a5e @assaf Added credits linking to Github contribution page.
authored Jan 13, 2011
167 task "doc:pdf", "Generate PDF documentation", ->
168 documentPages (err)->
169 onerror err
170 generatePDF onerror
2e14582 @assaf Added `querySelector` and `querySelectorAll` based on the [DOM
authored Dec 22, 2010
171 task "doc", "Generate all documentation", -> generateDocs onerror
0b1a192 @assaf Started using Docco for documentation.
authored Dec 14, 2010
172
2f9b7ee @assaf First NPM release.
authored Dec 21, 2010
173
e05c3f6 @assaf Fixed lack of JavaScript source code: CoffeeScript moved to src,
authored Dec 22, 2010
174 ## Publishing ##
2f9b7ee @assaf First NPM release.
authored Dec 21, 2010
175
cf1f734 @assaf Smarted Cakefile.
authored Dec 22, 2010
176 publishDocs = (callback)->
550bb16 @assaf Fixed the cake.
authored Jan 4, 2011
177 log "Uploading documentation ...", green
178 exec "rsync -chr --del --stats html/ labnotes.org:/var/www/zombie/", (err, stdout, stderr)->
179 log stdout, green
180 callback err
181 task "doc:publish", "Publish documentation to site", ->
9700c7c @assaf Upgraded to HTLM5 0.2.9.
authored Jan 8, 2011
182 documentPages (err)->
183 onerror err
184 documentSource (err)->
185 onerror err
186 generatePDF (err)->
187 onerror err
188 publishDocs onerror
2f9b7ee @assaf First NPM release.
authored Dec 21, 2010
189
190 task "publish", "Publish new version (Git, NPM, site)", ->
e37f031 @assaf Work around npm publish including all files in the current directory.
authored Jan 1, 2011
191 # Run tests, don't publish unless tests pass.
cf1f734 @assaf Smarted Cakefile.
authored Dec 22, 2010
192 runTests (err)->
e05c3f6 @assaf Fixed lack of JavaScript source code: CoffeeScript moved to src,
authored Dec 22, 2010
193 onerror err
e37f031 @assaf Work around npm publish including all files in the current directory.
authored Jan 2, 2011
194 # Clean up temporary files and such, want to create everything from
195 # scratch, don't want generated files we no longer use, etc.
20f5cc9 @assaf Now using npm bundle to manage runtime/dev dependencies when working …
authored Jan 1, 2011
196 clean (err)->
197 onerror err
cffd7ac @assaf Automatically git push on cake publish
authored Feb 17, 2011
198 exec "git push", (err)->
199 onerror err
200 fs.readFile "package.json", "utf8", (err, package)->
201 package = JSON.parse(package)
550bb16 @assaf Fixed the cake.
authored Jan 4, 2011
202
cffd7ac @assaf Automatically git push on cake publish
authored Feb 18, 2011
203 # Publish documentation, need these first to generate man pages,
204 # inclusion on NPM package.
205 generateDocs (err)->
20f5cc9 @assaf Now using npm bundle to manage runtime/dev dependencies when working …
authored Jan 1, 2011
206 onerror err
550bb16 @assaf Fixed the cake.
authored Jan 4, 2011
207
cffd7ac @assaf Automatically git push on cake publish
authored Feb 18, 2011
208 log "Publishing to NPM ...", green
3aeae31 @assaf Browser.visit returns but no longer fails on errors.
authored Nov 18, 2011
209 exec "npm publish", (err, stdout, stderr)->
210 log stdout, green
cffd7ac @assaf Automatically git push on cake publish
authored Feb 18, 2011
211 onerror err
212
3aeae31 @assaf Browser.visit returns but no longer fails on errors.
authored Nov 18, 2011
213 # Create a tag for this version and push changes to Github.
214 log "Tagging v#{package.version} ...", green
215 exec "git tag v#{package.version}", (err, stdout, stderr)->
216 log stdout, green
217 exec "git push --tags origin master", (err, stdout, stderr)->
5b3db2c @assaf Git tag at the very end of cake publish.
authored Feb 17, 2011
218 log stdout, green
219
cffd7ac @assaf Automatically git push on cake publish
authored Feb 18, 2011
220 # We can do this in parallel.
221 publishDocs onerror
Something went wrong with that request. Please try again.