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; } } // Always write out the build ID/build number which is the commit hash $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"; } }