mirror of
https://github.com/appwrite/appwrite
synced 2026-05-24 09:28:40 +00:00
Merge branch 'feat-sites' into chore-add-tests-for-empty-output-dir
This commit is contained in:
commit
2acce83257
4 changed files with 72 additions and 143 deletions
|
|
@ -143,80 +143,80 @@ function getFramework(string $frameworkEnum, array $overrides)
|
||||||
}
|
}
|
||||||
|
|
||||||
return [
|
return [
|
||||||
[
|
[
|
||||||
'key' => 'nxt-lnk',
|
'key' => 'nxt-lnk',
|
||||||
'name' => 'Nxt Lnk',
|
'name' => 'Nxt Lnk',
|
||||||
'useCases' => ['portfolio'],
|
'useCases' => ['portfolio'],
|
||||||
'screenshotDark' => $url . '/images/sites/templates/nxt-lnk-dark.png',
|
'screenshotDark' => $url . '/images/sites/templates/nxt-lnk-dark.png',
|
||||||
'screenshotLight' => $url . '/images/sites/templates/nxt-lnk-light.png',
|
'screenshotLight' => $url . '/images/sites/templates/nxt-lnk-light.png',
|
||||||
'frameworks' => [
|
'frameworks' => [
|
||||||
getFramework('NEXTJS', [
|
getFramework('NEXTJS', [
|
||||||
'providerRootDirectory' => './nextjs/nxtlnk',
|
'providerRootDirectory' => './nextjs/nxtlnk',
|
||||||
]),
|
]),
|
||||||
|
],
|
||||||
|
'vcsProvider' => 'github',
|
||||||
|
'providerRepositoryId' => 'templates-for-sites',
|
||||||
|
'providerOwner' => 'appwrite',
|
||||||
|
'providerVersion' => '0.3.*',
|
||||||
|
'variables' => []
|
||||||
],
|
],
|
||||||
'vcsProvider' => 'github',
|
|
||||||
'providerRepositoryId' => 'templates-for-sites',
|
|
||||||
'providerOwner' => 'appwrite',
|
|
||||||
'providerVersion' => '0.3.*',
|
|
||||||
'variables' => []
|
|
||||||
],
|
|
||||||
|
|
||||||
[
|
[
|
||||||
'key' => 'magic-portfolio',
|
'key' => 'magic-portfolio',
|
||||||
'name' => 'Magic Portfolio',
|
'name' => 'Magic Portfolio',
|
||||||
'useCases' => ['portfolio'],
|
'useCases' => ['portfolio'],
|
||||||
'screenshotDark' => $url . '/images/sites/templates/magic-portfolio-dark.png',
|
'screenshotDark' => $url . '/images/sites/templates/magic-portfolio-dark.png',
|
||||||
'screenshotLight' => $url . '/images/sites/templates/magic-portfolio-light.png',
|
'screenshotLight' => $url . '/images/sites/templates/magic-portfolio-light.png',
|
||||||
'frameworks' => [
|
'frameworks' => [
|
||||||
getFramework('NEXTJS', [
|
getFramework('NEXTJS', [
|
||||||
'providerRootDirectory' => './nextjs/magic-portfolio',
|
'providerRootDirectory' => './nextjs/magic-portfolio',
|
||||||
]),
|
]),
|
||||||
|
],
|
||||||
|
'vcsProvider' => 'github',
|
||||||
|
'providerRepositoryId' => 'templates-for-sites',
|
||||||
|
'providerOwner' => 'appwrite',
|
||||||
|
'providerVersion' => '0.3.*',
|
||||||
|
'variables' => []
|
||||||
],
|
],
|
||||||
'vcsProvider' => 'github',
|
|
||||||
'providerRepositoryId' => 'templates-for-sites',
|
|
||||||
'providerOwner' => 'appwrite',
|
|
||||||
'providerVersion' => '0.3.*',
|
|
||||||
'variables' => []
|
|
||||||
],
|
|
||||||
|
|
||||||
[
|
[
|
||||||
'key' => 'littlelink',
|
'key' => 'littlelink',
|
||||||
'name' => 'LittleLink',
|
'name' => 'LittleLink',
|
||||||
'useCases' => ['portfolio'],
|
'useCases' => ['portfolio'],
|
||||||
'screenshotDark' => $url . '/images/sites/templates/littlelink-dark.png',
|
'screenshotDark' => $url . '/images/sites/templates/littlelink-dark.png',
|
||||||
'screenshotLight' => $url . '/images/sites/templates/littlelink-light.png',
|
'screenshotLight' => $url . '/images/sites/templates/littlelink-light.png',
|
||||||
'frameworks' => [
|
'frameworks' => [
|
||||||
getFramework('OTHER', [
|
getFramework('OTHER', [
|
||||||
'providerRootDirectory' => './other/littlelink',
|
'providerRootDirectory' => './other/littlelink',
|
||||||
]),
|
]),
|
||||||
|
],
|
||||||
|
'vcsProvider' => 'github',
|
||||||
|
'providerRepositoryId' => 'templates-for-sites',
|
||||||
|
'providerOwner' => 'appwrite',
|
||||||
|
'providerVersion' => '0.3.*',
|
||||||
|
'variables' => []
|
||||||
],
|
],
|
||||||
'vcsProvider' => 'github',
|
|
||||||
'providerRepositoryId' => 'templates-for-sites',
|
|
||||||
'providerOwner' => 'appwrite',
|
|
||||||
'providerVersion' => '0.3.*',
|
|
||||||
'variables' => []
|
|
||||||
],
|
|
||||||
|
|
||||||
[
|
[
|
||||||
'key' => 'logspot',
|
'key' => 'logspot',
|
||||||
'name' => 'Logspot',
|
'name' => 'Logspot',
|
||||||
'useCases' => ['blog'],
|
'useCases' => ['blog'],
|
||||||
'screenshotDark' => $url . '/images/sites/templates/logspot-dark.png',
|
'screenshotDark' => $url . '/images/sites/templates/logspot-dark.png',
|
||||||
'screenshotLight' => $url . '/images/sites/templates/logspot-light.png',
|
'screenshotLight' => $url . '/images/sites/templates/logspot-light.png',
|
||||||
'frameworks' => [
|
'frameworks' => [
|
||||||
getFramework('NUXT', [
|
getFramework('NUXT', [
|
||||||
'providerRootDirectory' => './nuxt/logspot',
|
'providerRootDirectory' => './nuxt/logspot',
|
||||||
'buildCommand' => 'npm run generate',
|
'buildCommand' => 'npm run generate',
|
||||||
'outputDirectory' => './dist',
|
'outputDirectory' => './dist',
|
||||||
'adapter' => 'static',
|
'adapter' => 'static',
|
||||||
]),
|
]),
|
||||||
|
],
|
||||||
|
'vcsProvider' => 'github',
|
||||||
|
'providerRepositoryId' => 'templates-for-sites',
|
||||||
|
'providerOwner' => 'appwrite',
|
||||||
|
'providerVersion' => '0.3.*',
|
||||||
|
'variables' => []
|
||||||
],
|
],
|
||||||
'vcsProvider' => 'github',
|
|
||||||
'providerRepositoryId' => 'templates-for-sites',
|
|
||||||
'providerOwner' => 'appwrite',
|
|
||||||
'providerVersion' => '0.3.*',
|
|
||||||
'variables' => []
|
|
||||||
],
|
|
||||||
[
|
[
|
||||||
'key' => 'astro-nano',
|
'key' => 'astro-nano',
|
||||||
'name' => 'Astro Nano',
|
'name' => 'Astro Nano',
|
||||||
|
|
|
||||||
|
|
@ -205,7 +205,7 @@ services:
|
||||||
appwrite-console:
|
appwrite-console:
|
||||||
<<: *x-logging
|
<<: *x-logging
|
||||||
container_name: appwrite-console
|
container_name: appwrite-console
|
||||||
image: appwrite/console:5.3.0-sites-rc.27
|
image: appwrite/console:5.3.0-sites-rc.28
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
networks:
|
networks:
|
||||||
- appwrite
|
- appwrite
|
||||||
|
|
|
||||||
|
|
@ -60,10 +60,10 @@ class SitesCustomClientTest extends Scope
|
||||||
'frameworks' => ['nuxt']
|
'frameworks' => ['nuxt']
|
||||||
]);
|
]);
|
||||||
$this->assertEquals(200, $templates['headers']['status-code']);
|
$this->assertEquals(200, $templates['headers']['status-code']);
|
||||||
$this->assertGreaterThanOrEqual(3, $templates['body']['total']);
|
$this->assertGreaterThan(0, $templates['body']['total']);
|
||||||
$this->assertIsArray($templates['body']['templates']);
|
$this->assertIsArray($templates['body']['templates']);
|
||||||
foreach ($templates['body']['templates'] as $template) {
|
foreach ($templates['body']['templates'] as $template) {
|
||||||
$this->assertContains($template['useCases'][0], ['starter', 'ai']);
|
$this->assertContains($template['useCases'][0], ['starter']);
|
||||||
}
|
}
|
||||||
$this->assertArrayHasKey('frameworks', $templates['body']['templates'][0]);
|
$this->assertArrayHasKey('frameworks', $templates['body']['templates'][0]);
|
||||||
$this->assertContains('Nuxt', array_column($templates['body']['templates'][0]['frameworks'], 'name'));
|
$this->assertContains('Nuxt', array_column($templates['body']['templates'][0]['frameworks'], 'name'));
|
||||||
|
|
@ -74,13 +74,13 @@ class SitesCustomClientTest extends Scope
|
||||||
'x-appwrite-project' => $this->getProject()['$id'],
|
'x-appwrite-project' => $this->getProject()['$id'],
|
||||||
], $this->getHeaders()), [
|
], $this->getHeaders()), [
|
||||||
'limit' => 5,
|
'limit' => 5,
|
||||||
'offset' => 1,
|
'offset' => 0,
|
||||||
'useCases' => ['starter'],
|
'useCases' => ['starter'],
|
||||||
'frameworks' => ['nextjs']
|
'frameworks' => ['nextjs']
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$this->assertEquals(200, $templates['headers']['status-code']);
|
$this->assertEquals(200, $templates['headers']['status-code']);
|
||||||
$this->assertEquals(3, $templates['body']['total']);
|
$this->assertGreaterThan(0, $templates['body']['total']);
|
||||||
$this->assertIsArray($templates['body']['templates']);
|
$this->assertIsArray($templates['body']['templates']);
|
||||||
$this->assertArrayHasKey('frameworks', $templates['body']['templates'][0]);
|
$this->assertArrayHasKey('frameworks', $templates['body']['templates'][0]);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -758,77 +758,6 @@ class SitesCustomServerTest extends Scope
|
||||||
// // TODO: Implement testCreateDeploymentFromCLI() later
|
// // TODO: Implement testCreateDeploymentFromCLI() later
|
||||||
// }
|
// }
|
||||||
|
|
||||||
public function testCreateSiteAndDeploymentFromTemplate()
|
|
||||||
{
|
|
||||||
$starterTemplate = $this->getTemplate('nextjs-starter');
|
|
||||||
$this->assertEquals(200, $starterTemplate['headers']['status-code']);
|
|
||||||
|
|
||||||
$nextjsFramework = array_values(array_filter($starterTemplate['body']['frameworks'], function ($framework) {
|
|
||||||
return $framework['key'] === 'nextjs';
|
|
||||||
}))[0];
|
|
||||||
|
|
||||||
// If this fails, the template has variables, and this test needs to be updated
|
|
||||||
$this->assertEmpty($starterTemplate['body']['variables']);
|
|
||||||
|
|
||||||
$site = $this->createSite(
|
|
||||||
[
|
|
||||||
'siteId' => ID::unique(),
|
|
||||||
'name' => $starterTemplate['body']['name'],
|
|
||||||
'framework' => $nextjsFramework['key'],
|
|
||||||
'adapter' => $nextjsFramework['adapter'],
|
|
||||||
'buildCommand' => $nextjsFramework['buildCommand'],
|
|
||||||
'buildRuntime' => $nextjsFramework['buildRuntime'],
|
|
||||||
'fallbackFile' => $nextjsFramework['fallbackFile'],
|
|
||||||
'installCommand' => $nextjsFramework['installCommand'],
|
|
||||||
'outputDirectory' => $nextjsFramework['outputDirectory'],
|
|
||||||
'providerRootDirectory' => $nextjsFramework['providerRootDirectory'],
|
|
||||||
]
|
|
||||||
);
|
|
||||||
|
|
||||||
$this->assertEquals(201, $site['headers']['status-code']);
|
|
||||||
$this->assertNotEmpty($site['body']['$id']);
|
|
||||||
|
|
||||||
$siteId = $site['body']['$id'] ?? '';
|
|
||||||
|
|
||||||
$deployment = $this->createTemplateDeployment(
|
|
||||||
$siteId,
|
|
||||||
[
|
|
||||||
'owner' => $starterTemplate['body']['providerOwner'],
|
|
||||||
'repository' => $starterTemplate['body']['providerRepositoryId'],
|
|
||||||
'rootDirectory' => $nextjsFramework['providerRootDirectory'],
|
|
||||||
'version' => $starterTemplate['body']['providerVersion'],
|
|
||||||
'activate' => true,
|
|
||||||
]
|
|
||||||
);
|
|
||||||
|
|
||||||
$this->assertEquals(202, $deployment['headers']['status-code']);
|
|
||||||
$this->assertNotEmpty($deployment['body']['$id']);
|
|
||||||
|
|
||||||
$deployments = $this->listDeployments($siteId);
|
|
||||||
|
|
||||||
$this->assertEquals(200, $deployments['headers']['status-code']);
|
|
||||||
$this->assertEquals(1, $deployments['body']['total']);
|
|
||||||
|
|
||||||
$lastDeployment = $deployments['body']['deployments'][0];
|
|
||||||
|
|
||||||
$this->assertNotEmpty($lastDeployment['$id']);
|
|
||||||
$this->assertEquals(0, $lastDeployment['sourceSize']);
|
|
||||||
|
|
||||||
$deploymentId = $lastDeployment['$id'];
|
|
||||||
|
|
||||||
$this->assertEventually(function () use ($siteId, $deploymentId) {
|
|
||||||
$deployment = $this->getDeployment($siteId, $deploymentId);
|
|
||||||
|
|
||||||
$this->assertEquals(200, $deployment['headers']['status-code']);
|
|
||||||
$this->assertEquals('ready', $deployment['body']['status']);
|
|
||||||
}, 300000, 1000);
|
|
||||||
|
|
||||||
$site = $this->getSite($siteId);
|
|
||||||
$this->assertEquals(200, $site['headers']['status-code']);
|
|
||||||
|
|
||||||
$this->cleanupSite($siteId);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testCreateDeployment()
|
public function testCreateDeployment()
|
||||||
{
|
{
|
||||||
$siteId = $this->setupSite([
|
$siteId = $this->setupSite([
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue