|
1 |
| -module.exports = function(grunt) { |
2 |
| - grunt.initConfig({ |
3 |
| - pkg: grunt.file.readJSON("package.json"), |
4 |
| - basedir: require("path").resolve("."), |
5 |
| - test_app_uri: "http://localhost/webino/<%= pkg.name %>/._test/ZendSkeletonApplication/public/", |
6 |
| - clean: { |
7 |
| - log: { |
8 |
| - src: ["._log"] |
9 |
| - }, |
10 |
| - api: { |
11 |
| - src: ["._api"] |
12 |
| - }, |
13 |
| - test_app_vendor: { |
14 |
| - src: ["._test/ZendSkeletonApplication/vendor"] |
15 |
| - }, |
16 |
| - test_app_cfg: { |
17 |
| - src: ["._test/ZendSkeletonApplication/config/application.config.php"] |
18 |
| - } |
19 |
| - }, |
20 |
| - mkdir: { |
21 |
| - log: { |
22 |
| - options: { |
23 |
| - create: [ |
24 |
| - "._log", |
25 |
| - "._log/code-browser", |
26 |
| - "._log/coverage" |
27 |
| - ] |
28 |
| - } |
29 |
| - } |
30 |
| - }, |
31 |
| - exec: { |
32 |
| - classmap: { |
33 |
| - cmd: "php vendor/bin/classmap_generator.php -l src/<%= pkg.name %>" |
34 |
| - }, |
35 |
| - didef: { |
36 |
| - cmd: "php bin/definition_generator.php" |
37 |
| - }, |
38 |
| - phploc: { |
39 |
| - cmd: "vendor/bin/phploc --log-csv ._log/phploc.csv src" |
40 |
| - }, |
41 |
| - pdepend: { |
42 |
| - 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" |
43 |
| - }, |
44 |
| - phpcb: { |
45 |
| - cmd: "vendor/bin/phpcb --log ._log --source src --output ._log/code-browser" |
46 |
| - }, |
47 |
| - phpdoc: { |
48 |
| - cmd: "vendor/bin/phpdoc.php" |
49 |
| - }, |
50 |
| - selenium_start: { |
51 |
| - cmd: "sudo /etc/init.d/selenium start && sleep 5s" |
52 |
| - }, |
53 |
| - selenium_test: { |
54 |
| - cmd: "URI='" + (grunt.option('uri') || "<%= test_app_uri %>") + "' vendor/bin/phpunit -c test/selenium" |
55 |
| - }, |
56 |
| - selenium_stop: { |
57 |
| - cmd: "sudo /etc/init.d/selenium stop" |
58 |
| - }, |
59 |
| - link_precommit: { |
60 |
| - cmd: "ln -s <%= basedir %>/pre-commit <%= basedir %>/.git/hooks/pre-commit && chmod +x <%= basedir %>/pre-commit" |
61 |
| - }, |
62 |
| - add_classmap: { |
63 |
| - cmd: "git add src/<%= pkg.name %>/autoload_classmap.php" |
64 |
| - }, |
65 |
| - add_didef: { |
66 |
| - cmd: "git add data/di" |
67 |
| - }, |
68 |
| - get_composer: { |
69 |
| - cmd: "curl -sS https://getcomposer.org/installer | php" |
70 |
| - }, |
71 |
| - composer_self_update: { |
72 |
| - cmd: "php composer.phar self-update" |
73 |
| - }, |
74 |
| - composer_update_dev: { |
75 |
| - cmd: "php composer.phar update --dev --no-interaction" |
76 |
| - }, |
77 |
| - get_test_app: { |
78 |
| - cmd: "git clone git://github.com/zendframework/ZendSkeletonApplication.git ._test/ZendSkeletonApplication" |
79 |
| - }, |
80 |
| - test_app_reset: { |
81 |
| - cmd: "cd ._test/ZendSkeletonApplication && git reset HEAD --hard" |
82 |
| - }, |
83 |
| - test_app_clean: { |
84 |
| - cmd: "cd ._test/ZendSkeletonApplication && git clean -fdx" |
85 |
| - }, |
86 |
| - test_app_pull: { |
87 |
| - cmd: "cd ._test/ZendSkeletonApplication && git pull origin master" |
88 |
| - }, |
89 |
| - test_app_link_vendor: { |
90 |
| - cmd: "ln -s <%= basedir %>/vendor <%= basedir %>/._test/ZendSkeletonApplication/vendor" |
91 |
| - }, |
92 |
| - test_app_link_cfg: { |
93 |
| - cmd: "ln -s <%= basedir %>/test/resources/config/application.config.php <%= basedir %>/._test/ZendSkeletonApplication/config/application.config.php" |
94 |
| - } |
95 |
| - }, |
96 |
| - phplint: { |
97 |
| - src: ["src/**/*.php"], |
98 |
| - test: ["test/**/*.php"], |
99 |
| - config: ["config/**/*.php"] |
100 |
| - }, |
101 |
| - phpunit: { |
102 |
| - options: { |
103 |
| - configuration: "test", |
104 |
| - bin: "vendor/bin/phpunit", |
105 |
| - coverageHtml: "<%= basedir %>/._log/coverage", |
106 |
| - testdoxHtml: "<%= basedir %>/._log/testdox.html", |
107 |
| - coverageClover: "<%= basedir %>/._log/clover.xml", |
108 |
| - logJunit: "<%= basedir %>/._log/junit.xml", |
109 |
| - colors: true |
110 |
| - }, |
111 |
| - package: {dir: ""} |
112 |
| - }, |
113 |
| - phpcs: { |
114 |
| - options: { |
115 |
| - standard: "PSR2", |
116 |
| - extensions: "php", |
117 |
| - bin: "vendor/bin/phpcs", |
118 |
| - report: "checkstyle", |
119 |
| - reportFile: "._log/checkstyle.xml", |
120 |
| - verbose: true |
121 |
| - }, |
122 |
| - package: {dir: ["src", "test"]} |
123 |
| - }, |
124 |
| - phpmd: { |
125 |
| - options: { |
126 |
| - bin: "vendor/bin/phpmd", |
127 |
| - rulesets: "codesize,design,naming,unusedcode", |
128 |
| - reportFile: "._log/phpmd.xml" |
129 |
| - }, |
130 |
| - package: {dir: "src"} |
131 |
| - }, |
132 |
| - phpcpd: { |
133 |
| - options: { |
134 |
| - bin: "vendor/bin/phpcpd", |
135 |
| - reportFile: "._log/pmd-cpd.xml" |
136 |
| - }, |
137 |
| - package: {dir: "src"} |
138 |
| - }, |
139 |
| - todos: { |
140 |
| - options: { |
141 |
| - priorities : { |
142 |
| - low : null, |
143 |
| - med : /(TODO|todo)/, |
144 |
| - high : /(FIXME|fixme)/ |
145 |
| - }, |
146 |
| - reporter: { |
147 |
| - header: function (options) { |
148 |
| - grunt.file.write("._log/todos.txt", ""); |
149 |
| - return "-- Begin Task List --\n"; |
150 |
| - }, |
151 |
| - fileTasks: function (file, tasks, options) { |
152 |
| - if (!tasks.length) { |
153 |
| - return ""; |
154 |
| - } |
155 |
| - var result = ""; |
156 |
| - result += "For " + file + "\n"; |
157 |
| - tasks.forEach(function (task) { |
158 |
| - result += "[" + task.lineNumber + " - " + task.priority + "] " + task.line + "\n"; |
159 |
| - }); |
160 |
| - result += "\n"; |
161 |
| - grunt.file.write("._log/todos.txt", grunt.file.read("._log/todos.txt") + result); |
162 |
| - return result; |
163 |
| - }, |
164 |
| - footer: function () { |
165 |
| - return "-- End Task List--\n"; |
166 |
| - } |
167 |
| - }, |
168 |
| - verbose: false |
169 |
| - }, |
170 |
| - package: { |
171 |
| - src: ["src/**/*.php"] |
172 |
| - } |
173 |
| - } |
174 |
| - }); |
175 |
| - // |
176 |
| - grunt.registerTask( |
177 |
| - "build", |
178 |
| - "Build the package", |
179 |
| - [ |
180 |
| - "update", |
181 |
| - "test", |
182 |
| - "selenium_test", |
183 |
| - "analyze", |
184 |
| - "api" |
185 |
| - ] |
186 |
| - ); |
187 |
| - grunt.registerTask( |
188 |
| - "update", |
189 |
| - "Update the package development environment", |
190 |
| - [ |
191 |
| - "precommit:init", |
192 |
| - "composer:init", |
193 |
| - "test_app:init", |
194 |
| - "clean:test_app_vendor", |
195 |
| - "exec:test_app_link_vendor", |
196 |
| - "exec:composer_update_dev", |
197 |
| - "clean:test_app_cfg", |
198 |
| - "exec:test_app_link_cfg" |
199 |
| - ] |
200 |
| - ); |
201 |
| - grunt.registerTask( |
202 |
| - "test", |
203 |
| - "Run PHPUnit tests", |
204 |
| - [ |
205 |
| - "clean:log", |
206 |
| - "mkdir:log", |
207 |
| - "phplint", |
208 |
| - "phpunit", |
209 |
| - "phpcs" |
210 |
| - ] |
211 |
| - ); |
212 |
| - grunt.registerTask( |
213 |
| - "selenium_test", |
214 |
| - "Run Selenium tests", |
215 |
| - [ |
216 |
| - "exec:selenium_start", |
217 |
| - "exec:selenium_test", |
218 |
| - "exec:selenium_stop" |
219 |
| - ] |
220 |
| - ); |
221 |
| - grunt.registerTask( |
222 |
| - "analyze", |
223 |
| - "Analyze the code", |
224 |
| - [ |
225 |
| - "phpmd", |
226 |
| - "phpcpd", |
227 |
| - "exec:phploc", |
228 |
| - "exec:pdepend", |
229 |
| - "exec:phpcb", |
230 |
| - "todos" |
231 |
| - ] |
232 |
| - ); |
233 |
| - grunt.registerTask( |
234 |
| - "api", |
235 |
| - "Generate API", |
236 |
| - [ |
237 |
| - "clean:api", |
238 |
| - "exec:phpdoc" |
239 |
| - ] |
240 |
| - ); |
241 |
| - grunt.registerTask( |
242 |
| - "precommit:init", |
243 |
| - "Initialize git pre-commit", |
244 |
| - function() { |
245 |
| - if (grunt.file.isLink(".git/hooks/pre-commit")) { |
246 |
| - grunt.log.ok("Git pre-commit hook OK ..."); |
247 |
| - return; |
248 |
| - } |
249 |
| - grunt.log.ok("Installing git pre-commit hook ..."); |
250 |
| - grunt.task.run("exec:link_precommit"); |
251 |
| - } |
252 |
| - ); |
253 |
| - grunt.registerTask( |
254 |
| - "precommit", |
255 |
| - "Git pre-commit", |
256 |
| - [ |
257 |
| - "exec:classmap", |
258 |
| - "test", |
259 |
| - "exec:didef", |
260 |
| - "exec:add_classmap", |
261 |
| - "exec:add_didef" |
262 |
| - ] |
263 |
| - ); |
264 |
| - grunt.registerTask( |
265 |
| - "composer:init", |
266 |
| - "Initialize PHP composer", |
267 |
| - function() { |
268 |
| - if (grunt.file.isFile("composer.phar")) { |
269 |
| - grunt.log.ok("Updating composer.phar ..."); |
270 |
| - grunt.task.run("exec:composer_self_update"); |
271 |
| - return; |
272 |
| - } |
273 |
| - grunt.log.ok("Downloading composer.phar ..."); |
274 |
| - grunt.task.run("exec:get_composer"); |
| 1 | +var root = ''; |
| 2 | +if (undefined === process.env.NODE_PATH) { |
| 3 | + console.error('NODE_PATH is not configured, trying to resolve.'); |
| 4 | + root = (function () { |
| 5 | + try { |
| 6 | + require('shelljs/global'); |
| 7 | + return exec('npm root -g', {silent: true}).output.trim() + '/'; |
| 8 | + } catch(exc) { |
| 9 | + console.error('Assuming default NODE_PATH, did you initialize the module?'); |
275 | 10 | }
|
276 |
| - ); |
277 |
| - grunt.registerTask( |
278 |
| - "test_app:init", |
279 |
| - "Initialize test application", |
280 |
| - function() { |
281 |
| - if (grunt.file.isDir("._test/ZendSkeletonApplication")) { |
282 |
| - grunt.log.ok("Updating test application ..."); |
283 |
| - grunt.task.run(["exec:test_app_reset", "exec:test_app_clean", "exec:test_app_pull"]); |
284 |
| - return; |
285 |
| - } |
286 |
| - grunt.log.ok("Downloading test application ..."); |
287 |
| - grunt.task.run("exec:get_test_app"); |
288 |
| - } |
289 |
| - ); |
290 |
| - // |
291 |
| - grunt.loadNpmTasks("grunt-exec"); |
292 |
| - grunt.loadNpmTasks("grunt-contrib-clean"); |
293 |
| - grunt.loadNpmTasks("grunt-mkdir"); |
294 |
| - grunt.loadNpmTasks("grunt-phplint"); |
295 |
| - grunt.loadNpmTasks("grunt-phpunit"); |
296 |
| - grunt.loadNpmTasks("grunt-phpcs"); |
297 |
| - grunt.loadNpmTasks("grunt-phpmd"); |
298 |
| - grunt.loadNpmTasks("grunt-phpcpd"); |
299 |
| - grunt.loadNpmTasks("grunt-todos"); |
| 11 | + })(); |
| 12 | + |
| 13 | + root || (root = '/usr/lib/node_modules/'); |
| 14 | + process.env.NODE_PATH = root; |
| 15 | +} |
| 16 | +module.exports = function(grunt) { |
| 17 | + grunt.initConfig((function () { |
| 18 | + return require(root + 'webino-devkit'); |
| 19 | + })().config(grunt, ['module', 'github', 'zend'])); |
300 | 20 | };
|
0 commit comments