fix: return default adapter in framework detection response

This commit is contained in:
harsh mahajan committed 2026-06-15 13:01:55 +05:30
1 parent b242caa32b
commit 413157f32b
3 files changed
+30

No files matched your search

@@ -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' => '',
@@ -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',
]);
}
@@ -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