forked from webino/WebinoImageThumb
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGruntfile.js
300 lines (300 loc) · 9.64 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
294
295
296
297
298
299
300
module.exports = function(grunt) {
grunt.initConfig({
pkg: grunt.file.readJSON("package.json"),
basedir: require("path").resolve("."),
test_app_uri: "http://localhost/webino/<%= pkg.name %>/._test/ZendSkeletonApplication/public/",
clean: {
log: {
src: ["._log"]
},
api: {
src: ["._api"]
},
test_app_vendor: {
src: ["._test/ZendSkeletonApplication/vendor"]
},
test_app_cfg: {
src: ["._test/ZendSkeletonApplication/config/application.config.php"]
}
},
mkdir: {
log: {
options: {
create: [
"._log",
"._log/code-browser",
"._log/coverage"
]
}
}
},
exec: {
classmap: {
cmd: "php vendor/bin/classmap_generator.php -l src/<%= pkg.name %>"
},
didef: {
cmd: "php bin/definition_generator.php"
},
phploc: {
cmd: "vendor/bin/phploc --log-csv ._log/phploc.csv src"
},
pdepend: {
cmd: "vendor/bin/pdepend --summary-xml=._log/pdepend.xml --jdepend-xml=._log/jdepend.xml --jdepend-chart=._log/dependencies.svg --overview-pyramid=._log/overview-pyramid.svg src"
},
phpcb: {
cmd: "vendor/bin/phpcb --log ._log --source src --output ._log/code-browser"
},
phpdoc: {
cmd: "vendor/bin/phpdoc.php"
},
selenium_start: {
cmd: "sudo /etc/init.d/selenium start && sleep 5s"
},
selenium_test: {
cmd: "URI='" + (grunt.option('uri') || "<%= test_app_uri %>") + "' vendor/bin/phpunit -c test/selenium"
},
selenium_stop: {
cmd: "sudo /etc/init.d/selenium stop"
},
link_precommit: {
cmd: "ln -s <%= basedir %>/pre-commit <%= basedir %>/.git/hooks/pre-commit && chmod +x <%= basedir %>/pre-commit"
},
add_classmap: {
cmd: "git add src/<%= pkg.name %>/autoload_classmap.php"
},
add_didef: {
cmd: "git add data/di"
},
get_composer: {
cmd: "curl -sS https://getcomposer.org/installer | php"
},
composer_self_update: {
cmd: "php composer.phar self-update"
},
composer_update_dev: {
cmd: "php composer.phar update --dev --no-interaction"
},
get_test_app: {
cmd: "git clone git://github.com/zendframework/ZendSkeletonApplication.git ._test/ZendSkeletonApplication"
},
test_app_reset: {
cmd: "cd ._test/ZendSkeletonApplication && git reset HEAD --hard"
},
test_app_clean: {
cmd: "cd ._test/ZendSkeletonApplication && git clean -fdx"
},
test_app_pull: {
cmd: "cd ._test/ZendSkeletonApplication && git pull origin master"
},
test_app_link_vendor: {
cmd: "ln -s <%= basedir %>/vendor <%= basedir %>/._test/ZendSkeletonApplication/vendor"
},
test_app_link_cfg: {
cmd: "ln -s <%= basedir %>/test/resources/config/application.config.php <%= basedir %>/._test/ZendSkeletonApplication/config/application.config.php"
}
},
phplint: {
src: ["src/**/*.php"],
test: ["test/**/*.php"],
config: ["config/**/*.php"]
},
phpunit: {
options: {
configuration: "test",
bin: "vendor/bin/phpunit",
coverageHtml: "<%= basedir %>/._log/coverage",
testdoxHtml: "<%= basedir %>/._log/testdox.html",
coverageClover: "<%= basedir %>/._log/clover.xml",
logJunit: "<%= basedir %>/._log/junit.xml",
colors: true
},
package: {dir: ""}
},
phpcs: {
options: {
standard: "PSR2",
extensions: "php",
bin: "vendor/bin/phpcs",
report: "checkstyle",
reportFile: "._log/checkstyle.xml",
verbose: true
},
package: {dir: ["src", "test"]}
},
phpmd: {
options: {
bin: "vendor/bin/phpmd",
rulesets: "codesize,design,naming,unusedcode",
reportFile: "._log/phpmd.xml"
},
package: {dir: "src"}
},
phpcpd: {
options: {
bin: "vendor/bin/phpcpd",
reportFile: "._log/pmd-cpd.xml"
},
package: {dir: "src"}
},
todos: {
options: {
priorities : {
low : null,
med : /(TODO|todo)/,
high : /(FIXME|fixme)/
},
reporter: {
header: function (options) {
grunt.file.write("._log/todos.txt", "");
return "-- Begin Task List --\n";
},
fileTasks: function (file, tasks, options) {
if (!tasks.length) {
return "";
}
var result = "";
result += "For " + file + "\n";
tasks.forEach(function (task) {
result += "[" + task.lineNumber + " - " + task.priority + "] " + task.line + "\n";
});
result += "\n";
grunt.file.write("._log/todos.txt", grunt.file.read("._log/todos.txt") + result);
return result;
},
footer: function () {
return "-- End Task List--\n";
}
},
verbose: false
},
package: {
src: ["src/**/*.php"]
}
}
});
//
grunt.registerTask(
"build",
"Build the package",
[
"update",
"test",
"selenium_test",
"analyze",
"api"
]
);
grunt.registerTask(
"update",
"Update the package development environment",
[
"precommit:init",
"composer:init",
"test_app:init",
"clean:test_app_vendor",
"exec:test_app_link_vendor",
"exec:composer_update_dev",
"clean:test_app_cfg",
"exec:test_app_link_cfg"
]
);
grunt.registerTask(
"test",
"Run PHPUnit tests",
[
"clean:log",
"mkdir:log",
"phplint",
"phpunit",
"phpcs"
]
);
grunt.registerTask(
"selenium_test",
"Run Selenium tests",
[
"exec:selenium_start",
"exec:selenium_test",
"exec:selenium_stop"
]
);
grunt.registerTask(
"analyze",
"Analyze the code",
[
"phpmd",
"phpcpd",
"exec:phploc",
"exec:pdepend",
"exec:phpcb",
"todos"
]
);
grunt.registerTask(
"api",
"Generate API",
[
"clean:api",
"exec:phpdoc"
]
);
grunt.registerTask(
"precommit:init",
"Initialize git pre-commit",
function() {
if (grunt.file.isLink(".git/hooks/pre-commit")) {
grunt.log.ok("Git pre-commit hook OK ...");
return;
}
grunt.log.ok("Installing git pre-commit hook ...");
grunt.task.run("exec:link_precommit");
}
);
grunt.registerTask(
"precommit",
"Git pre-commit",
[
"exec:classmap",
"test",
"exec:didef",
"exec:add_classmap",
"exec:add_didef"
]
);
grunt.registerTask(
"composer:init",
"Initialize PHP composer",
function() {
if (grunt.file.isFile("composer.phar")) {
grunt.log.ok("Updating composer.phar ...");
grunt.task.run("exec:composer_self_update");
return;
}
grunt.log.ok("Downloading composer.phar ...");
grunt.task.run("exec:get_composer");
}
);
grunt.registerTask(
"test_app:init",
"Initialize test application",
function() {
if (grunt.file.isDir("._test/ZendSkeletonApplication")) {
grunt.log.ok("Updating test application ...");
grunt.task.run(["exec:test_app_reset", "exec:test_app_clean", "exec:test_app_pull"]);
return;
}
grunt.log.ok("Downloading test application ...");
grunt.task.run("exec:get_test_app");
}
);
//
grunt.loadNpmTasks("grunt-exec");
grunt.loadNpmTasks("grunt-contrib-clean");
grunt.loadNpmTasks("grunt-mkdir");
grunt.loadNpmTasks("grunt-phplint");
grunt.loadNpmTasks("grunt-phpunit");
grunt.loadNpmTasks("grunt-phpcs");
grunt.loadNpmTasks("grunt-phpmd");
grunt.loadNpmTasks("grunt-phpcpd");
grunt.loadNpmTasks("grunt-todos");
};