diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index 7d2d724..1ff6e76 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -9,7 +9,7 @@ jobs: fail-fast: true matrix: os: [ ubuntu-latest, windows-latest ] - php: [ 7.4, 8.0 ] + php: [ 8.0 ] stability: [ prefer-lowest, prefer-stable ] name: P${{ matrix.php }} - ${{ matrix.stability }} - ${{ matrix.os }} diff --git a/composer.json b/composer.json index 4bcbd8d..1f3fe2e 100644 --- a/composer.json +++ b/composer.json @@ -15,15 +15,15 @@ } ], "require": { - "php": "^7.4|^8.0", - "spatie/laravel-package-tools": "^1.4.3", - "illuminate/contracts": "^8.0|^9.0", + "php": "^8.0", + "spatie/laravel-package-tools": "^1.11.3", + "illuminate/contracts": "^9.0", "ext-json": "*" }, "require-dev": { "friendsofphp/php-cs-fixer": "^3.3", - "orchestra/testbench": "^6.15", - "phpunit/phpunit": "^9.3" + "orchestra/testbench": "^7.02", + "phpunit/phpunit": "^9.5" }, "autoload": { "psr-4": { diff --git a/config/langscanner.php b/config/langscanner.php index e7d19ca..a899b36 100644 --- a/config/langscanner.php +++ b/config/langscanner.php @@ -1,6 +1,7 @@ base_path('lang'), /* |-------------------------------------------------------------------------- | Translation methods diff --git a/src/Commands/LangscannerCommand.php b/src/Commands/LangscannerCommand.php index 5168a93..8698ebf 100644 --- a/src/Commands/LangscannerCommand.php +++ b/src/Commands/LangscannerCommand.php @@ -20,7 +20,7 @@ public function handle(Filesystem $filesystem): void if ($this->argument('language')) { $languages = new Languages([$this->argument('language')]); } else { - $languages = Languages::fromPath(resource_path('lang'), $filesystem); + $languages = Languages::fromPath(config('langscanner.lang_dir_path'), $filesystem); } foreach ($languages->all() as $language) { diff --git a/src/FileTranslations.php b/src/FileTranslations.php index cac893e..8c8ce35 100644 --- a/src/FileTranslations.php +++ b/src/FileTranslations.php @@ -17,7 +17,7 @@ public function __construct(array $opts) $this->language = $opts['language']; $this->disk = $opts['disk'] ?? resolve(Filesystem::class); - $this->rootPath = $opts['rootPath'] ?? resource_path('lang/'); + $this->rootPath = $opts['rootPath'] ?? config('langscanner.lang_dir_path') . '/'; } public function language(): string diff --git a/src/RequiredTranslations.php b/src/RequiredTranslations.php index 5aea3d4..2476b0a 100644 --- a/src/RequiredTranslations.php +++ b/src/RequiredTranslations.php @@ -15,17 +15,20 @@ class RequiredTranslations private array $translationMethods; private array $excludedPaths; private array $translations; + private string $langDirPath; public function __construct(array $options, Filesystem $disk = null) { Assert::keyExists($options, 'paths'); Assert::keyExists($options, 'excluded_paths'); Assert::keyExists($options, 'translation_methods'); + Assert::keyExists($options, 'lang_dir_path'); $this->disk = $disk ?? resolve(Filesystem::class); $this->paths = $options['paths']; $this->excludedPaths = $options['excluded_paths']; $this->translationMethods = $options['translation_methods']; + $this->langDirPath = $options['lang_dir_path']; } public function all(): array @@ -63,7 +66,7 @@ private function files(): array private function existingPhpTranslations(): array { - return Collection::make($this->disk->allFiles(resource_path('lang'))) + return Collection::make($this->disk->allFiles($this->langDirPath)) ->filter(fn ($file) => $file->getExtension() === 'php') ->reduce(function ($carry, $file) { $translations = $this->disk->getRequire($file->getRealPath()); diff --git a/tests/RequiredTranslationsTest.php b/tests/RequiredTranslationsTest.php index e6bd954..762ab10 100644 --- a/tests/RequiredTranslationsTest.php +++ b/tests/RequiredTranslationsTest.php @@ -15,6 +15,7 @@ public function it_finds_all_required_translations(): void 'paths' => [__DIR__ . '/fixtures/test-files'], 'excluded_paths' => [], 'translation_methods' => ['__', 'trans', 'trans_choice', '@lang', 'Lang::get'], + 'lang_dir_path' => base_path('lang'), ], new Filesystem(), );