From 385fe303cc1ea0a3f51206ebdc5df7bbc871b408 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matej=20Ba=C4=8Do?= Date: Sun, 27 Oct 2024 15:48:39 +0100 Subject: [PATCH] Fix leftover fields and attributes --- app/config/collections.php | 11 ----- app/config/site-templates.php | 40 ++++--------------- app/controllers/api/vcs.php | 1 - .../Modules/Sites/Http/Sites/CreateSite.php | 4 +- .../Modules/Sites/Http/Sites/UpdateSite.php | 5 +-- src/Appwrite/Utopia/Response/Model/Site.php | 6 --- .../Response/Model/TemplateFramework.php | 6 --- .../Utopia/Response/Model/TemplateSite.php | 25 ------------ 8 files changed, 10 insertions(+), 88 deletions(-) diff --git a/app/config/collections.php b/app/config/collections.php index 4c9b28ba01..dade8230be 100644 --- a/app/config/collections.php +++ b/app/config/collections.php @@ -3402,17 +3402,6 @@ $projectCollections = array_merge([ 'default' => APP_FUNCTION_SPECIFICATION_DEFAULT, 'filters' => [], ], - [ - '$id' => ID::custom('fallbackRedirect'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 2048, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], [ '$id' => ID::custom('serveRuntime'), 'type' => Database::VAR_STRING, diff --git a/app/config/site-templates.php b/app/config/site-templates.php index f1454433af..36630857b2 100644 --- a/app/config/site-templates.php +++ b/app/config/site-templates.php @@ -2,60 +2,36 @@ const TEMPLATE_FRAMEWORKS = [ 'SVELTEKIT' => [ - 'name' => 'sveltekit' + 'name' => 'Svelte Kit' ], 'NEXTJS' => [ - 'name' => 'nextjs' + 'name' => 'Next.js' ], ]; -function getFramework($framework, $installCommand, $buildCommand, $outputDirectory, $fallbackRedirect, $providerRootDirectory) +function getFramework($framework, $installCommand, $buildCommand, $outputDirectory, $providerRootDirectory) { return [ 'name' => $framework['name'], 'installCommand' => $installCommand, 'buildCommand' => $buildCommand, 'outputDirectory' => $outputDirectory, - 'fallbackRedirect' => $fallbackRedirect, 'providerRootDirectory' => $providerRootDirectory ]; } return [ [ - 'icon' => 'icon-lightning-bolt', 'id' => 'starter', - 'name' => 'Starter site', - 'tagline' => - 'A simple site to get started. Edit this site to explore endless possibilities with Appwrite Sites.', + 'name' => 'Personal portfolio', 'useCases' => ['starter'], 'frameworks' => [ - ...getFramework(TEMPLATE_FRAMEWORKS['SVELTEKIT'], 'npm install', 'npm run build', 'build', 'index.html', 'node/starter') + ...getFramework(TEMPLATE_FRAMEWORKS['SVELTEKIT'], 'npm install --force', 'npm run build', './build', './') ], - 'instructions' => 'For documentation and instructions check out file.', 'vcsProvider' => 'github', - 'providerRepositoryId' => 'templates', - 'providerOwner' => 'appwrite', - 'providerVersion' => '0.2.*', + 'providerRepositoryId' => 'portfolio-walter-o-brien', + 'providerOwner' => 'adityaoberai', + 'providerVersion' => '0.1.*', 'variables' => [], - 'scopes' => ['users.read'] ], - [ - 'icon' => 'icon-lightning-bolt', - 'id' => 'starter1', - 'name' => 'Starter1 site', - 'tagline' => - 'A simple site to get started. Edit this site to explore endless possibilities with Appwrite Sites.', - 'useCases' => ['messaging'], - 'frameworks' => [ - ...getFramework(TEMPLATE_FRAMEWORKS['SVELTEKIT'], 'npm install', 'npm run build', 'build', 'index.html', 'node/starter1') - ], - 'instructions' => 'For documentation and instructions check out file.', - 'vcsProvider' => 'github', - 'providerRepositoryId' => 'templates', - 'providerOwner' => 'appwrite', - 'providerVersion' => '0.2.*', - 'variables' => [], - 'scopes' => ['users.read'] - ] ]; diff --git a/app/controllers/api/vcs.php b/app/controllers/api/vcs.php index 753fd043c8..1a3b891b4c 100644 --- a/app/controllers/api/vcs.php +++ b/app/controllers/api/vcs.php @@ -204,7 +204,6 @@ $createGitDeployments = function (GitHub $github, string $providerInstallationId 'installCommand' => $resource->getAttribute('installCommand', ''), 'buildCommand' => $resource->getAttribute('buildCommand', ''), 'outputDirectory' => $resource->getAttribute('outputDirectory', ''), - 'fallbackRedirect' => $resource->getAttribute('fallbackRedirect', ''), 'type' => 'vcs', 'installationId' => $installationId, 'installationInternalId' => $installationInternalId, diff --git a/src/Appwrite/Platform/Modules/Sites/Http/Sites/CreateSite.php b/src/Appwrite/Platform/Modules/Sites/Http/Sites/CreateSite.php index 65666dddd1..cec416dab0 100644 --- a/src/Appwrite/Platform/Modules/Sites/Http/Sites/CreateSite.php +++ b/src/Appwrite/Platform/Modules/Sites/Http/Sites/CreateSite.php @@ -62,7 +62,6 @@ class CreateSite extends Base ->param('installCommand', '', new Text(8192, 0), 'Install Command.', true) ->param('buildCommand', '', new Text(8192, 0), 'Build Command.', true) ->param('outputDirectory', '', new Text(8192, 0), 'Output Directory for site.', true) - ->param('fallbackRedirect', '', new Text(8192, 0), 'Fallback Redirect URL for site in case a route is not found.', 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) ->param('providerBranch', '', new Text(128, 0), 'Production branch for the repo linked to the site.', true) @@ -90,7 +89,7 @@ class CreateSite extends Base ->callback([$this, 'action']); } - public function action(string $siteId, string $name, string $framework, bool $enabled, string $installCommand, string $buildCommand, string $outputDirectory, string $fallbackRedirect, string $installationId, 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 $dbForConsole, GitHub $github) + public function action(string $siteId, string $name, string $framework, bool $enabled, string $installCommand, string $buildCommand, string $outputDirectory, string $installationId, 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 $dbForConsole, GitHub $github) { $siteId = ($siteId == 'unique()') ? ID::unique() : $siteId; @@ -135,7 +134,6 @@ class CreateSite extends Base 'installCommand' => $installCommand, 'buildCommand' => $buildCommand, 'outputDirectory' => $outputDirectory, - 'fallbackRedirect' => $fallbackRedirect, 'search' => implode(' ', [$siteId, $name, $framework]), 'installationId' => $installation->getId(), 'installationInternalId' => $installation->getInternalId(), diff --git a/src/Appwrite/Platform/Modules/Sites/Http/Sites/UpdateSite.php b/src/Appwrite/Platform/Modules/Sites/Http/Sites/UpdateSite.php index b69eea7452..2e66782b81 100644 --- a/src/Appwrite/Platform/Modules/Sites/Http/Sites/UpdateSite.php +++ b/src/Appwrite/Platform/Modules/Sites/Http/Sites/UpdateSite.php @@ -60,7 +60,6 @@ class UpdateSite extends Base ->param('installCommand', '', new Text(8192, 0), 'Install Command.', true) ->param('buildCommand', '', new Text(8192, 0), 'Build Command.', true) ->param('outputDirectory', '', new Text(8192, 0), 'Output Directory for site.', true) - ->param('fallbackRedirect', '', new Text(8192, 0), 'Fallback Redirect URL for site in case a route is not found.', true) ->param('scopes', [], new ArrayList(new WhiteList(array_keys(Config::getParam('scopes')), true), APP_LIMIT_ARRAY_PARAMS_SIZE), 'List of scopes allowed for API key auto-generated for every execution. Maximum of ' . APP_LIMIT_ARRAY_PARAMS_SIZE . ' scopes are allowed.', true) //TODO: Update description of scopes ->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) @@ -84,7 +83,7 @@ class UpdateSite extends Base ->callback([$this, 'action']); } - public function action(string $siteId, string $name, string $framework, bool $enabled, string $installCommand, string $buildCommand, string $outputDirectory, string $fallbackRedirect, array $scopes, 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 $dbForConsole, GitHub $github) + public function action(string $siteId, string $name, string $framework, bool $enabled, string $installCommand, string $buildCommand, string $outputDirectory, array $scopes, 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 $dbForConsole, GitHub $github) { // TODO: If only branch changes, re-deploy $site = $dbForProject->getDocument('sites', $siteId); @@ -175,7 +174,6 @@ class UpdateSite extends Base $site->getAttribute('buildCommand') !== $buildCommand || $site->getAttribute('installCommand') !== $installCommand || $site->getAttribute('outputDirectory') !== $outputDirectory || - $site->getAttribute('fallbackRedirect') !== $fallbackRedirect || $site->getAttribute('providerRootDirectory') !== $providerRootDirectory || $site->getAttribute('framework') !== $framework ) { @@ -205,7 +203,6 @@ class UpdateSite extends Base 'buildCommand' => $buildCommand, 'installCommand' => $installCommand, 'outputDirectory' => $outputDirectory, - 'fallbackRedirect' => $fallbackRedirect, 'scopes' => $scopes, 'installationId' => $installation->getId(), 'installationInternalId' => $installation->getInternalId(), diff --git a/src/Appwrite/Utopia/Response/Model/Site.php b/src/Appwrite/Utopia/Response/Model/Site.php index f4c16b1219..ff275e30b8 100644 --- a/src/Appwrite/Utopia/Response/Model/Site.php +++ b/src/Appwrite/Utopia/Response/Model/Site.php @@ -83,12 +83,6 @@ class Site extends Model 'default' => '', 'example' => 'build', ]) - ->addRule('fallbackRedirect', [ - 'type' => self::TYPE_STRING, - 'description' => 'The URL to redirect to if the route is not found.', //TODO: Update the description - 'default' => '', - 'example' => 'https://appwrite.io', - ]) ->addRule('installationId', [ 'type' => self::TYPE_STRING, 'description' => 'Site VCS (Version Control System) installation id.', diff --git a/src/Appwrite/Utopia/Response/Model/TemplateFramework.php b/src/Appwrite/Utopia/Response/Model/TemplateFramework.php index 8acfcf0017..6a41233a05 100644 --- a/src/Appwrite/Utopia/Response/Model/TemplateFramework.php +++ b/src/Appwrite/Utopia/Response/Model/TemplateFramework.php @@ -34,12 +34,6 @@ class TemplateFramework extends Model 'default' => '', 'example' => 'build', ]) - ->addRule('fallbackRedirect', [ - 'type' => self::TYPE_STRING, - 'description' => 'The fallback redirect for the site when a route is not found.', - 'default' => '', - 'example' => 'index.html', - ]) ->addRule('providerRootDirectory', [ 'type' => self::TYPE_STRING, 'description' => 'Path to site in VCS (Version Control System) repository', diff --git a/src/Appwrite/Utopia/Response/Model/TemplateSite.php b/src/Appwrite/Utopia/Response/Model/TemplateSite.php index 7eeff22076..ca02fcaf64 100644 --- a/src/Appwrite/Utopia/Response/Model/TemplateSite.php +++ b/src/Appwrite/Utopia/Response/Model/TemplateSite.php @@ -10,12 +10,6 @@ class TemplateSite extends Model public function __construct() { $this - ->addRule('icon', [ - 'type' => self::TYPE_STRING, - 'description' => 'Site Template Icon.', - 'default' => '', - 'example' => 'icon-lightning-bolt', - ]) ->addRule('id', [ 'type' => self::TYPE_STRING, 'description' => 'Site Template ID.', @@ -28,12 +22,6 @@ class TemplateSite extends Model 'default' => '', 'example' => 'Starter site', ]) - ->addRule('tagline', [ - 'type' => self::TYPE_STRING, - 'description' => 'Site Template Tagline.', - 'default' => '', - 'example' => 'A simple site to get started.', - ]) ->addRule('useCases', [ 'type' => self::TYPE_STRING, 'description' => 'Site use cases.', @@ -48,12 +36,6 @@ class TemplateSite extends Model 'example' => [], 'array' => true ]) - ->addRule('instructions', [ - 'type' => self::TYPE_STRING, - 'description' => 'Site Template Instructions.', - 'default' => '', - 'example' => 'For documentation and instructions check out .', - ]) ->addRule('vcsProvider', [ 'type' => self::TYPE_STRING, 'description' => 'VCS (Version Control System) Provider.', @@ -84,13 +66,6 @@ class TemplateSite extends Model 'default' => [], 'example' => [], 'array' => true - ]) - ->addRule('scopes', [ - 'type' => self::TYPE_STRING, - 'description' => 'Site scopes.', - 'default' => [], - 'example' => 'users.read', - 'array' => true, ]); }