-
Notifications
You must be signed in to change notification settings - Fork 27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added bump version task for replacing the DEPLOY_VERSION placeholder #31
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
<?php | ||
/** | ||
* @package JoRobo | ||
* | ||
* @copyright Copyright (C) 2005 - 2017 Open Source Matters, Inc. All rights reserved. | ||
* @license GNU General Public License version 2 or later; see LICENSE.txt | ||
*/ | ||
|
||
namespace Joomla\Jorobo\Tasks; | ||
|
||
use Robo\Result; | ||
use Robo\Task\BaseTask; | ||
use Robo\Contract\TaskInterface; | ||
use Robo\Exception\TaskException; | ||
|
||
/** | ||
* Bump the version of an Joomla extension | ||
* | ||
* @package Joomla\Jorobo\Tasks\Component | ||
*/ | ||
class BumpVersion extends JTask implements TaskInterface | ||
{ | ||
use \Robo\Task\Development\loadTasks; | ||
use \Robo\Common\TaskIO; | ||
|
||
/** | ||
* Constructor | ||
* | ||
* @since 1.0 | ||
*/ | ||
public function __construct() | ||
{ | ||
parent::__construct(); | ||
} | ||
|
||
/** | ||
* Maps all parts of an extension into a Joomla! installation | ||
* | ||
* @return bool | ||
* | ||
* @since 1.0 | ||
*/ | ||
public function run() | ||
{ | ||
$this->say('Updating ' . $this->getJConfig()->extension . " to " . $this->getJConfig()->version); | ||
|
||
// Reusing the header config here | ||
$exclude = explode(",", trim($this->getJConfig()->header->exclude)); | ||
|
||
$path = realpath($this->getJConfig()->source); | ||
$fileTypes = explode(",", trim($this->getJConfig()->header->files)); | ||
|
||
$changedFiles = 0; | ||
|
||
foreach (new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($path)) as $filename) | ||
{ | ||
if (substr($filename, 0, 1) == '.') | ||
{ | ||
continue; | ||
} | ||
|
||
$file = new \SplFileInfo($filename); | ||
|
||
if (!in_array($file->getExtension(), $fileTypes)) | ||
{ | ||
continue; | ||
} | ||
|
||
// Skip directories in exclude list | ||
if (isset($exclude) && count($exclude)) | ||
{ | ||
$relative = str_replace(realpath($path), "", $file->getPath()); | ||
|
||
// It is possible to have multiple exclude directories | ||
foreach ($exclude as $e) | ||
{ | ||
if (stripos($relative, $e) !== false) | ||
{ | ||
$this->say("Excluding " . $filename); | ||
continue 2; | ||
} | ||
} | ||
} | ||
|
||
// Load the file | ||
$fileContents = file_get_contents($file->getRealPath()); | ||
|
||
if (preg_match('#__DEPLOY_VERSION__#', $fileContents)) | ||
{ | ||
$fileContents = preg_replace('#__DEPLOY_VERSION__#', $this->getJConfig()->version, $fileContents); | ||
|
||
$this->say('Updating file: ' . $file->getRealPath()); | ||
|
||
file_put_contents($file->getRealPath(), $fileContents); | ||
|
||
$changedFiles++; | ||
} | ||
} | ||
|
||
$this->say('Updated ' . $changedFiles . ' files'); | ||
|
||
return true; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I sent a fix for this in #30 since it needs to be set before the configuration. I'll fix that PR to get it merged asap.