From 8897ccee7f5c8025a69485366c12596538cedd54 Mon Sep 17 00:00:00 2001 From: Duncan McClean Date: Wed, 2 Sep 2026 18:24:05 +0100 Subject: [PATCH] load installed starter kit config files into the running app Co-Authored-By: Claude Fable 5.1 Claude-Session: https://claude.ai/code/session_01P8oP7YLEc2PqCXo9aCRdna --- src/StarterKits/InstallableModule.php | 17 +++++++++++++++++ tests/StarterKits/InstallTest.php | 14 ++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/src/StarterKits/InstallableModule.php b/src/StarterKits/InstallableModule.php index fb42f5503b4..0beb51462ae 100644 --- a/src/StarterKits/InstallableModule.php +++ b/src/StarterKits/InstallableModule.php @@ -74,11 +74,28 @@ protected function installFiles(): self { $this->installableFiles()->each(function ($toPath, $fromPath) { $this->installFile($fromPath, $toPath, $this->installer->console()); + $this->loadInstalledConfig($toPath); }); return $this; } + /** + * Load installed config file into the running app, so later install steps see it. + */ + private function loadInstalledConfig(string $path): void + { + $configPath = Path::tidy(config_path()).'/'; + + if (! Str::startsWith($path, $configPath) || ! Str::endsWith($path, '.php')) { + return; + } + + $key = Str::of($path)->after($configPath)->beforeLast('.php')->replace('/', '.')->toString(); + + config()->set($key, array_merge(config($key, []), require $path)); + } + /** * Install starter kit module dependencies. */ diff --git a/tests/StarterKits/InstallTest.php b/tests/StarterKits/InstallTest.php index 29969ee5be6..fff7b9bbb71 100644 --- a/tests/StarterKits/InstallTest.php +++ b/tests/StarterKits/InstallTest.php @@ -118,6 +118,20 @@ public function it_installs_from_export_paths() $this->assertFileHasContent('bobsled_pics', config_path('filesystems.php')); } + #[Test] + public function it_loads_installed_config_files_into_the_running_app() + { + $this->files->put($this->preparePath($this->kitRepoPath('config/statamic/hockey.php')), " 'calgary'];"); + + $this->assertNull(config('filesystems.disks.bobsled_pics')); + $this->assertNull(config('statamic.hockey')); + + $this->installCoolRunnings(); + + $this->assertEquals('local', config('filesystems.disks.bobsled_pics.driver')); + $this->assertEquals('calgary', config('statamic.hockey.rink')); + } + #[Test] public function it_installs_from_github() {