diff --git a/composer.json b/composer.json index e9408df0..279b0079 100644 --- a/composer.json +++ b/composer.json @@ -86,7 +86,8 @@ "mockery/mockery": "^1.4.4", "orchestra/testbench": "^9.0", "pestphp/pest": "^3.0", - "phpstan/phpstan-mockery": "^1.1" + "phpstan/phpstan-mockery": "^1.1", + "qossmic/deptrac": "^2.0" }, "config": { "optimize-autoloader": true, @@ -121,6 +122,10 @@ "minimum-stability": "dev", "prefer-stable": true, "scripts": { + "archtest": [ + "./vendor/bin/deptrac analyze", + "./vendor/bin/pest tests/Arch.php" + ], "post-autoload-dump": [ "Illuminate\\Foundation\\ComposerScripts::postAutoloadDump", "@php artisan package:discover --ansi" diff --git a/composer.lock b/composer.lock index 19ea6985..b9cefd5b 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "67ae3a3987355f098ee6f850c6f8e846", + "content-hash": "3ffa3d4a189ba5d296ca71166298a74f", "packages": [ { "name": "amphp/amp", @@ -15743,6 +15743,51 @@ }, "time": "2024-09-11T15:47:29+00:00" }, + { + "name": "qossmic/deptrac", + "version": "2.0.1", + "source": { + "type": "git", + "url": "https://github.com/qossmic/deptrac.git", + "reference": "f646695c1468051138e1347d89590f9084fa6256" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/qossmic/deptrac/zipball/f646695c1468051138e1347d89590f9084fa6256", + "reference": "f646695c1468051138e1347d89590f9084fa6256", + "shasum": "" + }, + "require": { + "ext-json": "*", + "php": "^8.1" + }, + "suggest": { + "ext-dom": "For using the JUnit output formatter" + }, + "bin": [ + "bin/deptrac", + "deptrac.phar" + ], + "type": "library", + "autoload": { + "files": [ + "bootstrap.php" + ], + "psr-4": { + "Qossmic\\Deptrac\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "Deptrac is a static code analysis tool that helps to enforce rules for dependencies between software layers.", + "support": { + "issues": "https://github.com/qossmic/deptrac/issues", + "source": "https://github.com/qossmic/deptrac/tree/2.0.1" + }, + "time": "2024-06-17T10:43:11+00:00" + }, { "name": "rector/rector", "version": "1.2.5", diff --git a/deptrac.yaml b/deptrac.yaml new file mode 100644 index 00000000..0ce2e48d --- /dev/null +++ b/deptrac.yaml @@ -0,0 +1,30 @@ +deptrac: + paths: + - ./app + - ./modules + exclude_files: + - '#.*Test.php$#' + layers: + - name: AppFiles + collectors: + - type: bool + must: + - type: classLike + value: .* + - type: directory + value: app/.* + + - name: ModuleFiles + collectors: + - type: bool + must: + - type: classLike + value: .* + - type: directory + value: modules/.* + + ruleset: + ModuleFiles: + - AppFiles + AppFiles: + - ModuleFiles diff --git a/tests/Arch.php b/tests/Arch.php index 7cb5f3b6..288e21cb 100644 --- a/tests/Arch.php +++ b/tests/Arch.php @@ -2,14 +2,10 @@ arch() ->expect('App') - ->not->toUse(['die', 'dd', 'dump']); - + ->not->toUse(['die', 'dd', 'dump']) + ->not->toHaveFileSystemPermissions('0777'); arch() - ->expect(globArch('App\*\Models')) - ->toExtend('Illuminate\Database\Eloquent\Model') - ->toBeClasses(); - -arch('app') - ->expect('App') + ->expect('Modules') + ->not->toUse(['die', 'dd', 'dump']) ->not->toHaveFileSystemPermissions('0777');