forked from druids/werkzeug
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Gruntfile.coffee
211 lines (185 loc) · 4.85 KB
/
Gruntfile.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
module.exports = (grunt) ->
bowerDir = 'bower_components'
closureLibDir = bowerDir + '/closure-library'
appDirs = [
closureLibDir
'var/wzk'
]
coffeeFiles = [
'wzk/**/*.coffee'
]
appCompiledOutputPath =
'var/app.js'
depsPath =
'var/wzk/deps.js'
# from closure base.js dir to app root dir
depsPrefix = '../../../../'
getCoffeeConfig = (filepath = coffeeFiles) ->
[
expand: true
src: filepath
dest: 'var/'
ext: '.js'
]
grunt.initConfig
clean:
all:
options:
force: true
src: [
'var/wzk/**/*.js'
]
coffee:
all:
options:
bare: true
files: [
expand: true
src: coffeeFiles
dest: 'var/'
ext: '.js'
]
coffee2closure:
all:
files: [
expand: true
src: 'var/wzk/**/*.js'
ext: '.js'
]
esteDeps:
all:
options:
depsWriterPath: closureLibDir + '/closure/bin/build/depswriter.py'
outputFile: depsPath
prefix: depsPrefix
root: appDirs
zuckrig:
all:
options:
filter: (file) -> not /_test.js$/.test(file)
files: [
expand: true
src: [
'var/wzk/**/*.js'
]
ext: '.js'
]
esteBuilder:
options:
closureBuilderPath: closureLibDir+ '/closure/bin/build/closurebuilder.py'
compilerPath: bowerDir + '/closure-compiler/compiler.jar'
# needs Java 1.7+, see http://goo.gl/iS3o6
fastCompilation: true
root: '<%= esteDeps.all.options.root %>'
depsPath: '<%= esteDeps.all.options.outputFile %>'
compilerFlags: if grunt.option('stage') == 'debug' then [
'--output_wrapper="(function(){%output%})();"'
'--compilation_level="ADVANCED_OPTIMIZATIONS"'
'--warning_level="VERBOSE"'
'--define=goog.DEBUG=true'
'--debug=true'
'--formatting="PRETTY_PRINT"'
]
else [
'--output_wrapper="(function(){%output%})();"'
'--compilation_level="ADVANCED_OPTIMIZATIONS"'
'--warning_level="VERBOSE"'
'--define=goog.DEBUG=false'
]
all:
options:
namespace: '*'
outputFilePath: appCompiledOutputPath
esteUnitTests:
options:
basePath: closureLibDir + '/closure/goog/base.js'
all:
options:
depsPath: '<%= esteDeps.all.options.outputFile %>'
useReact: false
prefix: '<%= esteDeps.all.options.prefix %>'
src: [
'var/wzk/**/*_test.js'
]
esteWatch:
options:
dirs: [
closureLibDir + '/**/'
'wzk/**/'
'var/wzk/**/'
]
coffee: (filepath) ->
config = getCoffeeConfig filepath
grunt.config ['coffee', 'all', 'files'], config
grunt.config ['zuckrig', 'all', 'files'], config
grunt.config ['coffee2closure', 'all', 'files'], config
['coffee', 'zuckrig', 'coffee2closure']
js: (filepath) ->
grunt.config ['esteDeps', 'all', 'src'], filepath
grunt.config ['esteUnitTests', 'all', 'src'], filepath
['esteDeps', 'esteUnitTests']
coffeelint:
options:
no_backticks:
level: 'ignore'
max_line_length:
level: 'ignore'
line_endings:
value: 'unix'
level: 'error'
no_empty_param_list:
level: 'warn'
space_operators:
level: 'warn'
cyclomatic_complexity:
level: 'warn'
all:
files: [
expand: true
src: coffeeFiles
ext: '.js'
]
bump:
options:
bump: true
files: ['package.json', 'bower.json']
commitFiles: ['-a']
commit: true
tagName: '%VERSION%'
tagMessage: 'Release %VERSION%'
commitMessage: '%VERSION%'
pushTo: 'origin'
grunt.loadNpmTasks 'grunt-bump'
grunt.loadNpmTasks 'grunt-contrib-clean'
grunt.loadNpmTasks 'grunt-contrib-coffee'
grunt.loadNpmTasks 'grunt-este-watch'
grunt.loadNpmTasks 'grunt-coffeelint'
grunt.loadNpmTasks 'grunt-este'
grunt.loadNpmTasks 'grunt-este-watch'
grunt.loadNpmTasks 'grunt-zuckrig-closure'
grunt.registerTask 'build', 'Build app.', ->
tasks = [
"clean"
"coffee"
'zuckrig'
"coffee2closure"
"coffeelint"
"esteDeps"
"esteUnitTests"
"esteBuilder"
]
grunt.task.run tasks
grunt.registerTask 'run', 'Build app and run watchers.', ->
tasks = [
"clean"
"coffee"
'zuckrig'
"coffee2closure"
"coffeelint"
"esteDeps"
"esteUnitTests"
"esteWatch"
]
grunt.task.run tasks
grunt.registerTask 'default', 'run'
grunt.registerTask 'test', 'build'