From d67b9b4b46e27fbb7ae566743d8e4ef67415e5f0 Mon Sep 17 00:00:00 2001 From: Sai Asish Y Date: Sun, 16 Aug 2026 02:51:44 -0700 Subject: [PATCH] Skip composer repositories without a url when checking for the path repository Signed-off-by: Sai Asish Y --- src/Console/Commands/Make/MakeModule.php | 2 +- tests/Commands/Make/MakeModuleTest.php | 29 ++++++++++++++++++++++++ 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/src/Console/Commands/Make/MakeModule.php b/src/Console/Commands/Make/MakeModule.php index 97bef56..4586072 100644 --- a/src/Console/Commands/Make/MakeModule.php +++ b/src/Console/Commands/Make/MakeModule.php @@ -187,7 +187,7 @@ protected function updateCoreComposerConfig(): void $repository_already_exists = collect($definition['repositories']) ->contains(function($repository) use ($module_config) { - return $repository['url'] === $module_config['url']; + return is_array($repository) && ($repository['url'] ?? null) === $module_config['url']; }); if (false === $repository_already_exists) { diff --git a/tests/Commands/Make/MakeModuleTest.php b/tests/Commands/Make/MakeModuleTest.php index 274743d..654a49a 100644 --- a/tests/Commands/Make/MakeModuleTest.php +++ b/tests/Commands/Make/MakeModuleTest.php @@ -56,6 +56,35 @@ public function test_it_scaffolds_a_new_module(): void $this->assertContains($repository, $app_composer_contents['repositories']); } + public function test_it_ignores_repositories_without_a_url(): void + { + $fs = $this->filesystem(); + $app_composer_file = $this->getApplicationBasePath().'/composer.json'; + $original = $fs->get($app_composer_file); + + $definition = json_decode($original, true); + $definition['repositories'] = [['packagist.org' => false]]; + $fs->put($app_composer_file, json_encode($definition)); + + try { + $this->artisan(MakeModule::class, [ + 'name' => 'test-module', + '--accept-default-namespace' => true, + ])->assertExitCode(0); + + $app_composer_contents = json_decode($fs->get($app_composer_file), true); + + $this->assertContains(['packagist.org' => false], $app_composer_contents['repositories']); + $this->assertContains([ + 'type' => 'path', + 'url' => 'app-modules/*', + 'options' => ['symlink' => true], + ], $app_composer_contents['repositories']); + } finally { + $fs->put($app_composer_file, $original); + } + } + public function test_it_scaffolds_a_new_module_based_on_custom_config(): void { $fs = $this->filesystem();