From f43461a285bc32ebaa4633a49db28e499c2347c5 Mon Sep 17 00:00:00 2001 From: YNWA Fawzy <38886749+Cybrarist@users.noreply.github.com> Date: Tue, 1 Oct 2024 10:09:52 +0400 Subject: [PATCH 1/3] Allow custom stub file to be used for board. --- src/Commands/MakeKanbanBoardCommand.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Commands/MakeKanbanBoardCommand.php b/src/Commands/MakeKanbanBoardCommand.php index 9124d1b..a364386 100644 --- a/src/Commands/MakeKanbanBoardCommand.php +++ b/src/Commands/MakeKanbanBoardCommand.php @@ -14,11 +14,13 @@ class MakeKanbanBoardCommand extends GeneratorCommand protected function getStub() { - return __DIR__ . '/../../stubs/board.stub'; + return file_exists($customPath = $this->laravel->basePath('/stubs/filament-kanban/board.stub')) + ? $customPath + : __DIR__.'/../../stubs/board.stub'; } protected function getDefaultNamespace($rootNamespace) { - return $rootNamespace . '\Filament\Pages'; + return $rootNamespace.'\Filament\Pages'; } } From ae6e278dfc52a4c54b728373e85d9cf7967745fd Mon Sep 17 00:00:00 2001 From: Mo Khosh Date: Tue, 1 Oct 2024 16:33:39 +0330 Subject: [PATCH 2/3] delete previously generated files --- tests/Tests/KanbanBoardTest.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/Tests/KanbanBoardTest.php b/tests/Tests/KanbanBoardTest.php index fbc7d58..5760961 100644 --- a/tests/Tests/KanbanBoardTest.php +++ b/tests/Tests/KanbanBoardTest.php @@ -1,5 +1,6 @@ app->basePath('app/Filament/Pages/TestBoard.php')); $pagesPath = $this->app->basePath('app/Filament/Pages'); $this->artisan('make:kanban TestBoard')->assertExitCode(0); From ae4fc60d96063ea7d564a699a00256d7bb6caf19 Mon Sep 17 00:00:00 2001 From: Mo Khosh Date: Tue, 1 Oct 2024 16:34:43 +0330 Subject: [PATCH 3/3] add tests for custom stub generation --- tests/Tests/KanbanBoardTest.php | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/tests/Tests/KanbanBoardTest.php b/tests/Tests/KanbanBoardTest.php index 5760961..73ebe6e 100644 --- a/tests/Tests/KanbanBoardTest.php +++ b/tests/Tests/KanbanBoardTest.php @@ -20,6 +20,21 @@ ->toContainAsFile('class TestBoard extends KanbanBoard'); }); +it('can make kanban board from custom stub', function () { + File::delete($this->app->basePath('app/Filament/Pages/TestBoard.php')); + File::delete($this->app->basePath('stubs/filament-kanban/board.stub')); + File::ensureDirectoryExists($this->app->basePath('/stubs/filament-kanban/')); + File::put($this->app->basePath('/stubs/filament-kanban/board.stub'), 'custom stub'); + + $pagesPath = $this->app->basePath('app/Filament/Pages'); + + $this->artisan('make:kanban TestBoard')->assertExitCode(0); + + expect($pagesPath . '/TestBoard.php') + ->toBeFile() + ->toContainAsFile('custom stub'); +}); + it('loads statuses', function () { $statuses = TaskStatus::statuses() ->pluck('title')