e6d38f9338
* Add PHP 7.4 to build matrix * DB fix * YAML parser fix in test data * Show versions * Package updates * Track used ICAOs * 7.4 METAR parsing fix * METAR parser fix * Formatting * Add meters to response units * Call instance for unit conversion * Return value * Catch exception for unknown quantity * Comment fix * Formatting * METAR parsing fixes on PHP 7.4 * Package updates * More random airport ID * More random airport ID * Properly disable toolbar * Semver written out to version file * Use dev as default identifier
64 lines
2.1 KiB
PHP
64 lines
2.1 KiB
PHP
<?php
|
|
|
|
namespace App\Console\Commands;
|
|
|
|
use App\Contracts\Command;
|
|
use App\Services\VersionService;
|
|
use Symfony\Component\Yaml\Yaml;
|
|
|
|
class Version extends Command
|
|
{
|
|
protected $signature = 'phpvms:version {--write} {--base-only} {--write-full-version} {version?}';
|
|
|
|
private $versionSvc;
|
|
|
|
public function __construct(VersionService $versionSvc)
|
|
{
|
|
parent::__construct();
|
|
|
|
$this->versionSvc = $versionSvc;
|
|
}
|
|
|
|
/**
|
|
* Run dev related commands
|
|
*
|
|
* @throws \Symfony\Component\Yaml\Exception\ParseException
|
|
*/
|
|
public function handle()
|
|
{
|
|
if ($this->option('write')) {
|
|
// Write the updated build number out to the file
|
|
$version_file = config_path('version.yml');
|
|
$cfg = Yaml::parse(file_get_contents($version_file));
|
|
|
|
// If a version is being passed in, the update the build, etc data against this
|
|
if ($this->argument('version')) {
|
|
$version = \SemVer\SemVer\Version::fromString($this->argument('version'));
|
|
if ($this->option('write_full_version')) {
|
|
$cfg['current']['major'] = $version->getMajor();
|
|
$cfg['current']['minor'] = $version->getMinor();
|
|
$cfg['current']['patch'] = $version->getPatch();
|
|
}
|
|
|
|
$prerelease = $version->getPreRelease();
|
|
if (strpos($prerelease, '.') !== false) {
|
|
$prerelease = explode('.', $prerelease);
|
|
$cfg['current']['prerelease'] = $prerelease[0];
|
|
$cfg['current']['buildmetadata'] = $prerelease[1];
|
|
} else {
|
|
$cfg['current']['prerelease'] = $prerelease;
|
|
}
|
|
}
|
|
|
|
$build_number = $this->versionSvc->getBuildId($cfg);
|
|
$cfg['current']['commit'] = $build_number;
|
|
$cfg['build']['number'] = $build_number;
|
|
|
|
file_put_contents($version_file, Yaml::dump($cfg, 4, 2));
|
|
}
|
|
|
|
$version = $this->versionSvc->getCurrentVersion(!$this->option('base-only'));
|
|
echo $version."\n";
|
|
}
|
|
}
|