-
-
Notifications
You must be signed in to change notification settings - Fork 28
Expand file tree
/
Copy pathRoboFile.php
More file actions
226 lines (197 loc) · 6.21 KB
/
Copy pathRoboFile.php
File metadata and controls
226 lines (197 loc) · 6.21 KB
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
<?php
/**
* @package Jorobo
*
* @copyright Copyright (C) 2005 - 2015 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
use Joomla\Jorobo\Tasks\AssetJSON;
use Joomla\Jorobo\Tasks\Tasks;
use Robo\Collection\CollectionBuilder;
use Robo\Symfony\ConsoleIO;
if (!defined('JPATH_BASE')) {
define('JPATH_BASE', __DIR__);
}
// PSR-4 Autoload by composer
require_once JPATH_BASE . '/vendor/autoload.php';
/**
* Sample RoboFile - adjust to your needs, extend your own
*
* @since 1.0.0
*/
class RoboFile extends \Robo\Tasks
{
use Tasks;
/**
* Initialize Robo
*/
public function __construct()
{
$this->stopOnFail(true);
}
/**
* Map into Joomla installation.
*
* @param String $target The target joomla instance
*
* @return void
*/
public function map($target, $params = ['base' => JPATH_BASE])
{
$this->task(\Joomla\Jorobo\Tasks\Map::class, $target, $params)->run();
}
/**
* Build the joomla extension package
*
* @param array $params Additional params
*
* @return void
*/
public function build(ConsoleIO $io, $params = ['dev' => false, 'base' => JPATH_BASE])
{
$this->task(\Joomla\Jorobo\Tasks\Build::class, $params)->run();
}
/**
* Generate an extension skeleton - not implemented yet
*
* @param array $extensions Extensions to build (com_xy, mod_xy, pkg_name, plg_type_name, tpl_name)
*
* @return void
*/
public function generate(array $extensions, $params = ['base' => JPATH_BASE])
{
foreach ($extensions as $extension) {
switch (substr($extension, 0, 3)) {
case 'com':
$this->task(\Joomla\Jorobo\Tasks\Generate\Component::class, $extension, $params)->run();
break;
case 'mod':
$this->task(\Joomla\Jorobo\Tasks\Generate\Module::class, $extension, $params)->run();
break;
case 'pkg':
$this->task(\Joomla\Jorobo\Tasks\Generate\Package::class, $extension, $params)->run();
break;
case 'plg':
$this->task(\Joomla\Jorobo\Tasks\Generate\Plugin::class, $extension, $params)->run();
break;
case 'tpl':
$this->task(\Joomla\Jorobo\Tasks\Generate\Template::class, $extension, $params)->run();
break;
}
}
}
/**
* Generate a component skeleton - not implemented yet
*
* @param string $name Component name to build (e.g. com_xy)
*
* @return void
*/
public function generateComponent($name, $params = ['base' => JPATH_BASE, 'site' => true, 'api' => false, 'media' => false])
{
$this->task(\Joomla\Jorobo\Tasks\Generate\Component::class, $name, $params)->run();
}
/**
* Generate a new component view skeleton - not implemented yet
*
* @param string $name Component name to target (e.g. com_xy)
* @param string $view Name of the view (e.g. article)
*
* @return void
*/
public function generateView($name, $view, $params = ['base' => JPATH_BASE])
{
$this->task(\Joomla\Jorobo\Tasks\Generate\Component::class, $name, $params)->run();
}
/**
* Generate a module skeleton - not implemented yet
*
* The module is generated in a folder structure fitting to directly
* commit to a git repository. The structure follows the best coding
* examples for Joomla 4.
*
* @param string $name Module name to build (e.g. mod_xy)
* @param array $params
* @option $base A base path for the repository
* @option $client Select the client to build for ('site' or 'admin')
*
* @return void
*/
public function generateModule($name, $params = ['base' => JPATH_BASE, 'client' => 'site'])
{
$this->task(\Joomla\Jorobo\Tasks\Generate\Module::class, $name, $params)->run();
}
/**
* Update copyright headers for this project. (Set the text up in the jorobo.ini)
*
* @return void
*/
public function headers($params = ['base' => JPATH_BASE])
{
$this->task(\Joomla\Jorobo\Tasks\CopyrightHeader::class, $params)->run();
}
/**
* Bump Version placeholder __DEPLOY_VERSION__ in this project. (Set the version up in the jorobo.ini)
*
* @return void
*
* @since 1.0.0
*/
public function bump($params = ['base' => JPATH_BASE])
{
$this->task(\Joomla\Jorobo\Tasks\BumpVersion::class, $params)->run();
}
/**
* Generate joomla.asset.json files
*
* @return void
* @since __DEPLOY_VERSION__
*/
public function assetJSON()
{
if (!file_exists('jorobo.ini')) {
$this->_copy('jorobo.dist.ini', 'jorobo.ini');
}
$this->task(\Joomla\Jorobo\Tasks\AssetJSON::class)->run();
}
/**
* Generate/extend changelog.xml
*
* @return void
* @since __DEPLOY_VERSION__
*/
public function changelog()
{
if (!file_exists('jorobo.ini')) {
$this->_copy('jorobo.dist.ini', 'jorobo.ini');
}
$this->task(\Joomla\Jorobo\Tasks\Changelog::class)->run();
}
/**
* Minify all JS + CSS files in the project
*
* @param string $path Additional a relative path to a folder which should be searched only
*
* @return void
*/
public function minify(ConsoleIO $io, $path)
{
$this->say('Starting minifiying "src/' . $path . '"');
$this->writeln('');
$files = $this->loadMedia('src/' . $path);
if (!empty($files['css'])) {
$filePaths = $files['css'];
foreach ($filePaths as $file) {
$this->taskMinify($file)->run();
}
}
if (!empty($files['js'])) {
$filePaths = $files['js'];
foreach ($filePaths as $file) {
$this->taskMinify($file)->run();
}
}
$this->writeln('');
$this->yell('Minifying done!');
}
}