forked from sorich87/bootstrap-tour
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.coffee
214 lines (193 loc) · 6.07 KB
/
gulpfile.coffee
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
gulp = require 'gulp'
$ = require('gulp-load-plugins') lazy: false
extend = require('util')._extend
streamqueue = require 'streamqueue'
spawn = require('child_process').spawn
karma = require('karma').server
karmaConfig = require './karma.json'
pkg = require './package.json'
name = pkg.name
paths =
src: './src'
dist: './build'
test: './test'
docs: './docs'
server =
host: 'localhost'
port: 3000
banner = '''
/* ========================================================================
* <%= pkg.name %> - v<%= pkg.version %>
* <%= pkg.homepage %>
* ========================================================================
* Copyright 2012-2013 <%= pkg.author.name %>
*
* ========================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* ========================================================================
*/
'''
# coffee
gulp.task 'coffee', ->
gulp
.src "#{paths.src}/coffee/#{name}.coffee"
.pipe $.changed "#{paths.dist}/js"
.pipe $.coffeelint './coffeelint.json'
.pipe $.coffeelint.reporter()
.on 'error', $.util.log
.pipe $.coffee bare: true
.on 'error', $.util.log
.pipe $.header banner, pkg: pkg
.pipe gulp.dest "#{paths.dist}/js"
.pipe gulp.dest "#{paths.src}/docs/assets/js"
.pipe gulp.dest paths.test
.pipe $.uglify()
.pipe $.header banner, pkg: pkg
.pipe $.rename suffix: '.min'
.pipe gulp.dest "#{paths.dist}/js"
gulp.task 'coffee-standalone', ->
streamqueue objectMode: true,
gulp
.src [
"./bower_components/bootstrap/js/tooltip.js"
"./bower_components/bootstrap/js/popover.js"
]
,
gulp
.src "#{paths.src}/coffee/#{name}.coffee"
.pipe $.changed "#{paths.dist}/js"
.pipe $.coffeelint './coffeelint.json'
.pipe $.coffeelint.reporter()
.on 'error', $.util.log
.pipe $.coffee bare: true
.on 'error', $.util.log
.pipe $.concat "#{name}-standalone.js"
.pipe $.header banner, pkg: pkg
.pipe gulp.dest "#{paths.dist}/js"
.pipe $.uglify()
.pipe $.header banner, pkg: pkg
.pipe $.rename suffix: '.min'
.pipe gulp.dest "#{paths.dist}/js"
# less
gulp.task 'less', ->
gulp
.src [
"#{paths.src}/less/#{name}.less"
]
.pipe $.changed "#{paths.dist}/css"
.pipe $.less()
.on 'error', $.util.log
.pipe $.header banner, pkg: pkg
.pipe gulp.dest "#{paths.dist}/css"
.pipe gulp.dest "#{paths.src}/docs/assets/css"
.pipe $.less compress: true, cleancss: true
.pipe $.header banner, pkg: pkg
.pipe $.rename suffix: '.min'
.pipe gulp.dest "#{paths.dist}/css"
gulp.task 'less-standalone', ->
gulp
.src "#{paths.src}/less/#{name}-standalone.less"
.pipe $.changed "#{paths.dist}/css"
.pipe $.less()
.on 'error', $.util.log
.pipe $.header banner, pkg: pkg
.pipe gulp.dest "#{paths.dist}/css"
.pipe $.less compress: true, cleancss: true
.pipe $.header banner, pkg: pkg
.pipe $.rename suffix: '.min'
.pipe gulp.dest "#{paths.dist}/css"
# test
gulp.task 'test-coffee', ['coffee'], ->
gulp
.src "#{paths.src}/coffee/#{name}.spec.coffee"
.pipe $.changed paths.test
.pipe $.coffeelint './coffeelint.json'
.pipe $.coffeelint.reporter()
.on 'error', $.util.log
.pipe $.coffee()
.on 'error', $.util.log
.pipe gulp.dest paths.test
gulp.task 'test-go', ['test-coffee'], (done) ->
karma.start extend(karmaConfig, singleRun: true), done
# docs
gulp.task 'docs-build', ['coffee', 'less'], (done) ->
spawn 'jekyll', ['build']
.on 'close', done
gulp.task 'docs-copy', ['docs-build'], ->
gulp
.src "./bower_components/**/*"
.pipe gulp.dest "#{paths.docs}/components"
gulp.task 'docs-coffee', ['docs-build'], ->
gulp
.src "#{paths.src}/coffee/#{name}.docs.coffee"
.pipe $.changed "#{paths.docs}/assets/js"
.pipe $.coffeelint.reporter()
.on 'error', $.util.log
.pipe $.coffee()
.on 'error', $.util.log
.pipe gulp.dest "#{paths.docs}/assets/js"
# clean
gulp.task 'clean-dist', ->
gulp
.src paths.dist
.pipe $.clean()
gulp.task 'clean-test', ->
gulp
.src paths.test
.pipe $.clean()
gulp.task 'clean-docs', ->
gulp
.src paths.docs
.pipe $.clean()
# connect
gulp.task 'connect', ['docs'], ->
$.connect.server
root: [paths.docs]
host: server.host
port: server.port
livereload: true
# open
gulp.task 'open', ['connect'], ->
gulp
.src "#{paths.docs}/index.html"
.pipe $.open '', url: "http://#{server.host}:#{server.port}"
gulp.task 'watch', ['connect'], ->
gulp.watch "#{paths.src}/coffee/#{name}.coffee", ['coffee', 'coffee-standalone']
gulp.watch "#{paths.src}/less/#{name}.less", ["less", "less-standalone"]
gulp.watch "#{paths.src}/less/#{name}-standalone.less", ['less-standalone']
gulp.watch "#{paths.src}/coffee/#{name}.spec.coffee", ['test']
gulp.watch [
"#{paths.src}/coffee/#{name}.docs.coffee"
"#{paths.src}/docs/**/*"
], ['docs']
gulp.watch [
"#{paths.dist}/js/**/*.js"
"#{paths.dist}/css/**/*.css"
"#{paths.docs}/index.html"
]
.on 'change', (event) ->
gulp.src event.path
.pipe $.connect.reload()
# bump
gulp.task 'bump', ['test'], ->
bumpType = $.util.env.type || 'patch'
return gulp.src(['./bower.json', './package.json', './smart.json'])
.pipe $.bump(type: bumpType)
.pipe gulp.dest('./')
# tasks
gulp.task 'clean', ['clean-dist', 'clean-test', 'clean-docs']
gulp.task 'server', ['connect', 'open', 'watch']
gulp.task 'dist', ['coffee', 'coffee-standalone', 'less', 'less-standalone']
gulp.task 'test', ['coffee', 'test-coffee', 'test-go']
gulp.task 'docs', ['coffee', 'less', 'docs-build', 'docs-copy', 'docs-coffee']
gulp.task 'default', ['dist', 'docs', 'server']