forked from Addepar/ember-widgets
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGruntfile.coffee
249 lines (225 loc) · 8.36 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
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
# Gruntfile courtesy of trek (https://github.com/trek/)
# ember-todos-with-build-tools-tests-and-other-modern-conveniences
module.exports = (grunt) ->
grunt.loadNpmTasks "grunt-bower-task"
grunt.loadNpmTasks "grunt-contrib-uglify"
grunt.loadNpmTasks "grunt-contrib-jshint"
grunt.loadNpmTasks "grunt-contrib-qunit"
grunt.loadNpmTasks "grunt-neuter"
grunt.loadNpmTasks "grunt-contrib-watch"
grunt.loadNpmTasks "grunt-ember-templates"
grunt.loadNpmTasks "grunt-contrib-coffee"
grunt.loadNpmTasks "grunt-contrib-less"
grunt.loadNpmTasks "grunt-contrib-copy"
grunt.loadNpmTasks "grunt-contrib-clean"
grunt.loadNpmTasks "grunt-karma"
grunt.loadNpmTasks "grunt-banner"
grunt.loadNpmTasks "grunt-text-replace"
grunt.initConfig
pkg: grunt.file.readJSON('package.json')
clean:
target: ['build', 'dist' , 'gh_pages']
karma:
continuous: # continuous integration mode
configFile: 'karma.conf.js'
singleRun: true
unit:
configFile: 'karma.conf.js'
singleRun: true
exclude: ['build/src/ember_widgets.js', 'tests/functional/*.js', 'tests/integration/*.js'],
functional:
configFile: 'karma.conf.js'
singleRun: true
exclude: ['build/src/ember_widgets.js', 'tests/unit/*.js', 'tests/integration/*.js'],
integration:
configFile: 'karma.conf.js'
singleRun: true
exclude: ['build/src/ember_widgets.js', 'tests/unit/*.js', 'tests/functional/*.js'],
default:
configFile: 'karma.conf.js'
singleRun: false
uglify:
"dist/js/ember-widgets.min.js": "dist/js/ember-widgets.js"
# https://github.com/yatskevich/grunt-bower-task
bower:
install:
options:
targetDir: 'vendor'
layout: 'byComponent'
install: true
verbose: true
cleanTargetDir: false
cleanBowerDir: true
bowerOptions: {}
coffee:
srcs:
options:
bare: true
expand: true
cwd: "src/"
src: [ "**/*.coffee" ]
dest: "build/src/"
ext: ".js"
app:
options:
bare: true
expand: true
cwd: "app/"
src: [ "**/*.coffee" ]
dest: "build/app/"
ext: ".js"
tests:
options:
bare: true
sourceMap: false
expand: true
cwd: "tests/"
src: ["**/*.coffee" ]
dest: "tests/"
ext: ".js"
emberTemplates:
options:
templateName: (sourceFile) ->
sourceFile.replace(/src\/templates\//, '')
.replace(/app\/templates\//, '')
'build/src/templates.js': ["src/templates/**/*.hbs"]
'build/app/templates.js': ["app/templates/**/*.hbs"]
neuter:
options:
includeSourceURL: yes
"dist/js/ember-widgets.js": "build/src/ember_widgets.js"
"gh_pages/app.js": "build/app/app.js"
less:
development:
options:
yuicompress: no
files:
"dist/css/ember-widgets.css": "src/css/ember-widgets.less"
app:
options:
yuicompress: no
files:
"gh_pages/css/app.css": "app/assets/css/app.less"
usebanner:
dist:
options:
banner: '/*!\n* <%=pkg.name %> v<%=pkg.version%>\n' +
'* Copyright 2013-<%=grunt.template.today("yyyy")%> Addepar Inc.\n' +
'* See LICENSE.\n*/',
files:
src: ['dist/js/*', 'dist/css/*']
replace:
global_version:
src: ['VERSION']
overwrite: true
replacements: [{
from: /.*\..*\..*/
to: '<%=pkg.version%>'
}]
main_coffee_version:
src: ['src/ember_widgets.coffee']
overwrite: true
replacements: [{
from: /Ember.Widgets.VERSION = '.*\..*\..*'/
to: "Ember.Widgets.VERSION = '<%=pkg.version%>'"
}]
# Copy build/app/assets/css into gh_pages/asset and other assets from app
copy:
gh_pages:
files: [
{src: ['dist/css/ember-widgets.css'], dest: 'gh_pages/css/ember-widgets.css'},
{src: ['app/index.html'], dest: 'gh_pages/index.html'},
{expand: true, flatten: true, cwd: 'dependencies/', src: ['**/*.js'], dest: 'gh_pages/lib'},
{expand: true, flatten: true, cwd: 'dependencies/', src: ['**/*.css'], dest: 'gh_pages/css'},
{expand: true, flatten: true, cwd: 'vendor/', src: ['**/*.js'], dest: 'gh_pages/lib'},
{expand: true, flatten: true, cwd: 'vendor/', src: ['**/*.css'], dest: 'gh_pages/css'},
{expand: true, cwd: 'vendor/font-awesome/fonts/', src: ['**'], dest: 'gh_pages/fonts'},
{expand: true, cwd: 'app/assets/font/', src: ['**'], dest: 'gh_pages/fonts'},
{expand: true, cwd: 'app/assets/img/', src: ['**'], dest: 'gh_pages/img'},
{expand: true, cwd: 'src/img/', src: ['**'], dest: 'gh_pages/img'}
{expand: true, cwd: 'src/img/', src: ['**'], dest: 'dist/img'}
]
###
Watch files for changes.
Changes in dependencies/ember.js or src javascript
will trigger the neuter task.
Changes to any templates will trigger the emberTemplates
task (which writes a new compiled file into dependencies/)
and then neuter all the files again.
###
watch:
grunt:
files: [ "Gruntfile.coffee" ]
tasks: [ "default" ]
src:
files: [ "src/**/*.coffee"]
tasks: [ "coffee:srcs", "neuter" ]
test:
files: [ "tests/**/*.coffee"]
tasks: [ "coffee:tests", "neuter" ]
src_handlebars:
files: [ "src/**/*.hbs" ]
tasks: [ "emberTemplates", "neuter" ]
app:
files: [ "app/**/*.coffee", "dependencies/**/*.js", "vendor/**/*.js" ]
tasks: [ "coffee:app", "neuter" ]
app_handlebars:
files: [ "app/**/*.hbs"]
tasks: [ "emberTemplates", "neuter" ]
less:
files: [ "src/**/*.less", "src/**/*.css",
"dependencies/**/*.less", "dependencies/**/*.css",
"vendor/**/*.less", "vendor/**/*.css",
"app/assets/**/*.less", "app/assets/**/*.css" ]
tasks: ["less", "copy"]
copy:
files: [ "app/index.html" ]
tasks: [ "copy" ]
bower:
files: [ 'bower.json']
tasks: [ 'bower']
uglify:
files: [ 'dist/js/ember-widgets.js' ]
tasks: [ 'uglify' ]
###
Runs all .html files found in the test/ directory through PhantomJS.
Prints the report in your terminal.
###
qunit:
all: [ "tests/**/*.html" ]
###
Reads the projects .jshintrc file and applies coding
standards. Doesn't lint the dependencies or test
support files.
###
jshint:
all: ['Gruntfile.js', 'src/**/*.js', 'test/**/*.js', '!dependencies/*.*', '!vendor/*.*', '!test/support/*.*']
options:
jshintrc: ".jshintrc"
###
Find all the <whatever>_test.js files in the test folder.
These will get loaded via script tags when the task is run.
This gets run as part of the larger 'test' task registered
below.
###
build_test_runner_file:
all: [ "tests/**/*_test.js" ]
###
A task to build the test runner html file that get place in
/test so it will be picked up by the qunit task. Will
place a single <script> tag into the body for every file passed to
its coniguration above in the grunt.initConfig above.
###
grunt.registerMultiTask "build_test_runner_file", "Creates a test runner file.", ->
tmpl = grunt.file.read("tests/support/runner.html.tmpl")
renderingContext = data:
files: @filesSrc.map (fileSrc) -> fileSrc.replace "tests/", ""
grunt.file.write "tests/runner.html", grunt.template.process(tmpl, renderingContext)
grunt.registerTask "build_srcs", [ "coffee:srcs", "emberTemplates", "neuter" ]
grunt.registerTask "build_app", [ "coffee:app", "emberTemplates", "neuter" ]
grunt.registerTask "build_tests", [ "coffee:tests", "emberTemplates", "neuter" ]
# build dist files: same as default but no bower or watch
grunt.registerTask "dist", ->
grunt.config "neuter.options.includeSourceURL", no
grunt.task.run [ "clean", "replace", "build_srcs", "build_app", "build_tests", "less", "copy", "uglify", "usebanner" ]
grunt.registerTask "default", [ "clean", "bower", "replace", "build_srcs", "build_app", "build_tests", "less", "copy", "uglify", "usebanner", "watch" ]