From 5f6de45e789e84b22bd45ba78a88507545c9fba6 Mon Sep 17 00:00:00 2001 From: Jesse Leite Date: Tue, 12 Nov 2024 15:46:47 -0500 Subject: [PATCH] Implement `package/composer.json` validation. --- src/StarterKits/Exporter.php | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/StarterKits/Exporter.php b/src/StarterKits/Exporter.php index 472b9b934b..67b0718ac2 100644 --- a/src/StarterKits/Exporter.php +++ b/src/StarterKits/Exporter.php @@ -49,6 +49,7 @@ public function export(): void $this ->validateExportPath() ->validateConfig() + ->validatePackage() ->instantiateModules() ->clearExportPath() ->exportModules() @@ -81,6 +82,22 @@ protected function validateConfig(): self return $this; } + /** + * Validate package folder, if it exists. + */ + protected function validatePackage(): self + { + if (! $this->files->exists(base_path('package'))) { + return $this; + } + + if (! $this->files->exists(base_path('package/composer.json'))) { + throw new StarterKitException('Package config [package/composer.json] does not exist.'); + } + + return $this; + } + /** * Instantiate and validate modules that are to be installed. */