From d80731e7dbbd160f37dea6b1ad952928e8e9a9b2 Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Wed, 11 Dec 2024 19:14:10 +1300 Subject: [PATCH] Allow pushing SDK to new branches --- src/Appwrite/Platform/Tasks/SDKs.php | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/src/Appwrite/Platform/Tasks/SDKs.php b/src/Appwrite/Platform/Tasks/SDKs.php index 6e37f270a4..126dcd7fb4 100644 --- a/src/Appwrite/Platform/Tasks/SDKs.php +++ b/src/Appwrite/Platform/Tasks/SDKs.php @@ -41,15 +41,15 @@ class SDKs extends Action $this ->desc('Generate Appwrite SDKs') ->param('platform', null, new Nullable(new Text(256)), 'Selected Platform', optional: true) - ->param('sdk', null, new Nullable(new Text(256)), 'Selected SDK', optional:true) - ->param('version', null, new Nullable(new Text(256)), 'Selected SDK', optional:true) + ->param('sdk', null, new Nullable(new Text(256)), 'Selected SDK', optional: true) + ->param('version', null, new Nullable(new Text(256)), 'Selected SDK', optional: true) ->param('git', null, new Nullable(new WhiteList(['yes', 'no'])), 'Should we use git push?', optional: true) - ->param('production', null, new Nullable(new WhiteList(['yes', 'no'])), 'Should we push to production?', optional:true) - ->param('message', null, new Nullable(new Text(256)), 'Commit Message', optional:true) + ->param('production', null, new Nullable(new WhiteList(['yes', 'no'])), 'Should we push to production?', optional: true) + ->param('message', null, new Nullable(new Text(256)), 'Commit Message', optional: true) ->callback([$this, 'action']); } - public function action(?string $selectedPlatform, ?string $selectedSDK, ?string $version, ?string $git, ?string $production, ?string $message) + public function action(?string $selectedPlatform, ?string $selectedSDK, ?string $version, ?string $git, ?string $production, ?string $message): void { $selectedPlatform ??= Console::confirm('Choose Platform ("' . APP_PLATFORM_CLIENT . '", "' . APP_PLATFORM_SERVER . '", "' . APP_PLATFORM_CONSOLE . '" or "*" for all):'); $selectedSDK ??= \strtolower(Console::confirm('Choose SDK ("*" for all):')); @@ -275,9 +275,13 @@ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND \exec('rm -rf ' . $target . ' && \ mkdir -p ' . $target . ' && \ cd ' . $target . ' && \ - git init --initial-branch=' . $gitBranch . ' && \ + git init && \ git remote add origin ' . $gitUrl . ' && \ - git fetch origin ' . $gitBranch . ' && \ + git fetch origin && \ + git checkout main || git checkout -b main && \ + git pull origin main && \ + git checkout ' . $gitBranch . ' || git checkout -b ' . $gitBranch . ' && \ + git fetch origin ' . $gitBranch . ' || git push -u origin ' . $gitBranch . ' && \ git pull origin ' . $gitBranch . ' && \ rm -rf ' . $target . '/* && \ cp -r ' . $result . '/. ' . $target . '/ && \