-
Notifications
You must be signed in to change notification settings - Fork 7
/
Gruntfile.js
120 lines (109 loc) · 3.1 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
var fs = require('node-fs-extra');
module.exports = function(grunt) {
grunt.initConfig({
jshint: {
server: {
src: ['Gruntfile.js',
'server/features/**/*.js',
'server/server.js',
'server/routes/**/*.js',
'server/manager/**/*.js',
'server/dao/**/*.js',
'server/util/**/*.js',
'server/middleware/**/*.js',
'server/config/**/*.js'
]
},
client: {
options: {
extract: 'auto'
},
src: ['server/public/*.html', 'server/public/elements/**/*.html', 'server/public/elements/**/*.js', 'server/public/util/**/*.js']
}
},
cucumberjs: {
options: {
format: 'pretty'
},
features : ['server/features/*']
},
vulcanize: {
default: {
options: {
csp: true,
excludes: {
imports: [
"polymer.html"
]
}
},
files: {
'server/public/dist/index.html': 'server/public/index.html'
},
}
},
'dist-client': {
default: {}
},
shell: {
runLocalServer: {
command: 'DEBUG=social-scoreboard* node server/server'
},
runLocalServerWin32: {
command: [
'set DEBUG=social-scoreboard*',
'node server/server'
].join('&&')
},
apiaryCompile: {
command: 'node ./server/api/apiary/apiary.preprocesor.js'
},
dredd: {
command: 'CONFIG=dredd dredd ./server/api/apiary/apiary.apib http://localhost:8000 --hookfiles=./server/api/apiary/hooks.js'
}
},
env: {
cucumber : {
CONFIG : "cucumber"
}
}
});
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-cucumberjs');
grunt.loadNpmTasks('grunt-vulcanize');
grunt.loadNpmTasks('grunt-env');
grunt.loadNpmTasks('grunt-shell');
grunt.registerMultiTask('dist-client', 'Prepare client files to distribution', function() {
var inDir = './server/public/';
var outDir = inDir + 'dist/';
grunt.log.writeln('Removing client/dist directory...');
var done = this.async();
fs.remove(outDir, function(err, result) {
if (err) {
grunt.log.error(err);
done(err);
} else {
fs.mkdirsSync(outDir);
grunt.task.run('vulcanize');
fs.copySync(inDir + 'font', outDir + 'font');
fs.copySync(inDir + 'img', outDir + 'img');
fs.copySync(inDir + 'bower_components', outDir + 'bower_components');
fs.copySync(inDir + 'css', outDir + 'css');
fs.copySync(inDir + 'elements/point-setter/presenter.js', outDir + 'elements/point-setter/presenter.js'); //TODO Minify this- Vulvanize can't do it
done();
}
});
});
grunt.registerTask('server-test', ['env:cucumber', 'jshint:server', 'cucumberjs']);
grunt.registerTask('apiary', ['shell:apiaryCompile']);
grunt.registerTask('dredd', ['shell:apiaryCompile', 'shell:dredd']);
grunt.registerTask('default', ['jshint:client', 'jshint:server', 'shell:runLocalServer']);
grunt.registerTask('set-debug-and-run', 'Set DEBUG env var', function() {
if (process.platform === "win32") {
grunt.task.run('shell:runLocalServerWin32');
} else {
grunt.task.run('shell:runLocalServer');
}
});
grunt.registerTask('default', ['jshint:client', 'jshint:server', 'set-debug-and-run']);
};