|
1
|
|
|
<?php declare(strict_types=1); |
|
2
|
|
|
/** |
|
3
|
|
|
* Created by Vitaly Iegorov <[email protected]>. |
|
4
|
|
|
* on 22.09.16 at 14:14 |
|
5
|
|
|
*/ |
|
6
|
|
|
namespace samsonframework\bitbucket; |
|
7
|
|
|
|
|
8
|
|
|
use Symfony\Component\Console\Command\Command; |
|
9
|
|
|
use Symfony\Component\Console\Input\InputDefinition; |
|
10
|
|
|
use Symfony\Component\Console\Input\InputInterface; |
|
11
|
|
|
use Symfony\Component\Console\Input\InputOption; |
|
12
|
|
|
use Symfony\Component\Console\Output\OutputInterface; |
|
13
|
|
|
use Symfony\Component\Console\Logger\ConsoleLogger; |
|
14
|
|
|
|
|
15
|
|
|
/** |
|
16
|
|
|
* Class ReporterCommand |
|
17
|
|
|
* |
|
18
|
|
|
* @author Vitaly Egorov <[email protected]> |
|
19
|
|
|
*/ |
|
20
|
|
|
class ReporterCommand extends Command |
|
21
|
|
|
{ |
|
22
|
|
|
protected function configure() |
|
23
|
|
|
{ |
|
24
|
|
|
$this |
|
25
|
|
|
->setName('reporter') |
|
26
|
|
|
->setDescription('Report data to BitBucket pull request') |
|
27
|
|
|
->setDefinition( |
|
28
|
|
|
new InputDefinition(array( |
|
29
|
|
|
new InputOption('username', 'u', InputOption::VALUE_REQUIRED, 'BitBucket account user name'), |
|
30
|
|
|
new InputOption('password', 'pwd', InputOption::VALUE_REQUIRED, ' BitBucket account password'), |
|
31
|
|
|
new InputOption('repo', 'r', InputOption::VALUE_REQUIRED, 'BitBucket repository name'), |
|
32
|
|
|
new InputOption('account', 'a', InputOption::VALUE_REQUIRED, 'BitBucket account name'), |
|
33
|
|
|
new InputOption('pull', 'p', InputOption::VALUE_REQUIRED, 'BiBucket pull request id'), |
|
34
|
|
|
new InputOption('md', 'md', InputOption::VALUE_REQUIRED, 'PHP Mess Detector reporter xml path'), |
|
35
|
|
|
new InputOption('screenshots', 's', InputOption::VALUE_REQUIRED, 'ScreenShots reporter folder path'), |
|
36
|
|
|
//new InputOption('cpd', 'cpd', InputOption::VALUE_REQUIRED), |
|
37
|
|
|
//new InputOption('jshint', 'js', InputOption::VALUE_REQUIRED), |
|
38
|
|
|
//new InputOption('lesshint', 'less', InputOption::VALUE_REQUIRED), |
|
39
|
|
|
//new InputOption('csshint', 'css', InputOption::VALUE_REQUIRED), |
|
40
|
|
|
)) |
|
41
|
|
|
); |
|
42
|
|
|
} |
|
43
|
|
|
|
|
44
|
|
|
protected function execute(InputInterface $input, OutputInterface $output) |
|
45
|
|
|
{ |
|
46
|
|
|
$logger = new ConsoleLogger($output); |
|
47
|
|
|
|
|
48
|
|
|
$reporter = new CloudReporter( |
|
49
|
|
|
new \Bitbucket\API\Authentication\Basic($input->getOption('username'), $input->getOption('password')), |
|
50
|
|
|
$logger, |
|
51
|
|
|
$input->getOption('account'), |
|
52
|
|
|
$input->getOption('repo'), |
|
53
|
|
|
(int)$input->getOption('pull') |
|
54
|
|
|
); |
|
55
|
|
|
|
|
56
|
|
|
if (null !== ($argument = $input->getOption('md'))) { |
|
57
|
|
|
$reporter->addReporter(new MessDetectorReporter($argument)); |
|
58
|
|
|
} |
|
59
|
|
|
|
|
60
|
|
|
if (null !== ($argument = $input->getOption('screenshots'))) { |
|
61
|
|
|
$reporter->addReporter(new ScreenshotReporter($argument)); |
|
62
|
|
|
} |
|
63
|
|
|
|
|
64
|
|
|
$reporter->report(); |
|
65
|
|
|
} |
|
66
|
|
|
} |
|
67
|
|
|
|