Skip to content

Commit 2f02635

Browse files
committed
feat: upgrade to next symfony lts version and rework output class
1 parent 9d0af6a commit 2f02635

File tree

95 files changed

+891
-418
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

95 files changed

+891
-418
lines changed

composer.json

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,14 @@
2323
"league/flysystem-sftp": "^2.0",
2424
"nesbot/carbon": "^2.40",
2525
"phpseclib/phpseclib": "^2.0.31",
26-
"symfony/config": "^4.4",
27-
"symfony/console": "^4.4",
28-
"symfony/dependency-injection": "^4.4",
29-
"symfony/event-dispatcher": "^4.4",
30-
"symfony/filesystem": "^4.4",
31-
"symfony/finder": "^4.4.24",
32-
"symfony/process": "^4.4",
33-
"symfony/yaml": "^4.4",
26+
"symfony/config": "^5.4",
27+
"symfony/console": "^5.4",
28+
"symfony/dependency-injection": "^5.4",
29+
"symfony/event-dispatcher": "^5.4",
30+
"symfony/filesystem": "^5.4",
31+
"symfony/finder": "^5.4",
32+
"symfony/process": "^5.4",
33+
"symfony/yaml": "^5.4",
3434
"tightenco/collect": "^8.0"
3535
},
3636
"require-dev": {

grumphp.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ grumphp:
3030
phpmd:
3131
exclude:
3232
- 'Command/Project/InitializeProjectCommand.php'
33+
- 'Console/Output.php'
3334
- 'ApiClient.php'
3435
- 'activate-ymir-plugin.php'
3536
ruleset: ['phpmd.xml']

src/Command/AbstractCommand.php

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,15 @@
1919
use Symfony\Component\Console\Exception\RuntimeException;
2020
use Symfony\Component\Console\Input\ArrayInput;
2121
use Symfony\Component\Console\Input\InputInterface;
22-
use Symfony\Component\Console\Output\OutputInterface;
22+
use Symfony\Component\Console\Output\OutputInterface as SymfonyOutputInterface;
2323
use Ymir\Cli\ApiClient;
2424
use Ymir\Cli\CliConfiguration;
2525
use Ymir\Cli\Command\Network\CreateNetworkCommand;
2626
use Ymir\Cli\Command\Provider\ConnectProviderCommand;
27-
use Ymir\Cli\Console\ConsoleOutput;
2827
use Ymir\Cli\Console\HiddenInputOption;
2928
use Ymir\Cli\Console\InputDefinition;
29+
use Ymir\Cli\Console\Output;
30+
use Ymir\Cli\Console\OutputInterface;
3031
use Ymir\Cli\Exception\ApiClientException;
3132
use Ymir\Cli\Exception\CommandCancelledException;
3233
use Ymir\Cli\ProjectConfiguration\ProjectConfiguration;
@@ -82,7 +83,7 @@ public function addHiddenOption($name, $shortcut = null, $mode = null, $default
8283
/**
8384
* Determine the cloud provider to use.
8485
*/
85-
protected function determineCloudProvider(string $question, InputInterface $input, ConsoleOutput $output): int
86+
protected function determineCloudProvider(string $question, InputInterface $input, OutputInterface $output): int
8687
{
8788
$providerId = $this->getStringOption($input, 'provider', true);
8889
$providers = $this->apiClient->getProviders($this->cliConfiguration->getActiveTeamId());
@@ -107,7 +108,7 @@ protected function determineCloudProvider(string $question, InputInterface $inpu
107108
/**
108109
* Determine the network to use.
109110
*/
110-
protected function determineNetwork(string $question, InputInterface $input, ConsoleOutput $output): int
111+
protected function determineNetwork(string $question, InputInterface $input, OutputInterface $output): int
111112
{
112113
$networkIdOrName = null;
113114

@@ -137,7 +138,7 @@ protected function determineNetwork(string $question, InputInterface $input, Con
137138
/**
138139
* Determine the network to use or create one otherwise.
139140
*/
140-
protected function determineOrCreateNetwork(string $question, InputInterface $input, ConsoleOutput $output)
141+
protected function determineOrCreateNetwork(string $question, InputInterface $input, OutputInterface $output)
141142
{
142143
$networks = $this->apiClient->getTeamNetworks($this->cliConfiguration->getActiveTeamId())->whereNotIn('status', ['deleting', 'failed']);
143144

@@ -159,7 +160,7 @@ protected function determineOrCreateNetwork(string $question, InputInterface $in
159160
/**
160161
* Determine the project to use.
161162
*/
162-
protected function determineProject(string $question, InputInterface $input, ConsoleOutput $output): int
163+
protected function determineProject(string $question, InputInterface $input, OutputInterface $output): int
163164
{
164165
$projects = $this->apiClient->getTeamProjects($this->cliConfiguration->getActiveTeamId());
165166

@@ -187,7 +188,7 @@ protected function determineProject(string $question, InputInterface $input, Con
187188
/**
188189
* Determine the cloud provider region to use.
189190
*/
190-
protected function determineRegion(string $question, int $providerId, InputInterface $input, ConsoleOutput $output): string
191+
protected function determineRegion(string $question, int $providerId, InputInterface $input, OutputInterface $output): string
191192
{
192193
$region = $this->getStringOption($input, 'region', true);
193194
$regions = $this->apiClient->getRegions($providerId);
@@ -206,15 +207,15 @@ protected function determineRegion(string $question, int $providerId, InputInter
206207
/**
207208
* {@inheritdoc}
208209
*/
209-
protected function execute(InputInterface $input, OutputInterface $output)
210+
protected function execute(InputInterface $input, SymfonyOutputInterface $output)
210211
{
211212
if (!$input->isInteractive() && $this->mustBeInteractive()) {
212213
throw new RuntimeException(sprintf('Cannot run "%s" command in non-interactive mode', $input->getFirstArgument()));
213214
} elseif (LoginCommand::NAME !== $this->getName() && !$this->apiClient->isAuthenticated()) {
214215
throw new RuntimeException(sprintf('Please authenticate using the "%s" command before using this command', LoginCommand::NAME));
215216
}
216217

217-
return $this->perform($input, new ConsoleOutput($input, $output)) ?? 0;
218+
return $this->perform($input, new Output($input, $output)) ?? 0;
218219
}
219220

220221
/**
@@ -334,7 +335,7 @@ protected function getStringOption(InputInterface $input, string $option, bool $
334335
/**
335336
* Invoke another console command.
336337
*/
337-
protected function invoke(OutputInterface $output, string $command, array $arguments = []): int
338+
protected function invoke(SymfonyOutputInterface $output, string $command, array $arguments = []): int
338339
{
339340
$application = $this->getApplication();
340341

@@ -356,7 +357,7 @@ protected function mustBeInteractive(): bool
356357
/**
357358
* Retry an API operation.
358359
*/
359-
protected function retryApi(callable $callable, string $message, ConsoleOutput $output)
360+
protected function retryApi(callable $callable, string $message, OutputInterface $output)
360361
{
361362
while (true) {
362363
try {
@@ -392,5 +393,5 @@ protected function wait(callable $callable, int $timeout = 60, int $sleep = 1)
392393
/**
393394
* Perform the command.
394395
*/
395-
abstract protected function perform(InputInterface $input, ConsoleOutput $output);
396+
abstract protected function perform(InputInterface $input, OutputInterface $output);
396397
}

src/Command/Cache/AbstractCacheCommand.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,14 @@
1616
use Symfony\Component\Console\Exception\RuntimeException;
1717
use Symfony\Component\Console\Input\InputInterface;
1818
use Ymir\Cli\Command\AbstractCommand;
19-
use Ymir\Cli\Console\ConsoleOutput;
19+
use Ymir\Cli\Console\OutputInterface;
2020

2121
abstract class AbstractCacheCommand extends AbstractCommand
2222
{
2323
/**
2424
* Determine the cache that the command is interacting with.
2525
*/
26-
protected function determineCache(string $question, InputInterface $input, ConsoleOutput $output): array
26+
protected function determineCache(string $question, InputInterface $input, OutputInterface $output): array
2727
{
2828
$caches = $this->apiClient->getCaches($this->cliConfiguration->getActiveTeamId());
2929
$cacheIdOrName = $this->getStringArgument($input, 'cache');

src/Command/Cache/CacheTunnelCommand.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
use Ymir\Cli\ApiClient;
2222
use Ymir\Cli\CliConfiguration;
2323
use Ymir\Cli\Command\Network\AddBastionHostCommand;
24-
use Ymir\Cli\Console\ConsoleOutput;
24+
use Ymir\Cli\Console\OutputInterface;
2525
use Ymir\Cli\ProjectConfiguration\ProjectConfiguration;
2626
use Ymir\Cli\Support\Arr;
2727

@@ -74,7 +74,7 @@ protected function configure()
7474
/**
7575
* {@inheritdoc}
7676
*/
77-
protected function perform(InputInterface $input, ConsoleOutput $output)
77+
protected function perform(InputInterface $input, OutputInterface $output)
7878
{
7979
$cache = $this->determineCache('Which cache cluster would you like to connect to', $input, $output);
8080

src/Command/Cache/CreateCacheCommand.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
use Symfony\Component\Console\Input\InputOption;
2121
use Tightenco\Collect\Support\Collection;
2222
use Ymir\Cli\Command\AbstractCommand;
23-
use Ymir\Cli\Console\ConsoleOutput;
23+
use Ymir\Cli\Console\OutputInterface;
2424
use Ymir\Cli\Exception\CommandCancelledException;
2525
use Ymir\Cli\ProjectConfiguration\CacheConfigurationChange;
2626

@@ -49,7 +49,7 @@ protected function configure()
4949
/**
5050
* {@inheritdoc}
5151
*/
52-
protected function perform(InputInterface $input, ConsoleOutput $output)
52+
protected function perform(InputInterface $input, OutputInterface $output)
5353
{
5454
$name = $this->getStringArgument($input, 'name');
5555

@@ -77,7 +77,7 @@ protected function perform(InputInterface $input, ConsoleOutput $output)
7777
/**
7878
* Determine the cache cluster type to create.
7979
*/
80-
private function determineType(Collection $network, InputInterface $input, ConsoleOutput $output): string
80+
private function determineType(Collection $network, InputInterface $input, OutputInterface $output): string
8181
{
8282
if (!isset($network['provider']['id'])) {
8383
throw new RuntimeException('The Ymir API failed to return information on the cloud provider');

src/Command/Cache/DeleteCacheCommand.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
use Symfony\Component\Console\Input\InputArgument;
1717
use Symfony\Component\Console\Input\InputInterface;
1818
use Ymir\Cli\Command\Network\RemoveNatGatewayCommand;
19-
use Ymir\Cli\Console\ConsoleOutput;
19+
use Ymir\Cli\Console\OutputInterface;
2020

2121
class DeleteCacheCommand extends AbstractCacheCommand
2222
{
@@ -41,7 +41,7 @@ protected function configure()
4141
/**
4242
* {@inheritdoc}
4343
*/
44-
protected function perform(InputInterface $input, ConsoleOutput $output)
44+
protected function perform(InputInterface $input, OutputInterface $output)
4545
{
4646
$cache = $this->determineCache('Which cache cluster would you like to delete', $input, $output);
4747

src/Command/Cache/ListCachesCommand.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
use Symfony\Component\Console\Input\InputInterface;
1717
use Ymir\Cli\Command\AbstractCommand;
18-
use Ymir\Cli\Console\ConsoleOutput;
18+
use Ymir\Cli\Console\OutputInterface;
1919

2020
class ListCachesCommand extends AbstractCommand
2121
{
@@ -39,7 +39,7 @@ protected function configure()
3939
/**
4040
* {@inheritdoc}
4141
*/
42-
protected function perform(InputInterface $input, ConsoleOutput $output)
42+
protected function perform(InputInterface $input, OutputInterface $output)
4343
{
4444
$output->table(
4545
['Id', 'Name', 'Provider', 'Network', 'Region', 'Status', 'Type'],

src/Command/Certificate/DeleteCertificateCommand.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
use Symfony\Component\Console\Input\InputArgument;
1717
use Symfony\Component\Console\Input\InputInterface;
18-
use Ymir\Cli\Console\ConsoleOutput;
18+
use Ymir\Cli\Console\OutputInterface;
1919

2020
class DeleteCertificateCommand extends AbstractCertificateCommand
2121
{
@@ -40,7 +40,7 @@ protected function configure()
4040
/**
4141
* {@inheritdoc}
4242
*/
43-
protected function perform(InputInterface $input, ConsoleOutput $output)
43+
protected function perform(InputInterface $input, OutputInterface $output)
4444
{
4545
$certificateId = $this->getCertificateArgument($input);
4646

src/Command/Certificate/GetCertificateInfoCommand.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
use Symfony\Component\Console\Helper\TableSeparator;
1717
use Symfony\Component\Console\Input\InputArgument;
1818
use Symfony\Component\Console\Input\InputInterface;
19-
use Ymir\Cli\Console\ConsoleOutput;
19+
use Ymir\Cli\Console\OutputInterface;
2020

2121
class GetCertificateInfoCommand extends AbstractCertificateCommand
2222
{
@@ -41,7 +41,7 @@ protected function configure()
4141
/**
4242
* {@inheritdoc}
4343
*/
44-
protected function perform(InputInterface $input, ConsoleOutput $output)
44+
protected function perform(InputInterface $input, OutputInterface $output)
4545
{
4646
$certificate = $this->apiClient->getCertificate($this->getCertificateArgument($input));
4747

0 commit comments

Comments
 (0)