From 413157f32bfbb49b11b1edb177a72f29aa9082ff Mon Sep 17 00:00:00 2001 From: harsh mahajan Date: Mon, 15 Jun 2026 13:01:55 +0530 Subject: [PATCH] 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