forked from hackfoldr/hackfoldr
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.ls
225 lines (186 loc) · 6.34 KB
/
gulpfile.ls
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
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
env-override = (json) ->
for key of json when process.env[key]?
json[key] = that
json
require! fs
require-json = -> JSON.parse fs.readFileSync it, \utf-8
config = env-override require-json('./app/config.jsenv')
paths =
pub: '_public'
index: 'app/*.jade'
template: 'app/partials/**/*.jade'
assets: 'app/assets/**'
js-vendor: 'vendor/scripts/*.js'
js-env: 'app/*.jsenv'
ls-app: 'app/**/*.ls'
css-vendor: 'vendor/styles/*.css'
stylus: 'app/styles/*.styl'
require! <[gulp gulp-util gulp-concat gulp-livescript gulp-livereload streamqueue gulp-karma path gulp-if]>
gutil = gulp-util
{protractor, webdriver_update} = require 'gulp-protractor'
livereload-server = require(\tiny-lr)!
livereload = -> gulp-livereload livereload-server
production = true if gutil.env.env is \production
var http-server
gulp.task \httpServer ->
require! express
port = 3333
app = express!
app.use require('connect-livereload')!
app.use express.static path.resolve paths.pub
app.all '/**' (req, res, next) ->
res.sendfile __dirname + '/_public/index.html'
http-server := require \http .create-server app
http-server.listen port, ->
gutil.log "Running on " + gutil.colors.bold.inverse "http://localhost:#port"
gulp.task 'build' <[assets template fonts:vendor images:vendor js:app js:vendor css]>
gulp.task 'dev' <[build httpServer]> ->
port = 35729
livereload-server.listen port, -> gutil.log it if it
gulp.watch paths.index, <[index]>
gulp.watch paths.template, <[template]>
gulp.watch paths.assets, <[assets]>
gulp.watch [paths.js-env, paths.ls-app] <[js:app]>
gulp.watch paths.stylus, <[css]>
gulp.task 'webdriver_update' webdriver_update
gulp.task 'protractor' <[webdriver_update httpServer]> ->
gulp.src ["./test/e2e/app/*.ls"]
.pipe protractor configFile: "./test/protractor.conf.ls"
.on 'error' ->
throw it
gulp.task 'test:e2e' <[protractor]> ->
http-server.close!
gulp.task 'protractor:sauce' <[webdriver_update build httpServer]> ->
args =
'--selenium-address'
''
'--sauce-user'
process.env.SAUCE_USERNAME
'--sauce-key'
process.env.SAUCE_ACCESS_KEY
'--capabilities.build'
process.env.TRAVIS_BUILD_NUMBER
if process.env.TRAVIS_JOB_NUMBER
#args['capabilities.tunnel-identifier'] = that
args.push '--capabilities.tunnel-identifier'
args.push that
gulp.src ["./test/e2e/app/*.ls"]
.pipe protractor do
configFile: "./test/protractor.conf.ls"
args: args
.on 'error' ->
throw it
gulp.task 'test:sauce' <[protractor:sauce]> ->
http-server.close!
gulp.task 'test:unit' <[build]> ->
gulp.start 'test:karma'
gulp.task 'test:karma' ->
gulp.src [
* "_public/js/vendor.js"
* "_public/js/app.templates.js"
* "_public/js/app.js"
* "bower_components/angular-mocks/angular-mocks.js"
* "test/unit/**/*.spec.ls"
]
.pipe gulp-karma do
config-file: 'test/karma.conf.ls'
action: 'run'
browsers: <[PhantomJS]>
.on 'error' ->
console.log it
throw it
require! <[gulp-json-editor gulp-insert gulp-commonjs gulp-uglify]>
gulp.task 'js:app' ->
env = gulp.src paths.js-env
.pipe gulp-json-editor env-override
.pipe gulp-insert.prepend 'module.exports = '
.pipe gulp-commonjs!
app = gulp.src paths.ls-app
.pipe gulp-livescript({+bare}).on \error gutil.log
s = streamqueue { +objectMode }
.done env, app
.pipe gulp-concat 'app.js'
.pipe gulp-if production, gulp-uglify!
.pipe gulp.dest "#{paths.pub}/js"
require! <[gulp-filter bower main-bower-files gulp-stylus gulp-csso gulp-flatten]>
gulp.task 'bower' ->
bower.commands.install!on \end (results) ->
for pkg, data of results
gutil.log do
gutil.colors.magenta data.pkgMeta.name
gutil.colors.cyan data.pkgMeta.version
"installed"
gulp.task 'fonts:vendor' <[bower]> ->
gulp.src main-bower-files!
.pipe gulp-filter <[**/*.eof **/*.ttf **/*.svg **/*.woff]>
.pipe gulp-flatten!
.pipe gulp.dest "#{paths.pub}/fonts"
gulp.task 'images:vendor' <[bower]> ->
gulp.src main-bower-files!
.pipe gulp-filter <[**/*.jpg **/*.jpeg **/*.png **/*.gif]>
.pipe gulp-flatten!
.pipe gulp.dest "#{paths.pub}/images"
gulp.task 'js:vendor' <[bower]> ->
bower = gulp.src main-bower-files!
.pipe gulp-filter <[**/*.js !**/*.min.js]>
s = streamqueue { +objectMode }
.done bower, gulp.src paths.js-vendor
.pipe gulp-concat 'vendor.js'
.pipe gulp-if production, gulp-uglify!
.pipe gulp.dest "#{paths.pub}/js"
.pipe livereload!
gulp.task 'css' <[bower]> ->
vendor = gulp.src paths.css-vendor
bower = gulp.src main-bower-files!
.pipe gulp-filter <[**/*.css !**/*.min.css]>
bower-styl = gulp.src main-bower-files!
.pipe gulp-filter (.path is /\.styl$/)
.pipe gulp-stylus use: <[nib]>
styl = gulp.src paths.stylus
.pipe gulp-filter (.path isnt /\/_[^/]+\.styl$/) # isnt files for including
.pipe gulp-stylus use: <[nib]>
s = streamqueue { +objectMode }
.done vendor, bower, bower-styl, styl
.pipe gulp-concat 'app.css'
.pipe gulp-if production, gulp-csso!
.pipe gulp.dest "#{paths.pub}/css"
.pipe livereload!
require! <[gulp-angular-templatecache gulp-jade]>
gulp.task 'index' ->
pretty = yes if gutil.env.env isnt 'production'
gulp.src paths.index
.pipe gulp-jade do
pretty: pretty
locals:
googleAnalytics: config.GA_ID
domainName: config.DOMAIN_NAME
.pipe gulp.dest "#{paths.pub}"
.pipe livereload!
gulp.task 'template' <[index]> ->
gulp.src paths.template
.pipe gulp-jade!
.pipe gulp-angular-templatecache 'app.templates.js' do
base: "#{process.cwd!}/app"
filename: 'app.templates.js'
module: 'app.templates'
standalone: true
.pipe gulp.dest "#{paths.pub}/js"
.pipe livereload!
gulp.task 'assets' ->
gulp.src paths.assets
.pipe gulp.dest paths.pub
gulp.task 'default' <[build]>
require! <[gulp-replace]>
gulp.task 'replace', ->
gulp.src 'templates/deploy'
.pipe gulp-replace /GITHUB_ACCOUNT/, config.GITHUB_ACCOUNT
.pipe gulp.dest '.'
gulp.src 'templates/app.ls'
.pipe gulp-replace /HACKFOLDR_ID/, config.HACKFOLDR_ID
.pipe gulp.dest 'app'
gulp.src 'templates/controllers.ls'
.pipe gulp-replace /HACKFOLDR_ID/, config.HACKFOLDR_ID
.pipe gulp.dest 'app/app'
gulp.src 'templates/CNAME'
.pipe gulp-replace /DOMAIN_NAME/, config.DOMAIN_NAME
.pipe gulp.dest 'app/assets'