Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/Concerns/Optionable.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ trait Optionable
protected array $options = [
Options::CONNECTION,
Options::FORCE,
Options::SILENT,
Options::MUTE,
];

protected function configure(): void
Expand Down Expand Up @@ -48,7 +48,7 @@ protected function availableOptions(): array
[Options::PATH, null, InputOption::VALUE_OPTIONAL, 'The path to the actions files to be executed'],
[Options::REALPATH, null, InputOption::VALUE_NONE, 'Indicate any provided action file paths are pre-resolved absolute path'],
[Options::STEP, null, InputOption::VALUE_OPTIONAL, 'Force the actions to be run so they can be rolled back individually'],
[Options::SILENT, null, InputOption::VALUE_NONE, 'Turns off the output of informational messages'],
[Options::MUTE, null, InputOption::VALUE_NONE, 'Turns off the output of informational messages'],
];
}

Expand Down
2 changes: 1 addition & 1 deletion src/Console/Fresh.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@ class Fresh extends Command
Options::FORCE,
Options::PATH,
Options::REALPATH,
Options::SILENT,
Options::MUTE,
];
}
2 changes: 1 addition & 1 deletion src/Console/Make.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,6 @@ class Make extends Command
Options::FORCE,
Options::PATH,
Options::REALPATH,
Options::SILENT,
Options::MUTE,
];
}
2 changes: 1 addition & 1 deletion src/Console/Migrate.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@ class Migrate extends Command
Options::CONNECTION,
Options::PATH,
Options::REALPATH,
Options::SILENT,
Options::MUTE,
];
}
2 changes: 1 addition & 1 deletion src/Console/Refresh.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@ class Refresh extends Command
Options::FORCE,
Options::PATH,
Options::REALPATH,
Options::SILENT,
Options::MUTE,
];
}
2 changes: 1 addition & 1 deletion src/Console/Reset.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@ class Reset extends Command
Options::FORCE,
Options::PATH,
Options::REALPATH,
Options::SILENT,
Options::MUTE,
];
}
2 changes: 1 addition & 1 deletion src/Console/Rollback.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@ class Rollback extends Command
Options::PATH,
Options::REALPATH,
Options::STEP,
Options::SILENT,
Options::MUTE,
];
}
2 changes: 1 addition & 1 deletion src/Console/Status.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@ class Status extends Command
Options::CONNECTION,
Options::PATH,
Options::REALPATH,
Options::SILENT,
Options::MUTE,
];
}
4 changes: 2 additions & 2 deletions src/Constants/Options.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ class Options

public const FORCE = 'force';

public const MUTE = 'mute';

public const NAME = 'name';

public const PATH = 'path';

public const REALPATH = 'realpath';

public const SILENT = 'silent';

public const STEP = 'step';
}
27 changes: 18 additions & 9 deletions src/Notifications/Beautiful.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,43 +6,52 @@

use Closure;
use Illuminate\Console\View\Components\Factory;
use Illuminate\Support\Optional;

class Beautiful extends Notification
{
protected Factory|Optional|null $components = null;
protected ?Factory $components = null;

public function line(string $string, ?string $style = null): void
{
$this->components()->line($style, $string, $this->verbosity);
if ($this->canSpeak()) {
$this->components()->line($style, $string, $this->verbosity);
}
}

public function info(string $string): void
{
$this->components()->info($string, $this->verbosity);
if ($this->canSpeak()) {
$this->components()->info($string, $this->verbosity);
}
}

public function warning(string $string): void
{
$this->components()->warn($string, $this->verbosity);
if ($this->canSpeak()) {
$this->components()->warn($string, $this->verbosity);
}
}

public function task(string $description, Closure $task): void
{
$this->components()->task($description, $task);
if ($this->canSpeak()) {
$this->components()->task($description, $task);
}
}

public function twoColumn(string $first, string $second): void
{
$this->components()->twoColumnDetail($first, $second, $this->verbosity);
if ($this->canSpeak()) {
$this->components()->twoColumnDetail($first, $second, $this->verbosity);
}
}

protected function components(): Factory|Optional
protected function components(): Factory
{
if (! is_null($this->components)) {
return $this->components;
}

return $this->component = $this->canSpeak() ? new Factory($this->output) : optional();
return $this->components = new Factory($this->output);
}
}
10 changes: 5 additions & 5 deletions src/Processors/Install.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ public function handle(): void
});
}

protected function isFile(string $path): bool
{
return Str::of($path)->lower()->endsWith('.php');
}

protected function exists(): bool
{
return $this->repository->repositoryExists();
Expand All @@ -40,9 +45,4 @@ protected function ensureDirectory(): void
? Directory::ensureDirectory(Path::dirname($this->options->path))
: Directory::ensureDirectory($this->options->path);
}

protected function isFile(string $path): bool
{
return Str::of($path)->lower()->endsWith('.php');
}
}
4 changes: 2 additions & 2 deletions src/Processors/Migrate.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ class Migrate extends Processor
{
public function handle(): void
{
$this->ensureRepository();
$this->showCaption();
$this->ensureRepository();
$this->runActions($this->getCompleted());
}

Expand All @@ -32,7 +32,7 @@ protected function ensureRepository(): void
$this->runCommand(Names::INSTALL, [
'--' . Options::CONNECTION => $this->options->connection,
'--' . Options::FORCE => true,
'--' . Options::SILENT => true,
'--' . Options::MUTE => true,
]);
}

Expand Down
20 changes: 20 additions & 0 deletions tests/Commands/InstallTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Tests\Commands;

use DragonCode\LaravelActions\Constants\Names;
use DragonCode\LaravelActions\Constants\Options;
use Tests\TestCase;

class InstallTest extends TestCase
Expand All @@ -25,4 +26,23 @@ public function testAlreadyCreated(): void

$this->assertDatabaseHasTable($this->table);
}

public function testMutedCreate(): void
{
$this->assertDatabaseDoesntTable($this->table);

$this->artisan(Names::INSTALL, ['--' . Options::MUTE => true])->assertExitCode(0);

$this->assertDatabaseHasTable($this->table);
}

public function testMutedAlreadyCreated(): void
{
$this->assertDatabaseDoesntTable($this->table);

$this->artisan(Names::INSTALL, ['--' . Options::MUTE => true])->assertExitCode(0);
$this->artisan(Names::INSTALL, ['--' . Options::MUTE => true])->assertExitCode(0);

$this->assertDatabaseHasTable($this->table);
}
}