This repository has been archived by the owner on Feb 13, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 15
/
Gruntfile.js
150 lines (130 loc) · 5.71 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
/**
* Grunt configuration - http://gruntjs.com
*/
module.exports = function (grunt) {
'use strict';
require('time-grunt')(grunt);
// Project configuration.
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
// files to be used (minimatch syntax) - https://github.com/isaacs/minimatch
files: {
jshint: [
'Gruntfile.js',
'web/js/**/*.js'
]
},
dirs: {
phpcs: [
'app/*.php',
'src',
'tests'
],
phpmd: [
'src',
'tests'
]
},
// https://github.com/gruntjs/grunt-contrib-jshint
jshint: {
options: {
jshintrc: '.jshintrc'
},
files: {
src: '<%= files.jshint %>'
}
},
// https://github.com/jharding/grunt-exec
exec: {
'mac-paths': {
cmd: function (user) {
user = user || '_www';
return ('mkdir -p app/cache ' +
'&& mkdir -p app/log ' +
'&& sudo chmod +a "' + user + ' allow delete,write,append,file_inherit,directory_inherit" app/cache app/log ' +
'&& sudo chmod +a "`whoami` allow delete,write,append,file_inherit,directory_inherit" app/cache app/log');
}
},
'ubuntu-paths': {
cmd: function (user) {
user = user || 'www-data';
return ('mkdir -p app/cache ' +
'&& mkdir -p app/log ' +
'&& sudo setfacl -R -m u:'+user+':rwx -m u:`whoami`:rwx app/cache app/log ' +
'&& sudo setfacl -dR -m u:'+user+':rwx -m u:`whoami`:rwx app/cache app/log ');
}
},
// https://github.com/sebastianbergmann/phpunit/
'phpunit': {
cmd: 'vendor/bin/phpunit -c phpunit.xml.dist'
},
'phpunit-ci': {
cmd: 'vendor/bin/phpunit -c phpunit.xml.dist ' +
'--coverage-html build/coverage ' +
'--coverage-clover build/logs/clover.xml ' +
'--log-junit build/logs/junit.xml'
},
'phpunit-travis': {
cmd: 'vendor/bin/phpunit --coverage-clover build/logs/clover.xml'
},
// http://www.squizlabs.com/php-codesniffer
'phpcs': {
cmd: function () {
return 'mkdir -p build/reports && vendor/bin/phpcs --report=full --report=checkstyle --report-checkstyle=build/reports/checkstyle.xml ' +
'--standard=PSR2 --extensions=php ' + grunt.config.data.dirs.phpcs.join(' ');
}
},
'phpcs-travis': {
cmd: function () {
return 'vendor/bin/phpcs --standard=PSR2 --extensions=php ' + grunt.config.data.dirs.phpcs.join(' ');
}
},
// http://phpmd.org/documentation/index.html
'phpmd': {
cmd: function () {
return 'vendor/bin/phpmd ' + grunt.config.data.dirs.phpmd.join(',') + ' text phpmd.xml --suffixes=php';
}
},
'phpmd-ci': {
cmd: function () {
return 'mkdir -p build/reports && vendor/bin/phpmd ' + grunt.config.data.dirs.phpmd.join(',') + ' xml phpmd.xml --suffixes=php --reportfile build/reports/phpmd.xml';
}
},
'composer-install': {
cmd: 'composer --dev install'
},
'ci-prepare': {
cmd: 'curl -s https://getcomposer.org/installer | php' +
'&& php composer.phar --dev install' +
'&& rm composer.phar ' +
'&& mkdir -p app/log ' +
'&& mkdir -p app/cache ' +
'&& rm -rf app/cache/*'
},
'npm-install': {
cmd: 'npm install'
},
'bundle-install': {
cmd: 'bundle install'
}
}
}
)
;
// Tasks from NPM
grunt.loadNpmTasks('grunt-exec');
grunt.loadNpmTasks('grunt-contrib-jshint');
// Task aliases
grunt.registerTask('ubuntu-paths', 'Set up log and cache paths on a Mac', 'exec:ubuntu-paths');
grunt.registerTask('mac-paths', 'Set up log and cache paths on a Mac', 'exec:mac-paths');
grunt.registerTask('phpunit', 'PHP Unittests', 'exec:phpunit');
grunt.registerTask('phpunit-ci', 'PHP Unittests for CI', 'exec:phpunit-ci');
grunt.registerTask('phpcs', 'PHP Codesniffer', 'exec:phpcs');
grunt.registerTask('phpmd', 'PHP Mess Detector', 'exec:phpmd');
grunt.registerTask('install', 'Install all project dependencies', ['exec:npm-install', 'exec:composer-install', 'exec:bundle-install']);
grunt.registerTask('default', ['qa']);
grunt.registerTask('qa', ['phpunit', 'phpcs', 'phpmd']);
grunt.registerTask('jenkins', ['exec:ci-prepare', 'phpunit-ci', 'phpcs', 'exec:phpmd-ci']);
grunt.registerTask('travis', ['exec:composer-install', 'exec:phpunit-travis', 'exec:phpcs-travis', 'phpmd']);
}
;