diff --git a/spec/dependencies/dependency_types.spec.php b/spec/dependencies/dependency_types.spec.php new file mode 100644 index 0000000..1aae91d --- /dev/null +++ b/spec/dependencies/dependency_types.spec.php @@ -0,0 +1,9 @@ +toBe(['themes', 'plugins']); + }); + }); +}); diff --git a/src/Dependencies/DependencyTypes.php b/src/Dependencies/DependencyTypes.php new file mode 100644 index 0000000..e3de5af --- /dev/null +++ b/src/Dependencies/DependencyTypes.php @@ -0,0 +1,16 @@ +isErr()) { return $resultLoad; } - $dependencyTypes = ['themes', 'plugins']; $git = new \Dxw\Whippet\Git\Git($this->dir); $results = []; - foreach ($dependencyTypes as $type) { + foreach (DependencyTypes::getDependencyTypes() as $type) { foreach ($this->lockFile->getDependencies($type) as $dep) { $result = $git::tag_for_commit($dep['src'], $dep['revision']); if ($result->isErr()) { diff --git a/src/Dependencies/Installer.php b/src/Dependencies/Installer.php index f837db2..e76475c 100644 --- a/src/Dependencies/Installer.php +++ b/src/Dependencies/Installer.php @@ -28,7 +28,7 @@ public function installAll() $dependencies = []; - foreach (['themes', 'plugins'] as $type) { + foreach (DependencyTypes::getDependencyTypes() as $type) { $dependencies[$type] = $this->lockFile->getDependencies($type); } diff --git a/src/Dependencies/Updater.php b/src/Dependencies/Updater.php index 37cba7e..d7977dc 100644 --- a/src/Dependencies/Updater.php +++ b/src/Dependencies/Updater.php @@ -57,7 +57,7 @@ public function updateAll() $allDependencies = []; - foreach (['themes', 'plugins'] as $type) { + foreach (DependencyTypes::getDependencyTypes() as $type) { $allDependencies[$type] = $this->jsonFile->getDependencies($type); } @@ -133,7 +133,7 @@ private function updateHash() private function createGitIgnore() { - foreach (['themes', 'plugins'] as $type) { + foreach (DependencyTypes::getDependencyTypes() as $type) { foreach ($this->jsonFile->getDependencies($type) as $dep) { $this->addDependencyToIgnoresArray($type, $dep['name']); } @@ -151,7 +151,7 @@ private function loadGitignore() } // Iterate through locked dependencies and remove from gitignore - foreach (['themes', 'plugins'] as $type) { + foreach (DependencyTypes::getDependencyTypes() as $type) { foreach ($this->lockFile->getDependencies($type) as $dep) { $line = $this->getGitignoreDependencyLine($type, $dep['name']); $index = array_search($line, $this->ignores); diff --git a/src/Dependencies/Validator.php b/src/Dependencies/Validator.php index 17ab56d..209638e 100644 --- a/src/Dependencies/Validator.php +++ b/src/Dependencies/Validator.php @@ -46,7 +46,7 @@ public function validate(bool $enforceRefs = false) // Check that entries in whippet.json // match entries in whippet.lock - foreach (['themes', 'plugins'] as $type) { + foreach (DependencyTypes::getDependencyTypes() as $type) { $whippetJsonDependencies = $whippetJson->getDependencies($type); $whippetLockDependencies = $whippetLock->getDependencies($type); if (count($whippetJsonDependencies) !== count($whippetLockDependencies)) {