Skip to content

Commit 899f6e4

Browse files
Merge pull request #75 from TheDragonCode/3.x
Fixed information messages
2 parents 67f462d + 16addca commit 899f6e4

File tree

5 files changed

+41
-18
lines changed

5 files changed

+41
-18
lines changed

docs/prologue/changelog/3.x.md

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
# 3.x
22

3-
# 3.0.0
4-
5-
- Coming Soon
6-
73
## v3.0-RC2 - 2022-10-12
84

95
**Full Changelog**: https://github.com/TheDragonCode/laravel-migration-actions/compare/v3.0-RC1...v3.0-RC2

src/Processors/Processor.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ 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

@@ -55,6 +55,11 @@ protected function getFiles(?Closure $filter = null, ?string $path = null, bool
5555
fn (Arrayable $array) => $array
5656
->map(fn (string $value) => Str::of(realpath($value))->after(realpath($path))->ltrim('\\/')->toString())
5757
)
58+
->when(
59+
! $withExtension,
60+
fn (Arrayable $array) => $array
61+
->map(fn (string $value) => Str::before($value, '.php'))
62+
)
5863
->toArray();
5964
}
6065

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)