From df604cb2ef241ca72d50956c52b66fb2832cba10 Mon Sep 17 00:00:00 2001 From: Chirag Aggarwal Date: Wed, 4 Mar 2026 13:16:55 +0530 Subject: [PATCH] refactor: derive supported SDKs from config instead of hardcoded array Replace the static supportedSDKS array with a getSupportedSDKs() method that reads SDK keys from the sdks.php config file. This eliminates the need to maintain the list in two places. --- src/Appwrite/Platform/Tasks/SDKs.php | 38 ++++++++++------------------ 1 file changed, 14 insertions(+), 24 deletions(-) diff --git a/src/Appwrite/Platform/Tasks/SDKs.php b/src/Appwrite/Platform/Tasks/SDKs.php index f2103893a9..27095e6ec2 100644 --- a/src/Appwrite/Platform/Tasks/SDKs.php +++ b/src/Appwrite/Platform/Tasks/SDKs.php @@ -41,28 +41,17 @@ use Utopia\Validator\WhiteList; class SDKs extends Action { - protected array $supportedSDKS = [ - 'web', - 'cli', - 'php', - 'nodejs', - 'deno', - 'python', - 'ruby', - 'flutter', - 'react-native', - 'dart', - 'go', - 'swift', - 'apple', - 'dotnet', - 'android', - 'graphql', - 'rest', - 'markdown', - 'agent-skills', - 'cursor-plugin' - ]; + protected function getSupportedSDKs(): array + { + $keys = []; + $platforms = Config::getParam('sdks'); + foreach ($platforms as $platform) { + foreach ($platform['sdks'] as $sdk) { + $keys[] = $sdk['key']; + } + } + return \array_unique($keys); + } public static function getName(): string { @@ -100,8 +89,9 @@ class SDKs extends Action if (! $sdks) { $selectedPlatform ??= Console::confirm('Choose Platform ("' . implode('", "', static::getPlatforms()) . '" or "*" for all):'); $selectedSDK ??= \strtolower(Console::confirm('Choose SDK ("*" for all):')); - if ($selectedSDK !== '*' && ! \in_array($selectedSDK, $this->supportedSDKS)) { - throw new \Exception('Unknown SDK "' . $selectedSDK . '" given. Options are: ' . implode(', ', $this->supportedSDKS)); + $supportedSDKs = $this->getSupportedSDKs(); + if ($selectedSDK !== '*' && ! \in_array($selectedSDK, $supportedSDKs)) { + throw new \Exception('Unknown SDK "' . $selectedSDK . '" given. Options are: ' . implode(', ', $supportedSDKs)); } } else { $sdks = explode(',', $sdks);