From 1817f6d5c72f6461880040906999404142e6a2a8 Mon Sep 17 00:00:00 2001 From: Davert Date: Tue, 5 Aug 2014 05:48:51 +0300 Subject: [PATCH] Semver task can update versions without writing to file --- CHANGELOG.md | 7 ++++++ RoboFile.php | 17 +++++++++----- composer.json | 2 +- composer.lock | 47 +++++++++++++++++++-------------------- robo.phar | Bin 1549650 -> 1550422 bytes src/Runner.php | 2 +- src/Task/Development.php | 35 ++++++++++++++++------------- 7 files changed, 62 insertions(+), 48 deletions(-) mode change 100755 => 100644 robo.phar diff --git a/CHANGELOG.md b/CHANGELOG.md index e393f5b56..b0fad53d5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,12 @@ # Changelog +#### 0.4.5 + +* [Semver] may accepts version as argument *2014-08-05* +* [Changelog] changed style *2014-06-27* +* [GenMarkDown] fixed formatting annotations *2014-06-27* + + #### 0.4.4 06/05/2014 * Output can be disabled in all executable tasks by ->printed(false) diff --git a/RoboFile.php b/RoboFile.php index 62fdea2f5..8c67f46fd 100644 --- a/RoboFile.php +++ b/RoboFile.php @@ -23,6 +23,15 @@ public function release() $this->pharPublish(); } + /** + * Copies robo.phar to /usr/bin + */ + public function pharInstallGlobal() + { + $this->say("Sudo required, copying..."); + copy('robo.phar', '/usr/bin/robo'); + } + public function test($args = "") { return $this->taskCodecept() @@ -30,7 +39,7 @@ public function test($args = "") ->run(); } - public function added($addition) + public function changed($addition) { $this->taskChangelog() ->version(\Robo\Runner::VERSION) @@ -40,11 +49,7 @@ public function added($addition) public function versionBump($version = null) { - if (!$version) { - $versionParts = explode('.', \Robo\Runner::VERSION); - $versionParts[count($versionParts)-1]++; - $version = implode('.', $versionParts); - } + if (!$version) $version = $this->taskSemVer(\Robo\Runner::VERSION)->increment(); $this->taskReplaceInFile(__DIR__.'/src/Runner.php') ->from("VERSION = '".\Robo\Runner::VERSION."'") ->to("VERSION = '".$version."'") diff --git a/composer.json b/composer.json index 3f67c03eb..c845da0f5 100644 --- a/composer.json +++ b/composer.json @@ -23,7 +23,7 @@ "henrikbjorn/lurker" : "1.0.*@dev" }, "require-dev": { - "codeception/codeception": "@dev", + "codeception/codeception": "*", "codeception/verify": "*", "codeception/aspect-mock": "*" } diff --git a/composer.lock b/composer.lock index 2ecdb09dd..9811be31c 100644 --- a/composer.lock +++ b/composer.lock @@ -3,7 +3,7 @@ "This file locks the dependencies of your project to a known state", "Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file" ], - "hash": "883a377fa5dfa22dfd42c479ecc6acaa", + "hash": "f410ed4f74fc855b2d7bc9cf7f913367", "packages": [ { "name": "henrikbjorn/lurker", @@ -469,16 +469,16 @@ }, { "name": "codeception/codeception", - "version": "dev-master", + "version": "2.0.1", "source": { "type": "git", "url": "https://github.com/Codeception/Codeception.git", - "reference": "4ff02cce0994adb570bc3c3820603d2070d6b3af" + "reference": "07511243c22ab1229047cda593bc6b29fb4511a4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/Codeception/Codeception/zipball/4ff02cce0994adb570bc3c3820603d2070d6b3af", - "reference": "4ff02cce0994adb570bc3c3820603d2070d6b3af", + "url": "https://api.github.com/repos/Codeception/Codeception/zipball/07511243c22ab1229047cda593bc6b29fb4511a4", + "reference": "07511243c22ab1229047cda593bc6b29fb4511a4", "shasum": "" }, "require": { @@ -534,7 +534,7 @@ "functional testing", "unit testing" ], - "time": "2014-06-04 03:01:06" + "time": "2014-06-21 01:03:08" }, { "name": "codeception/verify", @@ -736,16 +736,16 @@ }, { "name": "guzzlehttp/guzzle", - "version": "4.1.0", + "version": "4.1.2", "source": { "type": "git", "url": "https://github.com/guzzle/guzzle.git", - "reference": "85a0ba7de064493c928a8bcdc5eef01e0bde9953" + "reference": "095cf4db559bebc78d967890eb93280d8ceb5a08" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/guzzle/guzzle/zipball/85a0ba7de064493c928a8bcdc5eef01e0bde9953", - "reference": "85a0ba7de064493c928a8bcdc5eef01e0bde9953", + "url": "https://api.github.com/repos/guzzle/guzzle/zipball/095cf4db559bebc78d967890eb93280d8ceb5a08", + "reference": "095cf4db559bebc78d967890eb93280d8ceb5a08", "shasum": "" }, "require": { @@ -764,7 +764,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "4.0.x-dev" + "dev-master": "4.1.x-dev" } }, "autoload": { @@ -797,7 +797,7 @@ "rest", "web service" ], - "time": "2014-05-28 05:13:19" + "time": "2014-06-18 18:22:41" }, { "name": "guzzlehttp/streams", @@ -1211,16 +1211,16 @@ }, { "name": "phpunit/phpunit", - "version": "4.1.1", + "version": "4.1.3", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "1d6b554732382879045e11c56decd4be76130720" + "reference": "939cb801b3b2aa253aedd0b279f40bb8f35cec91" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/1d6b554732382879045e11c56decd4be76130720", - "reference": "1d6b554732382879045e11c56decd4be76130720", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/939cb801b3b2aa253aedd0b279f40bb8f35cec91", + "reference": "939cb801b3b2aa253aedd0b279f40bb8f35cec91", "shasum": "" }, "require": { @@ -1281,20 +1281,20 @@ "testing", "xunit" ], - "time": "2014-05-24 10:48:51" + "time": "2014-06-11 14:15:47" }, { "name": "phpunit/phpunit-mock-objects", - "version": "2.1.0", + "version": "2.1.4", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit-mock-objects.git", - "reference": "da0eb04d8ee95ec2898187e407e519c118d3d27c" + "reference": "1a894a16b6c15fcdc5ef2b110f0e6233952c9b0f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit-mock-objects/zipball/da0eb04d8ee95ec2898187e407e519c118d3d27c", - "reference": "da0eb04d8ee95ec2898187e407e519c118d3d27c", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit-mock-objects/zipball/1a894a16b6c15fcdc5ef2b110f0e6233952c9b0f", + "reference": "1a894a16b6c15fcdc5ef2b110f0e6233952c9b0f", "shasum": "" }, "require": { @@ -1338,7 +1338,7 @@ "mock", "xunit" ], - "time": "2014-05-02 07:04:11" + "time": "2014-06-07 16:22:57" }, { "name": "sebastian/comparator", @@ -1827,8 +1827,7 @@ ], "minimum-stability": "stable", "stability-flags": { - "henrikbjorn/lurker": 20, - "codeception/codeception": 20 + "henrikbjorn/lurker": 20 }, "platform": { "php": ">=5.4.0" diff --git a/robo.phar b/robo.phar old mode 100755 new mode 100644 index 025d3657e4b635073c22d05c9dd83c437c70461c..2cdb25e1f1e026e7a5d6a25c9e2967daee881dc4 GIT binary patch delta 5737 zcmai1c~q2Fmj76bf?|g%l?ba$MItuWJ*7;VhF?_OeN&PkvA@%ZuT-FNSO zzjv4S{oB=&Pj8l-`gcpK)Wzd)$Fc%(fmJc$s8v0pi#5&l*5wK&SKw{WaZO)^#zQ;r z4xh>5AlSwS7k;PUxVEJ(v*6MWci3pN26vyc(IKjBI}p#`M^s9LQ^(1KGRcP>R1tD9RBJDJl`4D>frmJCZ-2 zIo9HQxf9LLJ85ywJ6GUgc3E=Vi?tT1;OYcw&29>0?Z$Kq3fkF|y@UoQtK z2z{J5?zbCwxV6X!E(V6cTfRQ1@TM<$y1=gy=VreK#0dXNRCt~#+<9!@Jecf}ZXpn+ z{AP%wnQ}Qy`P-qS9bbpo%x}gW{}IS>4^L)&02gBy!f=2Lk^($YAU~i6@xnAl1X8{X z1(E{AEMoRxB*&epSr;QI=nIy^Qn8 zxE>;dsW3ST%fm_N9Tuu>!m|o!EAs}I*>UhuxE~5U3MV!<&ZeW@nyp8-<}$ZV-}z$K z%MC{(Xv6sk+MrRBV1=CHT=EZ}g{^i@d!^DC#+#HvdhqyP5%IjBY zbbI;fbht_8;=?~}PKO3h79$IIh)9=%RR&$PZw5u36^jGy;khSSJtCn$W>BC%%vg!q zQx;P77Z+0H>u2=_u75htDqk|>EwP1^Ma1!jMRey^7Hz_VA9Looi%G@4@NsrJ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i~KK;QSE&I diff --git a/src/Runner.php b/src/Runner.php index dad61032c..47850ebbf 100644 --- a/src/Runner.php +++ b/src/Runner.php @@ -14,7 +14,7 @@ class Runner { use Output; - const VERSION = '0.4.4'; + const VERSION = '0.4.5'; const ROBOCLASS = 'RoboFile'; const ROBOFILE = 'RoboFile.php'; diff --git a/src/Task/Development.php b/src/Task/Development.php index 299a2979a..92523846b 100644 --- a/src/Task/Development.php +++ b/src/Task/Development.php @@ -105,8 +105,8 @@ public function run() if (empty($this->log)) { return Result::error($this, "Changelog is empty"); } - $text = implode("\n", array_map(function ($i) { return "* $i"; }, $this->log))."\n"; - $ver = "#### {$this->version} ".date('m/d/Y')."\n\n"; + $text = implode("\n", array_map(function ($i) { return "* $i *".date('Y-m-d')."*"; }, $this->log))."\n"; + $ver = "#### {$this->version}\n\n"; $text = $ver . $text; if (!file_exists($this->filename)) { @@ -380,7 +380,7 @@ protected function documentPropertyDocBlock(\ReflectionProperty $reflectedProper } } $propertyDoc = self::indentDoc($propertyDoc, 7); - $propertyDoc = preg_replace("~@(.*?)([$\s])~", ' * `$1` $2', $propertyDoc); // format annotations + $propertyDoc = preg_replace("~^@(.*?)([$\s])~", ' * `$1` $2', $propertyDoc); // format annotations if (is_callable($this->processPropertyDocBlock)) { $propertyDoc = call_user_func($this->processPropertyDocBlock, $reflectedProperty, $propertyDoc); } @@ -398,7 +398,7 @@ protected function documentParam(\ReflectionParameter $param) if ($param->allowsNull()) { $text .= ' = null'; } else { - $text .= ' = '.$param->getDefaultValue(); + $text .= ' = '.str_replace("\n",' ', print_r($param->getDefaultValue(), true)); } } @@ -458,7 +458,7 @@ protected function documentMethodDocBlock(\ReflectionMethod $reflectedMethod) } $methodDoc = self::indentDoc($methodDoc, 7); - $methodDoc = preg_replace("~@(.*?)([$\s])~", ' * `$1` $2', $methodDoc); // format annotations + $methodDoc = preg_replace("~^@(.*?) ([$\s])~m", ' * `$1` $2', $methodDoc); // format annotations if (is_callable($this->processMethodDocBlock)) { $methodDoc = call_user_func($this->processMethodDocBlock, $reflectedMethod, $methodDoc); } @@ -502,13 +502,19 @@ class SemVerTask implements TaskInterface 'metadata' => '' ]; - public function __construct($pathToSemVer = '.semver') + public function __construct($semVerFileOrVersion = '.semver') { - $this->path = $pathToSemVer; + if (file_exists($semVerFileOrVersion)) { + $this->path = $semVerFileOrVersion; + $version = file_get_contents($this->path); - if (file_exists($this->path)) { - $this->parse(); + } elseif (preg_match('~^(\d+)\.(\d+).(\d+)~', $semVerFileOrVersion)) { + $version = $semVerFileOrVersion; } + if (!preg_match_all(self::REGEX, implode("\n", $version), $matches)) { + throw new TaskException($this, 'Bad semver file.'); + } + $this->parse($version); } public function __toString() @@ -593,6 +599,9 @@ public function metadata($data) public function run() { + if (!$this->path) { + throw new TaskException($this, "No semver file specified, use __toString() to get current version"); + } $written = $this->dump(); return new Result($this, (int)($written !== false), $this->__toString()); } @@ -604,14 +613,8 @@ protected function dump() return file_put_contents($this->path, $semver); } - protected function parse() + protected function parse($version) { - $output = file_get_contents($this->path); - - if (!preg_match_all(self::REGEX, implode("\n", $output), $matches)) { - throw new TaskException($this, 'Bad semver file.'); - } - list(, $major, $minor, $patch, $special, $metadata) = array_map('current', $matches); $this->version = compact('major', 'minor', 'patch', 'special', 'metadata'); }