-
Notifications
You must be signed in to change notification settings - Fork 11
/
gulpfile.coffee.unused
195 lines (190 loc) · 6.34 KB
/
gulpfile.coffee.unused
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
187
188
189
190
191
192
193
194
195
fs = require('fs')
path = require('path')
#{spawnSync} = require('child_process')
wrench = require('wrench')
marked = require('marked')
uglify = require("uglify-js")
browserify = require('browserify')
fileify = require('fileify-lm')
gulp = require('gulp')
taskListing = require('gulp-task-listing')
run = require('gulp-run')
Orchestrator = require('orchestrator')
orchestrator = new Orchestrator()
gulp.task 'default', taskListing
gulp.task 'hello-world', ->
run('echo Hello World').exec()
gulp.task 'cdn', ->
console.log('pushing to Google Cloud Storage')
process.chdir(__dirname)
run("gsutil cp ./deploy/* gs://versions.lumenize.com/v#{require('./package.json').version}/").exec(->
run('gsutil setmeta -h "Content-Type: application/javascript" -h "Cache-Control: public, max-age=31556926, no-transform" gs://versions.lumenize.com/v' + require('./package.json').version + '/*').exec()
)
#runSync = (command, options, next) ->
# {stderr, stdout} = runSyncRaw(command, options)
# if stderr?.length > 0
# console.error("Error running `#{command}`\n" + stderr)
# process.exit(1)
# if next?
# next(stdout)
# else
# if stdout?.length > 0
# console.log("Stdout running command '#{command}'...\n" + stdout)
#
#runSyncNoExit = (command, options = []) ->
# {stderr, stdout} = runSyncRaw(command, options)
# console.log("Output of running '#{command + ' ' + options.join(' ')}'...\n#{stderr}\n#{stdout}\n")
# return {stderr, stdout}
#
#runSyncRaw = (command, options) ->
# output = spawnSync(command, options)
# stdout = output.stdout?.toString()
# stderr = output.stderr?.toString()
# return {stderr, stdout}
#
#task('doctest', 'Test examples in documenation.', () ->
# process.chdir(__dirname)
# runSync('coffeedoctest', ['--readme', 'src', 'lumenize.coffee'])
#)
#
#task('docs', 'Generate docs with JSDuckify/JSDuck and place in ./docs', () ->
# runSync('cake doctest')
# process.chdir(__dirname)
# # create README.html
# readmeDotCSSString = fs.readFileSync('read-me.css', 'utf8')
# readmeDotMDString = fs.readFileSync('README.md', 'utf8')
# readmeDotHTMLString = marked(readmeDotMDString)
# readmeDotHTMLString = """
# <style>
# #{readmeDotCSSString}
# </style>
# <body>
# <div class="readme">
# #{readmeDotHTMLString}
# </div>
# </body>
# """
# fs.writeFileSync(path.join(__dirname, 'docs', 'README.html'), readmeDotHTMLString)
#
# # jsduckify
# {name, version} = require('./package.json')
# outputDirectory = path.join(__dirname, 'docs', "#{name}-docs")
# if fs.existsSync(outputDirectory)
# wrench.rmdirSyncRecursive(outputDirectory, false)
# process.chdir(__dirname)
# runSync('jsduckify', ['-d', outputDirectory, __dirname])
#)
#
#task('pub-docs', 'Build docs and push out to web', () ->
# invoke('docs')
# invoke('pubDocsRaw')
#)
#
#task('pubDocsRaw', 'Publish docs to Google Cloud Storage', () ->
# process.chdir(__dirname)
# console.log('pushing docs to Google Cloud Storage')
# runSync('gsutil -m cp -R docs gs://versions.lumenize.com')
#)
#
#task('publish', 'Publish to npm, add git tags, push to Google CDN', () ->
# process.chdir(__dirname)
# invoke('build')
#
# console.log('Running tests')
# process.chdir(__dirname)
# runSync('cake', ['test']) # Doing this externally to make it synchronous
#
# invoke('docs')
#
# console.log('Checking git status --porcelain')
# runSync('git', ['status', '--porcelain'], (stdout) ->
# if stdout.length == 0
#
# console.log('checking origin/master')
# {stderr, stdout} = runSyncNoExit('git', ['rev-parse', 'origin/master'])
# console.log('checking master')
# stdoutOrigin = stdout
# {stderr, stdout} = runSyncNoExit('git', ['rev-parse', 'master'])
# stdoutMaster = stdout
#
# if stdoutOrigin == stdoutMaster
#
# console.log('running npm publish')
# runSyncNoExit('npm', ['publish', '.'])
#
# if fs.existsSync('npm-debug.log')
# console.error('`npm publish` failed. See npm-debug.log for details.')
# else
#
# console.log('creating git tag')
# runSyncNoExit("git", ["tag", "v#{require('./package.json').version}"])
# runSyncNoExit("git", ["push", "--tags"])
#
# invoke('cdn')
#
# invoke('pubDocsRaw')
# else
# console.error('Origin and master out of sync. Not publishing.')
# else
# console.error('`git status --porcelain` was not clean. Not publishing.')
# )
#)
#
#task('cdn', 'Push runtime code to content delivery network (CDN)', () ->
# console.log('pushing to Google Cloud Storage')
# process.chdir(__dirname)
# runSyncNoExit("gsutil", ["cp", "./deploy/*", "gs://versions.lumenize.com/v#{require('./package.json').version}/"])
# runSyncNoExit('gsutil', ['setmeta', '-h', "Content-Type: application/javascript", '-h', "Cache-Control: public, max-age=31556926, no-transform", 'gs://versions.lumenize.com/v' + require('./package.json').version + '/*'])
#)
#
#task('build', 'Build with browserify and place in ./deploy', () ->
# invoke('update-bower-version')
#
# console.log('Compiling...')
# runSyncNoExit('coffee', ['-c', 'lumenize.coffee', 'src'])
#
# console.log('Browserifying...')
# b = browserify()
# b.use(fileify('files', __dirname + '/node_modules/tztime/files'))
# b.ignore(['files'])
# b.require("./lumenize")
# {name, version} = require('./package.json')
# fileString = """
# /*
# #{name} version: #{version}
# */
# #{b.bundle()}
# """
# deployFileName = "deploy/#{name}.js"
# unless fs.existsSync('deploy')
# fs.mkdirSync('deploy')
# fs.writeFileSync(deployFileName, fileString)
#
# minFileString = uglify.minify(deployFileName).code
# fs.writeFileSync("deploy/#{name}-min.js", minFileString)
#
# console.log('done')
# # !TODO: Need to run tests on the browserified version
#)
#
#task('update-bower-version', 'Update bower.json with the version number specified in package.json', () ->
# bowerJSON = require('./bower.json')
# bowerJSON.version = require('./package.json').version
# fs.writeFileSync("./bower.json", JSON.stringify(bowerJSON, null, 2))
#)
#
#task('test', 'Run the test suite with nodeunit', () ->
# require('coffee-script/register')
# {reporters} = require('nodeunit')
# process.chdir(__dirname)
# reporters.default.run(['test'], undefined, (failure) ->
# if failure?
# console.error(failure)
# process.exit(1)
# )
#)
#
#task('testall', 'Run tests and doctests', () ->
# runSync('cake doctest')
# invoke('test')
#)