This repository has been archived by the owner on Sep 22, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gruntfile.coffee
119 lines (103 loc) · 3.7 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
module.exports = (grunt) ->
coffeeConfig = {
compile:
files: {
"fake_titan.js": ["coffee/fake_titan.coffee"]
"js/app.js" : ["coffee/app.coffee"]
"js/directives.js" : ["coffee/directives.coffee"]
"js/minioncontroller.js" : ["coffee/minioncontroller.coffee"]
"js/multiminioncontroller.js" : ["coffee/multiminioncontroller.coffee"]
},
options:
sourceMap: false
bare: false
}
bowerConfig = {
install:
options:
targetDir: "./build/www/pages/kncminion/lib"
cleanTargetDir: true
layout : "byType"
}
copyConfig = {
main:
files: [
{ expand: true, cwd: 'html/', src: [ '**'], dest: 'build/www/pages/kncminion/'}
{ expand: true, cwd: 'images/', src: [ '**'], dest: 'build/www/pages/kncminion/images'}
{ expand: true, cwd: 'build/www/pages/kncminion/lib/bootstrap', src: [ 'glyphicons*'], dest: 'build/www/pages/kncminion/lib/fonts'}
{ expand: true, src: ['js/**'], dest: 'build/www/pages/kncminion/' }
{ expand: true, cwd: 'scripts/cgi-bin/', src: [ '**'], dest: 'build/www/pages/cgi-bin' }
{ expand: false, src: 'scripts/runme.sh', dest: 'firmwarebuild/files/runme.sh' }
]
}
compressConfig = {
etc:
options:
mode: 'tgz'
archive: 'firmwarebuild/files/etc.tgz'
expand: true,
cwd: 'config/'
src: ['**/*']
www:
options:
mode: 'tgz'
archive: 'firmwarebuild/files/www.tgz'
expand: true,
cwd: 'build/'
src: ['**/*']
firmwarefile:
options:
mode: 'tgz'
archive: () -> 'firmwarebuild/kncminion-' + grunt.option('gitRevision') + '.bin'
expand: true,
cwd: 'firmwarebuild/files'
src: ['**/*']
}
cleanConfig = [ 'build/**', 'firmwarebuild/**' ]
gitDescribeConfig = {
tagname:
options:
failOnError: false
template: "-{%=tag%}-{%=object%}{%=dirty%}"
}
textReplaceCfg = {
version: {
src: ['build/www/pages/**/*.html']
overwrite: true
replacements: [{
from: 'APPVERSION_HERE',
to: () -> grunt.option('gitRevision')
}]
}
}
cfg = {
coffee: coffeeConfig
bower: bowerConfig
copy: copyConfig
compress: compressConfig
clean: cleanConfig
"git-describe": gitDescribeConfig
replace: textReplaceCfg
}
grunt.initConfig(cfg)
grunt.loadNpmTasks('grunt-contrib-coffee')
grunt.loadNpmTasks('grunt-bower-task')
grunt.loadNpmTasks('grunt-contrib-copy')
grunt.loadNpmTasks('grunt-contrib-compress')
grunt.loadNpmTasks('grunt-contrib-clean')
grunt.loadNpmTasks('grunt-git-describe')
grunt.loadNpmTasks('grunt-text-replace')
grunt.registerTask('saveRevision', () ->
grunt.event.once('git-describe', (rev) ->
revision = "unknown"
if rev.tag?
revision = rev.tag
else if rev.object?
revision = rev.object
if rev.dirty?
revision += rev.dirty
grunt.option('gitRevision', revision)
)
)
taskList = ['clean','saveRevision', 'git-describe:tagname','coffee','bower','copy','replace:version', 'compress:www', 'compress:etc', 'compress:firmwarefile']
grunt.registerTask('default', taskList)