Skip to content

Commit c741dbb

Browse files
authored
Merge pull request #2 from justbetter/feature/laravel-12
2 parents be79849 + fd75589 commit c741dbb

23 files changed

+264
-62
lines changed

.github/workflows/analyse.yml

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,12 @@ jobs:
99
fail-fast: true
1010
matrix:
1111
os: [ubuntu-latest]
12-
php: [8.3]
13-
laravel: [10.*, 11.*]
12+
php: [8.4]
13+
laravel: [12]
1414
stability: [prefer-stable]
1515
include:
16-
- laravel: 10.*
17-
testbench: 8.*
18-
- laravel: 11.*
19-
testbench: 9.*
16+
- laravel: 12.*
17+
testbench: 10.*
2018

2119
name: P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.stability }} - ${{ matrix.os }}
2220

.github/workflows/coverage.yml

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,12 @@ jobs:
99
fail-fast: true
1010
matrix:
1111
os: [ubuntu-latest]
12-
php: [8.3]
13-
laravel: [10.*, 11.*]
12+
php: [8.4]
13+
laravel: [12.*]
1414
stability: [prefer-stable]
1515
include:
16-
- laravel: 10.*
17-
testbench: 8.*
18-
- laravel: 11.*
19-
testbench: 9.*
16+
- laravel: 12.*
17+
testbench: 10.*
2018

2119
name: P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.stability }} - ${{ matrix.os }}
2220

@@ -36,5 +34,5 @@ jobs:
3634
composer config allow-plugins.pestphp/pest-plugin true
3735
composer require "laravel/framework:${{ matrix.laravel }}" "orchestra/testbench:${{ matrix.testbench }}" pestphp/pest --no-interaction --no-update
3836
composer update --${{ matrix.stability }} --prefer-dist --no-interaction
39-
- name: Execute tests
40-
run: XDEBUG_MODE=coverage php vendor/bin/pest --coverage --min=100
37+
- name: Coverage
38+
run: composer coverage

.github/workflows/style.yml

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
name: style
22

3-
on:
4-
push:
5-
branches:
6-
- main
3+
on: ['push', 'pull_request']
4+
75
jobs:
86
style:
97
name: Style
@@ -16,17 +14,12 @@ jobs:
1614
- name: Setup PHP
1715
uses: shivammathur/setup-php@v2
1816
with:
19-
php-version: 8.3
17+
php-version: 8.4
2018
extensions: dom, curl, libxml, mbstring, zip, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, imagick, fileinfo
2119
coverage: none
2220

2321
- name: Install dependencies
2422
run: composer install
2523

2624
- name: Style
27-
run: composer fix-style
28-
29-
- name: Commit Changes
30-
uses: stefanzweifel/git-auto-commit-action@v4
31-
with:
32-
commit_message: Fix styling changes
25+
run: composer style

.github/workflows/tests.yml

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,14 @@ jobs:
99
fail-fast: true
1010
matrix:
1111
os: [ubuntu-latest]
12-
php: [8.2, 8.3]
13-
laravel: [10.*, 11.*]
12+
php: [8.3, 8.4]
13+
laravel: [11.*, 12.*]
1414
stability: [prefer-stable]
1515
include:
16-
- laravel: 10.*
17-
testbench: 8.*
1816
- laravel: 11.*
1917
testbench: 9.*
20-
exclude:
21-
- laravel: 11.*
22-
php: 8.1
18+
- laravel: 12.*
19+
testbench: 10.*
2320

2421
name: P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.stability }} - ${{ matrix.os }}
2522

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,14 @@ php artisan akeneo-image:process {disk} {path} {--force}
7979
php artisan akeneo-image:upload {image-id}
8080
```
8181

82+
### Cleanup
83+
84+
You may optionally run the cleanup command to remove images:
85+
86+
```shell
87+
php artisan akeneo-image:cleanup --days=30
88+
```
89+
8290
## Quality
8391

8492
To ensure the quality of this package, run the following command:

composer.json

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,17 @@
1111
}
1212
],
1313
"require": {
14-
"php": "^8.1",
14+
"php": "^8.3",
1515
"justbetter/laravel-akeneo-client": "^1.4",
16-
"laravel/framework": "^10.0|^11.0"
16+
"laravel/framework": "^11.0|^12.0"
1717
},
1818
"require-dev": {
19-
"larastan/larastan": "^2.9",
20-
"laravel/pint": "^1.10",
21-
"orchestra/testbench": "^8.0|^9.0",
22-
"phpstan/phpstan-mockery": "^1.1",
23-
"phpunit/phpunit": "^10.2"
19+
"larastan/larastan": "^3.0",
20+
"laravel/pint": "^1.22",
21+
"orchestra/testbench": "^10.0",
22+
"phpstan/phpstan-mockery": "^2.0",
23+
"phpunit/phpunit": "^11.5",
24+
"pestphp/pest": "^3.7"
2425
},
2526
"autoload": {
2627
"psr-4": {
@@ -34,6 +35,7 @@
3435
},
3536
"scripts": {
3637
"test": "phpunit",
38+
"coverage": "XDEBUG_MODE=coverage php vendor/bin/pest --coverage --min=100",
3739
"analyse": "phpstan",
3840
"style": "pint --test",
3941
"quality": [
@@ -45,7 +47,8 @@
4547
"config": {
4648
"sort-packages": true,
4749
"allow-plugins": {
48-
"php-http/discovery": true
50+
"php-http/discovery": true,
51+
"pestphp/pest-plugin": true
4952
}
5053
},
5154
"extra": {

phpstan.neon

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,5 @@ parameters:
77
- src
88
- tests
99
level: 8
10-
checkMissingIterableValueType: false
10+
ignoreErrors:
11+
- identifier: missingType.iterableValue

src/Actions/CleanupImages.php

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?php
2+
3+
namespace JustBetter\AkeneoImages\Actions;
4+
5+
use Illuminate\Support\Facades\Storage;
6+
use JustBetter\AkeneoImages\Contracts\CleansupImages;
7+
use JustBetter\AkeneoImages\Models\Image;
8+
9+
class CleanupImages implements CleansupImages
10+
{
11+
public function cleanup(int $days): void
12+
{
13+
Image::query()
14+
->where('created_at', '<=', now()->subDays($days))
15+
->get()
16+
->each(function (Image $image): void {
17+
if (Storage::disk($image->disk)->exists($image->path)) {
18+
Storage::disk($image->disk)->delete($image->path);
19+
}
20+
21+
$image->delete();
22+
});
23+
}
24+
25+
public static function bind(): void
26+
{
27+
app()->singleton(CleansupImages::class, static::class);
28+
}
29+
}

src/Actions/UploadImage.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@ class UploadImage implements UploadsImage
1111
{
1212
public function __construct(
1313
protected Akeneo $akeneo
14-
) {
15-
}
14+
) {}
1615

1716
public function upload(Image $image): Image
1817
{
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?php
2+
3+
namespace JustBetter\AkeneoImages\Commands;
4+
5+
use Illuminate\Console\Command;
6+
use JustBetter\AkeneoImages\Jobs\CleanupImagesJob;
7+
8+
class CleanupImagesCommand extends Command
9+
{
10+
protected $signature = 'akeneo-image:cleanup {--days=}';
11+
12+
protected $description = 'Cleanup images that are older than the specified number of days.';
13+
14+
public function handle(): int
15+
{
16+
$days = (int) $this->option('days');
17+
18+
CleanupImagesJob::dispatch($days);
19+
20+
return static::SUCCESS;
21+
}
22+
}

0 commit comments

Comments
 (0)