forked from tomchentw-deprecated/ng-fire-alarm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.ls
199 lines (164 loc) · 5.28 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
require! {
fs
'event-stream'
gulp
'gulp-livescript'
'gulp-header'
'gulp-uglify'
'gulp-rename'
'gulp-bump'
'gulp-exec'
'gulp-conventional-changelog'
'gulp-jade'
'gulp-ruby-sass'
'gulp-concat'
'gulp-livereload'
'tiny-lr'
express
'connect-livereload'
}
function getJsonFile
fs.readFileSync './package.json', 'utf-8' |> JSON.parse
function getHeaderStream
const jsonFile = getJsonFile!
const date = new Date
gulp-header """
/*! ng-fire-alarm - v #{ jsonFile.version } - #{ date }
* #{ jsonFile.homepage }
* Copyright (c) #{ date.getFullYear! } [#{ jsonFile.author.name }](#{ jsonFile.author.url });
* Licensed [#{ jsonFile.license.type }](#{ jsonFile.license.url })
*/
"""
function getBuildStream (output = true)
stream = gulp.src 'src/ng-fire-alarm.ls'
.pipe gulp-livescript!
.pipe getHeaderStream!
if output
stream = stream
.pipe gulp.dest '.'
.pipe gulp.dest 'vendor/assets/javascripts/'
stream
function getUglifyStream (output)
return getBuildStream output
.pipe gulp-uglify!
.pipe getHeaderStream!
.pipe gulp-rename extname: '.min.js'
gulp.task 'bare-build' ->
return gulp.src 'src/ng-fire-alarm.ls'
.pipe gulp-livescript bare: true
.pipe gulp.dest 'tmp/'
.pipe gulp-exec('bower install')
gulp.task 'karma' <[ bare-build ]> ->
stream = gulp.src 'src/ng-fire-alarm.spec.ls'
.pipe gulp-livescript!
.pipe gulp.dest 'tmp/'
.pipe gulp-exec('karma start test/karma.conf.js')
const TO_COVERALLS = 'find ./coverage -name lcov.info -follow -type f -print0 | xargs -0 cat | node_modules/.bin/coveralls'
stream = stream.pipe gulp-exec(TO_COVERALLS) if process.env.TRAVIS
return stream
gulp.task 'protractor' <[ build ]> ->
stream = gulp.src 'src/ng-fire-alarm.scenario.ls'
.pipe gulp-livescript!
.pipe gulp.dest 'tmp/'
# stream = stream.pipe gulp-exec [
# 'cd test/scenario-rails'
# 'bundle install'
# 'RAILS_ENV=test rake db:drop db:migrate'
# 'rails s -d -e test -p 2999'
# 'cd ../..'
# ].join ' && ' unless process.env.TRAVIS
stream = stream.pipe gulp-exec('protractor test/protractor.conf.js')
# stream = stream.pipe gulp-exec('kill $(lsof -i :2999 -t)') unless process.env.TRAVIS
return stream
gulp.task 'bump' ->
return gulp.src <[ package.json bower.json ]>
.pipe gulp-bump type: 'patch'
.pipe gulp.dest '.'
gulp.task 'uglify' <[ bump ]> ->
return getUglifyStream true
.pipe gulp.dest '.'
gulp.task 'before-release' <[ uglify ]> ->
const jsonFile = getJsonFile!
const commitMsg = "chore(release): v#{ jsonFile.version }"
return gulp.src <[ package.json CHANGELOG.md ]>
.pipe gulp-conventional-changelog!
.pipe gulp.dest '.'
.pipe gulp-exec('git add -A')
.pipe gulp-exec("git commit -m '#{ commitMsg }'")
.pipe gulp-exec("git tag -a v#{ jsonFile.version } -m '#{ commitMsg }'")
gulp.task 'release-git' <[ before-release ]> ->
return gulp.src 'package.json'
.pipe gulp-exec('git push')
.pipe gulp-exec('git push --tags')
gulp.task 'release-gem' <[ before-release ]> ->
return gulp.src 'package.json'
.pipe gulp-exec('rake build release')
gulp.task 'release-npm' <[ before-release ]> ->
return gulp.src 'package.json'
.pipe gulp-exec('npm publish')
/*
* gh-pages
*/
gulp.task 'gh-pages:html' ->
return gulp.src 'gh-pages/index.jade'
.pipe gulp-jade!
.pipe gulp.dest 'build'
.pipe gulp-livereload(livereload)
gulp.task 'gh-pages:css' ->
return gulp.src 'gh-pages/application.scss'
.pipe gulp-ruby-sass do
loadPath: <[ bower_components/bootstrap-sass/vendor/assets/stylesheets ]>
cacheLocation: 'tmp/.sass-cache'
style: 'compressed'
.pipe gulp.dest 'build'
.pipe gulp-livereload(livereload)
gulp.task 'gh-pages:uglify' ->
return getUglifyStream false
.pipe gulp.dest 'tmp'
gulp.task 'gh-pages:prettify' ->
return gulp.src 'bower_components/google-code-prettify/src/prettify.js'
.pipe gulp-uglify!
.pipe gulp.dest 'tmp'
gulp.task 'gh-pages:ls' ->
return gulp.src 'gh-pages/application.ls'
.pipe gulp-livescript!
.pipe gulp-uglify!
.pipe gulp.dest 'tmp'
gulp.task 'gh-pages:js' <[ gh-pages:uglify gh-pages:prettify gh-pages:ls ]> ->
return gulp.src <[
bower_components/angular/angular.min.js
bower_components/angular-ui-bootstrap-bower/ui-bootstrap-tpls.min.js
bower_components/firebase/firebase.js
bower_components/firebase-simple-login/firebase-simple-login.js
tmp/prettify.js
tmp/ng-fire-alarm.min.js
tmp/application.js
]>
.pipe gulp-concat 'application.js'
.pipe gulp.dest 'build'
.pipe gulp-livereload(livereload)
const server = express!
server.use connect-livereload!
server.use express.static './build'
const livereload = tiny-lr!
/*
* Public tasks:
*
* test, watch, release
*/
gulp.task 'test' <[ karma protractor ]>
gulp.task 'build' getBuildStream
gulp.task 'watch' <[ test ]> ->
gulp.watch 'src/*.ls' <[ karma ]> # optimize if needed
gulp.task 'gh-pages' <[ gh-pages:html gh-pages:css gh-pages:js ]> !->
server.listen 5000
livereload.listen 35729
gulp.watch 'gh-pages/**/*.jade' <[ gh-pages:html ]>
gulp.watch 'gh-pages/*.ls' <[ gh-pages:js ]>
gulp.watch 'gh-pages/**/*.scss' <[ gh-pages:css ]>
gulp.task 'release' <[ release-git release-gem release-npm ]>
/*
* Public tasks end
*
*
*/