2015-07-23 17:44:24 +02:00
|
|
|
<?php namespace Todaymade\Daux\Console;
|
2015-07-14 22:06:01 +02:00
|
|
|
|
|
|
|
use Symfony\Component\Console\Application as SymfonyApplication;
|
|
|
|
|
|
|
|
class Application extends SymfonyApplication
|
|
|
|
{
|
2016-07-29 22:44:35 +02:00
|
|
|
public function __construct($name = 'UNKNOWN', $version = 'UNKNOWN')
|
|
|
|
{
|
2016-07-29 07:58:48 +02:00
|
|
|
parent::__construct($name, $version);
|
2015-07-14 22:06:01 +02:00
|
|
|
|
2016-07-29 07:58:48 +02:00
|
|
|
$this->add(new Generate());
|
|
|
|
$this->add(new Serve());
|
2018-06-07 20:40:38 +02:00
|
|
|
$this->add(new ClearCache());
|
2018-06-04 22:52:21 +02:00
|
|
|
|
2020-04-22 22:24:52 +02:00
|
|
|
$app_name = 'daux/daux.io';
|
2018-06-04 22:52:21 +02:00
|
|
|
|
|
|
|
$up = '..' . DIRECTORY_SEPARATOR;
|
|
|
|
$composer = __DIR__ . DIRECTORY_SEPARATOR . $up . $up . $up . $up . $up . 'composer.lock';
|
2020-04-22 22:24:52 +02:00
|
|
|
$version = 'unknown';
|
2018-06-04 22:52:21 +02:00
|
|
|
|
|
|
|
if (file_exists($composer)) {
|
|
|
|
$app = json_decode(file_get_contents($composer));
|
|
|
|
$packages = $app->packages;
|
2020-04-22 22:24:52 +02:00
|
|
|
|
2018-06-04 22:52:21 +02:00
|
|
|
foreach ($packages as $package) {
|
|
|
|
if ($package->name == $app_name) {
|
|
|
|
$version = $package->version;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
$this->setVersion($version);
|
|
|
|
$this->setName($app_name);
|
2015-07-14 22:06:01 +02:00
|
|
|
}
|
|
|
|
}
|