Skip to content

Commit

Permalink
bug EasyCorp#103 Allow Symfony 5 components (Lustmored)
Browse files Browse the repository at this point in the history
This PR was squashed before being merged into the 1.0.x-dev branch (closes EasyCorp#103).

Discussion
----------

Allow Symfony 5 components

Also closes EasyCorp#100 - use new Process method to create object from shell command when available

Commits
-------

483be54 Allow Symfony 5 components
  • Loading branch information
javiereguiluz committed Jan 30, 2020
2 parents f6c45c2 + 483be54 commit 8357c08
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 14 deletions.
14 changes: 11 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,17 @@ matrix:
env:
- SYMFONY_VERSION="dev-master"
- CHECK_PHP_SYNTAX="no"
- php: 7.1
- php: 7.2
env:
- SYMFONY_VERSION="3.2.*"
- SYMFONY_VERSION="3.4.*"
- CHECK_PHP_SYNTAX="yes"
- php: 7.2
env:
- SYMFONY_VERSION="4.4.*"
- CHECK_PHP_SYNTAX="yes"
- php: 7.2
env:
- SYMFONY_VERSION="5.0.*"
- CHECK_PHP_SYNTAX="yes"
allow_failures:
- php: nightly
Expand All @@ -31,7 +39,7 @@ before_install:
- echo opcache.enable_cli = 1 >> $INI_FILE
- rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini
- composer self-update
- if [[ "$SYMFONY_VERSION" != "" ]]; then composer require "symfony/symfony:${SYMFONY_VERSION}" --no-update; fi;
- if [[ "$SYMFONY_VERSION" != "" ]]; then composer require "symfony/framework-bundle:${SYMFONY_VERSION}" --no-update; fi;

install:
- if [[ "$CHECK_PHP_SYNTAX" == "yes" ]]; then composer require --dev --no-update friendsofphp/php-cs-fixer; fi;
Expand Down
16 changes: 8 additions & 8 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@
}
],
"require": {
"php": ">=7.1.0",
"symfony/console": "~2.3|~3.0|~4.0",
"symfony/dependency-injection": "~2.3|~3.0|~4.0",
"symfony/expression-language": "~2.4|~3.0|~4.0",
"symfony/filesystem": "~2.3|~3.0|~4.0",
"symfony/http-foundation": "~2.3|~3.0|~4.0",
"symfony/http-kernel": "~2.3|~3.0|~4.0",
"php": ">=7.2.0",
"symfony/console": "~2.3|~3.0|~4.0|~5.0",
"symfony/dependency-injection": "~2.3|~3.0|~4.0|~5.0",
"symfony/expression-language": "~2.4|~3.0|~4.0|~5.0",
"symfony/filesystem": "~2.3|~3.0|~4.0|~5.0",
"symfony/http-foundation": "~2.3|~3.0|~4.0|~5.0",
"symfony/http-kernel": "~2.3|~3.0|~4.0|~5.0",
"symfony/polyfill-mbstring": "^1.3",
"symfony/process": "~2.3|~3.0|~4.0"
"symfony/process": "~2.3|~3.0|~4.0|~5.0"
},
"require-dev": {
"phpunit/phpunit": "^6.1"
Expand Down
2 changes: 2 additions & 0 deletions src/Command/DeployCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ protected function execute(InputInterface $input, OutputInterface $output)
$deployer = include $this->configFilePath;
$deployer->initialize($context);
$deployer->doDeploy();

return 0;
}

private function createDefaultConfigFile(InputInterface $input, OutputInterface $output, string $defaultConfigPath, string $stageName): void
Expand Down
2 changes: 2 additions & 0 deletions src/Command/RollbackCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,5 +72,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
$deployer = include $this->configFilePath;
$deployer->initialize($context);
$deployer->doRollback();

return 0;
}
}
2 changes: 1 addition & 1 deletion src/Configuration/DefaultConfiguration.php
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@ private function setDefaultConfiguration(int $symfonyMajorVersion, $symfonyMinor
$this->sharedFiles = ['app/config/parameters.yml'];
$this->sharedDirs = ['var/logs'];
$this->writableDirs = ['var/cache/', 'var/logs/'];
} elseif (4 === $symfonyMajorVersion || (3 === $symfonyMajorVersion && 4 >= $symfonyMinorVersion)) {
} elseif (4 <= $symfonyMajorVersion || (3 === $symfonyMajorVersion && 4 >= $symfonyMinorVersion)) {
$this->_symfonyEnvironmentEnvVarName = 'APP_ENV';
$this->setDirs('bin', 'config', 'var/cache', 'var/log', 'src', 'templates', 'public');
$this->controllersToRemove([]);
Expand Down
13 changes: 11 additions & 2 deletions src/Task/TaskRunner.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,15 @@ public function run(Task $task): array
return $results;
}

private function createProcess(string $shellCommand): Process
{
if (method_exists(Process::class, 'fromShellCommandline')) {
return Process::fromShellCommandline($shellCommand);
}

return new Process($shellCommand);
}

private function doRun(Server $server, string $shellCommand, array $envVars): TaskCompleted
{
if ($server->has(Property::project_dir)) {
Expand All @@ -63,9 +72,9 @@ private function doRun(Server $server, string $shellCommand, array $envVars): Ta
}

if ($server->isLocalHost()) {
$process = new Process($shellCommand);
$process = $this->createProcess($shellCommand);
} else {
$process = new Process(sprintf('%s %s', $server->getSshConnectionString(), escapeshellarg($shellCommand)));
$process = $this->createProcess(sprintf('%s %s', $server->getSshConnectionString(), escapeshellarg($shellCommand)));
}

$process->setTimeout(null);
Expand Down

0 comments on commit 8357c08

Please sign in to comment.