forked from IBM/taxinomitis
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Gruntfile.js
199 lines (185 loc) · 5.95 KB
/
Gruntfile.js
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
module.exports = function(grunt) {
// something unique to protect against problems from browsers
// caching old versions of JS
const now = new Date();
const VERSION = now.getTime();
grunt.initConfig({
clean : {
ts : ['./dist'],
web : ['./web']
},
ts : {
options : {
fast : 'never'
},
default : {
tsconfig : './tsconfig.json'
}
},
tslint : {
options : {
configuration : './tslint.json',
project : './tsconfig.json'
},
all : {
src : [
'src/**/*.ts',
'!node_modules/**/*.ts'
]
}
},
eslint : {
options : {
configFile : './.eslintrc.json'
},
target : [ 'dist/**/*.js' ]
},
mochaTest : {
test : {
options : {
timeout : 20000
},
src : ['dist/tests/**/*.js']
}
},
nyc : {
cover : {
options : {
cwd : './dist',
include : ['lib/**'],
exclude : ['tests/**'],
reporter: ['lcov', 'text-summary'],
reportDir : '../coverage'
},
cmd : false,
args : ['grunt', 'mochaTest']
}
},
'bower-install-simple' : {
options : {
cwd : './public',
directory : '../web/static/bower_components'
},
prod : {
options : {
production : true
}
},
dev : {
options : {
production : false
}
}
},
copy : {
twittercard : {
src : 'public/twitter-card.html',
dest : 'web/dynamic/twitter-card.html'
},
crossdomain : {
src : 'public/crossdomain.xml',
dest : 'web/dynamic/crossdomain.xml'
},
scratchx : {
expand : true,
cwd : 'public/scratchx',
src : '**',
dest : 'web/scratchx'
},
datasets : {
expand : true,
cwd : 'public/datasets',
src : '**',
dest : 'web/datasets'
},
jsapp : {
src : 'public/app.js',
dest : 'web/static/app-' + VERSION + '.js',
options : {
process : function (content, srcpath) {
return grunt.template.process(content, { data : { VERSION }})
}
}
},
components : {
expand : true,
cwd : 'public/components',
src : '**',
dest : 'web/static/components-' + VERSION,
options : {
process : function (content, srcpath) {
return grunt.template.process(content, { data : { VERSION }})
}
}
},
languages : {
expand : true,
cwd : 'public/languages',
src : '**',
dest : 'web/static/languages-' + VERSION
},
images : {
expand : true,
cwd : 'public/images',
src : '**',
dest : 'web/static/images'
}
},
cssmin : {
target : {
files : [
{
src : ['public/app.css', 'public/components/**/*.css'],
dest : 'web/static/style-' + VERSION + '.min.css'
}
]
}
},
postcss : {
options : {
map : false,
processors: [
require('autoprefixer')
]
},
dist : {
src : 'web/static/style*css'
}
}
});
grunt.loadNpmTasks('gruntify-eslint');
grunt.loadNpmTasks('grunt-ts');
grunt.loadNpmTasks('grunt-tslint');
grunt.loadNpmTasks('grunt-mocha-test');
grunt.loadNpmTasks('grunt-simple-nyc');
grunt.loadNpmTasks('grunt-bower-install-simple');
grunt.loadNpmTasks('grunt-contrib-clean');
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.loadNpmTasks('grunt-contrib-cssmin');
grunt.loadNpmTasks('grunt-postcss');
//-----------------------------------
// back-end tasks
//-----------------------------------
// compile the typescript code and run the linter
grunt.registerTask('compile', ['ts', 'tslint:all', 'eslint']);
// run the back-end unit and integration tests, with coverage
grunt.registerTask('test', ['nyc:cover']);
//-----------------------------------
// front-end tasks
//-----------------------------------
// fetch UI third-party dependencies
grunt.registerTask('bower', ['bower-install-simple']);
// install Scratchx into the deployment
grunt.registerTask('scratchx', ['copy:scratchx', 'copy:crossdomain']);
// copy the datasets mini-site into the deployment
grunt.registerTask('datasets', ['copy:datasets']);
// copy the Twitter card into the deployment
grunt.registerTask('twitter', ['copy:twittercard']);
// minify the CSS
grunt.registerTask('css', ['cssmin', 'postcss:dist']);
// prepare the main app
grunt.registerTask('uiapp', ['copy:jsapp', 'copy:components', 'copy:languages', 'copy:images']);
//
grunt.registerTask('frontendfiles', ['bower', 'scratchx', 'datasets', 'twitter']);
grunt.registerTask('default', ['compile', 'test']);
};