Skip to content

Commit

Permalink
Remove import: ‘@config syntax, and implicitly import instead.
Browse files Browse the repository at this point in the history
  • Loading branch information
jesseleite committed Nov 11, 2024
1 parent 37b10c2 commit 5ded91e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
12 changes: 11 additions & 1 deletion src/StarterKits/InstallableModules.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ protected function instantiateModuleRecursively(Collection|array|string $config,
{
if ($imported = $config === '@import') {
$config = $this->importModuleConfig($key);
} elseif ($imported = Arr::get($config, 'import') === '@config') {
} elseif ($imported = $this->moduleConfigExists($key)) {
$config = $this->importModuleConfig($key)->merge($config);
}

Expand Down Expand Up @@ -170,6 +170,16 @@ protected function relativeModulePath(string $key, ?string $path = null): string
: $base;
}

/**
* Determine whether module config exists.
*/
protected function moduleConfigExists(string $key): bool
{
return $this->files->exists(
$this->starterKitPath($this->relativeModulePath($key, 'module.yaml'))
);
}

/**
* Scope installable files to imported module.
*/
Expand Down
6 changes: 3 additions & 3 deletions tests/StarterKits/InstallTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1120,14 +1120,14 @@ public function it_can_merge_imported_module_config_with_starter_kit_config()
'modules' => [
'seo' => [
'prompt' => 'Want some extra SEO magic?', // handle prompt flow here
'import' => '@config', // but import and merge rest of config
// implicitly import and merge rest of config in here
],
'js' => [
'prompt' => 'Want one of these fancy JS options?',
'options' => [
'react' => [
'label' => 'React JS', // handle prompt option label here
'import' => '@config', // but import and merge rest of config
// implicitly import and merge rest of config in here
],
'svelte' => [
'export_paths' => [
Expand All @@ -1154,7 +1154,7 @@ public function it_can_merge_imported_module_config_with_starter_kit_config()
config: [
'label' => 'This should not get used, because prompt config in starter-kit.yaml takes precedence!',
'export_paths' => [
$this->moveKitRepoFile('modules/js/react', 'resources/js/react.js'),
$this->moveKitRepoFile('modules/js/react', 'resources/js/react.js'), // but this should still be imported and installed
],
],
);
Expand Down

0 comments on commit 5ded91e

Please sign in to comment.