From 413157f32bfbb49b11b1edb177a72f29aa9082ff Mon Sep 17 00:00:00 2001 From: harsh mahajan Date: Mon, 15 Jun 2026 13:01:55 +0530 Subject: [PATCH 1/4] fix: return default adapter in framework detection response --- .../Repositories/Detections/Create.php | 5 +++++ .../Response/Model/DetectionFramework.php | 6 ++++++ .../e2e/Services/VCS/VCSConsoleClientTest.php | 19 +++++++++++++++++++ 3 files changed, 30 insertions(+) diff --git a/src/Appwrite/Platform/Modules/VCS/Http/Installations/Repositories/Detections/Create.php b/src/Appwrite/Platform/Modules/VCS/Http/Installations/Repositories/Detections/Create.php index 4da5699a4e..eefae34b09 100644 --- a/src/Appwrite/Platform/Modules/VCS/Http/Installations/Repositories/Detections/Create.php +++ b/src/Appwrite/Platform/Modules/VCS/Http/Installations/Repositories/Detections/Create.php @@ -160,6 +160,7 @@ class Create extends Action 'installCommand' => '', 'buildCommand' => '', 'outputDirectory' => '', + 'adapter' => '', ]); $detector = new Framework($packager); @@ -203,6 +204,10 @@ class Create extends Action $framework = 'other'; } $output->setAttribute('framework', $framework); + + $frameworkConfig = $frameworks[$framework] ?? []; + $defaultAdapter = \array_key_first($frameworkConfig['adapters'] ?? []) ?? ''; + $output->setAttribute('adapter', $defaultAdapter); } else { $output = new Document([ 'runtime' => '', diff --git a/src/Appwrite/Utopia/Response/Model/DetectionFramework.php b/src/Appwrite/Utopia/Response/Model/DetectionFramework.php index 00f318ba4a..873839dae4 100644 --- a/src/Appwrite/Utopia/Response/Model/DetectionFramework.php +++ b/src/Appwrite/Utopia/Response/Model/DetectionFramework.php @@ -38,6 +38,12 @@ class DetectionFramework extends Detection 'description' => 'Site Output Directory', 'default' => '', 'example' => 'dist', + ]) + ->addRule('adapter', [ + 'type' => self::TYPE_STRING, + 'description' => 'Site Adapter', + 'default' => '', + 'example' => 'ssr', ]); } diff --git a/tests/e2e/Services/VCS/VCSConsoleClientTest.php b/tests/e2e/Services/VCS/VCSConsoleClientTest.php index 513d2c1824..4c129ec953 100644 --- a/tests/e2e/Services/VCS/VCSConsoleClientTest.php +++ b/tests/e2e/Services/VCS/VCSConsoleClientTest.php @@ -185,6 +185,7 @@ final class VCSConsoleClientTest extends Scope $this->assertEquals('npm install', $framework['body']['installCommand']); $this->assertEquals('npm run build', $framework['body']['buildCommand']); $this->assertEquals('./build', $framework['body']['outputDirectory']); + $this->assertEquals('ssr', $framework['body']['adapter']); $framework = $this->client->call(Client::METHOD_POST, '/vcs/github/installations/' . $installationId . '/detections', array_merge([ 'x-appwrite-project' => $this->getProject()['$id'], @@ -200,6 +201,7 @@ final class VCSConsoleClientTest extends Scope $this->assertEquals('npm install', $framework['body']['installCommand']); $this->assertEquals('npm run build', $framework['body']['buildCommand']); $this->assertEquals('./dist', $framework['body']['outputDirectory']); + $this->assertEquals('ssr', $framework['body']['adapter']); $framework = $this->client->call(Client::METHOD_POST, '/vcs/github/installations/' . $installationId . '/detections', array_merge([ 'x-appwrite-project' => $this->getProject()['$id'], @@ -215,6 +217,23 @@ final class VCSConsoleClientTest extends Scope $this->assertEquals('npm install', $framework['body']['installCommand']); $this->assertEquals('npm run build', $framework['body']['buildCommand']); $this->assertEquals('./build', $framework['body']['outputDirectory']); + $this->assertEquals('ssr', $framework['body']['adapter']); + + $framework = $this->client->call(Client::METHOD_POST, '/vcs/github/installations/' . $installationId . '/detections', array_merge([ + 'x-appwrite-project' => $this->getProject()['$id'], + 'content-type' => 'application/json', + ], $this->getHeaders()), [ + 'providerRepositoryId' => $this->providerRepositoryId4, + 'type' => 'framework', + 'providerRootDirectory' => 'tanstack-start/starter' + ]); + + $this->assertEquals(200, $framework['headers']['status-code']); + $this->assertEquals('tanstack-start', $framework['body']['framework']); + $this->assertEquals('npm install', $framework['body']['installCommand']); + $this->assertEquals('npm run build', $framework['body']['buildCommand']); + $this->assertEquals('./.output', $framework['body']['outputDirectory']); + $this->assertEquals('ssr', $framework['body']['adapter']); /** * Test for FAILURE From 134d94d0eb8e005cd14ee8d7cae63311772011d4 Mon Sep 17 00:00:00 2001 From: harsh mahajan Date: Wed, 17 Jun 2026 13:51:59 +0530 Subject: [PATCH 2/4] feat: detect framework adapter from config files pre-build - Add adapter field to detection endpoint response - Read framework config files from GitHub to detect SSR/static adapter - Uses utopia-php/detector 0.2.5 getConfigFiles()/getAdapter() hooks - Falls back to framework config default when detection is inconclusive - Short-circuit package.json fetch using already-fetched packages content --- composer.lock | 12 ++--- .../Repositories/Detections/Create.php | 45 +++++++++++++++---- 2 files changed, 43 insertions(+), 14 deletions(-) diff --git a/composer.lock b/composer.lock index 703189e5f9..2ceccec441 100644 --- a/composer.lock +++ b/composer.lock @@ -3742,16 +3742,16 @@ }, { "name": "utopia-php/detector", - "version": "0.2.4", + "version": "0.2.5", "source": { "type": "git", "url": "https://github.com/utopia-php/detector.git", - "reference": "a564381108518ce6d18b6ab441f1448bd8355afd" + "reference": "20f7e2ea8084176fae88a473f82f410281978a3b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/detector/zipball/a564381108518ce6d18b6ab441f1448bd8355afd", - "reference": "a564381108518ce6d18b6ab441f1448bd8355afd", + "url": "https://api.github.com/repos/utopia-php/detector/zipball/20f7e2ea8084176fae88a473f82f410281978a3b", + "reference": "20f7e2ea8084176fae88a473f82f410281978a3b", "shasum": "" }, "require": { @@ -3781,9 +3781,9 @@ ], "support": { "issues": "https://github.com/utopia-php/detector/issues", - "source": "https://github.com/utopia-php/detector/tree/0.2.4" + "source": "https://github.com/utopia-php/detector/tree/0.2.5" }, - "time": "2026-02-17T11:26:34+00:00" + "time": "2026-06-17T08:16:37+00:00" }, { "name": "utopia-php/di", diff --git a/src/Appwrite/Platform/Modules/VCS/Http/Installations/Repositories/Detections/Create.php b/src/Appwrite/Platform/Modules/VCS/Http/Installations/Repositories/Detections/Create.php index eefae34b09..2bcdf09dc3 100644 --- a/src/Appwrite/Platform/Modules/VCS/Http/Installations/Repositories/Detections/Create.php +++ b/src/Appwrite/Platform/Modules/VCS/Http/Installations/Repositories/Detections/Create.php @@ -191,23 +191,51 @@ class Create extends Action $output->setAttribute('installCommand', $framework->getInstallCommand()); $output->setAttribute('buildCommand', $framework->getBuildCommand()); $output->setAttribute('outputDirectory', $framework->getOutputDirectory()); - $framework = $framework->getName(); + $frameworkName = $framework->getName(); + + $configContent = ''; + foreach ($framework->getConfigFiles() as $configFile) { + if ($configFile === 'package.json') { + $configContent = $packages; + break; + } + if (!\in_array($configFile, $files, true)) { + continue; + } + try { + $configPath = \rtrim($providerRootDirectory, '/') . '/' . $configFile; + $configResponse = $github->getRepositoryContent($owner, $repositoryName, $configPath); + $configContent = $configResponse['content'] ?? ''; + if (!empty($configContent)) { + break; + } + } catch (FileNotFound $e) { + // Try next config file + } + } + + $detectedAdapter = !empty($configContent) ? $framework->getAdapter($configContent) : ''; } else { - $framework = 'other'; + $frameworkName = 'other'; + $detectedAdapter = ''; $output->setAttribute('installCommand', ''); $output->setAttribute('buildCommand', ''); $output->setAttribute('outputDirectory', ''); } $frameworks = Config::getParam('frameworks'); - if (!\in_array($framework, \array_keys($frameworks), true)) { - $framework = 'other'; + if (!\in_array($frameworkName, \array_keys($frameworks), true)) { + $frameworkName = 'other'; } - $output->setAttribute('framework', $framework); + $output->setAttribute('framework', $frameworkName); - $frameworkConfig = $frameworks[$framework] ?? []; - $defaultAdapter = \array_key_first($frameworkConfig['adapters'] ?? []) ?? ''; - $output->setAttribute('adapter', $defaultAdapter); + $frameworkConfig = $frameworks[$frameworkName] ?? []; + if (!empty($frameworkConfig['adapters'])) { + $adapter = (!empty($detectedAdapter) && isset($frameworkConfig['adapters'][$detectedAdapter])) + ? $detectedAdapter + : \array_key_first($frameworkConfig['adapters']); + $output->setAttribute('adapter', $adapter); + } } else { $output = new Document([ 'runtime' => '', @@ -318,4 +346,5 @@ class Create extends Action $response->dynamic($output, $type === 'framework' ? Response::MODEL_DETECTION_FRAMEWORK : Response::MODEL_DETECTION_RUNTIME); } + } From bcf2be9c969946b02489f1b919365ed8ec697706 Mon Sep 17 00:00:00 2001 From: harsh mahajan Date: Wed, 17 Jun 2026 13:56:00 +0530 Subject: [PATCH 3/4] fix: remove redundant comments and no-op attribute assignments --- .../Http/Installations/Repositories/Detections/Create.php | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/Appwrite/Platform/Modules/VCS/Http/Installations/Repositories/Detections/Create.php b/src/Appwrite/Platform/Modules/VCS/Http/Installations/Repositories/Detections/Create.php index 2bcdf09dc3..f80e400bde 100644 --- a/src/Appwrite/Platform/Modules/VCS/Http/Installations/Repositories/Detections/Create.php +++ b/src/Appwrite/Platform/Modules/VCS/Http/Installations/Repositories/Detections/Create.php @@ -152,7 +152,6 @@ class Create extends Action $contentResponse = $github->getRepositoryContent($owner, $repositoryName, \rtrim($providerRootDirectory, '/') . '/package.json'); $packages = $contentResponse['content'] ?? ''; } catch (FileNotFound $e) { - // Continue detection without package.json } $output = new Document([ @@ -210,7 +209,6 @@ class Create extends Action break; } } catch (FileNotFound $e) { - // Try next config file } } @@ -218,9 +216,6 @@ class Create extends Action } else { $frameworkName = 'other'; $detectedAdapter = ''; - $output->setAttribute('installCommand', ''); - $output->setAttribute('buildCommand', ''); - $output->setAttribute('outputDirectory', ''); } $frameworks = Config::getParam('frameworks'); From bbf6bb603b0b577b5fbf3afe620a6a2cbaa49339 Mon Sep 17 00:00:00 2001 From: harsh mahajan Date: Wed, 17 Jun 2026 14:06:22 +0530 Subject: [PATCH 4/4] fix: remove package.json special-case in config file loop --- .../VCS/Http/Installations/Repositories/Detections/Create.php | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/Appwrite/Platform/Modules/VCS/Http/Installations/Repositories/Detections/Create.php b/src/Appwrite/Platform/Modules/VCS/Http/Installations/Repositories/Detections/Create.php index f80e400bde..eaf3834036 100644 --- a/src/Appwrite/Platform/Modules/VCS/Http/Installations/Repositories/Detections/Create.php +++ b/src/Appwrite/Platform/Modules/VCS/Http/Installations/Repositories/Detections/Create.php @@ -194,10 +194,6 @@ class Create extends Action $configContent = ''; foreach ($framework->getConfigFiles() as $configFile) { - if ($configFile === 'package.json') { - $configContent = $packages; - break; - } if (!\in_array($configFile, $files, true)) { continue; }