From 27f2c55016e40bb853b82ec3f92d0e52fc00c838 Mon Sep 17 00:00:00 2001 From: Damian Mooyman Date: Thu, 12 Oct 2017 15:59:35 +1300 Subject: [PATCH] Fix i18n collector --- src/Commands/Release/Branch.php | 5 ----- src/Model/Modules/Module.php | 15 +++++++++++++++ src/Model/Modules/Project.php | 21 +++++++++++++++++++++ src/Model/Release/LibraryRelease.php | 2 +- src/Steps/Release/UpdateTranslations.php | 5 +++-- 5 files changed, 40 insertions(+), 8 deletions(-) diff --git a/src/Commands/Release/Branch.php b/src/Commands/Release/Branch.php index 65f0018..78a49fb 100644 --- a/src/Commands/Release/Branch.php +++ b/src/Commands/Release/Branch.php @@ -67,11 +67,6 @@ class Branch extends Release self::NONE => self::NONE_DESCRIPTION, ]; - /** - * Default branch option - */ - const DEFAULT_OPTION = self::AUTO; - protected function fire() { // Get arguments diff --git a/src/Model/Modules/Module.php b/src/Model/Modules/Module.php index b1a9cc0..2a8cd2b 100644 --- a/src/Model/Modules/Module.php +++ b/src/Model/Modules/Module.php @@ -88,6 +88,21 @@ public function getRelativeMainDirectory() return substr($dir, strlen($base) + 1); } + /** + * Get parameter to pass to i18n text collector + * + * @return string + */ + public function getI18nTextCollectorName() + { + $dir = $this->getRelativeMainDirectory(); + // If short name has any slashes just use composer name instead + if (preg_match('#\w[\\/]\w#', $dir)) { + return $this->getName(); + } + return $dir; + } + /** * Determine if this project has a .tx configured * diff --git a/src/Model/Modules/Project.php b/src/Model/Modules/Project.php index 540f757..c8a4f65 100644 --- a/src/Model/Modules/Project.php +++ b/src/Model/Modules/Project.php @@ -2,6 +2,7 @@ namespace SilverStripe\Cow\Model\Modules; +use BadMethodCallException; use Generator; use InvalidArgumentException; @@ -110,4 +111,24 @@ public function getProject() { return $this; } + + /** + * Get path to sake executable + * + * @return string + */ + public function getSakePath() + { + $candidates = [ + $this->getDirectory() . '/vendor/bin/sake', // New standard location + $this->getDirectory() . '/vendor/silverstripe/framework/sake', + $this->getDirectory() . '/framework/sake', + ]; + foreach ($candidates as $candidate) { + if (file_exists($candidate)) { + return $candidate; + } + } + throw new BadMethodCallException("sake bin could not be found in this project"); + } } diff --git a/src/Model/Release/LibraryRelease.php b/src/Model/Release/LibraryRelease.php index 73728a8..eb00540 100644 --- a/src/Model/Release/LibraryRelease.php +++ b/src/Model/Release/LibraryRelease.php @@ -245,7 +245,7 @@ public function setChangelog($changelog) * @param string $default Default value to get if no value found * @return string */ - public function getBranching($default = Branch::DEFAULT_OPTION) + public function getBranching($default = Branch::AUTO) { return $this->branching ?: $default; } diff --git a/src/Steps/Release/UpdateTranslations.php b/src/Steps/Release/UpdateTranslations.php index d2b0c9e..403dbaf 100644 --- a/src/Steps/Release/UpdateTranslations.php +++ b/src/Steps/Release/UpdateTranslations.php @@ -279,12 +279,13 @@ protected function collectStrings(OutputInterface $output, $modules) // Get code dirs for each module $dirs = array(); foreach ($modules as $module) { - $dirs[] = $module->getRelativeMainDirectory(); + $dirs[] = $module->getI18nTextCollectorName(); } $sakeCommand = sprintf( - '(cd %s && ./framework/sake dev/tasks/i18nTextCollectorTask "flush=all" "merge=1" "module=%s")', + '(cd %s && %s dev/tasks/i18nTextCollectorTask "flush=all" "merge=1" "module=%s")', $this->getProject()->getDirectory(), + $this->getProject()->getSakePath(), implode(',', $dirs) ); $this->runCommand($output, $sakeCommand, "Error encountered running i18nTextCollectorTask");