|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/* |
|
4
|
|
|
* This file is part of the puli/cli package. |
|
5
|
|
|
* |
|
6
|
|
|
* (c) Bernhard Schussek <[email protected]> |
|
7
|
|
|
* |
|
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
|
9
|
|
|
* file that was distributed with this source code. |
|
10
|
|
|
*/ |
|
11
|
|
|
|
|
12
|
|
|
namespace Puli\Cli; |
|
13
|
|
|
|
|
14
|
|
|
use Puli\Cli\Handler\BindCommandHandler; |
|
15
|
|
|
use Puli\Cli\Handler\BuildCommandHandler; |
|
16
|
|
|
use Puli\Cli\Handler\CatCommandHandler; |
|
17
|
|
|
use Puli\Cli\Handler\ConfigCommandHandler; |
|
18
|
|
|
use Puli\Cli\Handler\FindCommandHandler; |
|
19
|
|
|
use Puli\Cli\Handler\InstallerCommandHandler; |
|
20
|
|
|
use Puli\Cli\Handler\LsCommandHandler; |
|
21
|
|
|
use Puli\Cli\Handler\MapCommandHandler; |
|
22
|
|
|
use Puli\Cli\Handler\ModuleCommandHandler; |
|
23
|
|
|
use Puli\Cli\Handler\PluginCommandHandler; |
|
24
|
|
|
use Puli\Cli\Handler\PublishCommandHandler; |
|
25
|
|
|
use Puli\Cli\Handler\SelfUpdateCommandHandler; |
|
26
|
|
|
use Puli\Cli\Handler\ServerCommandHandler; |
|
27
|
|
|
use Puli\Cli\Handler\TreeCommandHandler; |
|
28
|
|
|
use Puli\Cli\Handler\TypeCommandHandler; |
|
29
|
|
|
use Puli\Cli\Handler\UpgradeCommandHandler; |
|
30
|
|
|
use Puli\Cli\Handler\UrlCommandHandler; |
|
31
|
|
|
use Puli\Cli\Proxy\DiscoveryManagerProxy; |
|
32
|
|
|
use Puli\Cli\Proxy\RepositoryManagerProxy; |
|
33
|
|
|
use Puli\Manager\Api\Container; |
|
34
|
|
|
use Puli\Manager\Api\Context\ProjectContext; |
|
35
|
|
|
use Puli\Manager\Api\Module\InstallInfo; |
|
36
|
|
|
use Puli\Manager\Api\Server\Server; |
|
37
|
|
|
use Puli\Manager\Module\ModuleFileConverter; |
|
38
|
|
|
use Webmozart\Console\Api\Args\Format\Argument; |
|
39
|
|
|
use Webmozart\Console\Api\Args\Format\Option; |
|
40
|
|
|
use Webmozart\Console\Api\Event\ConsoleEvents; |
|
41
|
|
|
use Webmozart\Console\Api\Event\PreHandleEvent; |
|
42
|
|
|
use Webmozart\Console\Api\Formatter\Style; |
|
43
|
|
|
use Webmozart\Console\Config\DefaultApplicationConfig; |
|
44
|
|
|
|
|
45
|
|
|
/** |
|
46
|
|
|
* The configuration of the Puli CLI. |
|
47
|
|
|
* |
|
48
|
|
|
* @since 1.0 |
|
49
|
|
|
* |
|
50
|
|
|
* @author Bernhard Schussek <[email protected]> |
|
51
|
|
|
* @author Stephan Wentz <[email protected]> |
|
52
|
|
|
*/ |
|
53
|
|
|
class PuliApplicationConfig extends DefaultApplicationConfig |
|
54
|
|
|
{ |
|
55
|
|
|
/** |
|
56
|
|
|
* The version of the Puli CLI. |
|
57
|
|
|
*/ |
|
58
|
|
|
const VERSION = '@package_version@'; |
|
59
|
|
|
|
|
60
|
|
|
/** |
|
61
|
|
|
* @var Container |
|
62
|
|
|
*/ |
|
63
|
|
|
private $puli; |
|
64
|
|
|
|
|
65
|
|
|
/** |
|
66
|
|
|
* Creates the configuration. |
|
67
|
|
|
* |
|
68
|
|
|
* @param Container $puli The Puli service container |
|
|
|
|
|
|
69
|
|
|
*/ |
|
70
|
|
|
public function __construct(Container $puli = null) |
|
71
|
|
|
{ |
|
72
|
|
|
// Start Puli already so that plugins can change the CLI configuration |
|
73
|
|
|
$this->puli = $puli ?: new Container(getcwd()); |
|
74
|
|
|
|
|
75
|
|
|
if (!$this->puli->isStarted()) { |
|
76
|
|
|
$this->puli->start(); |
|
77
|
|
|
} |
|
78
|
|
|
|
|
79
|
|
|
parent::__construct(); |
|
80
|
|
|
} |
|
81
|
|
|
|
|
82
|
|
|
/** |
|
83
|
|
|
* {@inheritdoc} |
|
84
|
|
|
*/ |
|
85
|
|
|
protected function configure() |
|
86
|
|
|
{ |
|
87
|
|
|
// Make sure the console and Puli use the same event dispatcher so that |
|
88
|
|
|
// Puli plugins can listen to the console events. |
|
89
|
|
|
// Add the dispatcher before parent::configure() so that the parent |
|
90
|
|
|
// listeners don't get overwritten. |
|
91
|
|
|
$this->setEventDispatcher($this->puli->getEventDispatcher()); |
|
92
|
|
|
|
|
93
|
|
|
parent::configure(); |
|
94
|
|
|
|
|
95
|
|
|
$puli = $this->puli; |
|
96
|
|
|
$context = $this->puli->getContext(); |
|
97
|
|
|
|
|
98
|
|
|
$this |
|
99
|
|
|
->setName('puli') |
|
100
|
|
|
->setDisplayName('Puli') |
|
101
|
|
|
->setVersion(self::VERSION) |
|
102
|
|
|
|
|
103
|
|
|
// Enable debug for unreleased versions only. Split the string to |
|
104
|
|
|
// prevent its replacement during release |
|
105
|
|
|
->setDebug('@pack'.'age_version@' === self::VERSION) |
|
106
|
|
|
|
|
107
|
|
|
->addStyle(Style::tag('good')->fgGreen()) |
|
108
|
|
|
->addStyle(Style::tag('bad')->fgRed()) |
|
109
|
|
|
; |
|
110
|
|
|
|
|
111
|
|
|
if ($context instanceof ProjectContext) { |
|
112
|
|
|
// Don't do a version check in the global context (if not in a project) |
|
113
|
|
|
$this->addEventListener( |
|
114
|
|
|
ConsoleEvents::PRE_HANDLE, |
|
115
|
|
|
function (PreHandleEvent $event) use ($context) { |
|
116
|
|
|
$io = $event->getIO(); |
|
117
|
|
|
$moduleFile = $context->getRootModuleFile(); |
|
118
|
|
|
|
|
119
|
|
|
// Don't show warning for "upgrade" command |
|
120
|
|
|
if ('upgrade' === $event->getCommand()->getName()) { |
|
121
|
|
|
return; |
|
122
|
|
|
} |
|
123
|
|
|
|
|
124
|
|
|
if (version_compare($moduleFile->getVersion(), ModuleFileConverter::VERSION, '<')) { |
|
125
|
|
|
$io->errorLine(sprintf( |
|
126
|
|
|
'<warn>Warning: Your puli.json file has version %s, '. |
|
127
|
|
|
'but the latest version is %s. Run "puli upgrade" to '. |
|
128
|
|
|
'upgrade to %s.</warn>', |
|
129
|
|
|
$moduleFile->getVersion(), |
|
130
|
|
|
ModuleFileConverter::VERSION, |
|
131
|
|
|
ModuleFileConverter::VERSION |
|
132
|
|
|
)); |
|
133
|
|
|
} |
|
134
|
|
|
} |
|
135
|
|
|
); |
|
136
|
|
|
} |
|
137
|
|
|
|
|
138
|
|
|
$this |
|
|
|
|
|
|
139
|
|
|
->beginCommand('bind') |
|
140
|
|
|
->setDescription('Bind resources to binding types') |
|
141
|
|
|
->setHandler(function () use ($puli) { |
|
142
|
|
|
return new BindCommandHandler( |
|
143
|
|
|
$puli->getDiscoveryManager(), |
|
144
|
|
|
$puli->getModuleManager()->getModules() |
|
145
|
|
|
); |
|
146
|
|
|
}) |
|
147
|
|
|
|
|
148
|
|
|
->beginOptionCommand('add') |
|
149
|
|
|
->markAnonymous() |
|
150
|
|
|
->addArgument('artifact', Argument::REQUIRED, 'A class name or a query for resources') |
|
151
|
|
|
->addArgument('type', Argument::REQUIRED, 'The name of the binding type') |
|
152
|
|
|
->addOption('language', null, Option::REQUIRED_VALUE, 'The language of the resource query', 'glob', 'language') |
|
153
|
|
|
->addOption('param', null, Option::REQUIRED_VALUE | Option::MULTI_VALUED, 'A binding parameter in the form <key>=<value>', null, 'key=value') |
|
154
|
|
|
->addOption('class', null, Option::NO_VALUE, 'Force adding of a class binding') |
|
155
|
|
|
->addOption('force', 'f', Option::NO_VALUE, 'Add binding even if the binding type does not exist') |
|
156
|
|
|
->setHandlerMethod('handleAdd') |
|
157
|
|
|
->end() |
|
158
|
|
|
|
|
159
|
|
|
->beginOptionCommand('list') |
|
160
|
|
|
->markDefault() |
|
161
|
|
|
->addOption('root', null, Option::NO_VALUE, 'Show bindings of the root module') |
|
162
|
|
|
->addOption('module', 'm', Option::REQUIRED_VALUE | Option::MULTI_VALUED, 'Show bindings of a module', null, 'module') |
|
163
|
|
|
->addOption('all', 'a', Option::NO_VALUE, 'Show bindings of all modules') |
|
164
|
|
|
->addOption('enabled', null, Option::NO_VALUE, 'Show enabled bindings') |
|
165
|
|
|
->addOption('disabled', null, Option::NO_VALUE, 'Show disabled bindings') |
|
166
|
|
|
->addOption('type-not-found', null, Option::NO_VALUE, 'Show bindings whose type is not found') |
|
167
|
|
|
->addOption('type-not-enabled', null, Option::NO_VALUE, 'Show bindings whose type is not enabled') |
|
168
|
|
|
->addOption('ignored', null, Option::NO_VALUE, 'Show bindings whose type is disabled') |
|
169
|
|
|
->addOption('invalid', null, Option::NO_VALUE, 'Show bindings with invalid parameters') |
|
170
|
|
|
->addOption('language', null, Option::REQUIRED_VALUE, 'The language of the resource query', 'glob', 'language') |
|
171
|
|
|
->addOption('param', null, Option::REQUIRED_VALUE | Option::MULTI_VALUED, 'A binding parameter in the form <key>=<value>', null, 'key=value') |
|
172
|
|
|
->setHandlerMethod('handleList') |
|
173
|
|
|
->end() |
|
174
|
|
|
|
|
175
|
|
|
->beginOptionCommand('update', 'u') |
|
176
|
|
|
->addArgument('uuid', Argument::REQUIRED, 'The UUID (prefix) of the updated binding') |
|
177
|
|
|
->addOption('query', null, Option::REQUIRED_VALUE, 'A query for resources') |
|
178
|
|
|
->addOption('class', null, Option::REQUIRED_VALUE, 'A class name') |
|
179
|
|
|
->addOption('type', null, Option::REQUIRED_VALUE, 'The name of the binding type') |
|
180
|
|
|
->addOption('language', null, Option::REQUIRED_VALUE, 'The language of the resource query', null, 'language') |
|
181
|
|
|
->addOption('param', null, Option::REQUIRED_VALUE | Option::MULTI_VALUED, 'A binding parameter in the form <key>=<value>', null, 'key=value') |
|
182
|
|
|
->addOption('unset-param', null, Option::REQUIRED_VALUE | Option::MULTI_VALUED, 'Unset a binding parameter', null, 'key') |
|
183
|
|
|
->addOption('force', 'f', Option::NO_VALUE, 'Update binding even if the binding type does not exist') |
|
184
|
|
|
->setHandlerMethod('handleUpdate') |
|
185
|
|
|
->end() |
|
186
|
|
|
|
|
187
|
|
|
->beginOptionCommand('delete', 'd') |
|
188
|
|
|
->addArgument('uuid', Argument::REQUIRED, 'The UUID (prefix) of the removed binding') |
|
189
|
|
|
->setHandlerMethod('handleDelete') |
|
190
|
|
|
->end() |
|
191
|
|
|
|
|
192
|
|
|
->beginOptionCommand('enable') |
|
193
|
|
|
->addArgument('uuid', Argument::REQUIRED, 'The UUID (prefix) of the enabled binding') |
|
194
|
|
|
->setHandlerMethod('handleEnable') |
|
195
|
|
|
->end() |
|
196
|
|
|
|
|
197
|
|
|
->beginOptionCommand('disable') |
|
198
|
|
|
->addArgument('uuid', Argument::REQUIRED, 'The UUID (prefix) of the disabled binding') |
|
199
|
|
|
->setHandlerMethod('handleDisable') |
|
200
|
|
|
->end() |
|
201
|
|
|
->end() |
|
202
|
|
|
; |
|
203
|
|
|
|
|
204
|
|
|
$this |
|
205
|
|
|
->beginCommand('build') |
|
206
|
|
|
->setDescription('Build the resource repository/discovery') |
|
207
|
|
|
->addArgument('target', Argument::OPTIONAL, 'The build target. One of "repository", "discovery", "factory" and "all"', 'all') |
|
208
|
|
|
->setHandler(function () use ($puli) { |
|
209
|
|
|
return new BuildCommandHandler( |
|
210
|
|
|
// Use proxies to make sure this command runs even if |
|
211
|
|
|
// the factory file is corrupt. If the file is corrupt, |
|
212
|
|
|
// we get an error when loading the actual managers. |
|
213
|
|
|
new RepositoryManagerProxy($puli), |
|
214
|
|
|
new DiscoveryManagerProxy($puli), |
|
215
|
|
|
$puli->getFactoryManager() |
|
216
|
|
|
); |
|
217
|
|
|
}) |
|
218
|
|
|
->end() |
|
219
|
|
|
; |
|
220
|
|
|
|
|
221
|
|
|
$this |
|
222
|
|
|
->beginCommand('cat') |
|
223
|
|
|
->setDescription('Concatenate a file resource in the repository') |
|
224
|
|
|
->addArgument('path', Argument::REQUIRED, 'The path of a resource') |
|
225
|
|
|
->setHandler(function () use ($puli) { |
|
226
|
|
|
return new CatCommandHandler( |
|
227
|
|
|
$puli->getRepository() |
|
228
|
|
|
); |
|
229
|
|
|
}) |
|
230
|
|
|
->end() |
|
231
|
|
|
; |
|
232
|
|
|
|
|
233
|
|
|
$this |
|
|
|
|
|
|
234
|
|
|
->beginCommand('config') |
|
235
|
|
|
->setDescription('Display and modify configuration values') |
|
236
|
|
|
->setHandler(function () use ($puli) { |
|
237
|
|
|
return new ConfigCommandHandler($puli->getRootModuleFileManager()); |
|
238
|
|
|
}) |
|
239
|
|
|
|
|
240
|
|
|
->beginSubCommand('list') |
|
241
|
|
|
->markDefault() |
|
242
|
|
|
->addOption('parsed', null, Option::NO_VALUE, 'Replace placeholders by their values in the output') |
|
243
|
|
|
->setHandlerMethod('handleList') |
|
244
|
|
|
->end() |
|
245
|
|
|
|
|
246
|
|
|
->beginSubCommand('show') |
|
247
|
|
|
->markAnonymous() |
|
248
|
|
|
->addArgument('key', Argument::REQUIRED, 'The configuration key to show. May contain wildcards ("*")') |
|
249
|
|
|
->addOption('parsed', null, Option::NO_VALUE, 'Replace placeholders by their values in the output') |
|
250
|
|
|
->setHandlerMethod('handleShow') |
|
251
|
|
|
->end() |
|
252
|
|
|
|
|
253
|
|
|
->beginSubCommand('set') |
|
254
|
|
|
->markAnonymous() |
|
255
|
|
|
->addArgument('key', Argument::REQUIRED, 'The modified configuration key') |
|
256
|
|
|
->addArgument('value', Argument::REQUIRED, 'The value to set for the configuration key') |
|
257
|
|
|
->setHandlerMethod('handleSet') |
|
258
|
|
|
->end() |
|
259
|
|
|
|
|
260
|
|
|
->beginOptionCommand('reset', 'r') |
|
261
|
|
|
->addArgument('key', Argument::REQUIRED, 'The configuration key(s) to reset. May contain wildcards ("*")') |
|
262
|
|
|
->setHandlerMethod('handleReset') |
|
263
|
|
|
->end() |
|
264
|
|
|
->end() |
|
265
|
|
|
; |
|
266
|
|
|
|
|
267
|
|
|
$this |
|
268
|
|
|
->beginCommand('find') |
|
269
|
|
|
->setDescription('Find resources by different criteria') |
|
270
|
|
|
->addOption('path', null, Option::REQUIRED_VALUE, 'The resource path. May contain the wildcard "*"') |
|
271
|
|
|
->addOption('name', null, Option::REQUIRED_VALUE, 'The resource filename. May contain the wildcard "*"') |
|
272
|
|
|
->addOption('class', null, Option::REQUIRED_VALUE, 'The short name of a resource class') |
|
273
|
|
|
->addOption('type', null, Option::REQUIRED_VALUE, 'The name of a binding type') |
|
274
|
|
|
->addOption('language', null, Option::REQUIRED_VALUE, 'The language of the query passed with --path', 'glob') |
|
275
|
|
|
->setHandler(function () use ($puli) { |
|
276
|
|
|
return new FindCommandHandler( |
|
277
|
|
|
$puli->getRepository(), |
|
278
|
|
|
$puli->getDiscovery() |
|
279
|
|
|
); |
|
280
|
|
|
}) |
|
281
|
|
|
->end() |
|
282
|
|
|
; |
|
283
|
|
|
|
|
284
|
|
|
$this |
|
|
|
|
|
|
285
|
|
|
->beginCommand('installer') |
|
286
|
|
|
->setDescription('Manage the installers used to install web resources') |
|
287
|
|
|
->setHandler(function () use ($puli) { |
|
288
|
|
|
return new InstallerCommandHandler($puli->getInstallerManager()); |
|
289
|
|
|
}) |
|
290
|
|
|
|
|
291
|
|
|
->beginOptionCommand('list') |
|
292
|
|
|
->markDefault() |
|
293
|
|
|
->addOption('long', 'l', Option::NO_VALUE, 'Print the fully-qualified class name') |
|
294
|
|
|
->setHandlerMethod('handleList') |
|
295
|
|
|
->end() |
|
296
|
|
|
|
|
297
|
|
|
->beginOptionCommand('add', 'a') |
|
298
|
|
|
->addArgument('name', Argument::REQUIRED, 'The name of the installer') |
|
299
|
|
|
->addArgument('class', Argument::REQUIRED, 'The fully-qualified class name of the installer') |
|
300
|
|
|
->addOption('description', null, Option::REQUIRED_VALUE | Option::MULTI_VALUED, 'The description of the installer') |
|
301
|
|
|
->addOption('param', null, Option::REQUIRED_VALUE | Option::MULTI_VALUED, 'Additional installer parameters') |
|
302
|
|
|
->setHandlerMethod('handleAdd') |
|
303
|
|
|
->end() |
|
304
|
|
|
|
|
305
|
|
|
->beginOptionCommand('delete', 'd') |
|
306
|
|
|
->addArgument('name', Argument::REQUIRED, 'The name of the installer to remove') |
|
307
|
|
|
->setHandlerMethod('handleDelete') |
|
308
|
|
|
->end() |
|
309
|
|
|
->end() |
|
310
|
|
|
; |
|
311
|
|
|
|
|
312
|
|
|
$this |
|
313
|
|
|
->beginCommand('ls') |
|
314
|
|
|
->setDescription('List the children of a resource in the repository') |
|
315
|
|
|
->addArgument('path', Argument::OPTIONAL, 'The path of a resource', '/') |
|
316
|
|
|
->addOption('long', 'l', Option::NO_VALUE, 'Print more information about each child') |
|
317
|
|
|
->setHandler(function () use ($puli) { |
|
318
|
|
|
return new LsCommandHandler( |
|
319
|
|
|
$puli->getRepository() |
|
320
|
|
|
); |
|
321
|
|
|
}) |
|
322
|
|
|
->end() |
|
323
|
|
|
; |
|
324
|
|
|
|
|
325
|
|
|
$this |
|
|
|
|
|
|
326
|
|
|
->beginCommand('map') |
|
327
|
|
|
->setDescription('Display and change path mappings') |
|
328
|
|
|
->setHandler(function () use ($puli) { |
|
329
|
|
|
return new MapCommandHandler( |
|
330
|
|
|
$puli->getRepositoryManager(), |
|
331
|
|
|
$puli->getModuleManager()->getModules() |
|
332
|
|
|
); |
|
333
|
|
|
}) |
|
334
|
|
|
|
|
335
|
|
|
->beginOptionCommand('add') |
|
336
|
|
|
->markAnonymous() |
|
337
|
|
|
->addArgument('path', Argument::REQUIRED) |
|
338
|
|
|
->addArgument('file', Argument::REQUIRED | Argument::MULTI_VALUED) |
|
339
|
|
|
->addOption('force', 'f', Option::NO_VALUE, 'Map even if the target path does not exist') |
|
340
|
|
|
->setHandlerMethod('handleAdd') |
|
341
|
|
|
->end() |
|
342
|
|
|
|
|
343
|
|
|
->beginOptionCommand('list') |
|
344
|
|
|
->markDefault() |
|
345
|
|
|
->addOption('root', null, Option::NO_VALUE, 'Show mappings of the root module') |
|
346
|
|
|
->addOption('module', 'm', Option::REQUIRED_VALUE | Option::MULTI_VALUED, 'Show mappings of a module', null, 'module') |
|
347
|
|
|
->addOption('all', 'a', Option::NO_VALUE, 'Show mappings of all modules') |
|
348
|
|
|
->addOption('enabled', null, Option::NO_VALUE, 'Show enabled mappings') |
|
349
|
|
|
->addOption('not-found', null, Option::NO_VALUE, 'Show mappings whose referenced paths do not exist') |
|
350
|
|
|
->addOption('conflict', null, Option::NO_VALUE, 'Show conflicting mappings') |
|
351
|
|
|
->setHandlerMethod('handleList') |
|
352
|
|
|
->end() |
|
353
|
|
|
|
|
354
|
|
|
->beginOptionCommand('update', 'u') |
|
355
|
|
|
->addArgument('path', Argument::REQUIRED) |
|
356
|
|
|
->addOption('add', 'a', Option::REQUIRED_VALUE | Option::MULTI_VALUED | Option::PREFER_LONG_NAME, 'Add a file to the path mapping', null, 'file') |
|
357
|
|
|
->addOption('remove', 'r', Option::REQUIRED_VALUE | Option::MULTI_VALUED | Option::PREFER_LONG_NAME, 'Remove a file from the path mapping', null, 'file') |
|
358
|
|
|
->addOption('force', 'f', Option::NO_VALUE, 'Map even if the target path does not exist') |
|
359
|
|
|
->setHandlerMethod('handleUpdate') |
|
360
|
|
|
->end() |
|
361
|
|
|
|
|
362
|
|
|
->beginOptionCommand('delete', 'd') |
|
363
|
|
|
->addArgument('path', Argument::REQUIRED) |
|
364
|
|
|
->addArgument('file', Argument::OPTIONAL) |
|
365
|
|
|
->setHandlerMethod('handleDelete') |
|
366
|
|
|
->end() |
|
367
|
|
|
->end() |
|
368
|
|
|
; |
|
369
|
|
|
|
|
370
|
|
|
$this |
|
|
|
|
|
|
371
|
|
|
->beginCommand('module') |
|
372
|
|
|
->setDescription('Display the installed modules') |
|
373
|
|
|
->setHandler(function () use ($puli) { |
|
374
|
|
|
return new ModuleCommandHandler($puli->getModuleManager()); |
|
375
|
|
|
}) |
|
376
|
|
|
|
|
377
|
|
|
->beginOptionCommand('install', 'i') |
|
378
|
|
|
->addArgument('path', Argument::REQUIRED, 'The path to the module') |
|
379
|
|
|
->addArgument('name', Argument::OPTIONAL, 'The name of the module. Taken from puli.json if not passed.') |
|
380
|
|
|
->addOption('installer', null, Option::REQUIRED_VALUE, 'The name of the installer', InstallInfo::DEFAULT_INSTALLER_NAME) |
|
381
|
|
|
->addOption('dev', null, Option::NO_VALUE, 'Install the module in the development environment') |
|
382
|
|
|
->setHandlerMethod('handleInstall') |
|
383
|
|
|
->end() |
|
384
|
|
|
|
|
385
|
|
|
->beginOptionCommand('list') |
|
386
|
|
|
->markDefault() |
|
387
|
|
|
->addOption('installer', null, Option::REQUIRED_VALUE, 'Show modules installed by a specific installer') |
|
388
|
|
|
->addOption('enabled', null, Option::NO_VALUE, 'Show enabled modules') |
|
389
|
|
|
->addOption('not-found', null, Option::NO_VALUE, 'Show modules that could not be found') |
|
390
|
|
|
->addOption('not-loadable', null, Option::NO_VALUE, 'Show modules that could not be loaded') |
|
391
|
|
|
->addOption('dev', null, Option::NO_VALUE, 'Show modules of the development environment') |
|
392
|
|
|
->addOption('prod', null, Option::NO_VALUE, 'Show modules of the production environment') |
|
393
|
|
|
->addOption('format', null, Option::REQUIRED_VALUE, 'The format of the output. You can use the variables %name%, %install_path%, %installer% and %state% in the format string', null, 'format') |
|
394
|
|
|
->setHandlerMethod('handleList') |
|
395
|
|
|
->end() |
|
396
|
|
|
|
|
397
|
|
|
->beginOptionCommand('rename') |
|
398
|
|
|
->addArgument('name', Argument::REQUIRED, 'The name of the module') |
|
399
|
|
|
->addArgument('new-name', Argument::REQUIRED, 'The new name of the module') |
|
400
|
|
|
->setHandlerMethod('handleRename') |
|
401
|
|
|
->end() |
|
402
|
|
|
|
|
403
|
|
|
->beginOptionCommand('delete', 'd') |
|
404
|
|
|
->addArgument('name', Argument::REQUIRED, 'The name of the module') |
|
405
|
|
|
->setHandlerMethod('handleDelete') |
|
406
|
|
|
->end() |
|
407
|
|
|
|
|
408
|
|
|
->beginOptionCommand('clean') |
|
409
|
|
|
->setHandlerMethod('handleClean') |
|
410
|
|
|
->end() |
|
411
|
|
|
->end() |
|
412
|
|
|
; |
|
413
|
|
|
|
|
414
|
|
|
$this |
|
|
|
|
|
|
415
|
|
|
->beginCommand('plugin') |
|
416
|
|
|
->setDescription('Manage the installed Puli plugins') |
|
417
|
|
|
->setHandler(function () use ($puli) { |
|
418
|
|
|
return new PluginCommandHandler($puli->getRootModuleFileManager()); |
|
419
|
|
|
}) |
|
420
|
|
|
|
|
421
|
|
|
->beginOptionCommand('install', 'i') |
|
422
|
|
|
->addArgument('class', Argument::REQUIRED, 'The fully-qualified plugin class name') |
|
423
|
|
|
->setHandlerMethod('handleInstall') |
|
424
|
|
|
->end() |
|
425
|
|
|
|
|
426
|
|
|
->beginOptionCommand('list') |
|
427
|
|
|
->markDefault() |
|
428
|
|
|
->setHandlerMethod('handleList') |
|
429
|
|
|
->end() |
|
430
|
|
|
|
|
431
|
|
|
->beginOptionCommand('delete', 'd') |
|
432
|
|
|
->addArgument('class', Argument::REQUIRED, 'The fully-qualified plugin class name') |
|
433
|
|
|
->setHandlerMethod('handleDelete') |
|
434
|
|
|
->end() |
|
435
|
|
|
->end() |
|
436
|
|
|
; |
|
437
|
|
|
|
|
438
|
|
|
$this |
|
|
|
|
|
|
439
|
|
|
->beginCommand('publish') |
|
440
|
|
|
->setDescription('Manage public resources') |
|
441
|
|
|
->setHandler(function () use ($puli) { |
|
442
|
|
|
return new PublishCommandHandler( |
|
443
|
|
|
$puli->getAssetManager(), |
|
444
|
|
|
$puli->getInstallationManager(), |
|
445
|
|
|
$puli->getServerManager() |
|
446
|
|
|
); |
|
447
|
|
|
}) |
|
448
|
|
|
|
|
449
|
|
|
->beginOptionCommand('add') |
|
450
|
|
|
->markAnonymous() |
|
451
|
|
|
->addArgument('path', Argument::REQUIRED, 'The resource path') |
|
452
|
|
|
->addArgument('server', Argument::REQUIRED, 'The resource path') |
|
453
|
|
|
->addArgument('server-path', Argument::OPTIONAL, 'The path in the document root of the server', '/') |
|
454
|
|
|
->addOption('force', 'f', Option::NO_VALUE, 'Map even if the server does not exist') |
|
455
|
|
|
->setHandlerMethod('handleAdd') |
|
456
|
|
|
->end() |
|
457
|
|
|
|
|
458
|
|
|
->beginOptionCommand('update', 'u') |
|
459
|
|
|
->addArgument('uuid', Argument::REQUIRED, 'The UUID (prefix) of the mapping') |
|
460
|
|
|
->addOption('path', null, Option::REQUIRED_VALUE, 'The resource path') |
|
461
|
|
|
->addOption('server', 's', Option::REQUIRED_VALUE | Option::PREFER_LONG_NAME, 'The name of the target server') |
|
462
|
|
|
->addOption('server-path', null, Option::REQUIRED_VALUE, 'The path in the document root') |
|
463
|
|
|
->addOption('force', 'f', Option::NO_VALUE, 'Update even if the server does not exist') |
|
464
|
|
|
->setHandlerMethod('handleUpdate') |
|
465
|
|
|
->end() |
|
466
|
|
|
|
|
467
|
|
|
->beginOptionCommand('delete', 'd') |
|
468
|
|
|
->addArgument('uuid', Argument::REQUIRED, 'The UUID (prefix) of the mapping') |
|
469
|
|
|
->setHandlerMethod('handleDelete') |
|
470
|
|
|
->end() |
|
471
|
|
|
|
|
472
|
|
|
->beginOptionCommand('list', 'l') |
|
473
|
|
|
->markDefault() |
|
474
|
|
|
->setHandlerMethod('handleList') |
|
475
|
|
|
->end() |
|
476
|
|
|
|
|
477
|
|
|
->beginOptionCommand('install') |
|
478
|
|
|
->addArgument('server', Argument::OPTIONAL, 'The server to install. By default, all servers are installed') |
|
479
|
|
|
->setHandlerMethod('handleInstall') |
|
480
|
|
|
->end() |
|
481
|
|
|
->end() |
|
482
|
|
|
; |
|
483
|
|
|
|
|
484
|
|
|
$this |
|
485
|
|
|
->beginCommand('self-update') |
|
486
|
|
|
->setDescription('Update Puli to the latest version.') |
|
487
|
|
|
->addOption('stable', null, Option::NO_VALUE, 'Update to the latest stable version') |
|
488
|
|
|
->addOption('unstable', null, Option::NO_VALUE, 'Update to the latest unstable version') |
|
489
|
|
|
->setHandler(function () { |
|
490
|
|
|
return new SelfUpdateCommandHandler(); |
|
491
|
|
|
}) |
|
492
|
|
|
->enableIf('phar://' === substr(__DIR__, 0, 7)) |
|
493
|
|
|
->end() |
|
494
|
|
|
; |
|
495
|
|
|
|
|
496
|
|
|
$this |
|
|
|
|
|
|
497
|
|
|
->beginCommand('server') |
|
498
|
|
|
->setDescription('Manage your asset servers') |
|
499
|
|
|
->setHandler(function () use ($puli) { |
|
500
|
|
|
return new ServerCommandHandler($puli->getServerManager()); |
|
501
|
|
|
}) |
|
502
|
|
|
|
|
503
|
|
|
->beginOptionCommand('list') |
|
504
|
|
|
->markDefault() |
|
505
|
|
|
->setHandlerMethod('handleList') |
|
506
|
|
|
->end() |
|
507
|
|
|
|
|
508
|
|
|
->beginOptionCommand('add', 'a') |
|
509
|
|
|
->addArgument('name', Argument::REQUIRED, 'The name of the added server') |
|
510
|
|
|
->addArgument('document-root', Argument::REQUIRED, 'The document root of the server') |
|
511
|
|
|
->addOption('installer', null, Option::REQUIRED_VALUE, 'The name of the used installer', 'symlink') |
|
512
|
|
|
->addOption('url-format', null, Option::REQUIRED_VALUE, 'The format of the generated resource URLs', Server::DEFAULT_URL_FORMAT) |
|
513
|
|
|
->addOption('param', null, Option::REQUIRED_VALUE | Option::MULTI_VALUED, 'Additional parameters required by the resource installer') |
|
514
|
|
|
->setHandlerMethod('handleAdd') |
|
515
|
|
|
->end() |
|
516
|
|
|
|
|
517
|
|
|
->beginOptionCommand('update', 'u') |
|
518
|
|
|
->addArgument('name', Argument::REQUIRED, 'The name of the updated server') |
|
519
|
|
|
->addOption('document-root', null, Option::REQUIRED_VALUE, 'The document root of the server') |
|
520
|
|
|
->addOption('installer', null, Option::REQUIRED_VALUE, 'The name of the used installer', 'symlink') |
|
521
|
|
|
->addOption('url-format', null, Option::REQUIRED_VALUE, 'The format of the generated resource URLs', Server::DEFAULT_URL_FORMAT) |
|
522
|
|
|
->addOption('param', null, Option::REQUIRED_VALUE | Option::MULTI_VALUED, 'Additional parameters required by the resource installer') |
|
523
|
|
|
->addOption('unset-param', null, Option::REQUIRED_VALUE | Option::MULTI_VALUED, 'Parameters to remove from the server') |
|
524
|
|
|
->setHandlerMethod('handleUpdate') |
|
525
|
|
|
->end() |
|
526
|
|
|
|
|
527
|
|
|
->beginOptionCommand('delete', 'd') |
|
528
|
|
|
->addArgument('name', Argument::REQUIRED, 'The name of the server to remove') |
|
529
|
|
|
->setHandlerMethod('handleDelete') |
|
530
|
|
|
->end() |
|
531
|
|
|
->end() |
|
532
|
|
|
; |
|
533
|
|
|
|
|
534
|
|
|
$this |
|
535
|
|
|
->beginCommand('tree') |
|
536
|
|
|
->setDescription('Print the contents of a resource as tree') |
|
537
|
|
|
->addArgument('path', Argument::OPTIONAL, 'The path of a resource', '/') |
|
538
|
|
|
->setHandler(function () use ($puli) { |
|
539
|
|
|
return new TreeCommandHandler($puli->getRepository()); |
|
540
|
|
|
}) |
|
541
|
|
|
->end() |
|
542
|
|
|
; |
|
543
|
|
|
|
|
544
|
|
|
$this |
|
|
|
|
|
|
545
|
|
|
->beginCommand('type') |
|
546
|
|
|
->setDescription('Display and change binding types') |
|
547
|
|
|
->setHandler(function () use ($puli) { |
|
548
|
|
|
return new TypeCommandHandler( |
|
549
|
|
|
$puli->getDiscoveryManager(), |
|
550
|
|
|
$puli->getModuleManager()->getModules() |
|
551
|
|
|
); |
|
552
|
|
|
}) |
|
553
|
|
|
|
|
554
|
|
|
->beginOptionCommand('define') |
|
555
|
|
|
->addArgument('name', Argument::REQUIRED, 'The name of the binding type') |
|
556
|
|
|
->addOption('description', null, Option::REQUIRED_VALUE, 'A human-readable description of the type') |
|
557
|
|
|
->addOption('param', null, Option::REQUIRED_VALUE | Option::MULTI_VALUED, 'A type parameter in the form <key> or <key>=<value>', null, 'key=value') |
|
558
|
|
|
->addOption('param-description', null, Option::REQUIRED_VALUE | Option::MULTI_VALUED, 'A human-readable parameter description in the form <key>=<description>', null, 'key=description') |
|
559
|
|
|
->addOption('force', 'f', Option::NO_VALUE, 'Add type even if another type exists with the same name') |
|
560
|
|
|
->setHandlerMethod('handleDefine') |
|
561
|
|
|
->end() |
|
562
|
|
|
|
|
563
|
|
|
->beginSubCommand('list') |
|
564
|
|
|
->markDefault() |
|
565
|
|
|
->addOption('root', null, Option::NO_VALUE, 'Show types of the root module') |
|
566
|
|
|
->addOption('module', 'm', Option::REQUIRED_VALUE | Option::MULTI_VALUED, 'Show types of a module', null, 'module') |
|
567
|
|
|
->addOption('all', 'a', Option::NO_VALUE, 'Show types of all modules') |
|
568
|
|
|
->addOption('enabled', null, Option::NO_VALUE, 'Show enabled types') |
|
569
|
|
|
->addOption('duplicate', null, Option::NO_VALUE, 'Show duplicate types') |
|
570
|
|
|
->setHandlerMethod('handleList') |
|
571
|
|
|
->end() |
|
572
|
|
|
|
|
573
|
|
|
->beginOptionCommand('update', 'u') |
|
574
|
|
|
->addArgument('name', Argument::REQUIRED, 'The name of the binding type') |
|
575
|
|
|
->addOption('description', null, Option::REQUIRED_VALUE, 'A human-readable description of the type') |
|
576
|
|
|
->addOption('param', null, Option::REQUIRED_VALUE | Option::MULTI_VALUED, 'A type parameter in the form <key> or <key>=<value>', null, 'key=value') |
|
577
|
|
|
->addOption('param-description', null, Option::REQUIRED_VALUE | Option::MULTI_VALUED, 'A human-readable parameter description in the form <key>=<description>', null, 'key=description') |
|
578
|
|
|
->addOption('unset-param', null, Option::REQUIRED_VALUE | Option::MULTI_VALUED, 'Unset a type parameter', null, 'key') |
|
579
|
|
|
->setHandlerMethod('handleUpdate') |
|
580
|
|
|
->end() |
|
581
|
|
|
|
|
582
|
|
|
->beginOptionCommand('delete', 'd') |
|
583
|
|
|
->addArgument('name', Argument::REQUIRED, 'The name of the binding type') |
|
584
|
|
|
->setHandlerMethod('handleDelete') |
|
585
|
|
|
->end() |
|
586
|
|
|
->end() |
|
587
|
|
|
; |
|
588
|
|
|
|
|
589
|
|
|
$this |
|
590
|
|
|
->beginCommand('upgrade') |
|
591
|
|
|
->setDescription('Upgrades puli.json to the newest version') |
|
592
|
|
|
->addArgument('version', Argument::OPTIONAL, 'The version to upgrade/downgrade to', ModuleFileConverter::VERSION) |
|
593
|
|
|
->setHandler(function () use ($puli) { |
|
594
|
|
|
return new UpgradeCommandHandler($puli->getRootModuleFileManager()); |
|
595
|
|
|
}) |
|
596
|
|
|
->end() |
|
597
|
|
|
; |
|
598
|
|
|
|
|
599
|
|
|
$this |
|
600
|
|
|
->beginCommand('url') |
|
601
|
|
|
->setDescription('Generate the URL of a public resource') |
|
602
|
|
|
->addArgument('path', Argument::REQUIRED | Argument::MULTI_VALUED, 'The path of a resource') |
|
603
|
|
|
->setHandler(function () use ($puli) { |
|
604
|
|
|
return new UrlCommandHandler( |
|
605
|
|
|
$puli->getUrlGenerator(), |
|
606
|
|
|
$puli->getRepository() |
|
607
|
|
|
); |
|
608
|
|
|
}) |
|
609
|
|
|
->end() |
|
610
|
|
|
; |
|
611
|
|
|
} |
|
612
|
|
|
} |
|
613
|
|
|
|
This check looks for
@paramannotations where the type inferred by our type inference engine differs from the declared type.It makes a suggestion as to what type it considers more descriptive.
Most often this is a case of a parameter that can be null in addition to its declared types.