From 536879b7924f2d814813966a51ffed516243a47c Mon Sep 17 00:00:00 2001 From: Nico Devs Date: Sat, 4 Jan 2025 11:05:43 -0300 Subject: [PATCH] Fix: write bootstrap file only when missing routes API file (#731) --- src/Generators/RouteGenerator.php | 2 +- tests/Feature/Generators/RouteGeneratorTest.php | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Generators/RouteGenerator.php b/src/Generators/RouteGenerator.php index dc6e9ea9..d76021ea 100644 --- a/src/Generators/RouteGenerator.php +++ b/src/Generators/RouteGenerator.php @@ -101,7 +101,6 @@ protected function buildRouteLine($className, $slug, $method): string protected function setupApiRouter(): void { $this->createApiRoutesFileIfMissing(); - $this->configureApiRoutesInAppBootstrap(); } protected function createApiRoutesFileIfMissing(): void @@ -109,6 +108,7 @@ protected function createApiRoutesFileIfMissing(): void $apiPath = 'routes/api.php'; if (!$this->filesystem->exists($apiPath)) { $this->filesystem->put($apiPath, $this->filesystem->stub('routes.api.stub')); + $this->configureApiRoutesInAppBootstrap(); } } diff --git a/tests/Feature/Generators/RouteGeneratorTest.php b/tests/Feature/Generators/RouteGeneratorTest.php index 05ea1548..2458bd14 100644 --- a/tests/Feature/Generators/RouteGeneratorTest.php +++ b/tests/Feature/Generators/RouteGeneratorTest.php @@ -143,6 +143,9 @@ public function output_does_not_create_api_routes_file_when_it_exists(): void ->with('routes/api.php', $this->anything()) ->never(); + $this->filesystem->expects('replaceInFile') + ->never(); + $tokens = $this->blueprint->parse($this->fixture('drafts/api-routes-example.yaml')); $tree = $this->blueprint->analyze($tokens);