Skip to content

Commit e3d4ed0

Browse files
committed
refactor: remove Enlightn package and update related configurations
1 parent a6e8eaa commit e3d4ed0

File tree

9 files changed

+38
-21
lines changed

9 files changed

+38
-21
lines changed

.github/workflows/main.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ jobs:
8686
if: steps.vendor-cache.outputs.cache-hit != 'true'
8787
run: |
8888
composer require "laravel/framework:${{ matrix.laravel }}" "orchestra/testbench:${{ matrix.testbench }}" --no-interaction --no-update
89-
composer update --${{ matrix.dependency-stability }} --prefer-dist --no-interaction --no-suggest
89+
composer update --${{ matrix.dependency-stability }} --prefer-dist --no-interaction
9090
9191
- name: Update Dependencies with latest stable
9292
if: matrix.dependency-stability == 'prefer-stable'
@@ -136,7 +136,7 @@ jobs:
136136
laravel: [ '12.*' ]
137137
include:
138138
- laravel: 12.*
139-
testbench: 9.*
139+
testbench: 10.*
140140

141141
name: PHP ${{ matrix.php }} - Laravel ${{ matrix.laravel }} - ${{ matrix.dependency-stability }} - ${{ matrix.operating-system}}
142142

@@ -175,22 +175,22 @@ jobs:
175175
id: actions-cache
176176
with:
177177
path: ${{ steps.composer-cache.outputs.dir }}
178-
key: ${{ runner.os }}-composer-laravel-11-${{ matrix.php }}-${{ hashFiles('**/composer.lock') }}
178+
key: ${{ runner.os }}-composer-laravel-12-${{ matrix.php }}-${{ hashFiles('**/composer.lock') }}
179179
restore-keys: |
180-
${{ runner.os }}-composer-laravel-11-${{ matrix.php }}-
180+
${{ runner.os }}-composer-laravel-12-${{ matrix.php }}-
181181
182182
- name: Cache PHP dependencies (vendor)
183183
uses: actions/cache@v4
184184
id: vendor-cache
185185
with:
186186
path: vendor
187-
key: ${{ runner.os }}-build-laravel-11-${{ matrix.php }}-${{ hashFiles('**/composer.lock') }}
187+
key: ${{ runner.os }}-build-laravel-12-${{ matrix.php }}-${{ hashFiles('**/composer.lock') }}
188188

189189
- name: Install Laravel Dependencies
190190
if: steps.vendor-cache.outputs.cache-hit != 'true'
191191
run: |
192192
composer require "laravel/framework:${{ matrix.laravel }}" "orchestra/testbench:${{ matrix.testbench }}" --no-interaction --no-update
193-
composer update --${{ matrix.dependency-stability }} --prefer-dist --no-interaction --no-suggest
193+
composer update --${{ matrix.dependency-stability }} --prefer-dist --no-interaction
194194
195195
- name: Update Dependencies with latest stable
196196
if: matrix.dependency-stability == 'prefer-stable'

composer.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
"illuminate/support": "^11.0|^12.0"
3131
},
3232
"require-dev": {
33-
"enlightn/enlightn": "^2.3",
3433
"friendsofphp/php-cs-fixer": "^3.0",
3534
"larastan/larastan": "^2.0|^3.0",
3635
"laravel/pint": "^1.2",

src/Facades/GitHooks.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
/**
1010
* @see \Igorsgm\GitHooks\GitHooks
1111
*
12-
* @method static array getSupportedHooks()
13-
* @method static array getAvailableHooks()
12+
* @method static array<string> getSupportedHooks()
13+
* @method static array<string> getAvailableHooks()
1414
* @method static void install()
1515
* @method static ?string getHookStub()
1616
* @method static string getGitHooksDir()

src/Traits/ProcessHelper.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ trait ProcessHelper
2222
*/
2323
public function runCommands(string|array $commands, array $params = []): Process
2424
{
25+
/** @phpstan-ignore-next-line */
2526
$output = method_exists($this, 'getOutput') ? $this->getOutput() : null;
2627

2728
if ($output && ! $output->isDecorated()) {
@@ -50,6 +51,7 @@ public function runCommands(string|array $commands, array $params = []): Process
5051
}
5152

5253
$process->run(! $showOutput ? null : function (string $line) use ($output): void {
54+
/** @phpstan-ignore-next-line */
5355
if ($output !== null) {
5456
$output->write(' '.$line);
5557
}

src/Traits/WithAutoFix.php

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,11 @@ public function suggestAutoFixOrExit(): bool
4040

4141
private function shouldAttemptAutofix(): bool
4242
{
43+
// In test environment, skip Terminal check
44+
if (app()->environment('testing')) {
45+
return $this->command->confirm('Would you like to attempt to correct files automagically?');
46+
}
47+
4348
return Terminal::hasSttyAvailable() &&
4449
$this->command->confirm('Would you like to attempt to correct files automagically?');
4550
}
@@ -57,6 +62,9 @@ private function autoFixFiles(): bool
5762
return empty($this->filesBadlyFormattedPaths);
5863
}
5964

65+
/**
66+
* @param array<string, mixed> $params
67+
*/
6068
private function attemptToFixFile(string $filePath, array $params): bool
6169
{
6270
$fixerCommand = $this->dockerCommand($this->fixerCommand().' '.$filePath);
@@ -79,14 +87,17 @@ private function attemptToFixFile(string $filePath, array $params): bool
7987
return false;
8088
}
8189

82-
protected function outputDebugCommandIfEnabled($process): void
90+
protected function outputDebugCommandIfEnabled(mixed $process): void
8391
{
8492
if (config('git-hooks.debug_commands')) {
8593
$this->command->newLine();
8694
$this->command->getOutput()->write(PHP_EOL.' <bg=yellow;fg=white> DEBUG </> Executed command: '.$process->getCommandLine().PHP_EOL);
8795
}
8896
}
8997

98+
/**
99+
* @param array<string, mixed> $params
100+
*/
90101
protected function rerunAnalyzer(string $filePath, array $params): mixed
91102
{
92103
$command = $this->dockerCommand($this->analyzerCommand().' '.$filePath);
@@ -99,7 +110,7 @@ protected function rerunAnalyzer(string $filePath, array $params): mixed
99110
return $process;
100111
}
101112

102-
protected function handleFixFailure(string $filePath, $process): void
113+
protected function handleFixFailure(string $filePath, mixed $process): void
103114
{
104115
if (empty($this->filesBadlyFormattedPaths)) {
105116
$this->command->newLine();

src/Traits/WithFileAnalysis.php

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,13 @@ public function analizeCommittedFiles(Collection $commitFiles): self
3737
return $this;
3838
}
3939

40+
/**
41+
* @param Collection<int, ChangedFile> $files
42+
* @return array<int, string>
43+
*/
4044
protected function getAnalyzableFilePaths(Collection $files): array
4145
{
42-
return $files->filter(function ($file) {
43-
return $this->canFileBeAnalyzed($file);
44-
})->map->getFilePath()->toArray();
46+
return $files->filter(fn ($file) => $this->canFileBeAnalyzed($file))->map(fn ($file) => $file->getFilePath())->toArray();
4547
}
4648

4749
public function canFileBeAnalyzed(ChangedFile $file): bool
@@ -55,6 +57,9 @@ public function canFileBeAnalyzed(ChangedFile $file): bool
5557
return is_string($fileExtensions) && preg_match($fileExtensions, $file->getFilePath());
5658
}
5759

60+
/**
61+
* @param array<int, string> $filePaths
62+
*/
5863
protected function analyzeFiles(array $filePaths): void
5964
{
6065
$filePath = implode(' ', $filePaths);
@@ -67,15 +72,15 @@ protected function analyzeFiles(array $filePaths): void
6772
$process = $this->runCommands($command, $params);
6873

6974
if (config('git-hooks.debug_commands')) {
70-
$this->outputDebugCommand($process->getCommandLine());
75+
$this->outputDebugCommandIfEnabled($process);
7176
}
7277

7378
if (! $process->isSuccessful()) {
7479
$this->handleAnalysisFailure($filePath, $process);
7580
}
7681
}
7782

78-
protected function handleAnalysisFailure(string $filePath, $process): void
83+
protected function handleAnalysisFailure(string $filePath, mixed $process): void
7984
{
8085
if (empty($this->filesBadlyFormattedPaths)) {
8186
$this->command->newLine();

tests/Features/Commands/Hooks/EnlightnPreCommitHookTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
beforeEach(function () {
1313
$this->gitInit();
1414
$this->initializeTempDirectory(base_path('temp'));
15-
});
15+
})->skip('Enligthn package is not actively maintained anymore.');
1616

1717
test('Skips Enlightn check if there are no files added to commit', function () {
1818
$changedFiles = Mockery::mock(ChangedFiles::class)

tests/Fixtures/phpcsFixerFixture.php

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

33
$finder = PhpCsFixer\Finder::create()
44
->in([
5-
'./',
5+
'./',
66
])
77
->name('*.php')
88
->ignoreDotFiles(true)
99
->ignoreVCS(true);
1010

11-
return (new PhpCsFixer\Config())
11+
return (new PhpCsFixer\Config)
1212
->setRules([
1313
'@PSR12' => true,
1414
'array_syntax' => ['syntax' => 'short'],

tests/TestCase.php

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

33
namespace Igorsgm\GitHooks\Tests;
44

5-
use Enlightn\Enlightn\EnlightnServiceProvider;
5+
// use Enlightn\Enlightn\EnlightnServiceProvider;
66
use Igorsgm\GitHooks\Facades\GitHooks;
77
use Igorsgm\GitHooks\GitHooksServiceProvider;
88
use Igorsgm\GitHooks\Tests\Traits\WithTmpFiles;
@@ -76,7 +76,7 @@ protected function getPackageProviders($app)
7676
{
7777
return [
7878
GitHooksServiceProvider::class,
79-
EnlightnServiceProvider::class,
79+
// EnlightnServiceProvider::class,
8080
];
8181
}
8282

0 commit comments

Comments
 (0)