mirror of
				https://github.com/hauke68/Magallanes.git
				synced 2025-11-04 09:00:18 +01:00 
			
		
		
		
	Merge branch 'master' of https://github.com/andres-montanez/Magallanes
Conflicts: Mage/Task/Factory.php
This commit is contained in:
		
						commit
						66ea107229
					
				@ -310,7 +310,11 @@ class DeployCommand extends AbstractCommand implements RequiresEnvironment
 | 
				
			|||||||
    			    case 'targz':
 | 
					    			    case 'targz':
 | 
				
			||||||
    			    	$deployStrategy = 'deployment/strategy/tar-gz';
 | 
					    			    	$deployStrategy = 'deployment/strategy/tar-gz';
 | 
				
			||||||
    			    	break;
 | 
					    			    	break;
 | 
				
			||||||
 | 
					                            
 | 
				
			||||||
 | 
					                            case 'git-rebase':
 | 
				
			||||||
 | 
					    			    	$deployStrategy = 'deployment/strategy/git-rebase';
 | 
				
			||||||
 | 
					    			    	break;
 | 
				
			||||||
 | 
					                            
 | 
				
			||||||
    			    case 'guess':
 | 
					    			    case 'guess':
 | 
				
			||||||
    			    default:
 | 
					    			    default:
 | 
				
			||||||
    			    	if ($this->getConfig()->release('enabled', false) == true) {
 | 
					    			    	if ($this->getConfig()->release('enabled', false) == true) {
 | 
				
			||||||
 | 
				
			|||||||
@ -54,7 +54,7 @@ class UpgradeCommand extends AbstractCommand
 | 
				
			|||||||
        	// Check version
 | 
					        	// Check version
 | 
				
			||||||
        	$version = json_decode(file_get_contents(self::UPGRADE));
 | 
					        	$version = json_decode(file_get_contents(self::UPGRADE));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        	if ($version !== false) {
 | 
					        	if ($version !== false && $version !== null) {
 | 
				
			||||||
        		$versionCompare = version_compare(MAGALLANES_VERSION, $version->latest);
 | 
					        		$versionCompare = version_compare(MAGALLANES_VERSION, $version->latest);
 | 
				
			||||||
        		if ($versionCompare == 0) {
 | 
					        		if ($versionCompare == 0) {
 | 
				
			||||||
        			Console::output('<yellow>SKIP</yellow>', 0, 1);
 | 
					        			Console::output('<yellow>SKIP</yellow>', 0, 1);
 | 
				
			||||||
@ -94,4 +94,4 @@ class UpgradeCommand extends AbstractCommand
 | 
				
			|||||||
        	}
 | 
					        	}
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
@ -10,7 +10,6 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
namespace Mage\Command;
 | 
					namespace Mage\Command;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
use Mage\Command\AbstractCommand;
 | 
					 | 
				
			||||||
use Mage\Config;
 | 
					use Mage\Config;
 | 
				
			||||||
use Mage\Autoload;
 | 
					use Mage\Autoload;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -10,7 +10,6 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
namespace Mage;
 | 
					namespace Mage;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
use Symfony\Component\Yaml\Yaml;
 | 
					 | 
				
			||||||
use Exception;
 | 
					use Exception;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
@ -341,10 +340,20 @@ class Config
 | 
				
			|||||||
    public function getHostPort()
 | 
					    public function getHostPort()
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        $info = explode(':', $this->host);
 | 
					        $info = explode(':', $this->host);
 | 
				
			||||||
        $info[] = $this->deployment('port', '22');
 | 
					        $info[] = $this->deployment('port', '22');
 | 
				
			||||||
        return $info[1];
 | 
					        return $info[1];
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * Get the general Host Identity File Option
 | 
				
			||||||
 | 
					     *
 | 
				
			||||||
 | 
					     * @return string
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    public function getHostIdentityFileOption()
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        return $this->deployment('identity-file') ? ('-i ' . $this->deployment('identity-file') . ' ') : '';
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * Get the current Host
 | 
					     * Get the current Host
 | 
				
			||||||
     *
 | 
					     *
 | 
				
			||||||
@ -405,7 +414,7 @@ class Config
 | 
				
			|||||||
    	}
 | 
					    	}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    	// Global Config
 | 
					    	// Global Config
 | 
				
			||||||
        $config = $this->getEnvironmentOption('deployment', array());
 | 
					        $config = $this->getEnvironmentOption('deployment', array());
 | 
				
			||||||
        if (isset($config[$option])) {
 | 
					        if (isset($config[$option])) {
 | 
				
			||||||
            if (is_array($default) && ($config[$option] == '')) {
 | 
					            if (is_array($default) && ($config[$option] == '')) {
 | 
				
			||||||
                return $default;
 | 
					                return $default;
 | 
				
			||||||
@ -424,7 +433,7 @@ class Config
 | 
				
			|||||||
     * @param string $default
 | 
					     * @param string $default
 | 
				
			||||||
     * @return mixed
 | 
					     * @return mixed
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    public function release($option, $default = false)
 | 
					    public function release($option, $default = false)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
    	// Host Config
 | 
					    	// Host Config
 | 
				
			||||||
    	if (is_array($this->hostConfig) && isset($this->hostConfig['releases'])) {
 | 
					    	if (is_array($this->hostConfig) && isset($this->hostConfig['releases'])) {
 | 
				
			||||||
@ -432,17 +441,17 @@ class Config
 | 
				
			|||||||
    			return $this->hostConfig['releases'][$option];
 | 
					    			return $this->hostConfig['releases'][$option];
 | 
				
			||||||
    		}
 | 
					    		}
 | 
				
			||||||
    	}
 | 
					    	}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $config = $this->getEnvironmentOption('releases', array());
 | 
					        $config = $this->getEnvironmentOption('releases', array());
 | 
				
			||||||
        if (isset($config[$option])) {
 | 
					        if (isset($config[$option])) {
 | 
				
			||||||
            if (is_array($default) && ($config[$option] == '')) {
 | 
					            if (is_array($default) && ($config[$option] == '')) {
 | 
				
			||||||
                return $default;
 | 
					                return $default;
 | 
				
			||||||
            } else {
 | 
					            } else {
 | 
				
			||||||
                return $config[$option];
 | 
					                return $config[$option];
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        } else {
 | 
					        } else {
 | 
				
			||||||
            return $default;
 | 
					            return $default;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
@ -496,4 +505,4 @@ class Config
 | 
				
			|||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
@ -10,7 +10,6 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
namespace Mage;
 | 
					namespace Mage;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
use Mage\Config;
 | 
					 | 
				
			||||||
use Mage\Command\Factory;
 | 
					use Mage\Command\Factory;
 | 
				
			||||||
use Mage\Command\RequiresEnvironment;
 | 
					use Mage\Command\RequiresEnvironment;
 | 
				
			||||||
use Mage\Console\Colors;
 | 
					use Mage\Console\Colors;
 | 
				
			||||||
 | 
				
			|||||||
@ -10,7 +10,6 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
namespace Mage;
 | 
					namespace Mage;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
use Mage\Console;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
 * Mailer Helper.
 | 
					 * Mailer Helper.
 | 
				
			||||||
 | 
				
			|||||||
@ -12,8 +12,6 @@ namespace Mage\Task;
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
use Mage\Console;
 | 
					use Mage\Console;
 | 
				
			||||||
use Mage\Config;
 | 
					use Mage\Config;
 | 
				
			||||||
use Mage\Task\ErrorWithMessageException;
 | 
					 | 
				
			||||||
use Mage\Task\SkipException;
 | 
					 | 
				
			||||||
use Mage\Task\Releases\IsReleaseAware;
 | 
					use Mage\Task\Releases\IsReleaseAware;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
use Exception;
 | 
					use Exception;
 | 
				
			||||||
@ -192,7 +190,7 @@ abstract class AbstractTask
 | 
				
			|||||||
        // if general.yml includes "ssy_needs_tty: true", then add "-t" to the ssh command
 | 
					        // if general.yml includes "ssy_needs_tty: true", then add "-t" to the ssh command
 | 
				
			||||||
        $needs_tty = ($this->getConfig()->general('ssh_needs_tty',false) ? '-t' : '');
 | 
					        $needs_tty = ($this->getConfig()->general('ssh_needs_tty',false) ? '-t' : '');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $localCommand = 'ssh ' . $needs_tty . ' -p ' . $this->getConfig()->getHostPort() . ' '
 | 
					        $localCommand = 'ssh ' . $this->getConfig()->getHostIdentityFileOption() . $needs_tty . ' -p ' . $this->getConfig()->getHostPort() . ' '
 | 
				
			||||||
                      . '-q -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no '
 | 
					                      . '-q -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no '
 | 
				
			||||||
                      . $this->getConfig()->deployment('user') . '@' . $this->getConfig()->getHostName() . ' '
 | 
					                      . $this->getConfig()->deployment('user') . '@' . $this->getConfig()->getHostName() . ' '
 | 
				
			||||||
                      . '"cd ' . rtrim($this->getConfig()->deployment('to'), '/') . $releasesDirectory . ' && '
 | 
					                      . '"cd ' . rtrim($this->getConfig()->deployment('to'), '/') . $releasesDirectory . ' && '
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										40
									
								
								Mage/Task/BuiltIn/Composer/GenerateAutoload.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										40
									
								
								Mage/Task/BuiltIn/Composer/GenerateAutoload.php
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,40 @@
 | 
				
			|||||||
 | 
					<?php
 | 
				
			||||||
 | 
					namespace Mage\Task\BuiltIn\Composer;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					use Exception;
 | 
				
			||||||
 | 
					use Mage\Task\AbstractTask;
 | 
				
			||||||
 | 
					use Mage\Task\ErrorWithMessageException;
 | 
				
			||||||
 | 
					use Mage\Task\SkipException;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					class GenerateAutoload extends AbstractTask
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * Returns the Title of the Task
 | 
				
			||||||
 | 
					     * @return string
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    public function getName()
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        return 'Generating autoload files via composer [built-in]';
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * Runs the task
 | 
				
			||||||
 | 
					     *
 | 
				
			||||||
 | 
					     * @return boolean
 | 
				
			||||||
 | 
					     * @throws Exception
 | 
				
			||||||
 | 
					     * @throws ErrorWithMessageException
 | 
				
			||||||
 | 
					     * @throws SkipException
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    public function run()
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        $releasesDirectory = $this->getConfig()->release('directory', 'releases');
 | 
				
			||||||
 | 
					        $releasesDirectory = rtrim($this->getConfig()->deployment('to'), '/') . '/' . $releasesDirectory;
 | 
				
			||||||
 | 
					        $currentCopy = $releasesDirectory . '/' . $this->getConfig()->getReleaseId();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        $sharedFolderName = $this->getParameter('shared', 'shared');
 | 
				
			||||||
 | 
					        $sharedFolderName = rtrim($this->getConfig()->deployment('to'), '/') . '/' . $sharedFolderName;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        $composerPath = $this->getParameter('composer', "$sharedFolderName/composer.phar");
 | 
				
			||||||
 | 
					        return $this->runCommandRemote("/usr/bin/env php $composerPath --working-dir=$currentCopy dumpautoload --optimize", $output);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@ -59,14 +59,13 @@ class ReleaseTask extends AbstractTask implements IsReleaseAware, SkipOnOverride
 | 
				
			|||||||
            	$command .= ' && '
 | 
					            	$command .= ' && '
 | 
				
			||||||
                          . 'chown -h ' . $userGroup . ' ' . $symlink
 | 
					                          . 'chown -h ' . $userGroup . ' ' . $symlink
 | 
				
			||||||
                          . ' && '
 | 
					                          . ' && '
 | 
				
			||||||
                          . 'chown -R ' . $userGroup . ' ' . $currentCopy;
 | 
					                          . 'chown -R ' . $userGroup . ' ' . $currentCopy
 | 
				
			||||||
 | 
					                          . ' && '
 | 
				
			||||||
 | 
					                          . 'chown ' . $userGroup . ' ' . $releasesDirectory;
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            $result = $this->runCommandRemote($command);
 | 
					            $result = $this->runCommandRemote($command);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            // Set Directory Releases to same owner
 | 
					 | 
				
			||||||
            $result = $this->runCommandRemote('chown ' . $userGroup . ' ' . $releasesDirectory);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            return $result;
 | 
					            return $result;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        } else {
 | 
					        } else {
 | 
				
			||||||
@ -74,4 +73,4 @@ class ReleaseTask extends AbstractTask implements IsReleaseAware, SkipOnOverride
 | 
				
			|||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
@ -34,13 +34,13 @@ class GitRebaseTask extends AbstractTask implements IsReleaseAware
 | 
				
			|||||||
     * @see \Mage\Task\AbstractTask::run()
 | 
					     * @see \Mage\Task\AbstractTask::run()
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    public function run()
 | 
					    public function run()
 | 
				
			||||||
    {
 | 
					    {        
 | 
				
			||||||
    	$branch = $this->getParameter('branch');
 | 
					    	$branch = $this->getParameter('branch', 'master');
 | 
				
			||||||
    	$remote = $this->getParameter('remote');
 | 
					    	$remote = $this->getParameter('remote', 'origin');
 | 
				
			||||||
 | 
					                
 | 
				
			||||||
    	// Fetch Remote
 | 
					    	// Fetch Remote
 | 
				
			||||||
        $command = 'git fetch ' . $remote;
 | 
					        $command = 'git fetch ' . $remote;
 | 
				
			||||||
        $result = $this->runCommandRemote($command) && $result;
 | 
					        $result = $this->runCommandRemote($command);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        // Checkout
 | 
					        // Checkout
 | 
				
			||||||
        $command = 'git checkout ' . $branch;
 | 
					        $command = 'git checkout ' . $branch;
 | 
				
			||||||
 | 
				
			|||||||
@ -94,7 +94,7 @@ class RsyncTask extends AbstractTask implements IsReleaseAware
 | 
				
			|||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $command = 'rsync -avz '
 | 
					        $command = 'rsync -avz '
 | 
				
			||||||
                 . '--rsh="ssh -p' . $this->getConfig()->getHostPort() . '" '
 | 
					                 . '--rsh="ssh ' . $this->getConfig()->getHostIdentityFileOption() . '-p' . $this->getConfig()->getHostPort() . '" '
 | 
				
			||||||
                 . $this->excludes(array_merge($excludes, $userExcludes)) . ' '
 | 
					                 . $this->excludes(array_merge($excludes, $userExcludes)) . ' '
 | 
				
			||||||
                 . $this->getConfig()->deployment('from') . ' '
 | 
					                 . $this->getConfig()->deployment('from') . ' '
 | 
				
			||||||
                 . $this->getConfig()->deployment('user') . '@' . $this->getConfig()->getHostName() . ':' . $deployToDirectory;
 | 
					                 . $this->getConfig()->deployment('user') . '@' . $this->getConfig()->getHostName() . ':' . $deployToDirectory;
 | 
				
			||||||
 | 
				
			|||||||
@ -89,7 +89,7 @@ class TarGzTask extends AbstractTask implements IsReleaseAware
 | 
				
			|||||||
        $result = $this->runCommandLocal($command);
 | 
					        $result = $this->runCommandLocal($command);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        // Copy Tar Gz  to Remote Host
 | 
					        // Copy Tar Gz  to Remote Host
 | 
				
			||||||
        $command = 'scp -P ' . $this->getConfig()->getHostPort() . ' ' . $localTarGz . '.tar.gz '
 | 
					        $command = 'scp ' . $this->getConfig()->getHostIdentityFileOption() . '-P ' . $this->getConfig()->getHostPort() . ' ' . $localTarGz . '.tar.gz '
 | 
				
			||||||
                 . $this->getConfig()->deployment('user') . '@' . $this->getConfig()->getHostName() . ':' . $deployToDirectory;
 | 
					                 . $this->getConfig()->deployment('user') . '@' . $this->getConfig()->getHostName() . ':' . $deployToDirectory;
 | 
				
			||||||
        $result = $this->runCommandLocal($command) && $result;
 | 
					        $result = $this->runCommandLocal($command) && $result;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										50
									
								
								Mage/Task/BuiltIn/Filesystem/ApplyFacls.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										50
									
								
								Mage/Task/BuiltIn/Filesystem/ApplyFacls.php
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,50 @@
 | 
				
			|||||||
 | 
					<?php
 | 
				
			||||||
 | 
					namespace Mage\Task\BuiltIn\Filesystem;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					use Exception;
 | 
				
			||||||
 | 
					use Mage\Task\AbstractTask;
 | 
				
			||||||
 | 
					use Mage\Task\ErrorWithMessageException;
 | 
				
			||||||
 | 
					use Mage\Task\SkipException;
 | 
				
			||||||
 | 
					use Mage\Task\Releases\IsReleaseAware;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					class ApplyFacls extends AbstractTask implements IsReleaseAware
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * Returns the Title of the Task
 | 
				
			||||||
 | 
					     * @return string
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    public function getName()
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        return 'Set file ACLs on remote system [built-in]';
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * Runs the task
 | 
				
			||||||
 | 
					     *
 | 
				
			||||||
 | 
					     * @return boolean
 | 
				
			||||||
 | 
					     * @throws Exception
 | 
				
			||||||
 | 
					     * @throws ErrorWithMessageException
 | 
				
			||||||
 | 
					     * @throws SkipException
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    public function run()
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        $releasesDirectory = $this->getConfig()->release('directory', 'releases');
 | 
				
			||||||
 | 
					        $releasesDirectory = rtrim($this->getConfig()->deployment('to'), '/') . '/' . $releasesDirectory;
 | 
				
			||||||
 | 
					        $currentCopy = $releasesDirectory . '/' . $this->getConfig()->getReleaseId();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        $aclParam = $this->getParameter('acl_param', '');
 | 
				
			||||||
 | 
					        if (empty($aclParam)) {
 | 
				
			||||||
 | 
					            throw new SkipException('Parameter acl_param not set.');
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        $folders = $this->getParameter('folders', []);
 | 
				
			||||||
 | 
					        $recursive = $this->getParameter('recursive', false) ? ' -R ' : ' ';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        foreach ($folders as $folder) {
 | 
				
			||||||
 | 
					            $this->runCommandRemote("setfacl$recursive-m $aclParam $currentCopy/$folder", $output);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        return true;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
							
								
								
									
										54
									
								
								Mage/Task/BuiltIn/Filesystem/LinkSharedFilesTask.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										54
									
								
								Mage/Task/BuiltIn/Filesystem/LinkSharedFilesTask.php
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,54 @@
 | 
				
			|||||||
 | 
					<?php
 | 
				
			||||||
 | 
					namespace Mage\Task\BuiltIn\Filesystem;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					use Mage\Task\AbstractTask;
 | 
				
			||||||
 | 
					use Mage\Task\Releases\IsReleaseAware;
 | 
				
			||||||
 | 
					use Mage\Task\SkipException;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					class LinkSharedFilesTask extends AbstractTask implements IsReleaseAware
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * Returns the Title of the Task
 | 
				
			||||||
 | 
					     * @return string
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    public function getName()
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        return 'Linking files/folders from the shared folder into the current release [built-in]';
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * Runs the task
 | 
				
			||||||
 | 
					     *
 | 
				
			||||||
 | 
					     * @return boolean
 | 
				
			||||||
 | 
					     * @throws Exception
 | 
				
			||||||
 | 
					     * @throws \Mage\Task\ErrorWithMessageException
 | 
				
			||||||
 | 
					     * @throws SkipException
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    public function run()
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        $linkedFiles = $this->getParameter('linked_files', []);
 | 
				
			||||||
 | 
					        $linkedFolders = $this->getParameter('linked_folders', []);
 | 
				
			||||||
 | 
					        if (sizeof($linkedFiles) == 0 && sizeof($linkedFolders) == 0) {
 | 
				
			||||||
 | 
					            throw new SkipException('No files and folders configured for sym-linking.');
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        $sharedFolderName = $this->getParameter('shared', 'shared');
 | 
				
			||||||
 | 
					        $sharedFolderName = rtrim($this->getConfig()->deployment('to'), '/') . '/' . $sharedFolderName;
 | 
				
			||||||
 | 
					        $releasesDirectory = $this->getConfig()->release('directory', 'releases');
 | 
				
			||||||
 | 
					        $releasesDirectory = rtrim($this->getConfig()->deployment('to'), '/') . '/' . $releasesDirectory;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        $currentCopy = $releasesDirectory . '/' . $this->getConfig()->getReleaseId();
 | 
				
			||||||
 | 
					        foreach ($linkedFolders as $folder) {
 | 
				
			||||||
 | 
					            $command = "ln -nfs $sharedFolderName/$folder $currentCopy/$folder";
 | 
				
			||||||
 | 
					            $this->runCommandRemote($command);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        foreach ($linkedFiles as $folder) {
 | 
				
			||||||
 | 
					            $command = "ln -nfs $sharedFolderName/$folder $currentCopy/$folder";
 | 
				
			||||||
 | 
					            $this->runCommandRemote($command);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        return true;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@ -63,8 +63,7 @@ class ChangeBranchTask extends AbstractTask
 | 
				
			|||||||
     */
 | 
					     */
 | 
				
			||||||
    public function run()
 | 
					    public function run()
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
    	$scmConfig = $this->getConfig()->general('scm', array());
 | 
					        switch ($this->getConfig()->general('scm')) {
 | 
				
			||||||
        switch ((isset($scmConfig['type']) ? $scmConfig['type'] : false)) {
 | 
					 | 
				
			||||||
            case 'git':
 | 
					            case 'git':
 | 
				
			||||||
            	if ($this->getParameter('_changeBranchRevert', false)) {
 | 
					            	if ($this->getParameter('_changeBranchRevert', false)) {
 | 
				
			||||||
            		$command = 'git checkout ' . self::$startingBranch;
 | 
					            		$command = 'git checkout ' . self::$startingBranch;
 | 
				
			||||||
 | 
				
			|||||||
@ -12,8 +12,6 @@ namespace Mage\Task;
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
use Mage\Config;
 | 
					use Mage\Config;
 | 
				
			||||||
use Mage\Autoload;
 | 
					use Mage\Autoload;
 | 
				
			||||||
use Mage\Task\ErrorWithMessageException;
 | 
					 | 
				
			||||||
use Mage\Task\AbstractTask;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
use Exception;
 | 
					use Exception;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -29,6 +27,7 @@ class Factory
 | 
				
			|||||||
     *
 | 
					     *
 | 
				
			||||||
     * @param string|array $taskData
 | 
					     * @param string|array $taskData
 | 
				
			||||||
     * @param \Mage\Config $taskConfig
 | 
					     * @param \Mage\Config $taskConfig
 | 
				
			||||||
 | 
					     * @param Config $taskConfig
 | 
				
			||||||
     * @param boolean $inRollback
 | 
					     * @param boolean $inRollback
 | 
				
			||||||
     * @param string $stage
 | 
					     * @param string $stage
 | 
				
			||||||
     * @return \Mage\Task\AbstractTask
 | 
					     * @return \Mage\Task\AbstractTask
 | 
				
			||||||
@ -70,4 +69,4 @@ class Factory
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        return $instance;
 | 
					        return $instance;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user