Skip to content

Commit b6d9a1c

Browse files
Replace ConfigHelper with ConfigData
1 parent 34978e3 commit b6d9a1c

24 files changed

+182
-120
lines changed

config/deploy-operations.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,12 @@
3939
*/
4040

4141
'transactions' => [
42-
// | Determines whether the use of database transactions is enabled.
42+
// Determines whether the use of database transactions is enabled.
4343

4444
'enabled' => false,
4545

46-
// | The number of attempts to execute a request within a transaction before throwing an error.
46+
// The number of attempts to execute a request within a transaction before throwing an error.
47+
4748
'attempts' => 1,
4849
],
4950

@@ -146,6 +147,6 @@
146147
|
147148
*/
148149

149-
'full_path' => env('DEPLOY_OPERATIONS_SHOW_FULL_PATH', false),
150+
'full_path' => (bool) env('DEPLOY_OPERATIONS_SHOW_FULL_PATH', false),
150151
],
151152
];

database/migrations/2022_08_18_180137_change_migration_actions_table.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
declare(strict_types=1);
44

5-
use DragonCode\LaravelDeployOperations\Helpers\ConfigHelper;
5+
use DragonCode\LaravelDeployOperations\Data\Config\ConfigData;
66
use Illuminate\Database\Migrations\Migration;
77
use Illuminate\Database\Schema\Blueprint;
88
use Illuminate\Support\Facades\Schema;
@@ -49,6 +49,6 @@ protected function doesntHaveColumn(string $column): bool
4949

5050
protected function table(): string
5151
{
52-
return app(ConfigHelper::class)->table();
52+
return app(ConfigData::class)->table;
5353
}
5454
};

database/migrations/2023_01_21_172923_rename_migrations_actions_table_to_actions.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
declare(strict_types=1);
44

5-
use DragonCode\LaravelDeployOperations\Helpers\ConfigHelper;
5+
use DragonCode\LaravelDeployOperations\Data\Config\ConfigData;
66
use Illuminate\Database\Migrations\Migration;
77
use Illuminate\Support\Facades\Schema;
88

@@ -39,6 +39,6 @@ protected function doesntSame(string $first, string $second): bool
3939

4040
protected function table(): string
4141
{
42-
return app(ConfigHelper::class)->table();
42+
return app(ConfigData::class)->table;
4343
}
4444
};

database/migrations/2024_05_21_112438_rename_actions_table_to_operations.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
declare(strict_types=1);
44

5-
use DragonCode\LaravelDeployOperations\Helpers\ConfigHelper;
5+
use DragonCode\LaravelDeployOperations\Data\Config\ConfigData;
66
use Illuminate\Database\Migrations\Migration;
77
use Illuminate\Support\Facades\Schema;
88

@@ -39,6 +39,6 @@ protected function doesntSame(string $first, string $second): bool
3939

4040
protected function table(): string
4141
{
42-
return app(ConfigHelper::class)->table();
42+
return app(ConfigData::class)->table;
4343
}
4444
};

database/migrations/2024_05_21_114318_rename_column_in_operations_table.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
declare(strict_types=1);
44

5-
use DragonCode\LaravelDeployOperations\Helpers\ConfigHelper;
5+
use DragonCode\LaravelDeployOperations\Data\Config\ConfigData;
66
use Illuminate\Database\Migrations\Migration;
77
use Illuminate\Database\Schema\Blueprint;
88
use Illuminate\Support\Facades\Schema;
@@ -27,6 +27,6 @@ protected function rename(string $from, string $to): void
2727

2828
protected function table(): string
2929
{
30-
return app(ConfigHelper::class)->table();
30+
return app(ConfigData::class)->table;
3131
}
3232
};

src/Data/Casts/Config/ExcludeCast.php

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace DragonCode\LaravelDeployOperations\Data\Casts\Config;
6+
7+
use Illuminate\Support\Collection;
8+
use Illuminate\Support\Str;
9+
use Spatie\LaravelData\Casts\Cast;
10+
use Spatie\LaravelData\Support\Creation\CreationContext;
11+
use Spatie\LaravelData\Support\DataProperty;
12+
13+
class ExcludeCast implements Cast
14+
{
15+
public function cast(DataProperty $property, mixed $value, array $properties, CreationContext $context): array
16+
{
17+
return (new Collection($value))
18+
->map(static fn (string $path) => Str::replace(['\\', '/'], DIRECTORY_SEPARATOR, $path))
19+
->filter()
20+
->all();
21+
}
22+
}

src/Data/Casts/Config/PathCast.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace DragonCode\LaravelDeployOperations\Data\Casts\Config;
6+
7+
use Spatie\LaravelData\Casts\Cast;
8+
use Spatie\LaravelData\Support\Creation\CreationContext;
9+
use Spatie\LaravelData\Support\DataProperty;
10+
11+
use function rtrim;
12+
13+
class PathCast implements Cast
14+
{
15+
public function cast(DataProperty $property, mixed $value, array $properties, CreationContext $context): string
16+
{
17+
return rtrim($value, '\\/') . DIRECTORY_SEPARATOR;
18+
}
19+
}

src/Data/Casts/PathCast.php

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

55
namespace DragonCode\LaravelDeployOperations\Data\Casts;
66

7-
use DragonCode\LaravelDeployOperations\Helpers\ConfigHelper;
7+
use DragonCode\LaravelDeployOperations\Data\Config\ConfigData;
88
use Illuminate\Support\Str;
99
use Spatie\LaravelData\Casts\Cast;
1010
use Spatie\LaravelData\Support\Creation\CreationContext;
@@ -17,7 +17,7 @@ class PathCast implements Cast
1717
{
1818
public function cast(DataProperty $property, mixed $value, array $properties, CreationContext $context): string
1919
{
20-
$path = $this->config()->basePath((string) $value);
20+
$path = $this->config()->path . $value;
2121

2222
if ($properties['realpath'] ?? false) {
2323
return $value ?: $path;
@@ -31,8 +31,8 @@ protected function filename(string $path): false|string
3131
return realpath(Str::finish($path, '.php'));
3232
}
3333

34-
protected function config(): ConfigHelper
34+
protected function config(): ConfigData
3535
{
36-
return app(ConfigHelper::class);
36+
return app(ConfigData::class);
3737
}
3838
}

src/Data/Config/ConfigData.php

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace DragonCode\LaravelDeployOperations\Data\Config;
6+
7+
use DragonCode\LaravelDeployOperations\Data\Casts\Config\ExcludeCast;
8+
use DragonCode\LaravelDeployOperations\Data\Casts\Config\PathCast;
9+
use Spatie\LaravelData\Attributes\WithCast;
10+
use Spatie\LaravelData\Data;
11+
12+
class ConfigData extends Data
13+
{
14+
public ?string $connection;
15+
16+
public string $table;
17+
18+
#[WithCast(PathCast::class)]
19+
public string $path;
20+
21+
#[WithCast(ExcludeCast::class)]
22+
public ?array $exclude;
23+
24+
public bool $async;
25+
26+
public TransactionsData $transactions;
27+
28+
public QueueData $queue;
29+
30+
public ShowData $show;
31+
}

src/Data/Config/QueueData.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace DragonCode\LaravelDeployOperations\Data\Config;
6+
7+
use Spatie\LaravelData\Data;
8+
9+
class QueueData extends Data
10+
{
11+
public ?string $connection;
12+
13+
public ?string $name;
14+
}

0 commit comments

Comments
 (0)