1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* AppserverIo\RoboTasks\AbstractRoboFile |
5
|
|
|
* |
6
|
|
|
* NOTICE OF LICENSE |
7
|
|
|
* |
8
|
|
|
* This source file is subject to the Open Software License (OSL 3.0) |
9
|
|
|
* that is available through the world-wide-web at this URL: |
10
|
|
|
* http://opensource.org/licenses/osl-3.0.php |
11
|
|
|
* |
12
|
|
|
* PHP version 5 |
13
|
|
|
* |
14
|
|
|
* @author Tim Wagner <[email protected]> |
15
|
|
|
* @copyright 2015 TechDivision GmbH <[email protected]> |
16
|
|
|
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) |
17
|
|
|
* @link https://github.com/appserver-io/robo-tasks |
18
|
|
|
* @link http://www.appserver.io |
19
|
|
|
*/ |
20
|
|
|
|
21
|
|
|
namespace AppserverIo\RoboTasks; |
22
|
|
|
|
23
|
|
|
use Robo\Robo; |
24
|
|
|
use Robo\Tasks; |
25
|
|
|
|
26
|
|
|
/** |
27
|
|
|
* Abstract implementation of a Robo configuration class. |
28
|
|
|
* |
29
|
|
|
* @author Tim Wagner <[email protected]> |
30
|
|
|
* @copyright 2015 TechDivision GmbH <[email protected]> |
31
|
|
|
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) |
32
|
|
|
* @link https://github.com/appserver-io/robo-tasks |
33
|
|
|
* @link http://www.appserver.io |
34
|
|
|
*/ |
35
|
|
|
abstract class AbstractRoboFile extends Tasks |
36
|
|
|
{ |
37
|
|
|
|
38
|
|
|
/** |
39
|
|
|
* Load the appserver.io base tasks. |
40
|
|
|
* |
41
|
|
|
* @var \AppserverIo\RoboTasks\Base\loadTasks |
42
|
|
|
*/ |
43
|
|
|
use Base\loadTasks; |
44
|
|
|
|
45
|
|
|
/** |
46
|
|
|
<<<<<<< HEAD |
47
|
|
|
* Initializes the default configuration. |
48
|
|
|
*/ |
49
|
|
|
public function __construct() |
50
|
|
|
{ |
51
|
|
|
|
52
|
|
|
// initialize the default configuration |
53
|
|
|
Robo::config()->setDefault(sprintf('%s.%s', ConfigurationKeys::DIRS, ConfigurationKeys::SRC), sprintf('%s/src', getcwd())); |
54
|
|
|
Robo::config()->setDefault(sprintf('%s.%s', ConfigurationKeys::DIRS, ConfigurationKeys::VENDOR), sprintf('%s/vendor', getcwd())); |
55
|
|
|
Robo::config()->setDefault(sprintf('%s.%s', ConfigurationKeys::DIRS, ConfigurationKeys::TARGET), $targetDir = sprintf('%s/target', getcwd())); |
56
|
|
|
Robo::config()->setDefault(sprintf('%s.%s', ConfigurationKeys::DIRS, ConfigurationKeys::REPORTS), sprintf('%s/reports', $targetDir)); |
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
/** |
60
|
|
|
* The sync command implementation. |
61
|
|
|
* |
62
|
|
|
* @param array $opts The command OptionsHookDispatcher |
63
|
|
|
* |
64
|
|
|
* @return void |
65
|
|
|
*/ |
66
|
|
|
public function sync(array $opts = [InputOptionKeys::SRC => null, InputOptionKeys::DEST => null]) |
67
|
|
|
{ |
68
|
|
|
// load the task |
69
|
|
|
$task = $this->taskSync(); |
70
|
|
|
|
71
|
|
|
// set source directory |
72
|
|
|
if (isset($opts[InputOptionKeys::SRC])) { |
73
|
|
|
$task->src($opts[InputOptionKeys::SRC]); |
74
|
|
|
} |
75
|
|
|
|
76
|
|
|
// set target directory |
77
|
|
|
if (isset($opts[InputOptionKeys::DEST])) { |
78
|
|
|
$task->dest($opts[InputOptionKeys::DEST]); |
79
|
|
|
} |
80
|
|
|
|
81
|
|
|
// run the task |
82
|
|
|
$task->run(); |
83
|
|
|
} |
84
|
|
|
|
85
|
|
|
/** |
86
|
|
|
* Returns the source directory. |
87
|
|
|
* |
88
|
|
|
* @return string The source directory |
89
|
|
|
*/ |
90
|
|
|
protected function getSrcDir() |
91
|
|
|
{ |
92
|
|
|
return Robo::config()->get(sprintf('%s.%s', ConfigurationKeys::DIRS, ConfigurationKeys::SRC)); |
93
|
|
|
} |
94
|
|
|
|
95
|
|
|
/** |
96
|
|
|
* Returns the vendor directory. |
97
|
|
|
* |
98
|
|
|
* @return string The vendor directory |
99
|
|
|
*/ |
100
|
|
|
protected function getVendorDir() |
101
|
|
|
{ |
102
|
|
|
return Robo::config()->get(sprintf('%s.%s', ConfigurationKeys::DIRS, ConfigurationKeys::VENDOR)); |
103
|
|
|
} |
104
|
|
|
|
105
|
|
|
/** |
106
|
|
|
* Returns the reports directory. |
107
|
|
|
* |
108
|
|
|
* @return string The reports directory |
109
|
|
|
*/ |
110
|
|
|
protected function getReportsDir() |
111
|
|
|
{ |
112
|
|
|
return Robo::config()->get(sprintf('%s.%s', ConfigurationKeys::DIRS, ConfigurationKeys::REPORTS)); |
113
|
|
|
} |
114
|
|
|
|
115
|
|
|
/** |
116
|
|
|
* Returns the target directory. |
117
|
|
|
* |
118
|
|
|
* @return string The target directory |
119
|
|
|
*/ |
120
|
|
|
protected function getTargetDir() |
121
|
|
|
{ |
122
|
|
|
return Robo::config()->get(sprintf('%s.%s', ConfigurationKeys::DIRS, ConfigurationKeys::TARGET)); |
123
|
|
|
} |
124
|
|
|
} |
125
|
|
|
|