Run docker compose up
This commit is contained in:
parent
e81e0cef71
commit
959a0584e4
2 changed files with 20 additions and 8 deletions
|
@ -2,6 +2,7 @@
|
|||
|
||||
## Unrelased
|
||||
|
||||
- Run `docker compose up` if there is a `docker-compose.yaml` file when running `versa run`.
|
||||
- Add `--working-dir` to run versa in a different directory.
|
||||
- Add `-t` as a shortcut for `--type`.
|
||||
|
||||
|
|
13
versa
13
versa
|
@ -6,6 +6,7 @@ require __DIR__.'/vendor/autoload.php';
|
|||
use Symfony\Component\Console\Input\InputArgument;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\SingleCommandApplication;
|
||||
use Symfony\Component\Filesystem\Filesystem;
|
||||
use Symfony\Component\Process\Process;
|
||||
|
||||
$application = new SingleCommandApplication();
|
||||
|
@ -44,15 +45,25 @@ $application->setCode(function (InputInterface $input): int {
|
|||
break;
|
||||
|
||||
case 'run':
|
||||
$workingDir = $input->getOption('working-dir');
|
||||
$filesystem = new Filesystem();
|
||||
|
||||
if ($filesystem->exists($workingDir.'/docker-compose.yaml')) {
|
||||
$process = new Process(command: ['docker', 'compose', 'up']);
|
||||
$process->setTty(true);
|
||||
$process->setWorkingDirectory($workingDir);
|
||||
$process->run();
|
||||
} else {
|
||||
switch ($input->getOption('type')) {
|
||||
case 'sculpin':
|
||||
// TODO: how to pass arbitrary arguments, such as `--port 8001`?
|
||||
$process = new Process(command: ['./vendor/bin/sculpin', 'generate', '--server', '--watch']);
|
||||
$process->setTty(true);
|
||||
$process->setWorkingDirectory($input->getOption('working-dir'));
|
||||
$process->setWorkingDirectory($workingDir);
|
||||
$process->run();
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case 'test':
|
||||
|
|
Reference in a new issue