-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCakefile
100 lines (79 loc) · 2.25 KB
/
Cakefile
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
process.env.NODE_ENV ?= 'development'
gulp = require 'gulp'
gulp_if = require 'gulp-if'
gulp_coffee = require 'gulp-coffee'
gulp_concat = require 'gulp-concat'
{
kit,
kit: {
_, log, spawn, Promise,
path: {
join
}
}
} = require 'nobone'
node_bin = join 'node_modules', '.bin'
kit.require 'colors'
run_server = (opts) ->
{ port, st, open } = _.defaults opts, {
port: 8078
st: 'public'
open: false
}
kit.monitorApp {
bin: 'coffee'
args: ['./server.coffee', port, st, open]
watch_list: [
'./server.coffee'
'./kit/**/*.coffee'
'./public/css/core/*.styl'
]
}
##
# Options
##
option '-p', '--port [port]', 'Which port to listen to. Example: cake -p 8080 dev'
option '-q', '--quite',
'Running lint script at quite mode results in only printing errors.
Example: cake -q coffeelint'
option '-o', '--open', 'To open a webpage with default browser.'
option '-s', '--st [st]', 'Static directory.'
##
# Tasks
##
task 'setup', 'Setup project.', ->
setup = require './kit/setup'
setup.start()
task 'build', 'Build project.', ->
builder = require './kit/builder'
builder.build()
task 'init', 'Create init files for client.', ->
files = [
'bower_components/lodash/lodash.js'
'bower_components/requirejs/require.js'
]
for item in ['', 'webapp_']
dest_file = "#{item}init.js"
if item is 'webapp_'
files.unshift 'bower_components/zeptojs/dist/zepto.js'
else
files.unshift 'bower_components/jquery/dist/jquery.js'
gulp.src(files.concat "public/js/#{item}cfg.coffee")
.pipe(gulp_if /[.]coffee$/, gulp_coffee())
.pipe(gulp_concat "#{dest_file}")
.pipe(gulp.dest 'public/js')
log ">> Create: ".cyan + "public/js/#{dest_file}"
log ">> Create init files done.".green
task 'dev', 'Run project on Development mode.', (opts) ->
invoke 'init'
run_server(opts)
task 'coffeelint', 'Lint all coffee files.', (opts) ->
kit.require 'drives'
kit.warp [
'*.coffee'
'{kit,public}/**/*.coffee'
]
.load kit.drives.auto 'lint'
.load (f) ->
f.set null
.run()