Skip to content

Commit

Permalink
fix node arguments and options
Browse files Browse the repository at this point in the history
  • Loading branch information
fabio-ivona committed Jan 9, 2021
1 parent 936b9d3 commit aac5180
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 70 deletions.
81 changes: 36 additions & 45 deletions app/Containers/Commands/Composer.php
Original file line number Diff line number Diff line change
@@ -1,55 +1,46 @@
<?php
<?php /** @noinspection PhpUnhandledExceptionInspection */

/** @noinspection PhpMissingFieldTypeInspection */

namespace App\Containers\Commands;

use App\Exceptions\DockerServiceNotFoundException;
use App\Services\DockerService;
use App\Services\TerminalService;
use Illuminate\Contracts\Container\BindingResolutionException;
use LaravelZero\Framework\Commands\Command;
namespace App\Containers\Commands;

class Composer extends Command{
protected $signature = 'composer';
use App\Services\DockerService;
use App\Services\TerminalService;
use LaravelZero\Framework\Commands\Command;

protected $description = 'Runs a composer command';
class Composer extends Command
{
protected $signature = 'composer';

public function __construct()
{
parent::__construct();
$this->ignoreValidationErrors();
}

/**
* @param DockerService $docker_service
* @param TerminalService $terminal
*
* @return int
* @throws DockerServiceNotFoundException
* @throws BindingResolutionException
*/
public function handle(DockerService $docker_service, TerminalService $terminal){

$terminal->init($this->output);

$arguments = (string) $this->input;

if(empty($arguments)){
$this->info('Log into Composer Shell');

return $terminal->execute([
'docker-compose',
'run',
'--rm',
'composer',
'bash',
]);
} else{
$composer_commands = explode(' ', $arguments);
$commands = array_merge(['composer'], $composer_commands);
return $docker_service->service('composer')->run($terminal, $commands);
}
protected $description = 'Runs a composer command';

public function __construct()
{
parent::__construct();
$this->ignoreValidationErrors();
}

public function handle(DockerService $docker_service, TerminalService $terminal): int
{
$terminal->init($this->output);

$arguments = (string) $this->input;

if (empty($arguments)) {
$this->info('Log into Composer Shell');

return $terminal->execute([
'docker-compose',
'run',
'--rm',
'composer',
'bash',
]);
} else {
$composer_commands = explode(' ', $arguments);
$commands = array_merge(['composer'], $composer_commands);
return $docker_service->service('composer')->run($terminal, $commands);
}
}
}
54 changes: 29 additions & 25 deletions app/Containers/Commands/Node.php
Original file line number Diff line number Diff line change
@@ -1,41 +1,45 @@
<?php
<?php /** @noinspection PhpUnhandledExceptionInspection */

/** @noinspection PhpMissingFieldTypeInspection */

namespace App\Containers\Commands;

use App\Exceptions\DockerServiceNotFoundException;
namespace App\Containers\Commands;

use App\Services\DockerService;
use App\Services\TerminalService;
use Illuminate\Contracts\Container\BindingResolutionException;
use LaravelZero\Framework\Commands\Command;

class Node extends Command{
protected $signature = 'node
{commands* : node commands to execute} ';
protected $signature = 'node';

protected $description = 'Executes a node command';
protected $description = 'Runs a node command';

/**
* @param DockerService $docker_service
* @param TerminalService $terminal
* @return int
* @throws DockerServiceNotFoundException
* @throws BindingResolutionException
*/
public function handle(DockerService $docker_service, TerminalService $terminal){
public function __construct()
{
parent::__construct();
$this->ignoreValidationErrors();
}

public function handle(DockerService $docker_service, TerminalService $terminal): int
{
$terminal->init($this->output);

$commands = [
"node",
];

$composer_commands = $this->argument("commands");
if(!empty($composer_commands)){
$commands = array_merge($commands, $composer_commands);
$arguments = (string) $this->input;

if (empty($arguments)) {
$this->info('Log into Node Shell');

return $terminal->execute([
'docker-compose',
'run',
'--rm',
'node',
'bash',
]);
} else {
$node_commands = explode(' ', $arguments);
$commands = array_merge(['node'], $node_commands);
return $docker_service->service('node')->run($terminal, $commands);
}
return $docker_service->service('node')->run($terminal, $commands);


}
}

0 comments on commit aac5180

Please sign in to comment.