mirror of
https://github.com/hauke68/Magallanes.git
synced 2026-09-08 14:28:57 +02:00
[Nostromo] Initial Commit
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
namespace Mage\Task\BuiltIn\Composer;
|
||||
|
||||
use Symfony\Component\Process\Process;
|
||||
use Mage\Task\AbstractTask;
|
||||
|
||||
/**
|
||||
* Composer Task - Generate Autoload
|
||||
*
|
||||
* @author Andrés Montañez <andresmontanez@gmail.com>
|
||||
*/
|
||||
class GenerateAutoloadTask extends AbstractTask
|
||||
{
|
||||
public function getName()
|
||||
{
|
||||
return 'composer/generate-autoload';
|
||||
}
|
||||
|
||||
public function getDescription()
|
||||
{
|
||||
return '[Composer] Generate Autoload';
|
||||
}
|
||||
|
||||
public function execute()
|
||||
{
|
||||
$options = $this->getOptions();
|
||||
$command = $options['path'] . ' dumpautoload ' . $options['flags'];
|
||||
|
||||
/** @var Process $process */
|
||||
$process = $this->runtime->runCommand($command);
|
||||
|
||||
return $process->isSuccessful();
|
||||
}
|
||||
|
||||
protected function getOptions()
|
||||
{
|
||||
$options = array_merge(
|
||||
['path' => 'composer', 'flags' => '--optimize'],
|
||||
$this->runtime->getConfigOptions('composer', []),
|
||||
$this->options
|
||||
);
|
||||
|
||||
return $options;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
namespace Mage\Task\BuiltIn\Composer;
|
||||
|
||||
use Symfony\Component\Process\Process;
|
||||
use Mage\Task\AbstractTask;
|
||||
|
||||
/**
|
||||
* Composer Task - Install Vendors
|
||||
*
|
||||
* @author Andrés Montañez <andresmontanez@gmail.com>
|
||||
*/
|
||||
class InstallTask extends AbstractTask
|
||||
{
|
||||
public function getName()
|
||||
{
|
||||
return 'composer/install';
|
||||
}
|
||||
|
||||
public function getDescription()
|
||||
{
|
||||
return '[Composer] Install';
|
||||
}
|
||||
|
||||
public function execute()
|
||||
{
|
||||
$options = $this->getOptions();
|
||||
$command = $options['path'] . ' install ' . $options['flags'];
|
||||
|
||||
/** @var Process $process */
|
||||
$process = $this->runtime->runCommand($command);
|
||||
|
||||
return $process->isSuccessful();
|
||||
}
|
||||
|
||||
protected function getOptions()
|
||||
{
|
||||
$options = array_merge(
|
||||
['path' => 'composer', 'flags' => '--dev'],
|
||||
$this->runtime->getConfigOptions('composer', []),
|
||||
$this->options
|
||||
);
|
||||
|
||||
return $options;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of the Magallanes package.
|
||||
*
|
||||
* (c) Andrés Montañez <andres@andresmontanez.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Mage\Task\BuiltIn\Deploy\Release;
|
||||
|
||||
use Symfony\Component\Process\Process;
|
||||
use Mage\Task\AbstractTask;
|
||||
|
||||
/**
|
||||
* Release Task - Cleanup old releases
|
||||
*
|
||||
* @author Andrés Montañez <andresmontanez@gmail.com>
|
||||
*/
|
||||
class CleanupTask extends AbstractTask
|
||||
{
|
||||
public function getName()
|
||||
{
|
||||
return 'deploy/release/cleanup';
|
||||
}
|
||||
|
||||
public function getDescription()
|
||||
{
|
||||
return '[Release] Cleaning up old Releases';
|
||||
}
|
||||
|
||||
public function execute()
|
||||
{
|
||||
$hostPath = rtrim($this->runtime->getEnvironmentConfig('host_path'), '/');
|
||||
$currentReleaseId = $this->runtime->getReleaseId();
|
||||
$maxReleases = $this->runtime->getEnvironmentConfig('releases');
|
||||
|
||||
$cmdListReleases = sprintf('ls -1 %s/releases', $hostPath);
|
||||
|
||||
/** @var Process $process */
|
||||
$process = $this->runtime->runRemoteCommand($cmdListReleases, false);
|
||||
if ($process->isSuccessful()) {
|
||||
$releases = $process->getOutput();
|
||||
$releases = explode(PHP_EOL, trim($releases));
|
||||
|
||||
if (count($releases) > $maxReleases) {
|
||||
sort($releases);
|
||||
$releasesToDelete = array_slice($releases, 0, count($releases) - $maxReleases);
|
||||
foreach ($releasesToDelete as $releaseId) {
|
||||
if ($releaseId != $currentReleaseId) {
|
||||
$cmdDeleteRelease = sprintf('rm -rf %s/releases/%s', $hostPath, $releaseId);
|
||||
/** @var Process $process */
|
||||
$process = $this->runtime->runRemoteCommand($cmdDeleteRelease, false);
|
||||
if (!$process->isSuccessful()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of the Magallanes package.
|
||||
*
|
||||
* (c) Andrés Montañez <andres@andresmontanez.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Mage\Task\BuiltIn\Deploy\Release;
|
||||
|
||||
use Symfony\Component\Process\Process;
|
||||
use Mage\Task\AbstractTask;
|
||||
|
||||
/**
|
||||
* Release Task - Create the Release Directory
|
||||
*
|
||||
* @author Andrés Montañez <andresmontanez@gmail.com>
|
||||
*/
|
||||
class PrepareTask extends AbstractTask
|
||||
{
|
||||
public function getName()
|
||||
{
|
||||
return 'deploy/release/prepare';
|
||||
}
|
||||
|
||||
public function getDescription()
|
||||
{
|
||||
return '[Release] Preparing Release';
|
||||
}
|
||||
|
||||
public function execute()
|
||||
{
|
||||
$hostPath = rtrim($this->runtime->getEnvironmentConfig('host_path'), '/');
|
||||
|
||||
$cmdMakeDir = sprintf('mkdir -p %s/releases/%s', $hostPath, $this->runtime->getReleaseId());
|
||||
|
||||
/** @var Process $process */
|
||||
$process = $this->runtime->runRemoteCommand($cmdMakeDir, false);
|
||||
return $process->isSuccessful();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of the Magallanes package.
|
||||
*
|
||||
* (c) Andrés Montañez <andres@andresmontanez.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Mage\Task\BuiltIn\Deploy;
|
||||
|
||||
use Mage\Task\ExecuteOnRollbackInterface;
|
||||
use Symfony\Component\Process\Process;
|
||||
use Mage\Task\AbstractTask;
|
||||
|
||||
/**
|
||||
* Release Task - Create the Symlink
|
||||
*
|
||||
* @author Andrés Montañez <andresmontanez@gmail.com>
|
||||
*/
|
||||
class ReleaseTask extends AbstractTask implements ExecuteOnRollbackInterface
|
||||
{
|
||||
public function getName()
|
||||
{
|
||||
return 'deploy/release';
|
||||
}
|
||||
|
||||
public function getDescription()
|
||||
{
|
||||
return '[Release] Creating Symlink';
|
||||
}
|
||||
|
||||
public function execute()
|
||||
{
|
||||
$hostPath = rtrim($this->runtime->getEnvironmentConfig('host_path'), '/');
|
||||
$releaseId = $this->runtime->getReleaseId();
|
||||
|
||||
$cmdLinkRelease = sprintf('cd %s && ln -snf releases/%s current', $hostPath, $releaseId);
|
||||
|
||||
/** @var Process $process */
|
||||
$process = $this->runtime->runRemoteCommand($cmdLinkRelease, false);
|
||||
return $process->isSuccessful();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of the Magallanes package.
|
||||
*
|
||||
* (c) Andrés Montañez <andres@andresmontanez.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Mage\Task\BuiltIn\Deploy;
|
||||
|
||||
use Symfony\Component\Process\Process;
|
||||
use Mage\Task\AbstractTask;
|
||||
|
||||
/**
|
||||
* Rsync Task - Copy files with Rsync
|
||||
*
|
||||
* @author Andrés Montañez <andresmontanez@gmail.com>
|
||||
*/
|
||||
class RsyncTask extends AbstractTask
|
||||
{
|
||||
public function getName()
|
||||
{
|
||||
return 'deploy/rsync';
|
||||
}
|
||||
|
||||
public function getDescription()
|
||||
{
|
||||
return '[Deploy] Copying files with Rsync';
|
||||
}
|
||||
|
||||
public function execute()
|
||||
{
|
||||
$user = $this->runtime->getEnvironmentConfig('user');
|
||||
$host = $this->runtime->getWorkingHost();
|
||||
$hostPath = rtrim($this->runtime->getEnvironmentConfig('host_path'), '/');
|
||||
$targetDir = rtrim($hostPath, '/');
|
||||
|
||||
if ($this->runtime->getEnvironmentConfig('releases', false)) {
|
||||
$targetDir = sprintf('%s/releases/%s', $hostPath, $this->runtime->getReleaseId());
|
||||
}
|
||||
|
||||
$excludes = $this->getExcludes();
|
||||
$cmdRsync = sprintf('rsync -avz %s ./ %s@%s:%s', $excludes, $user, $host, $targetDir);
|
||||
|
||||
/** @var Process $process */
|
||||
$process = $this->runtime->runLocalCommand($cmdRsync, 600);
|
||||
return $process->isSuccessful();
|
||||
}
|
||||
|
||||
protected function getExcludes()
|
||||
{
|
||||
$excludes = $this->runtime->getEnvironmentConfig('exclude', []);
|
||||
$excludes = array_merge(['.git'], $excludes);
|
||||
|
||||
foreach ($excludes as &$exclude) {
|
||||
$exclude = '--exclude=' . $exclude;
|
||||
}
|
||||
|
||||
return implode(' ', $excludes);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of the Magallanes package.
|
||||
*
|
||||
* (c) Andrés Montañez <andres@andresmontanez.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Mage\Task\BuiltIn\Deploy\TarGz;
|
||||
|
||||
use Mage\Runtime\Exception\DeploymentException;
|
||||
use Symfony\Component\Process\Process;
|
||||
use Mage\Task\AbstractTask;
|
||||
|
||||
/**
|
||||
* TarGz Task - Delete temporal Tar
|
||||
*
|
||||
* @author Andrés Montañez <andresmontanez@gmail.com>
|
||||
*/
|
||||
class CleanupTask extends AbstractTask
|
||||
{
|
||||
public function getName()
|
||||
{
|
||||
return 'deploy/targz/cleanup';
|
||||
}
|
||||
|
||||
public function getDescription()
|
||||
{
|
||||
return '[Deploy] Cleanup TarGZ file';
|
||||
}
|
||||
|
||||
public function execute()
|
||||
{
|
||||
if (!$this->runtime->getEnvironmentConfig('releases', false)) {
|
||||
throw new DeploymentException('This task is only available with releases enabled', 400);
|
||||
}
|
||||
|
||||
$tarGzLocal = $this->runtime->getVar('targz_local');
|
||||
|
||||
$cmdDeleteTarGz = sprintf('rm %s', $tarGzLocal);
|
||||
|
||||
/** @var Process $process */
|
||||
$process = $this->runtime->runLocalCommand($cmdDeleteTarGz);
|
||||
if ($process->isSuccessful()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of the Magallanes package.
|
||||
*
|
||||
* (c) Andrés Montañez <andres@andresmontanez.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Mage\Task\BuiltIn\Deploy\TarGz;
|
||||
|
||||
use Mage\Runtime\Exception\DeploymentException;
|
||||
use Symfony\Component\Process\Process;
|
||||
use Mage\Task\AbstractTask;
|
||||
|
||||
/**
|
||||
* TarGz Task - Copy Tar
|
||||
*
|
||||
* @author Andrés Montañez <andresmontanez@gmail.com>
|
||||
*/
|
||||
class CopyTask extends AbstractTask
|
||||
{
|
||||
public function getName()
|
||||
{
|
||||
return 'deploy/targz/copy';
|
||||
}
|
||||
|
||||
public function getDescription()
|
||||
{
|
||||
return '[Deploy] Copying files with TarGZ';
|
||||
}
|
||||
|
||||
public function execute()
|
||||
{
|
||||
if (!$this->runtime->getEnvironmentConfig('releases', false)) {
|
||||
throw new DeploymentException('This task is only available with releases enabled', 400);
|
||||
}
|
||||
|
||||
$user = $this->runtime->getEnvironmentConfig('user');
|
||||
$host = $this->runtime->getWorkingHost();
|
||||
$scpFlags = $this->runtime->getEnvironmentConfig('scp', '-P 22 -q -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no');
|
||||
$hostPath = rtrim($this->runtime->getEnvironmentConfig('host_path'), '/');
|
||||
$currentReleaseId = $this->runtime->getReleaseId();
|
||||
|
||||
$targetDir = sprintf('%s/releases/%s', $hostPath, $currentReleaseId);
|
||||
|
||||
$tarGzLocal = $this->runtime->getVar('targz_local');
|
||||
$tarGzRemote = basename($tarGzLocal);
|
||||
|
||||
$cmdCopy = sprintf('scp %s %s %s@%s:%s/%s', $scpFlags, $tarGzLocal, $user, $host, $targetDir, $tarGzRemote);
|
||||
|
||||
/** @var Process $process */
|
||||
$process = $this->runtime->runLocalCommand($cmdCopy, 300);
|
||||
if ($process->isSuccessful()) {
|
||||
$cmdUntar = sprintf('cd %s && tar xfz %s', $targetDir, $tarGzRemote);
|
||||
$process = $this->runtime->runRemoteCommand($cmdUntar, false, 600);
|
||||
if ($process->isSuccessful()) {
|
||||
$cmdDelete = sprintf('rm %s/%s', $targetDir, $tarGzRemote);
|
||||
$process = $this->runtime->runRemoteCommand($cmdDelete, false);
|
||||
if ($process->isSuccessful()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of the Magallanes package.
|
||||
*
|
||||
* (c) Andrés Montañez <andres@andresmontanez.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Mage\Task\BuiltIn\Deploy\TarGz;
|
||||
|
||||
use Mage\Runtime\Exception\DeploymentException;
|
||||
use Symfony\Component\Process\Process;
|
||||
use Mage\Task\AbstractTask;
|
||||
|
||||
/**
|
||||
* TarGz Task - Create temporal Tar
|
||||
*
|
||||
* @author Andrés Montañez <andresmontanez@gmail.com>
|
||||
*/
|
||||
class PrepareTask extends AbstractTask
|
||||
{
|
||||
public function getName()
|
||||
{
|
||||
return 'deploy/targz/prepare';
|
||||
}
|
||||
|
||||
public function getDescription()
|
||||
{
|
||||
return '[Deploy] Preparing TarGz file';
|
||||
}
|
||||
|
||||
public function execute()
|
||||
{
|
||||
if (!$this->runtime->getEnvironmentConfig('releases', false)) {
|
||||
throw new DeploymentException('This task is only available with releases enabled', 400);
|
||||
}
|
||||
|
||||
$tarGzLocal = tempnam(sys_get_temp_dir(), 'mage');
|
||||
$this->runtime->setVar('targz_local', $tarGzLocal);
|
||||
|
||||
$excludes = $this->getExcludes();
|
||||
$cmdTarGz = sprintf('tar cfz %s %s ./', $tarGzLocal, $excludes);
|
||||
|
||||
/** @var Process $process */
|
||||
$process = $this->runtime->runLocalCommand($cmdTarGz, 300);
|
||||
return $process->isSuccessful();
|
||||
}
|
||||
|
||||
protected function getExcludes()
|
||||
{
|
||||
$excludes = $this->runtime->getEnvironmentConfig('exclude', []);
|
||||
$excludes = array_merge(['.git'], $excludes);
|
||||
|
||||
foreach ($excludes as &$exclude) {
|
||||
$exclude = '--exclude=' . $exclude;
|
||||
}
|
||||
|
||||
return implode(' ', $excludes);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of the Magallanes package.
|
||||
*
|
||||
* (c) Andrés Montañez <andres@andresmontanez.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Mage\Task\BuiltIn\Git;
|
||||
|
||||
use Mage\Task\SkipException;
|
||||
use Symfony\Component\Process\Process;
|
||||
use Mage\Task\AbstractTask;
|
||||
|
||||
/**
|
||||
* Git Task - Checkout Branch
|
||||
*
|
||||
* @author Andrés Montañez <andresmontanez@gmail.com>
|
||||
*/
|
||||
class ChangeBranchTask extends AbstractTask
|
||||
{
|
||||
public function getName()
|
||||
{
|
||||
return 'git/change-branch';
|
||||
}
|
||||
|
||||
public function getDescription()
|
||||
{
|
||||
$options = $this->getOptions();
|
||||
$branch = $options['branch'];
|
||||
|
||||
if ($this->runtime->getVar('git_revert_branch', false)) {
|
||||
$branch = $this->runtime->getVar('git_revert_branch');
|
||||
}
|
||||
|
||||
return sprintf('[Git] Change Branch (%s)', $branch);
|
||||
}
|
||||
|
||||
public function execute()
|
||||
{
|
||||
$options = $this->getOptions();
|
||||
$branch = $options['branch'];
|
||||
|
||||
if (!$this->runtime->getVar('git_revert_branch', false)) {
|
||||
$cmdGetCurrent = sprintf('%s branch | grep "*"', $options['path']);
|
||||
|
||||
/** @var Process $process */
|
||||
$process = $this->runtime->runLocalCommand($cmdGetCurrent);
|
||||
if ($process->isSuccessful()) {
|
||||
$initialBranch = str_replace('* ', '', trim($process->getOutput()));
|
||||
|
||||
if ($initialBranch == $branch) {
|
||||
throw new SkipException();
|
||||
} else {
|
||||
$this->runtime->setVar('git_revert_branch', $initialBranch);
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
$branch = $this->runtime->getVar('git_revert_branch');
|
||||
}
|
||||
|
||||
$cmdChange = sprintf('%s checkout %s', $options['path'], $branch);
|
||||
|
||||
/** @var Process $process */
|
||||
$process = $this->runtime->runLocalCommand($cmdChange);
|
||||
return $process->isSuccessful();
|
||||
}
|
||||
|
||||
protected function getOptions()
|
||||
{
|
||||
$config = $this->runtime->getEnvironmentConfig();
|
||||
$branch = 'master';
|
||||
if (array_key_exists('branch', $config)) {
|
||||
$branch = $config['branch'];
|
||||
}
|
||||
|
||||
$options = array_merge(
|
||||
['path' => 'git', 'branch' => $branch],
|
||||
$this->options
|
||||
);
|
||||
|
||||
return $options;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of the Magallanes package.
|
||||
*
|
||||
* (c) Andrés Montañez <andres@andresmontanez.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Mage\Task\BuiltIn\Git;
|
||||
|
||||
use Symfony\Component\Process\Process;
|
||||
use Mage\Task\AbstractTask;
|
||||
|
||||
/**
|
||||
* Git Task - Pull
|
||||
*
|
||||
* @author Andrés Montañez <andresmontanez@gmail.com>
|
||||
*/
|
||||
class UpdateTask extends AbstractTask
|
||||
{
|
||||
public function getName()
|
||||
{
|
||||
return 'git/update';
|
||||
}
|
||||
|
||||
public function getDescription()
|
||||
{
|
||||
return '[Git] Update';
|
||||
}
|
||||
|
||||
public function execute()
|
||||
{
|
||||
$options = $this->getOptions();
|
||||
$command = $options['path'] . ' pull';
|
||||
|
||||
/** @var Process $process */
|
||||
$process = $this->runtime->runLocalCommand($command);
|
||||
|
||||
return $process->isSuccessful();
|
||||
}
|
||||
|
||||
protected function getOptions()
|
||||
{
|
||||
$config = $this->runtime->getEnvironmentConfig();
|
||||
$branch = 'master';
|
||||
if (array_key_exists('branch', $config)) {
|
||||
$branch = $config['branch'];
|
||||
}
|
||||
|
||||
$options = array_merge(
|
||||
['path' => 'git', 'branch' => $branch],
|
||||
$this->options
|
||||
);
|
||||
|
||||
return $options;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of the Magallanes package.
|
||||
*
|
||||
* (c) Andrés Montañez <andres@andresmontanez.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Mage\Task\BuiltIn\Symfony;
|
||||
|
||||
use Symfony\Component\Process\Process;
|
||||
use Mage\Task\AbstractTask;
|
||||
|
||||
/**
|
||||
* Symfony Task - Dump Assetics
|
||||
*
|
||||
* @author Andrés Montañez <andresmontanez@gmail.com>
|
||||
*/
|
||||
class AsseticDumpTask extends AbstractTask
|
||||
{
|
||||
public function getName()
|
||||
{
|
||||
return 'symfony/assetic-dump';
|
||||
}
|
||||
|
||||
public function getDescription()
|
||||
{
|
||||
return '[Symfony] Assetic Dump';
|
||||
}
|
||||
|
||||
public function execute()
|
||||
{
|
||||
$options = $this->getOptions();
|
||||
$command = $options['console'] . ' assetic:dump --env=' . $options['env'] . ' ' . $options['flags'];
|
||||
|
||||
/** @var Process $process */
|
||||
$process = $this->runtime->runCommand($command);
|
||||
|
||||
return $process->isSuccessful();
|
||||
}
|
||||
|
||||
protected function getOptions()
|
||||
{
|
||||
$options = array_merge(
|
||||
['path' => 'bin/console', 'env' => 'dev', 'flags' => ''],
|
||||
$this->runtime->getConfigOptions('symfony', []),
|
||||
$this->options
|
||||
);
|
||||
|
||||
return $options;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of the Magallanes package.
|
||||
*
|
||||
* (c) Andrés Montañez <andres@andresmontanez.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Mage\Task\BuiltIn\Symfony;
|
||||
|
||||
use Symfony\Component\Process\Process;
|
||||
use Mage\Task\AbstractTask;
|
||||
|
||||
/**
|
||||
* Symfony Task - Install Assets
|
||||
*
|
||||
* @author Andrés Montañez <andresmontanez@gmail.com>
|
||||
*/
|
||||
class AssetsInstallTask extends AbstractTask
|
||||
{
|
||||
public function getName()
|
||||
{
|
||||
return 'symfony/assets-install';
|
||||
}
|
||||
|
||||
public function getDescription()
|
||||
{
|
||||
return '[Symfony] Assets Install';
|
||||
}
|
||||
|
||||
public function execute()
|
||||
{
|
||||
$options = $this->getOptions();
|
||||
$command = $options['console'] . ' assets:install --env=' . $options['env'] . ' ' . $options['flags'] . ' ' . $options['target'];
|
||||
|
||||
/** @var Process $process */
|
||||
$process = $this->runtime->runCommand($command);
|
||||
|
||||
return $process->isSuccessful();
|
||||
}
|
||||
|
||||
protected function getOptions()
|
||||
{
|
||||
$options = array_merge(
|
||||
['path' => 'bin/console', 'env' => 'dev', 'target' => 'web', 'flags' => '--symlink --relative'],
|
||||
$this->runtime->getConfigOptions('symfony', []),
|
||||
$this->options
|
||||
);
|
||||
|
||||
return $options;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of the Magallanes package.
|
||||
*
|
||||
* (c) Andrés Montañez <andres@andresmontanez.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Mage\Task\BuiltIn\Symfony;
|
||||
|
||||
use Symfony\Component\Process\Process;
|
||||
use Mage\Task\AbstractTask;
|
||||
|
||||
/**
|
||||
* Symfony Task - Clear Cache
|
||||
*
|
||||
* @author Andrés Montañez <andresmontanez@gmail.com>
|
||||
*/
|
||||
class CacheClearTask extends AbstractTask
|
||||
{
|
||||
public function getName()
|
||||
{
|
||||
return 'symfony/cache-clear';
|
||||
}
|
||||
|
||||
public function getDescription()
|
||||
{
|
||||
return '[Symfony] Cache Clear';
|
||||
}
|
||||
|
||||
public function execute()
|
||||
{
|
||||
$options = $this->getOptions();
|
||||
$command = $options['console'] . ' cache:clear --env=' . $options['env'] . ' ' . $options['flags'];
|
||||
|
||||
/** @var Process $process */
|
||||
$process = $this->runtime->runCommand($command);
|
||||
|
||||
return $process->isSuccessful();
|
||||
}
|
||||
|
||||
protected function getOptions()
|
||||
{
|
||||
$options = array_merge(
|
||||
['path' => 'bin/console', 'env' => 'dev', 'flags' => ''],
|
||||
$this->runtime->getConfigOptions('symfony', []),
|
||||
$this->options
|
||||
);
|
||||
|
||||
return $options;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of the Magallanes package.
|
||||
*
|
||||
* (c) Andrés Montañez <andres@andresmontanez.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Mage\Task\BuiltIn\Symfony;
|
||||
|
||||
use Symfony\Component\Process\Process;
|
||||
use Mage\Task\AbstractTask;
|
||||
|
||||
/**
|
||||
* Symfony Task - Cache Warmup
|
||||
*
|
||||
* @author Andrés Montañez <andresmontanez@gmail.com>
|
||||
*/
|
||||
class CacheWarmupTask extends AbstractTask
|
||||
{
|
||||
public function getName()
|
||||
{
|
||||
return 'symfony/cache-warmup';
|
||||
}
|
||||
|
||||
public function getDescription()
|
||||
{
|
||||
return '[Symfony] Cache Warmup';
|
||||
}
|
||||
|
||||
public function execute()
|
||||
{
|
||||
$options = $this->getOptions();
|
||||
$command = $options['console'] . ' cache:warmup --env=' . $options['env'] . ' ' . $options['flags'];
|
||||
|
||||
/** @var Process $process */
|
||||
$process = $this->runtime->runCommand($command);
|
||||
|
||||
return $process->isSuccessful();
|
||||
}
|
||||
|
||||
protected function getOptions()
|
||||
{
|
||||
$options = array_merge(
|
||||
['path' => 'bin/console', 'env' => 'dev', 'flags' => ''],
|
||||
$this->runtime->getConfigOptions('symfony', []),
|
||||
$this->options
|
||||
);
|
||||
|
||||
return $options;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user