[Nostromo] Refactor Runtime methods.

This commit is contained in:
Andrés Montañez
2017-01-11 22:22:21 -03:00
parent 7493e3cfae
commit b095cd0bb8
24 changed files with 75 additions and 108 deletions
@@ -43,7 +43,7 @@ class DumpAutoloadTask extends AbstractTask
protected function getOptions()
{
$userOptions = $this->runtime->getConfigOptions('composer', []);
$userOptions = $this->runtime->getConfigOption('composer', []);
$options = array_merge(
['path' => 'composer', 'flags' => '--optimize'],
(is_array($userOptions) ? $userOptions : []),
+1 -1
View File
@@ -43,7 +43,7 @@ class InstallTask extends AbstractTask
protected function getOptions()
{
$userOptions = $this->runtime->getConfigOptions('composer', []);
$userOptions = $this->runtime->getConfigOption('composer', []);
$options = array_merge(
['path' => 'composer', 'flags' => '--optimize-autoloader'],
(is_array($userOptions) ? $userOptions : []),
@@ -32,9 +32,9 @@ class CleanupTask extends AbstractTask
public function execute()
{
$hostPath = rtrim($this->runtime->getEnvParam('host_path'), '/');
$hostPath = rtrim($this->runtime->getEnvOption('host_path'), '/');
$currentReleaseId = $this->runtime->getReleaseId();
$maxReleases = $this->runtime->getEnvParam('releases');
$maxReleases = $this->runtime->getEnvOption('releases');
$cmdListReleases = sprintf('ls -1 %s/releases', $hostPath);
@@ -32,7 +32,7 @@ class PrepareTask extends AbstractTask
public function execute()
{
$hostPath = rtrim($this->runtime->getEnvParam('host_path'), '/');
$hostPath = rtrim($this->runtime->getEnvOption('host_path'), '/');
$cmdMakeDir = sprintf('mkdir -p %s/releases/%s', $hostPath, $this->runtime->getReleaseId());
+2 -2
View File
@@ -34,11 +34,11 @@ class ReleaseTask extends AbstractTask implements ExecuteOnRollbackInterface
public function execute()
{
if (!$this->runtime->getEnvParam('releases', false)) {
if (!$this->runtime->getEnvOption('releases', false)) {
throw new ErrorException('This task is only available with releases enabled', 40);
}
$hostPath = rtrim($this->runtime->getEnvParam('host_path'), '/');
$hostPath = rtrim($this->runtime->getEnvOption('host_path'), '/');
$releaseId = $this->runtime->getReleaseId();
$cmdLinkRelease = sprintf('cd %s && ln -snf releases/%s current', $hostPath, $releaseId);
+5 -5
View File
@@ -33,14 +33,14 @@ class RsyncTask extends AbstractTask
public function execute()
{
$flags = $this->runtime->getConfigOptions('rsync', '-avz');
$flags = $this->runtime->getConfigOption('rsync', '-avz');
$sshConfig = $this->runtime->getSSHConfig();
$user = $this->runtime->getEnvParam('user', $this->runtime->getCurrentUser());
$user = $this->runtime->getEnvOption('user', $this->runtime->getCurrentUser());
$host = $this->runtime->getWorkingHost();
$hostPath = rtrim($this->runtime->getEnvParam('host_path'), '/');
$hostPath = rtrim($this->runtime->getEnvOption('host_path'), '/');
$targetDir = rtrim($hostPath, '/');
if ($this->runtime->getEnvParam('releases', false)) {
if ($this->runtime->getEnvOption('releases', false)) {
throw new ErrorException('Can\'t be used with Releases, use "deploy/targz/copy"');
}
@@ -54,7 +54,7 @@ class RsyncTask extends AbstractTask
protected function getExcludes()
{
$excludes = $this->runtime->getEnvParam('exclude', []);
$excludes = $this->runtime->getEnvOption('exclude', []);
$excludes = array_merge(['.git'], $excludes);
foreach ($excludes as &$exclude) {
@@ -33,7 +33,7 @@ class CleanupTask extends AbstractTask
public function execute()
{
if (!$this->runtime->getEnvParam('releases', false)) {
if (!$this->runtime->getEnvOption('releases', false)) {
throw new ErrorException('This task is only available with releases enabled', 40);
}
+3 -3
View File
@@ -33,14 +33,14 @@ class CopyTask extends AbstractTask
public function execute()
{
if (!$this->runtime->getEnvParam('releases', false)) {
if (!$this->runtime->getEnvOption('releases', false)) {
throw new ErrorException('This task is only available with releases enabled', 40);
}
$user = $this->runtime->getEnvParam('user', $this->runtime->getCurrentUser());
$user = $this->runtime->getEnvOption('user', $this->runtime->getCurrentUser());
$host = $this->runtime->getWorkingHost();
$sshConfig = $sshConfig = $this->runtime->getSSHConfig();
$hostPath = rtrim($this->runtime->getEnvParam('host_path'), '/');
$hostPath = rtrim($this->runtime->getEnvOption('host_path'), '/');
$currentReleaseId = $this->runtime->getReleaseId();
$targetDir = sprintf('%s/releases/%s', $hostPath, $currentReleaseId);
@@ -33,7 +33,7 @@ class PrepareTask extends AbstractTask
public function execute()
{
if (!$this->runtime->getEnvParam('releases', false)) {
if (!$this->runtime->getEnvOption('releases', false)) {
throw new ErrorException('This task is only available with releases enabled', 40);
}
@@ -50,7 +50,7 @@ class PrepareTask extends AbstractTask
protected function getExcludes()
{
$excludes = $this->runtime->getEnvParam('exclude', []);
$excludes = $this->runtime->getEnvOption('exclude', []);
$excludes = array_merge(['.git'], $excludes);
foreach ($excludes as &$exclude) {
+1 -1
View File
@@ -70,7 +70,7 @@ class ChangeBranchTask extends AbstractTask
protected function getOptions()
{
$branch = $this->runtime->getEnvParam('branch', 'master');
$branch = $this->runtime->getEnvOption('branch', 'master');
$options = array_merge(
['path' => 'git', 'branch' => $branch],
$this->options
+1 -1
View File
@@ -43,7 +43,7 @@ class UpdateTask extends AbstractTask
protected function getOptions()
{
$branch = $this->runtime->getEnvParam('branch', 'master');
$branch = $this->runtime->getEnvOption('branch', 'master');
$options = array_merge(
['path' => 'git', 'branch' => $branch],
$this->options
+2 -2
View File
@@ -43,8 +43,8 @@ class AsseticDumpTask extends AbstractTask
protected function getOptions()
{
$userGlobalOptions = $this->runtime->getConfigOptions('symfony', []);
$userEnvOptions = $this->runtime->getEnvParam('symfony', []);
$userGlobalOptions = $this->runtime->getConfigOption('symfony', []);
$userEnvOptions = $this->runtime->getEnvOption('symfony', []);
$options = array_merge(
['console' => 'bin/console', 'env' => 'dev', 'flags' => ''],
(is_array($userGlobalOptions) ? $userGlobalOptions : []),
@@ -43,8 +43,8 @@ class AssetsInstallTask extends AbstractTask
protected function getOptions()
{
$userGlobalOptions = $this->runtime->getConfigOptions('symfony', []);
$userEnvOptions = $this->runtime->getEnvParam('symfony', []);
$userGlobalOptions = $this->runtime->getConfigOption('symfony', []);
$userEnvOptions = $this->runtime->getEnvOption('symfony', []);
$options = array_merge(
['console' => 'bin/console', 'env' => 'dev', 'target' => 'web', 'flags' => '--symlink --relative'],
(is_array($userGlobalOptions) ? $userGlobalOptions : []),
+2 -2
View File
@@ -43,8 +43,8 @@ class CacheClearTask extends AbstractTask
protected function getOptions()
{
$userGlobalOptions = $this->runtime->getConfigOptions('symfony', []);
$userEnvOptions = $this->runtime->getEnvParam('symfony', []);
$userGlobalOptions = $this->runtime->getConfigOption('symfony', []);
$userEnvOptions = $this->runtime->getEnvOption('symfony', []);
$options = array_merge(
['console' => 'bin/console', 'env' => 'dev', 'flags' => ''],
(is_array($userGlobalOptions) ? $userGlobalOptions : []),
+2 -2
View File
@@ -43,8 +43,8 @@ class CacheWarmupTask extends AbstractTask
protected function getOptions()
{
$userGlobalOptions = $this->runtime->getConfigOptions('symfony', []);
$userEnvOptions = $this->runtime->getEnvParam('symfony', []);
$userGlobalOptions = $this->runtime->getConfigOption('symfony', []);
$userEnvOptions = $this->runtime->getEnvOption('symfony', []);
$options = array_merge(
['console' => 'bin/console', 'env' => 'dev', 'flags' => ''],
(is_array($userGlobalOptions) ? $userGlobalOptions : []),