1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Juanber84\Console; |
4
|
|
|
|
5
|
|
|
use Juanber84\Console\Command\BatchProcessCommand; |
6
|
|
|
use Juanber84\Console\Command\SelfUpdateCommand; |
7
|
|
|
use Juanber84\Services\ApplicationService; |
8
|
|
|
use Juanber84\Services\GitHubService; |
9
|
|
|
use Symfony\Component\Console\Application as BaseApplication; |
10
|
|
|
|
11
|
|
|
class Application extends BaseApplication |
12
|
|
|
{ |
13
|
|
|
|
14
|
|
|
const MESSAGE_NAME = "Automatic deploy tool"; |
15
|
|
|
const MESSAGE_UPDATE = "New release available. Please execute"; |
16
|
|
|
|
17
|
|
|
private static $logo = " |
18
|
|
|
.----------------. .----------------. .----------------. |
19
|
|
|
| .--------------. || .--------------. || .--------------. | |
20
|
|
|
| | ________ | || | _________ | || | ______ | | |
21
|
|
|
| | |_ ___ `. | || | |_ ___ | | || | |_ __ \\ | | |
22
|
|
|
| | | | `. \\ | || | | |_ \\_| | || | | |__) | | | |
23
|
|
|
| | | | | | | || | | _| _ | || | | ___/ | | |
24
|
|
|
| | _| |___.' / | || | _| |___/ | | || | _| |_ | | |
25
|
|
|
| | |________.' | || | |_________| | || | |_____| | | |
26
|
|
|
| | | || | | || | | | |
27
|
|
|
| '--------------' || '-------------- ' || '--------------' | |
28
|
|
|
'----------------' '----------------' '----------------' |
29
|
|
|
"; |
30
|
|
|
|
31
|
|
|
private $applicationService; |
32
|
|
|
|
33
|
|
|
private $gitHubService; |
34
|
|
|
|
35
|
|
|
public function __construct(ApplicationService $applicationService, GitHubService $gitHubService) |
36
|
|
|
{ |
37
|
|
|
parent::__construct(); |
38
|
|
|
|
39
|
|
|
$this->applicationService = $applicationService; |
40
|
|
|
$this->gitHubService = $gitHubService; |
41
|
|
|
} |
42
|
|
|
|
43
|
|
|
public function getHelp() |
44
|
|
|
{ |
45
|
|
|
return self::$logo . parent::getHelp(); |
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
public function getLongVersion() |
49
|
|
|
{ |
50
|
|
|
$actualVersion = $this->applicationService->currentTimeVersion(); |
51
|
|
|
$latestVersion = $this->gitHubService->latestTimeVersion(); |
52
|
|
|
|
53
|
|
|
$message = ''; |
54
|
|
|
if ($actualVersion < $latestVersion) { |
55
|
|
|
$message .= "\n <bg=yellow;fg=black;options=bold>".self::MESSAGE_UPDATE." ".SelfUpdateCommand::COMMAND_NAME." to install.</>\n"; |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
$message .="\n <info>".self::MESSAGE_NAME." </info>".$actualVersion; |
59
|
|
|
|
60
|
|
|
return $message; |
61
|
|
|
} |
62
|
|
|
} |