mirror of
https://github.com/opdavies/versa.git
synced 2025-03-13 05:26:56 +00:00
Revert "Extract extraArgs
and workingDir
"
This reverts commit ee709b2966
.
This commit is contained in:
parent
01854538d4
commit
084f6fb3c7
|
@ -4,15 +4,9 @@ namespace App\Console\Command;
|
||||||
|
|
||||||
use Symfony\Component\Console\Command\Command;
|
use Symfony\Component\Console\Command\Command;
|
||||||
use Symfony\Component\Console\Input\InputArgument;
|
use Symfony\Component\Console\Input\InputArgument;
|
||||||
use Symfony\Component\Console\Input\InputInterface;
|
|
||||||
use Symfony\Component\Console\Output\OutputInterface;
|
|
||||||
|
|
||||||
abstract class AbstractCommand extends Command
|
abstract class AbstractCommand extends Command
|
||||||
{
|
{
|
||||||
protected ?string $extraArgs;
|
|
||||||
|
|
||||||
protected string $workingDir;
|
|
||||||
|
|
||||||
protected function configure(): void
|
protected function configure(): void
|
||||||
{
|
{
|
||||||
$this->addOption(
|
$this->addOption(
|
||||||
|
@ -38,12 +32,4 @@ abstract class AbstractCommand extends Command
|
||||||
default: '.',
|
default: '.',
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function execute(InputInterface $input, OutputInterface $output): int
|
|
||||||
{
|
|
||||||
$this->extraArgs = $input->getOption('extra-args');
|
|
||||||
$this->workingDir = $input->getOption('working-dir');
|
|
||||||
|
|
||||||
return Command::SUCCESS;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,14 +16,17 @@ final class BuildCommand extends AbstractCommand
|
||||||
{
|
{
|
||||||
$projectType = null;
|
$projectType = null;
|
||||||
|
|
||||||
|
$extraArgs = $input->getOption('extra-args');
|
||||||
|
$workingDir = $input->getOption('working-dir');
|
||||||
|
|
||||||
$filesystem = new Filesystem();
|
$filesystem = new Filesystem();
|
||||||
|
|
||||||
// Attempt to prepopulate some of the options, such as the project type
|
// Attempt to prepopulate some of the options, such as the project type
|
||||||
// based on its dependencies.
|
// based on its dependencies.
|
||||||
// TODO: move this logic to a service so it can be tested.
|
// TODO: move this logic to a service so it can be tested.
|
||||||
if ($filesystem->exists($this->workingDir.'/composer.json')) {
|
if ($filesystem->exists($workingDir.'/composer.json')) {
|
||||||
$json = json_decode(
|
$json = json_decode(
|
||||||
json: strval(file_get_contents($this->workingDir.'/composer.json')),
|
json: strval(file_get_contents($workingDir.'/composer.json')),
|
||||||
associative: true,
|
associative: true,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -42,15 +45,15 @@ final class BuildCommand extends AbstractCommand
|
||||||
// the option value if there is one.
|
// the option value if there is one.
|
||||||
$projectType = $input->getOption('type') ?? $projectType;
|
$projectType = $input->getOption('type') ?? $projectType;
|
||||||
|
|
||||||
$isDockerCompose = $filesystem->exists($this->workingDir . '/docker-compose.yaml');
|
$isDockerCompose = $filesystem->exists($workingDir . '/docker-compose.yaml');
|
||||||
|
|
||||||
switch ($projectType) {
|
switch ($projectType) {
|
||||||
case ProjectType::Drupal->value:
|
case ProjectType::Drupal->value:
|
||||||
if ($isDockerCompose) {
|
if ($isDockerCompose) {
|
||||||
$process = Process::create(
|
$process = Process::create(
|
||||||
command: ['docker', 'compose', 'build'],
|
command: ['docker', 'compose', 'build'],
|
||||||
extraArgs: $this->extraArgs,
|
extraArgs: $extraArgs,
|
||||||
workingDir: $this->workingDir,
|
workingDir: $workingDir,
|
||||||
);
|
);
|
||||||
|
|
||||||
$process->run();
|
$process->run();
|
||||||
|
@ -64,8 +67,8 @@ final class BuildCommand extends AbstractCommand
|
||||||
case ProjectType::Sculpin->value:
|
case ProjectType::Sculpin->value:
|
||||||
$process = Process::create(
|
$process = Process::create(
|
||||||
command: ['./vendor/bin/sculpin', 'generate'],
|
command: ['./vendor/bin/sculpin', 'generate'],
|
||||||
extraArgs: $this->extraArgs,
|
extraArgs: $extraArgs,
|
||||||
workingDir: $this->workingDir,
|
workingDir: $workingDir,
|
||||||
);
|
);
|
||||||
|
|
||||||
$process->run();
|
$process->run();
|
||||||
|
|
|
@ -11,13 +11,14 @@ final class InstallCommand extends AbstractCommand
|
||||||
{
|
{
|
||||||
public function execute(InputInterface $input, OutputInterface $output): int
|
public function execute(InputInterface $input, OutputInterface $output): int
|
||||||
{
|
{
|
||||||
parent::execute($input, $output);
|
$extraArgs = $input->getOption('extra-args');
|
||||||
|
$workingDir = $input->getOption('working-dir');
|
||||||
|
|
||||||
// TODO: Composer in Docker Compose?
|
// TODO: Composer in Docker Compose?
|
||||||
$process = Process::create(
|
$process = Process::create(
|
||||||
command: ['composer', 'install'],
|
command: ['composer', 'install'],
|
||||||
extraArgs: $this->extraArgs,
|
extraArgs: $extraArgs,
|
||||||
workingDir: $this->workingDir,
|
workingDir: $workingDir,
|
||||||
);
|
);
|
||||||
|
|
||||||
$process->setTimeout(null);
|
$process->setTimeout(null);
|
||||||
|
|
|
@ -13,15 +13,16 @@ final class RunCommand extends AbstractCommand
|
||||||
{
|
{
|
||||||
public function execute(InputInterface $input, OutputInterface $output): int
|
public function execute(InputInterface $input, OutputInterface $output): int
|
||||||
{
|
{
|
||||||
parent::execute($input, $output);
|
|
||||||
|
|
||||||
$projectType = null;
|
$projectType = null;
|
||||||
|
|
||||||
|
$extraArgs = $input->getOption('extra-args');
|
||||||
|
$workingDir = $input->getOption('working-dir');
|
||||||
|
|
||||||
// Attempt to prepopulate some of the options, such as the project type
|
// Attempt to prepopulate some of the options, such as the project type
|
||||||
// based on its dependencies.
|
// based on its dependencies.
|
||||||
// TODO: move this logic to a service so it can be tested.
|
// TODO: move this logic to a service so it can be tested.
|
||||||
$json = json_decode(
|
$json = json_decode(
|
||||||
json: strval(file_get_contents($this->workingDir.'/composer.json')),
|
json: strval(file_get_contents($workingDir.'/composer.json')),
|
||||||
associative: true,
|
associative: true,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -40,13 +41,13 @@ final class RunCommand extends AbstractCommand
|
||||||
$projectType = $input->getOption('type') ?? $projectType;
|
$projectType = $input->getOption('type') ?? $projectType;
|
||||||
|
|
||||||
$filesystem = new Filesystem();
|
$filesystem = new Filesystem();
|
||||||
$isDockerCompose = $filesystem->exists($this->workingDir . '/docker-compose.yaml');
|
$isDockerCompose = $filesystem->exists($workingDir . '/docker-compose.yaml');
|
||||||
|
|
||||||
if ($isDockerCompose) {
|
if ($isDockerCompose) {
|
||||||
$process = Process::create(
|
$process = Process::create(
|
||||||
command: ['docker', 'compose', 'up'],
|
command: ['docker', 'compose', 'up'],
|
||||||
extraArgs: $this->extraArgs,
|
extraArgs: $extraArgs,
|
||||||
workingDir: $this->workingDir,
|
workingDir: $workingDir,
|
||||||
);
|
);
|
||||||
$process->setTimeout(null);
|
$process->setTimeout(null);
|
||||||
|
|
||||||
|
@ -56,8 +57,8 @@ final class RunCommand extends AbstractCommand
|
||||||
case ProjectType::Sculpin->value:
|
case ProjectType::Sculpin->value:
|
||||||
$process = Process::create(
|
$process = Process::create(
|
||||||
command: ['./vendor/bin/sculpin', 'generate', '--server', '--watch'],
|
command: ['./vendor/bin/sculpin', 'generate', '--server', '--watch'],
|
||||||
extraArgs: $this->extraArgs,
|
extraArgs: $extraArgs,
|
||||||
workingDir: $this->workingDir,
|
workingDir: $workingDir,
|
||||||
);
|
);
|
||||||
$process->setTimeout(null);
|
$process->setTimeout(null);
|
||||||
|
|
||||||
|
|
|
@ -11,11 +11,12 @@ final class TestCommand extends AbstractCommand
|
||||||
{
|
{
|
||||||
public function execute(InputInterface $input, OutputInterface $output): int
|
public function execute(InputInterface $input, OutputInterface $output): int
|
||||||
{
|
{
|
||||||
parent::execute($input, $output);
|
$extraArgs = $input->getOption('extra-args');
|
||||||
|
$workingDir = $input->getOption('working-dir');
|
||||||
|
|
||||||
// TODO: move this logic to a service so it can be tested.
|
// TODO: move this logic to a service so it can be tested.
|
||||||
$json = json_decode(
|
$json = json_decode(
|
||||||
json: strval(file_get_contents($this->workingDir.'/composer.json')),
|
json: strval(file_get_contents($workingDir.'/composer.json')),
|
||||||
associative: true,
|
associative: true,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -32,8 +33,8 @@ final class TestCommand extends AbstractCommand
|
||||||
// TODO: commands in Docker Compose?
|
// TODO: commands in Docker Compose?
|
||||||
$process = Process::create(
|
$process = Process::create(
|
||||||
command: $command,
|
command: $command,
|
||||||
extraArgs: $this->extraArgs,
|
extraArgs: $extraArgs,
|
||||||
workingDir: $this->workingDir,
|
workingDir: $workingDir,
|
||||||
);
|
);
|
||||||
|
|
||||||
$process->run();
|
$process->run();
|
||||||
|
|
Loading…
Reference in a new issue