Rename site's adapter to rendering

This commit is contained in:
Matej Bačo committed 2025-02-15 00:46:43 +01:00
1 parent da9d442473
commit eaf928ec4c
13 files changed
+61 -61

No files matched your search

+1 -1
View File
@@ -1070,7 +1070,7 @@ return [
'filters' => [],
],
[
'$id' => ID::custom('adapter'), // ssr or static
'$id' => ID::custom('rendering'), // ssr or static
'type' => Database::VAR_STRING,
'format' => '',
'size' => 128,
+7 -7
View File
@@ -23,7 +23,7 @@ return [
'name' => 'Next.js',
'buildRuntime' => 'ssr-22',
'runtimes' => getVersions($templateRuntimes['NODE']['versions'], 'node'),
'adapters' => [
'renderingStrategies' => [
'ssr' => [
'key' => 'ssr',
'buildCommand' => 'npm run build',
@@ -49,7 +49,7 @@ return [
'name' => 'Nuxt',
'buildRuntime' => 'ssr-22',
'runtimes' => getVersions($templateRuntimes['NODE']['versions'], 'node'),
'adapters' => [
'renderingStrategies' => [
'ssr' => [
'key' => 'ssr',
'buildCommand' => 'npm run build',
@@ -75,7 +75,7 @@ return [
'name' => 'SvelteKit',
'buildRuntime' => 'ssr-22',
'runtimes' => getVersions($templateRuntimes['NODE']['versions'], 'node'),
'adapters' => [
'renderingStrategies' => [
'ssr' => [
'key' => 'ssr',
'buildCommand' => 'npm run build',
@@ -101,7 +101,7 @@ return [
'name' => 'Astro',
'buildRuntime' => 'ssr-22',
'runtimes' => getVersions($templateRuntimes['NODE']['versions'], 'node'),
'adapters' => [
'renderingStrategies' => [
'ssr' => [
'key' => 'ssr',
'buildCommand' => 'npm run build',
@@ -127,7 +127,7 @@ return [
'name' => 'Remix',
'buildRuntime' => 'ssr-22',
'runtimes' => getVersions($templateRuntimes['NODE']['versions'], 'node'),
'adapters' => [
'renderingStrategies' => [
'ssr' => [
'key' => 'ssr',
'buildCommand' => 'npm run build',
@@ -153,7 +153,7 @@ return [
'name' => 'Flutter',
'buildRuntime' => 'flutter-3.24',
'runtimes' => getVersions($templateRuntimes['FLUTTER']['versions'], 'flutter'),
'adapters' => [
'renderingStrategies' => [
'static' => [
'key' => 'static',
'buildCommand' => 'flutter build web',
@@ -170,7 +170,7 @@ return [
'name' => 'Other',
'buildRuntime' => 'ssr-22',
'runtimes' => getVersions($templateRuntimes['NODE']['versions'], 'node'),
'adapters' => [
'renderingStrategies' => [
'static' => [
'key' => 'static',
'buildCommand' => '',
+6 -6
View File
@@ -26,7 +26,7 @@ const TEMPLATE_FRAMEWORKS = [
'buildCommand' => 'npm run build',
'outputDirectory' => './build',
'buildRuntime' => 'ssr-22',
'adapter' => 'ssr',
'rendering' => 'ssr',
'fallbackFile' => null,
],
'NEXTJS' => [
@@ -36,7 +36,7 @@ const TEMPLATE_FRAMEWORKS = [
'buildCommand' => 'npm run build',
'outputDirectory' => './.next',
'buildRuntime' => 'ssr-22',
'adapter' => 'ssr',
'rendering' => 'ssr',
'fallbackFile' => null,
],
'NUXT' => [
@@ -46,7 +46,7 @@ const TEMPLATE_FRAMEWORKS = [
'buildCommand' => 'npm run build',
'outputDirectory' => './.output',
'buildRuntime' => 'ssr-22',
'adapter' => 'ssr',
'rendering' => 'ssr',
'fallbackFile' => null,
],
'REMIX' => [
@@ -56,7 +56,7 @@ const TEMPLATE_FRAMEWORKS = [
'buildCommand' => 'npm run build',
'outputDirectory' => './build',
'buildRuntime' => 'ssr-22',
'adapter' => 'ssr',
'rendering' => 'ssr',
'fallbackFile' => null,
],
'ASTRO' => [
@@ -66,7 +66,7 @@ const TEMPLATE_FRAMEWORKS = [
'buildCommand' => 'npm run build',
'outputDirectory' => './dist',
'buildRuntime' => 'ssr-22',
'adapter' => 'ssr',
'rendering' => 'ssr',
'fallbackFile' => null,
],
'FLUTTER' => [
@@ -76,7 +76,7 @@ const TEMPLATE_FRAMEWORKS = [
'buildCommand' => 'flutter build web',
'outputDirectory' => './build/web',
'buildRuntime' => 'flutter-3.24',
'adapter' => 'static',
'rendering' => 'static',
'fallbackFile' => null,
],
];
+4 -4
View File
@@ -216,7 +216,7 @@ function router(App $utopia, Database $dbForPlatform, callable $getProjectDB, Sw
default => null
};
if ($resource->getAttribute('adapter', '') === 'static') {
if ($resource->getAttribute('rendering', '') === 'static') {
$runtime = $runtimes['static-1'] ?? null;
}
@@ -413,9 +413,9 @@ function router(App $utopia, Database $dbForPlatform, callable $getProjectDB, Sw
$startCommand = $runtime['startCommand'];
if (!is_null($framework)) {
$adapter = ($framework['adapters'] ?? [])[$resource->getAttribute('adapter', '')] ?? null;
if (!is_null($adapter) && isset($adapter['startCommand'])) {
$startCommand = $adapter['startCommand'];
$rendering = ($framework['renderingStrategies'] ?? [])[$resource->getAttribute('rendering', '')] ?? null;
if (!is_null($rendering) && isset($rendering['startCommand'])) {
$startCommand = $rendering['startCommand'];
}
}
@@ -876,12 +876,12 @@ class Builds extends Action
$bundleCommand = '';
if (!is_null($framework)) {
$adapter = ($framework['adapters'] ?? [])[$resource->getAttribute('adapter', '')] ?? null;
if (!is_null($adapter) && isset($adapter['envCommand'])) {
$envCommand = $adapter['envCommand'];
$rendering = ($framework['renderingStrategies'] ?? [])[$resource->getAttribute('rendering', '')] ?? null;
if (!is_null($rendering) && isset($rendering['envCommand'])) {
$envCommand = $rendering['envCommand'];
}
if (!is_null($adapter) && isset($adapter['bundleCommand'])) {
$bundleCommand = $adapter['bundleCommand'];
if (!is_null($rendering) && isset($rendering['bundleCommand'])) {
$bundleCommand = $rendering['bundleCommand'];
}
}
@@ -76,7 +76,7 @@ class Create extends Base
->param('outputDirectory', '', new Text(8192, 0), 'Output Directory for site.', true)
->param('subdomain', '', new CustomId(), 'Unique custom sub-domain. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can\'t start with a special char. Max length is 36 chars.', true)
->param('buildRuntime', '', new WhiteList(array_keys(Config::getParam('runtimes')), true), 'Runtime to use during build step.')
->param('adapter', '', new Text(8192, 0), 'Framework adapter. Allows: static, ssr', true)
->param('rendering', '', new Text(8192, 0), 'Framework rendering strategy. Allows: static, ssr', true)
->param('installationId', '', new Text(128, 0), 'Appwrite Installation ID for VCS (Version Control System) deployment.', true)
->param('fallbackFile', '', new Text(255, 0), 'Fallback file for single page application sites.', true)
->param('providerRepositoryId', '', new Text(128, 0), 'Repository ID of the repo linked to the site.', true)
@@ -105,14 +105,14 @@ class Create extends Base
->callback([$this, 'action']);
}
public function action(string $siteId, string $name, string $framework, bool $enabled, int $timeout, string $installCommand, string $buildCommand, string $outputDirectory, string $subdomain, string $buildRuntime, string $adapter, string $installationId, ?string $fallbackFile, string $providerRepositoryId, string $providerBranch, bool $providerSilentMode, string $providerRootDirectory, string $templateRepository, string $templateOwner, string $templateRootDirectory, string $templateVersion, string $specification, Request $request, Response $response, Database $dbForProject, Document $project, Document $user, Event $queueForEvents, Build $queueForBuilds, Database $dbForPlatform, GitHub $github)
public function action(string $siteId, string $name, string $framework, bool $enabled, int $timeout, string $installCommand, string $buildCommand, string $outputDirectory, string $subdomain, string $buildRuntime, string $rendering, string $installationId, ?string $fallbackFile, string $providerRepositoryId, string $providerBranch, bool $providerSilentMode, string $providerRootDirectory, string $templateRepository, string $templateOwner, string $templateRootDirectory, string $templateVersion, string $specification, Request $request, Response $response, Database $dbForProject, Document $project, Document $user, Event $queueForEvents, Build $queueForBuilds, Database $dbForPlatform, GitHub $github)
{
if (!empty($adapter)) {
if (!empty($rendering)) {
$configFramework = Config::getParam('frameworks')[$framework] ?? [];
$adapters = \array_keys($configFramework['adapters'] ?? []);
$validator = new WhiteList($adapters, true);
if (!$validator->isValid($adapter)) {
throw new Exception(Exception::GENERAL_ARGUMENT_INVALID, 'Adapter not supported for the selected framework.');
$renderingStraregies = \array_keys($configFramework['renderingStrategies'] ?? []);
$validator = new WhiteList($renderingStraregies, true);
if (!$validator->isValid($rendering)) {
throw new Exception(Exception::GENERAL_ARGUMENT_INVALID, 'Rendering strategy not supported for the selected framework.');
}
}
@@ -187,7 +187,7 @@ class Create extends Base
'providerSilentMode' => $providerSilentMode,
'specification' => $specification,
'buildRuntime' => $buildRuntime,
'adapter' => $adapter,
'rendering' => $rendering,
]));
// Git connect logic
@@ -73,7 +73,7 @@ class Update extends Base
->param('buildCommand', '', new Text(8192, 0), 'Build Command.', true)
->param('outputDirectory', '', new Text(8192, 0), 'Output Directory for site.', true)
->param('buildRuntime', '', new WhiteList(array_keys(Config::getParam('runtimes')), true), 'Runtime to use during build step.', true)
->param('adapter', '', new Text(8192, 0), 'Framework adapter. Usuallly allows: static, ssr', true)
->param('rendering', '', new Text(8192, 0), 'Framework rendering strategy. Usuallly allows: static, ssr', true)
->param('fallbackFile', '', new Text(255, 0), 'Fallback file for single page application sites.', true)
->param('installationId', '', new Text(128, 0), 'Appwrite Installation ID for VCS (Version Control System) deployment.', true)
->param('providerRepositoryId', '', new Text(128, 0), 'Repository ID of the repo linked to the site.', true)
@@ -97,14 +97,14 @@ class Update extends Base
->callback([$this, 'action']);
}
public function action(string $siteId, string $name, string $framework, bool $enabled, int $timeout, string $installCommand, string $buildCommand, string $outputDirectory, string $buildRuntime, string $adapter, ?string $fallbackFile, string $installationId, ?string $providerRepositoryId, string $providerBranch, bool $providerSilentMode, string $providerRootDirectory, string $specification, Request $request, Response $response, Database $dbForProject, Document $project, Event $queueForEvents, Build $queueForBuilds, Database $dbForPlatform, GitHub $github)
public function action(string $siteId, string $name, string $framework, bool $enabled, int $timeout, string $installCommand, string $buildCommand, string $outputDirectory, string $buildRuntime, string $rendering, ?string $fallbackFile, string $installationId, ?string $providerRepositoryId, string $providerBranch, bool $providerSilentMode, string $providerRootDirectory, string $specification, Request $request, Response $response, Database $dbForProject, Document $project, Event $queueForEvents, Build $queueForBuilds, Database $dbForPlatform, GitHub $github)
{
if (!empty($adapter)) {
if (!empty($rendering)) {
$configFramework = Config::getParam('frameworks')[$framework] ?? [];
$adapters = \array_keys($configFramework['adapters'] ?? []);
$validator = new WhiteList($adapters, true);
if (!$validator->isValid($adapter)) {
throw new Exception(Exception::GENERAL_ARGUMENT_INVALID, 'Adapter not supported for the selected framework.');
$renderingStrategies = \array_keys($configFramework['renderingStrategies'] ?? []);
$validator = new WhiteList($renderingStrategies, true);
if (!$validator->isValid($rendering)) {
throw new Exception(Exception::GENERAL_ARGUMENT_INVALID, 'Rendering strategy not supported for the selected framework.');
}
}
@@ -238,7 +238,7 @@ class Update extends Base
'specification' => $specification,
'search' => implode(' ', [$siteId, $name, $framework]),
'buildRuntime' => $buildRuntime,
'adapter' => $adapter,
'rendering' => $rendering,
'fallbackFile' => $fallbackFile,
])));
+3 -3
View File
@@ -45,7 +45,7 @@ use Appwrite\Utopia\Response\Model\ErrorDev;
use Appwrite\Utopia\Response\Model\Execution;
use Appwrite\Utopia\Response\Model\File;
use Appwrite\Utopia\Response\Model\Framework;
use Appwrite\Utopia\Response\Model\FrameworkAdapter;
use Appwrite\Utopia\Response\Model\FrameworkRendering;
use Appwrite\Utopia\Response\Model\Func;
use Appwrite\Utopia\Response\Model\Headers;
use Appwrite\Utopia\Response\Model\HealthAntivirus;
@@ -258,7 +258,7 @@ class Response extends SwooleResponse
public const MODEL_SITE_LIST = 'siteList';
public const MODEL_FRAMEWORK = 'framework';
public const MODEL_FRAMEWORK_LIST = 'frameworkList';
public const MODEL_FRAMEWORK_ADAPTER = 'frameworkAdapter';
public const MODEL_FRAMEWORK_RENDERING = 'frameworkRendering';
public const MODEL_TEMPLATE_SITE = 'templateSite';
public const MODEL_TEMPLATE_SITE_LIST = 'templateSiteList';
public const MODEL_TEMPLATE_FRAMEWORK = 'templateFramework';
@@ -458,7 +458,7 @@ class Response extends SwooleResponse
->setModel(new Branch())
->setModel(new Runtime())
->setModel(new Framework())
->setModel(new FrameworkAdapter())
->setModel(new FrameworkRendering())
->setModel(new Deployment())
->setModel(new Execution())
->setModel(new Build())
@@ -35,9 +35,9 @@ class Framework extends Model
'example' => ['static-1', 'node-22'],
'array' => true,
])
->addRule('adapters', [
'type' => Response::MODEL_FRAMEWORK_ADAPTER,
'description' => 'List of supported adapters.',
->addRule('renderingStrategies', [
'type' => Response::MODEL_FRAMEWORK_RENDERING,
'description' => 'List of supported rendering strategies.',
'default' => '',
'example' => [[ 'key' => 'static', 'buildRuntime' => 'node-22', 'buildCommand' => 'npm run build', 'installCommand' => 'npm install', 'outputDirectory' => './dist' ]],
'array' => true,
@@ -5,7 +5,7 @@ namespace Appwrite\Utopia\Response\Model;
use Appwrite\Utopia\Response;
use Appwrite\Utopia\Response\Model;
class FrameworkAdapter extends Model
class FrameworkRendering extends Model
{
public function __construct()
{
@@ -44,7 +44,7 @@ class FrameworkAdapter extends Model
*/
public function getName(): string
{
return 'Framework Adapter';
return 'Framework Rendering';
}
/**
@@ -54,6 +54,6 @@ class FrameworkAdapter extends Model
*/
public function getType(): string
{
return Response::MODEL_FRAMEWORK_ADAPTER;
return Response::MODEL_FRAMEWORK_RENDERING;
}
}
+2 -2
View File
@@ -131,9 +131,9 @@ class Site extends Model
'default' => '',
'example' => 'node-22',
])
->addRule('adapter', [
->addRule('rendering', [
'type' => self::TYPE_STRING,
'description' => 'Site framework adapter.',
'description' => 'Site framework rendering strategy (adapter).',
'default' => null,
'example' => 'static',
])
@@ -52,9 +52,9 @@ class TemplateFramework extends Model
'default' => '',
'example' => 'node-22',
])
->addRule('adapter', [
->addRule('rendering', [
'type' => self::TYPE_STRING,
'description' => 'Site framework runtime',
'description' => 'Site framework rendering strategy',
'default' => '',
'example' => 'ssr',
])
@@ -279,7 +279,7 @@ class SitesCustomServerTest extends Scope
'siteId' => ID::unique(),
'name' => 'Astro site',
'framework' => 'astro',
'adapter' => 'ssr',
'rendering' => 'ssr',
'buildRuntime' => 'ssr-22',
'outputDirectory' => './dist',
'buildCommand' => 'npm run build',
@@ -559,7 +559,7 @@ class SitesCustomServerTest extends Scope
'siteId' => ID::unique(),
'name' => $starterTemplate['body']['name'],
'framework' => $nextjsFramework['key'],
'adapter' => $nextjsFramework['adapter'],
'rendering' => $nextjsFramework['rendering'],
'buildCommand' => $nextjsFramework['buildCommand'],
'buildRuntime' => $nextjsFramework['buildRuntime'],
'fallbackFile' => $nextjsFramework['fallbackFile'],
@@ -1194,7 +1194,7 @@ class SitesCustomServerTest extends Scope
$this->assertArrayHasKey('key', $framework);
$this->assertArrayHasKey('buildRuntime', $framework);
$this->assertArrayHasKey('runtimes', $framework);
$this->assertArrayHasKey('adapters', $framework);
$this->assertArrayHasKey('renderingStrategies', $framework);
}
public function testSiteTemplate(): void
@@ -1208,7 +1208,7 @@ class SitesCustomServerTest extends Scope
'siteId' => ID::unique(),
'name' => 'Template site',
'framework' => $template['frameworks'][0]['key'],
'adapter' => $template['frameworks'][0]['adapter'],
'rendering' => $template['frameworks'][0]['rendering'],
'buildRuntime' => $template['frameworks'][0]['buildRuntime'],
'outputDirectory' => $template['frameworks'][0]['outputDirectory'],
'buildCommand' => $template['frameworks'][0]['buildCommand'],
@@ -1258,7 +1258,7 @@ class SitesCustomServerTest extends Scope
'siteId' => ID::unique(),
'name' => 'Startup site',
'framework' => 'other',
'adapter' => 'static',
'rendering' => 'static',
'buildRuntime' => 'static-1',
'outputDirectory' => './',
'buildCommand' => '',
@@ -1292,7 +1292,7 @@ class SitesCustomServerTest extends Scope
'siteId' => ID::unique(),
'name' => 'Startup 2 site',
'framework' => 'other',
'adapter' => 'static',
'rendering' => 'static',
'buildRuntime' => 'static-1',
'outputDirectory' => './',
'buildCommand' => '',
@@ -1332,7 +1332,7 @@ class SitesCustomServerTest extends Scope
'siteId' => ID::unique(),
'name' => 'Startup 2 site',
'framework' => 'other',
'adapter' => 'static',
'rendering' => 'static',
'buildRuntime' => 'static-1',
'outputDirectory' => './',
'buildCommand' => '',
@@ -1352,7 +1352,7 @@ class SitesCustomServerTest extends Scope
'siteId' => ID::unique(),
'name' => 'A site',
'framework' => 'other',
'adapter' => 'static',
'rendering' => 'static',
'buildRuntime' => 'static-1',
'outputDirectory' => './',
'buildCommand' => '',
@@ -1414,7 +1414,7 @@ class SitesCustomServerTest extends Scope
'siteId' => ID::unique(),
'name' => 'Startup site',
'framework' => 'other',
'adapter' => 'static',
'rendering' => 'static',
'buildRuntime' => 'static-1',
'outputDirectory' => './',
'buildCommand' => '',