Skip to content

Commit 285fedd

Browse files
Fixed information messages
1 parent 8603eb9 commit 285fedd

File tree

4 files changed

+45
-16
lines changed

4 files changed

+45
-16
lines changed

src/Processors/Processor.php

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,15 +43,22 @@ public function __construct(
4343
$this->migrator->setConnection($this->options->connection)->setOutput($this->output);
4444
}
4545

46-
protected function getFiles(?Closure $filter = null, ?string $path = null, bool $realpath = false, bool $fullpath = false): array
46+
protected function getFiles(?Closure $filter = null, ?string $path = null, bool $realpath = false, bool $fullpath = false, bool $withExtension = true): array
4747
{
4848
$path = $this->getActionsPath($path, $realpath);
4949

5050
$names = $this->file->exists($path) ? [$path] : $this->file->allPaths($path, $filter, true);
5151

5252
return Arr::of($names)
53-
->when(! $fullpath, fn (Arrayable $array) => $array
54-
->map(fn (string $value) => Str::of(realpath($value))->after(realpath($path))->ltrim('\\/')->toString())
53+
->when(
54+
! $fullpath,
55+
fn (Arrayable $array) => $array
56+
->map(fn (string $value) => Str::of(realpath($value))->after(realpath($path))->ltrim('\\/')->toString())
57+
)
58+
->when(
59+
! $withExtension,
60+
fn (Arrayable $array) => $array
61+
->map(fn (string $value) => Str::before($value, '.php'))
5562
)
5663
->toArray();
5764
}

src/Processors/Status.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ protected function showStatus(array $actions, array $completed): void
5050

5151
protected function getData(): array
5252
{
53-
$files = $this->getFiles();
53+
$files = $this->getFiles(withExtension: false);
5454
$completed = $this->getCompleted();
5555

5656
return [$files, $completed];

src/Processors/Upgrade.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
namespace DragonCode\LaravelActions\Processors;
66

7+
use DragonCode\LaravelActions\Concerns\Anonymous;
78
use DragonCode\LaravelActions\ServiceProvider;
89
use DragonCode\Support\Facades\Filesystem\Directory;
910
use DragonCode\Support\Facades\Filesystem\File;
@@ -12,6 +13,8 @@
1213

1314
class Upgrade extends Processor
1415
{
16+
use Anonymous;
17+
1518
public function handle(): void
1619
{
1720
if ($this->alreadyUpgraded()) {
@@ -27,6 +30,7 @@ protected function run(): void
2730
{
2831
$this->moveFiles();
2932
$this->moveConfig();
33+
$this->callMigration();
3034
$this->clean();
3135
}
3236

@@ -137,6 +141,21 @@ protected function moveConfig(): void
137141
});
138142
}
139143

144+
protected function callMigration(): void
145+
{
146+
$this->notification->task('Call migration', function () {
147+
$path = $this->allowAnonymousMigrations()
148+
? __DIR__ . '/../../database/migrations/anonymous/2022_08_18_180137_change_migration_actions_table.php'
149+
: __DIR__ . '/../../database/migrations/named/2022_08_18_180137_change_migration_actions_table.php';
150+
151+
$this->artisan('migrate', [
152+
'--path' => $path,
153+
'--realpath' => true,
154+
'--force' => true,
155+
]);
156+
});
157+
}
158+
140159
protected function getOldFiles(): array
141160
{
142161
return $this->getFiles(path: database_path('actions'), realpath: true);

src/Services/Migrator.php

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -77,20 +77,23 @@ protected function hasAction(Action $action, string $method): bool
7777

7878
protected function runAction(Action $action, string $name, string $method): void
7979
{
80-
$this->notification->task("Action: $name", function () use ($action, $method) {
81-
if ($this->hasAction($action, $method)) {
82-
try {
83-
$this->runMethod($action, $method, $action->enabledTransactions(), $action->transactionAttempts());
84-
85-
$action->success();
86-
}
87-
catch (Throwable $e) {
88-
$action->failed();
89-
90-
throw $e;
80+
$this->notification->task(
81+
Str::of($name)->before('.php')->prepend('Action: ')->toString(),
82+
function () use ($action, $method) {
83+
if ($this->hasAction($action, $method)) {
84+
try {
85+
$this->runMethod($action, $method, $action->enabledTransactions(), $action->transactionAttempts());
86+
87+
$action->success();
88+
}
89+
catch (Throwable $e) {
90+
$action->failed();
91+
92+
throw $e;
93+
}
9194
}
9295
}
93-
});
96+
);
9497
}
9598

9699
protected function runMethod(Action $action, string $method, bool $transactions, int $attempts): void

0 commit comments

Comments
 (0)