. * @author niel * @copyright 2016 nZEDb */ namespace App\extensions\command; use App\extensions\console\Command; use App\extensions\util\Versions; /** * Returns the current version (or branch) of the indexer. * * Actions: * * all Show all of following info. * * branch Show git branch name. * * git Show git tag for current version. * * sql Show SQL patch level * * @package app\extensions\command */ class Version extends Command { /** * @var Versions; */ protected $versions = null; /** * Constructor. * * @param array $config */ public function __construct(array $config = []) { $this->versions = new Versions(); $this->setName('version') ->setHelp('Returns the current version (or branch) of the indexer. Actions: all Show all of following info. branch Show git branch name. git Show git tag for current version. sql Show SQL patch level'); parent::__construct($config); } public function all() { $this->git(); $this->sql(); } public function branch() { $this->primary('Git branch: ' . $this->versions->getGitBranch()); } /** * Fetch git tag for latest version. */ public function git() { $this->primary('Looking up Git tag version(s)'); $this->info('Hash: ' . $this->versions->getGitHeadHash()); $this->info('XML version: ' . $this->versions->getGitTagInFile()); $this->info('Git version: ' . $this->versions->getGitTagInRepo()); } /** * Fetch SQL latest patch version. */ public function sql() { $this->primary('Looking up SQL patch version(s)'); $latest = $this->versions->getSQLPatchFromFile(); $this->info("XML version: $latest"); try { $dbVersion = $this->versions->getSQLPatchFromDB(); $this->info(' DB version: ' . $dbVersion); } catch (\Exception $e) { $this->error($e->getMessage()); } } }