forked from mar10/fancytree
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Gruntfile.coffee
409 lines (370 loc) · 13.9 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
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
###
Build scripts for Fancytree
###
# jshint directives for the generated JS:
###jshint node: true, unused: false ###
"use strict"
module.exports = (grunt) ->
grunt.initConfig
pkg:
grunt.file.readJSON("package.json")
# Project metadata, used by the <banner> directive.
meta:
# banner: "/*! <%= pkg.title || pkg.name %> - v<%= pkg.version %> - " +
banner: "/*! <%= pkg.title || pkg.name %> - @VERSION - @DATE\n" +
# "<%= grunt.template.today('yyyy-mm-dd HH:mm') %>\n" +
"<%= pkg.homepage ? ' * ' + pkg.homepage + '\\n' : '' %>" +
" * Copyright (c) <%= grunt.template.today('yyyy') %> <%= pkg.author.name %>;" +
" Licensed <%= _.pluck(pkg.licenses, 'type').join(', ') %> */\n"
checkrepo:
beforeBump:
tag:
eq: "<%= pkg.version %>" # Check if highest repo tag == pkg.version
# tagged: false # Require last commit (HEAD) to be tagged
clean: true # // Require repo to be clean (no unstaged changes)
beforeRelease:
tag:
lt: "<%= pkg.version %>" # Check if highest repo tag is lower than pkg.version
# tagged: false # Require last commit (HEAD) to be tagged
clean: true # // Require repo to be clean (no unstaged changes)
clean:
build:
src: [ "build" ]
dist:
src: [ "dist" ]
extMin:
src: [ "build/jquery.fancytree.*.min.js" ]
# compress:
# dist:
# options:
# archive: "archive/<%= pkg.name %>-<%= pkg.version %>.zip"
# files: [
# {expand: true, cwd: "dist/", src: ["**/*"], dest: ""}
# ]
concat:
core:
options:
stripBanners: true
src: ["<banner:meta.banner>"
# "lib/intro.js"
"src/<%= pkg.name %>.js"
# "lib/outro.js"
]
dest: "build/<%= pkg.name %>.js"
all:
options:
stripBanners: true
src: [
"<%= meta.banner %>"
# "lib/intro.js"
"src/jquery.fancytree.js"
"src/jquery.fancytree.childcounter.js"
"src/jquery.fancytree.clones.js"
# "src/jquery.fancytree.columnview.js"
"src/jquery.fancytree.dnd.js"
"src/jquery.fancytree.edit.js"
"src/jquery.fancytree.filter.js"
"src/jquery.fancytree.glyph.js"
"src/jquery.fancytree.gridnav.js"
# "src/jquery.fancytree.menu.js"
"src/jquery.fancytree.persist.js"
"src/jquery.fancytree.table.js"
"src/jquery.fancytree.themeroller.js"
# "src/jquery.fancytree.wide.js"
# "lib/outro.js"
]
dest: "build/<%= pkg.name %>-all.js"
custom:
options:
banner: "<%= meta.banner %>"
stripBanners: true
process: (src, fspec) ->
# Remove all comments, including /*! ... */
src = src.replace(/\/\*(.|\n)*\*\//g, "")
if /fancytree..+.min.js/.test(fspec)
# If it is an extension:
# Prepend a one-liner instead
fspec = fspec.substr(6) # strip 'build/'
src = "\n/*! Extension '" + fspec + "' */" + src
return src
src: [
"lib/intro.js"
"build/jquery.fancytree.min.js"
"build/jquery.fancytree.childcounter.min.js"
"build/jquery.fancytree.clones.min.js"
# "build/jquery.fancytree.columnview.min.js"
"build/jquery.fancytree.dnd.min.js"
"build/jquery.fancytree.edit.min.js"
"build/jquery.fancytree.filter.min.js"
"build/jquery.fancytree.glyph.min.js"
"build/jquery.fancytree.gridnav.min.js"
# "build/jquery.fancytree.menu.min.js"
"build/jquery.fancytree.persist.min.js"
"build/jquery.fancytree.table.min.js"
"build/jquery.fancytree.themeroller.min.js"
# "src/jquery.fancytree.wide.js"
"lib/outro.js"
]
dest: "build/<%= pkg.name %>-all.min.js"
connect:
forever:
options:
port: 8080
base: "./"
keepalive: true
dev: # pass on, so subsequent tasks (like watch) can start
options:
port: 8080
base: "./"
keepalive: false
sauce:
options:
hostname: "localhost"
port: 9999
base: ""
keepalive: false
copy:
build: # copy production files to build folder
files: [{
expand: true # required for cwd
cwd: "src/"
src: ["skin-**/*.{css,gif,png}", "*.txt"]
dest: "build/"
}, {
expand: true
cwd: "src/"
src: ["jquery.*.js"]
dest: "build/src/"
}, {
# src: ["*.txt", "*.md"]
src: ["MIT-LICENSE.txt"]
dest: "build/"
}]
dist: # copy build folder to dist
files: [{expand: true, cwd: "build/", src: ["**"], dest: "dist/"}]
cssmin:
options:
report: "min"
build:
expand: true
cwd: "build/"
src: ["**/*.fancytree.css", "!*.min.css"]
dest: "build/"
ext: ".fancytree.min.css"
docco:
docs:
src: ["src/jquery.fancytree.childcounter.js"]
options:
output: "doc/annotated-src"
exec:
tabfix:
# Cleanup whitespace according to http://contribute.jquery.org/style-guide/js/
# (requires https://github.com/mar10/tabfix)
# cmd: "tabfix -t --line=UNIX -r -m*.js,*.css,*.html,*.json -inode_modules src demo test"
cmd: "tabfix -t -r -m*.js,*.css,*.html,*.json -inode_modules src demo test"
upload:
# FTP upload the demo files (requires https://github.com/mar10/pyftpsync)
cmd: "pyftpsync --progress upload . ftp://www.wwwendt.de/tech/fancytree --delete-unmatched --omit build,node_modules,.*,_* -x"
# cmd: "pyftpsync --progress upload . ftp://www.wwwendt.de/tech/fancytree --omit build,node_modules,.*,_* -x"
htmllint:
all: ["demo/**/*.html", "doc/**/*.html", "test/**/*.html"]
jsdoc:
build:
src: ["src/*.js", "doc/README.md", "doc/jsdoctest.js"]
options:
destination: "doc/jsdoc_new"
# template: "bin/jsdoc3-moogle",
# template: "node_modules/ink-docstrap/template",
template: "../docstrap/template",
configure: "doc/jsdoc.conf.json"
verbose: true
jshint:
options:
# Linting according to http://contribute.jquery.org/style-guide/js/
jshintrc: ".jshintrc"
beforeConcat: [
# "Gruntfile.js"
"src/*.js"
"3rd-party/**/jquery.fancytree.*.js"
"test/unit/*.js"
]
afterConcat: [
"<%= concat.core.dest %>"
"<%= concat.all.dest %>"
]
less:
development:
options:
# paths: ["src/"]
# report: "min"
compress: false
yuicompress: false
# optimization: 10
files: [
{expand: true, cwd: "src/", src: "**/ui.fancytree.less", dest: "src/", ext: ".fancytree.css"}
]
qunit:
build: [
"test/unit/test-core-build.html"
]
develop: [
"test/unit/test-core.html"
"test/unit/test-ext-table.html"
"test/unit/test-ext-misc.html"
]
replace: # grunt-text-replace
production:
src: ["build/**/*.js"]
overwrite : true
replacements: [ {
from : /@DATE/g
to : "<%= grunt.template.today('yyyy-mm-dd\"T\"HH:MM') %>"
},{
from : /buildType:\s*\"[a-zA-Z]+\"/g
to : "buildType: \"production\""
},{
from : /debugLevel:\s*[0-9]/g
to : "debugLevel: 1"
} ]
release:
src: ["dist/**/*.js"]
overwrite : true
replacements: [ {
from : /@VERSION/g
to : "<%= pkg.version %>"
} ]
"saucelabs-qunit":
all:
options:
urls: ["http://localhost:9999/test/unit/test-core.html"]
# tunnelTimeout: 5
build: process.env.TRAVIS_JOB_ID
# concurrency: 3
throttled: 10
browsers: [
{ browserName: "chrome", platform: "Windows 7" }
{ browserName: "firefox", platform: "Windows 7" }
{ browserName: "firefox", platform: "Windows XP" }
{ browserName: "firefox", platform: "Linux" }
{ browserName: "internet explorer", version: "6", platform: "Windows XP" }
{ browserName: "internet explorer", version: "7", platform: "Windows XP" }
{ browserName: "internet explorer", version: "8", platform: "Windows XP" }
{ browserName: "internet explorer", version: "9", platform: "Windows 7" }
{ browserName: "internet explorer", version: "10", platform: "Windows 8" }
{ browserName: "internet explorer", version: "11", platform: "Windows 8.1" }
{ browserName: "safari", platform: "OS X 10.8" }
]
testname: "fancytree qunit tests"
uglify:
# build:
# options:
# banner: "<%= meta.banner %>"
# # preserveComments: "some"
# report: "min"
# sourceMap:
# (path) -> path.replace(/.js/, ".js.map")
# sourceMappingURL:
# (path) -> path.replace(/^build\//, "") + ".map"
# sourceMapPrefix: 1 # strip 'build/' from paths
# files:
# "build/<%= pkg.name %>.min.js": ["<%= concat.core.dest %>"],
# "build/<%= pkg.name %>-all.min.js": ["<%= concat.all.dest %>"]
custom:
options:
report: "min"
preserveComments: "some"
files: [
{
src: ["**/jquery.fancytree*.js", "!*.min.js"]
cwd: "src/"
dest: "build/"
expand: true
rename: (dest, src) ->
folder = src.substring(0, src.lastIndexOf("/"))
filename = src.substring(src.lastIndexOf("/"), src.length)
filename = filename.substring(0, filename.lastIndexOf("."))
return dest + folder + filename + ".min.js"
}
]
watch:
less:
files: "src/**/*.less"
tasks: ["less:development"]
jshint:
options:
atBegin: true
files: ["src/*.js", "test/unit/*.js"]
tasks: ["jshint:beforeConcat"]
yabs:
release:
common: # defaults for all tools
manifests: ['package.json', 'bower.json', 'fancytree.jquery.json']
# The following tools are run in order:
run_test: { tasks: ['test'] }
check: { clean: true, branch: ['master'], canPush: true }
bump: {} # 'bump' also uses the increment mode `yabs:release:MODE`
run_build: { tasks: ['make_release'] }
commit: { add: '.' }
tag: {}
push: { tags: true, useFollowTags: true },
githubRelease:
repo: "mar10/fancytree"
draft: false
bump_develop: { inc: 'prepatch' }
commit_develop: { message: 'Bump prerelease ({%= version %}) [ci skip]' }
push_develop: {}
# ----------------------------------------------------------------------------
# Load "grunt*" dependencies
for key of grunt.file.readJSON("package.json").devDependencies
grunt.loadNpmTasks key if key isnt "grunt" and key.indexOf("grunt") is 0
# Register tasks
grunt.registerTask "server", ["connect:forever"]
grunt.registerTask "dev", ["connect:dev", "watch"]
grunt.registerTask "tabfix", ["exec:tabfix"]
grunt.registerTask "test", [
"jshint:beforeConcat",
# "csslint",
"qunit:develop"
]
grunt.registerTask "sauce", ["connect:sauce", "saucelabs-qunit"]
if parseInt(process.env.TRAVIS_PULL_REQUEST, 10) > 0
# saucelab keys do not work on forks
# http://support.saucelabs.com/entries/25614798
grunt.registerTask "travis", ["test"]
else
grunt.registerTask "travis", ["test", "sauce"]
grunt.registerTask "default", ["test"]
grunt.registerTask "build", [
"less:development"
"test"
"jsdoc:build"
"docco:docs"
"clean:build"
"copy:build"
"cssmin:build"
"concat:core"
"concat:all"
"uglify:custom"
"concat:custom"
"clean:extMin"
"replace:production"
"jshint:afterConcat"
# "uglify:build"
"qunit:build"
]
grunt.registerTask "make_release", [
# "checkrepo:beforeRelease"
"exec:tabfix"
"build"
"clean:dist"
"copy:dist"
"clean:build"
"replace:release"
# "compress:dist"
# "tagrelease"
# "bumpup:prerelease"
]
grunt.registerTask "upload", [
"build"
"exec:upload"
]