-
Notifications
You must be signed in to change notification settings - Fork 0
/
Gruntfile.coffee
198 lines (177 loc) · 6.31 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
module.exports = (grunt) ->
# Measure how long Grunt tasks take
require('time-grunt')(grunt)
# Load grunt tasks automatically
require('load-grunt-tasks')(grunt)
pkgObj = grunt.file.readJSON('package.json')
pkgObj.cleanName = pkgObj.name.replace(/-/gi, ' ')
grunt.initConfig
# Project settings
app:
src: 'src'
dist: 'dist'
tools: 'tools'
iospath: 'var/mobile/Library/iWidgets'
fullPath: '<%= app.dist %>/<%= pkg.name %>/<%= app.iospath %>/' + pkgObj.cleanName
glyphSubset: '0123456789AMP:'
pkg: pkgObj
coffeelint:
options:
'indentation':
'value': 4
'max_line_length':
'level': 'ignore'
main: '<%= app.src %>/script/script.coffee'
gruntfile: 'Gruntfile.coffee'
coffee:
options:
sourceMap: true
bare: true
compile:
files:
'<%= app.src %>/script/script.js': '<%= app.src %>/script/script.coffee'
notify:
coffee:
options:
title: "#{pkgObj.cleanName} v<%= pkg.version %>"
message: 'CoffeeScript compiled.'
build:
options:
title: "#{pkgObj.cleanName} v<%= pkg.version %>"
message: "The build task completed successfully."
# Connect server
connect:
server:
options:
base: '<%= app.src %>'
livereload: 35729
hostname: '*'
open: true
debug: true
keepalive: true
concurrent:
server: ['connect:server', 'watch']
# Watch tasks
watch:
files:
options:
livereload: '<%= connect.server.options.livereload %>'
files: [
'<%= app.src %>/Widget.html'
'<%= app.src %>/script/script.js'
'<%= app.src %>/css/style.css'
]
coffee:
files: '<%= app.src %>/script/script.coffee'
tasks: [
'coffeelint:main'
'coffee'
'notify:coffee'
]
gruntfile:
files: 'Gruntfile.coffee'
tasks: 'coffeelint:gruntfile'
# Build specific
clean: ['<%= app.dist %>']
copy:
css:
options:
process: (content, srcpath) ->
content.replace('#timeface{color:red!important;}/*removed on build*/\n', '')
files: [
expand: true
cwd: '<%= app.src %>/css/'
src: [
'style.css'
]
dest: '<%= app.fullPath %>/css/'
]
dist:
files: [
expand: true
cwd: '<%= app.src %>'
src: [
'Options.plist'
'Widget.plist'
'fonts/*'
]
dest: '<%= app.fullPath %>/'
]
controlFile:
options:
process: (content, srcpath) ->
"""
#{content}Name: #{pkgObj.cleanName}
Version: #{pkgObj.version}
Description: #{pkgObj.description}
Homepage: #{pkgObj.homepage}
Author: #{pkgObj.author}
Maintainer: #{pkgObj.author}
"""
files: [
expand: true
cwd: '<%= app.src %>'
src: [
'control.txt'
]
dest: '<%= app.dist %>/<%= pkg.name %>/DEBIAN/'
rename: (dest, src) ->
dest + src.replace(src.substr(-4), '')
]
removelogging:
dist:
src: '<%= app.src %>/script/script.js'
dest: '<%= app.fullPath %>/script/script.js'
uglify:
options:
banner: "/*! #{pkgObj.cleanName} <%= pkg.version %> by <%= pkg.author %> <%= grunt.template.today(\"yyyy-mm-dd\") %> */\n"
dist:
src: '<%= app.fullPath %>/script/script.js'
dest: '<%= app.fullPath %>/script/script.js'
htmlmin:
dist:
options:
removeComments: true
collapseWhitespace: true
files: '<%= app.fullPath %>/Widget.html': '<%= app.src %>/Widget.html'
cssmin:
dist:
options:
banner: "/*! #{pkgObj.cleanName} <%= pkg.version %> by <%= pkg.author %> <%= grunt.template.today(\"yyyy-mm-dd\") %> */\n"
files: '<%= app.fullPath %>/css/style.css': ['<%= app.fullPath %>/css/style.css']
shell:
optimizeFonts: # this is not working properly yet
options:
stderr: true
stdin: true
stdout: true
execOptions:
cwd: '<%= app.tools %>/font-optimizer'
command: 'find "../../<%= app.fullPath %>/fonts" -maxdepth 1 -type f -exec ./subset.pl --chars="<%= app.glyphSubset %>" {} {} \\;'
createDeb:
options:
stderr: true
stdin: true
stdout: true
execOptions:
cwd: '<%= app.dist %>'
command: 'dpkg-deb -Zgzip -b <%= pkg.name %>'
grunt.registerTask 'default', [
'coffeelint'
'coffee'
]
grunt.registerTask 'serve', [
'concurrent:server'
]
grunt.registerTask 'build', [
'coffeelint'
'coffee'
'clean'
'copy'
'removelogging'
'uglify'
'htmlmin'
'cssmin'
'shell:createDeb'
'notify:build'
]