-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathgruntfile.js
293 lines (282 loc) · 9.79 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
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
'use strict';
module.exports = function(grunt) {
// These plugins provide necessary tasks.
// grunt.loadNpmTasks('jshint-stylish');
// load all grunt tasks matching the `grunt-*` pattern
require('load-grunt-tasks')(grunt);
// Project configuration
grunt.initConfig({
distdir: 'build',
/*
* The project metadata that can be loaded from the package.json and reused in the Gruntfile.
*/
pkg: grunt.file.readJSON('package.json'),
banner: '/*\n' +
' * TweetMap v<%= pkg.version %> (<%= pkg.homepage %>)\n' +
' * Copyright <%= grunt.template.today("yyyy") %>(c) <%= pkg.author %>\n' +
' * Licensed under <%= _.pluck(pkg.licenses, "type").join(", ") %>\n' +
' */\n\n',
/*
* The definition of all the sources files and their location.
*/
dirs: {
gruntfile: 'gruntfile.js',
server: {
jade: './server/src/app/view/**/*.jade',
src: 'server/**/*.js',
test: 'test/server/**/*.js'
},
client: {
js: './client/src/app/**/*.js',
css: './client/src/assets/**/*.css',
img: './client/src/assets/img',
tests: {
integration: {
config: 'test/karma/integration.conf.js',
src: 'test/karma/integration/**/*.js'
},
unit: {
config: './client/test/config/karma-unit.conf.js',
src: './client/test/unit/**/*.js'
}
}
}
},
/*
* Clean build directory.
*/
clean: ['<%= distdir %>/*'],
/*
* Static source code analyses. JSHint verifies that we are adhering
* to good coding styles, avoid pitfalls and much more.
* http://jshint.com/docs/
*
* We are configuring different settings for the different parts of our
* code, as browser environments are different to NodeJS environments.
*/
jshint: {
files: ['<%= dirs.client.js %>'],
options: {
// use a nice JSHint reporter
// reporter: require('jshint-stylish'),
// options here to override JSHint defaults
"node": true,
"browser": true,
"esnext": true,
"bitwise": true,
"curly": true,
"eqeqeq": true,
"immed": true,
"indent": 2,
"latedef": true,
"newcap": true,
"noarg": true,
"regexp": true,
"undef": true,
"unused": true,
"trailing": true,
"smarttabs": true,
"globals": {
"angular": false
}
}
},
/*
* Static source code analyses. JSHLint verifies that we are adhering
* to good coding styles, avoid pitfalls and much more.
* http://csslint.net/
*/
csslint: {
strict: {
options: {
import: 2
},
src: '<%= dirs.client.css %>'
}
},
/*
* Concatenate client javascript files.
*/
concat: {
options: {
banner: '<%= banner %>'
},
js: {
src: '<%= dirs.client.js %>',
dest: "<%= distdir %>/js/<%= pkg.name %>-v<%= pkg.version %>.js"
},
css: {
src: '<%= dirs.client.css %>',
dest: "<%= distdir %>/css/<%= pkg.name %>-v<%= pkg.version %>.css"
}
},
/*
* Minify JavaScript and CSS to make file sizes as small as possible for production website.
*/
uglify: {
options: {
banner: "<%= banner %>"
},
js: {
src: '<%= distdir %>/<%= pkg.name %>-v<%= pkg.version %>.js',
dest: "<%= distdir %>/<%= pkg.name %>-v<%= pkg.version %>.min.js"
}
// css: {
// src: '<%= distdir %>/<%= pkg.name %>-v<%= pkg.version %>.css',
// dest: "<%= distdir %>/<%= pkg.name %>-v<%= pkg.version %>.min.css"
// }
},
/*
* Minify PNG, JPEG and GIF images to make file sizes as small as possible for production website.
*/
imagemin: {
dynamic: {
files: [{
cwd: '<%= dirs.client.img %>',
src: ['**/*.{png,jpg,gif}'],
dest: '<%= distdir %>/img/'
}]
}
},
'bower-install': {
target: {
// Point to the html file that should be updated
// when you run `grunt bower-install`
html: 'server/src/app/views/includes/head.jade'
}
},
connect: {
testserver: {
options: {
port: 9999
}
}
},
shell: {
options: {
stdout: true
},
selenium: {
command: './selenium/start',
options: {
stdout: false,
async: true
}
},
protractor_install: {
command: 'node ./node_modules/protractor/bin/webdriver-manager update'
},
protractor_start: {
command: 'node ./node_modules/protractor/bin/webdriver-manager start'
},
npm_install: {
command: 'npm install'
}
},
watch: {
options: {
// Start a live reload server on the default port 35729
livereload: true
},
files:['<%= src.js %>', '<%= src.css %>', '<%= src.jade %>'],
tasks:['default','timestamp']
},
karma: {
unit: {
configFile: './client/test/config/karma-unit.conf.js',
autoWatch: false,
singleRun: true
},
unit_auto: {
configFile: './client/test/config/karma-unit.conf.js',
autoWatch: true,
singleRun: false
},
unit_coverage: {
configFile: './client/test/config/karma-unit.conf.js',
autoWatch: false,
singleRun: true,
reporters: ['progress', 'coverage'],
preprocessors: {
'app/scripts/*.js': ['coverage']
},
coverageReporter: {
type : 'html',
dir : 'coverage/'
}
}
},
protractor: {
options: {
keepAlive: true,
configFile: "./client/test/config/protractor.conf.js"
},
singlerun: {},
auto: {
keepAlive: true,
options: {
args: {
seleniumPort: 4444
}
}
}
},
saucelabs: {
options: {
reporter: 'Spec',
sauceTunnelId: process.env.TRAVIS_JOB_NUMBER,
sauceSession: 'Grunt Mocha Protractor',
browsers: [
{
base: 'SauceLabs',
browserName: 'Chrome',
platform: 'Windows 7'
},
{
base: 'SauceLabs',
browserName: 'Firefox'
},
{
base: 'SauceLabs',
browserName: 'Internet Explorer',
version: '10'
}
]
},
files: {
src: 'test/*.js'
}
}
});
// Print a timestamp (useful for when watching)
grunt.registerTask('timestamp', function() {
grunt.log.subhead(Date());
});
// Default task
grunt.registerTask('default', ['jshint']);
//single run tests
grunt.registerTask('test', ['jshint','test:unit', 'test:e2e']);
grunt.registerTask('test:unit', ['karma:unit']);
grunt.registerTask('test:e2e', ['protractor:singlerun']);
grunt.registerTask('protractor', ['shell:protractor_install','shell:protractor_start']);
//installation-related
grunt.registerTask('install', ['shell:protractor_install']);
grunt.registerTask('update', ['shell:npm_install', 'concat']);
grunt.registerTask('build', ['clean','imagemin','concat','uglify']);
// Generate the production version
// ------------------
grunt.registerTask('build:production', "Build a minified & production-ready version of your app.", [
'clean:dist',
'build:dist',
'copy:assemble',
'createDistVersion'
]);
/*
* Follow are production steps
* 1. Clean & copy files to build folder.. Do I need to that what if I just concate and minifide files straight away to disct folder?
* 2. jshint and csshint to verify that js and css syntax is ok
* 3. concat js files to one file
* 4. Minify files
*
* */
};