-
Notifications
You must be signed in to change notification settings - Fork 20
/
Copy pathgulpfile.coffee
199 lines (176 loc) · 5.45 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
'use strict'
gulp = require 'gulp'
coffee = require 'gulp-coffee'
concat = require 'gulp-concat'
connect = require 'gulp-connect'
header = require 'gulp-header'
karma = require('karma').server
uglify = require 'gulp-uglify'
gutil = require 'gulp-util'
stylus = require 'gulp-stylus'
yml = require 'gulp-yml'
pkg = require './package.json'
path =
bower : "./bower"
temp : "./build"
kitchensink: "./kitchensink/www/assets"
quojs: [
"quojs/source/quo.coffee"
"quojs/source/quo.ajax.coffee"
"quojs/source/quo.css.coffee"
"quojs/source/quo.element.coffee"
"quojs/source/quo.environment.coffee"
"quojs/source/quo.events.coffee"
"quojs/source/quo.gestures.coffee"
"quojs/source/quo.gestures.*.coffee"
"quojs/source/quo.output.coffee"
"quojs/source/quo.query.coffee"
]
core: [
"hamsa/source/*.coffee"
"source/*.coffee"
"source/core/*.coffee"
"source/class/*.coffee"
]
spec: ["spec/*.coffee"]
icons: "atoms-app/extension/icons/"
app =
coffee: [
"atoms-app/*.coffee"
"atoms-app/atom/*.coffee"
"atoms-app/molecule/*.coffee"
"atoms-app/organism/*.coffee"
]
stylus: ["atoms-app/style/*.styl"]
theme: ["atoms-app/theme/*.styl"]
extensions: [
"atoms-app/extension/**/*.coffee"
"atoms-app/extension/**/*.styl"
]
docs: ["atoms-app/docs/**/*"]
extensions =
common : ['carousel', 'gmaps', 'leaflet', 'payments', 'inputrange', 'calendar', 'table', 'crud']
appnima: ['user', 'payment']
kitchensink =
coffee: "kitchensink/source/**/*.coffee"
yml : "kitchensink/source/organisms/*.yml"
test = ["#{path.temp}/atoms.js", "#{path.temp}/spec.js"]
banner = [
"/**"
" * <%= pkg.name %> - <%= pkg.description %>"
" * @version v<%= pkg.version %>"
" * @link <%= pkg.homepage %>"
" * @author <%= pkg.author.name %> (<%= pkg.author.site %>)"
" * @license <%= pkg.license %>"
" */"
""
].join("\n")
gulp.task "webserver", ->
connect.server
port : 8000
livereload: true
gulp.task "core", ->
gulp.src path.quojs.concat path.core
.pipe concat "atoms.coffee"
.pipe coffee().on "error", gutil.log
.pipe gulp.dest path.temp
.pipe uglify mangle: true
.pipe header banner, pkg: pkg
.pipe gulp.dest path.bower
gulp.task "standalone", ->
gulp.src path.core
.pipe concat "atoms.standalone.coffee"
.pipe coffee().on "error", gutil.log
.pipe gulp.dest path.temp
.pipe uglify mangle: true
.pipe header banner, pkg: pkg
.pipe gulp.dest path.bower
.pipe connect.reload()
gulp.task "spec", ->
gulp.src path.spec
.pipe concat "spec.coffee"
.pipe coffee()
.pipe gulp.dest path.temp
gulp.task "test", ["core", "spec"], (done) ->
karma.start
configFile: __dirname + '/karma.js',
files: test
singleRun: true
, done
gulp.task "coffee", ->
gulp.src app.coffee
.pipe concat "atoms.app.coffee"
.pipe(coffee().on('error', gutil.log))
.pipe uglify mangle: false
.pipe header banner, pkg: pkg
.pipe gulp.dest path.bower
.pipe connect.reload()
gulp.task "stylus", ->
gulp.src app.stylus
.pipe concat "atoms.app.styl"
.pipe stylus
compress: true
errors: true
.pipe header banner, pkg: pkg
.pipe gulp.dest path.bower
.pipe connect.reload()
gulp.task "theme", ->
gulp.src app.theme
.pipe concat "atoms.app.theme.styl"
.pipe stylus
compress: true
errors: true
.pipe header banner, pkg: pkg
.pipe gulp.dest path.bower
.pipe connect.reload()
gulp.task "icons", ->
gulp.src path.icons + "*.styl"
.pipe concat "atoms.icons.styl"
.pipe(stylus(compress: true, errors: true))
.pipe header banner, pkg: pkg
.pipe gulp.dest path.icons
gulp.task "extensions", ->
process = (key, folder = "") ->
file = unless folder then "atoms.app.#{key}" else "atoms.app.#{folder}.#{key}"
folders = []
for element in ["atom", "molecule", "organism"]
folders.push "atoms-app/extension/#{folder}/#{key}/#{element}/*.coffee"
folder = "atoms-app/extension/#{folder}/#{key}/"
gulp.src folders
.pipe concat "#{file}.coffee"
.pipe coffee().on "error", gutil.log
.pipe uglify mangle: false
.pipe gulp.dest folder
gulp.src "#{folder}style/*.styl"
.pipe concat "#{file}.styl"
.pipe stylus compress: true
.pipe gulp.dest folder
.pipe connect.reload()
process extension for extension in extensions.common
process extension, "appnima" for extension in extensions.appnima
gulp.task "docs", ->
gulp.src app.docs
.pipe gulp.dest path.bower + "/docs"
gulp.task "kitchensink", ->
gulp.src kitchensink.coffee
.pipe concat "atoms.app.kitchensink.coffee"
.pipe coffee().on "error", gutil.log
.pipe gulp.dest path.temp
.pipe connect.reload()
gulp.src kitchensink.yml
.pipe yml().on "error", gutil.log
.pipe gulp.dest path.kitchensink + "/scaffolds"
gulp.task "init", ["core", "standalone", "coffee", "stylus", "theme", "extensions", "docs", "kitchensink"]
gulp.task "default", ->
gulp.run ["webserver"]
gulp.watch path.core, ["core", "standalone", "test"]
gulp.watch path.spec, ["test"]
gulp.watch path.quojs, ["core", "standalone", "test"]
gulp.watch path.icons + "*.styl", ["icons"]
gulp.watch app.coffee, ["coffee"]
gulp.watch app.stylus, ["stylus"]
gulp.watch app.theme, ["theme"]
gulp.watch app.extensions, ["extensions"]
gulp.watch app.docs, ["docs"]
gulp.watch kitchensink.coffee, ["kitchensink"]
gulp.watch kitchensink.yml, ["kitchensink"]