-
Notifications
You must be signed in to change notification settings - Fork 1
/
Gruntfile.coffee
186 lines (163 loc) · 4.11 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
fs = require 'fs'
module.exports = (grunt) ->
# Paths
SOURCE_DIR = 'app'
CONFIG_DIR = 'etc'
BUILD_DIR = 'public'
DOC_DIR = 'doc'
# Port to use to run the local webserver
PORT = process.env.LOCAL_PORT or 8888
# Load Grunt tasks
grunt.loadNpmTasks 'grunt-contrib-clean'
grunt.loadNpmTasks 'grunt-contrib-copy'
grunt.loadNpmTasks 'grunt-conventional-changelog'
grunt.loadNpmTasks 'grunt-bump'
grunt.loadNpmTasks 'grunt-karma'
grunt.loadNpmTasks 'grunt-docker'
grunt.loadNpmTasks 'grunt-shell-spawn'
grunt.loadNpmTasks 'grunt-brunch'
grunt.loadNpmTasks 'grunt-s3'
# Configuration
grunt.initConfig
# Package metadata
pkg: grunt.file.readJSON 'package.json'
# Bump version to both Bower and NPM
bump:
options:
files: ['package.json', 'bower.json']
commit: true
commitMessage: 'chore(release): version %VERSION%'
commitFiles: ['package.json', 'bower.json', 'CHANGELOG.md']
createTag: true
tagName: '%VERSION%'
tagMessage: 'Version %VERSION%'
push: false
# Documentation
docker:
app:
src: SOURCE_DIR
dest: DOC_DIR
options:
extras: ['fileSearch', 'goToLine']
# Clean house
clean:
build: [BUILD_DIR]
excess: [
"#{BUILD_DIR}/spec.js"
"#{BUILD_DIR}/_dev/"
]
# Testing
karma:
options:
configFile: "#{CONFIG_DIR}/karma.conf.coffee"
browsers: ['PhantomJS']
reporters: 'dots'
unit:
browsers: -> false
ci:
singleRun: true
copy:
# Copy over index as 404
'404':
src: "#{BUILD_DIR}/index.html"
dest: "#{BUILD_DIR}/404.html"
# Brunch commands
brunch:
serve:
action: 'serve'
port: PORT
serveAsync:
action: 'serve'
port: PORT
async: true
watch:
action: 'watch'
port: PORT
compile:
action: 'compile'
build:
action: 'build'
# AWS S3
s3Config: if fs.existsSync 'etc/s3.json'
grunt.file.readJSON 'etc/s3.json'
else
{}
s3:
options:
key: '<%= s3Config.key %>'
secret: '<%= s3Config.secret %>'
bucket: '<%= s3Config.bucket %>'
access: 'public-read'
verify: true
production:
sync: [
{
# Take the built files...
src: 'public/**/*'
# Put at the root of the specified bucket
dest: ''
rel: 'public'
}
]
# Execute arbitrary commands
shell:
options:
stdout: true
stderr: true
## Build tasks
# Usually you just want to run `grunt` to enter development mode, which
# re-assembles on change
grunt.registerTask 'default', [
'clean'
'brunch:compile' # Compile once for Karma
'brunch:serveAsync' # ... because this async op will not compile in time
'karma:unit:start'
]
# Just run server and watch files to serve
grunt.registerTask 'server', [
'clean'
'brunch:serve'
]
# Test mode. This is for continuous integration. To run tests locally, just
# run `grunt`
grunt.registerTask 'test', [
'clean'
'brunch:compile'
'brunch:serveAsync' # A local webserver may be used for testing
'karma:ci:start'
]
# JUST watch for file changes. Don't run server
grunt.registerTask 'watch', [
'clean'
'brunch:watch'
'copy:404'
]
# JUST compile, nothing else
grunt.registerTask 'compile', [
'clean'
'brunch:compile'
'copy:404'
]
# Build -- minify and uglify
grunt.registerTask 'build', [
'clean'
'brunch:build'
'copy:404'
'clean:excess'
]
# Push -- build and push to production on S3
grunt.registerTask 'push', (target) ->
return unless target?
# Build app and run on target
grunt.task.run ['build', target]
# Simply compile on heroku
grunt.registerTask 'heroku', ['compile']
# Release -- new version!
grunt.registerTask 'release', (type) ->
grunt.task.run [
'build'
'docker'
"bump-only:#{type or 'patch'}"
'changelog'
'bump-commit'
]