refactor: implement new adapter

This commit is contained in:
Arman
2024-12-02 15:38:48 +01:00
parent 185a5671ef
commit f99430f138
10 changed files with 476 additions and 511 deletions
+1 -1
View File
@@ -19,7 +19,7 @@
"e2e:ui": "playwright test tests/e2e --ui"
},
"dependencies": {
"@appwrite.io/console": "https://pkg.pr.new/appwrite/appwrite/@appwrite.io/console@a5fc2e0",
"@appwrite.io/console": "https://pkg.pr.new/appwrite/appwrite/@appwrite.io/console@9033",
"@appwrite.io/pink": "0.25.0",
"@appwrite.io/pink-icons": "0.25.0",
"@appwrite.io/pink-icons-svelte": "1.0.0-next.7",
+435 -446
View File
File diff suppressed because it is too large Load Diff
@@ -16,7 +16,7 @@
import ProductionBranch from '../../productionBranch.svelte';
import Configuration from './configuration.svelte';
import Aside from '../../aside.svelte';
import { BuildRuntime, Framework, ID, Query, ServeRuntime } from '@appwrite.io/console';
import { Framework, ID, Query } from '@appwrite.io/console';
import type { Models } from '@appwrite.io/console';
import { onMount } from 'svelte';
@@ -28,14 +28,13 @@
let name = '';
let id = '';
let framework: Models.Framework =
data.frameworks.frameworks.find((f) => f.key === Framework.Static) ||
data.frameworks.frameworks[0];
let framework: Models.Framework = data.frameworks.frameworks[0];
let adapter = framework?.adapters[0];
let branch: string;
let rootDir = './';
let installCommand = framework?.defaultInstallCommand;
let buildCommand = framework?.defaultBuildCommand;
let outputDirectory = framework?.defaultOutputDirectory;
let installCommand = adapter?.installCommand;
let buildCommand = adapter?.buildCommand;
let outputDirectory = adapter?.outputDirectory;
let variables: Partial<Models.Variable>[] = [];
let silentMode = false;
@@ -62,18 +61,13 @@
async function create() {
try {
const fr = Object.values(Framework).find((f) => f === framework.key);
const buildRuntime = Object.values(BuildRuntime).find(
(f) => f === framework.defaultBuildRuntime
);
const serveRuntime = Object.values(ServeRuntime).find(
(f) => f === framework.defaultServeRuntime
);
let site = await sdk.forProject.sites.create(
id || ID.unique(),
name,
fr,
buildRuntime,
serveRuntime,
undefined,
framework.buildRuntime,
undefined,
undefined,
installCommand,
@@ -26,7 +26,7 @@
import ProductionBranch from '../../productionBranch.svelte';
import Configuration from './configuration.svelte';
import Aside from '../../aside.svelte';
import { BuildRuntime, Framework, ID, Query, ServeRuntime } from '@appwrite.io/console';
import { Framework, ID, Query } from '@appwrite.io/console';
import Domain from '../../domain.svelte';
import { NewRepository, Repositories, RepositoryBehaviour } from '$lib/components/git';
@@ -106,18 +106,13 @@
}
try {
const fr = Object.values(Framework).find((f) => f === framework.key);
const buildRuntime = Object.values(BuildRuntime).find(
(f) => f === framework.buildRuntime
);
const serveRuntime = Object.values(ServeRuntime).find(
(f) => f === framework.serveRuntime
);
let site = await sdk.forProject.sites.create(
id || ID.unique(),
name,
fr,
buildRuntime,
serveRuntime,
undefined,
framework.buildRuntime,
undefined,
undefined,
framework.installCommand,
@@ -7,7 +7,7 @@
import { addNotification } from '$lib/stores/notifications';
import { sdk } from '$lib/stores/sdk';
import { onMount } from 'svelte';
import { BuildRuntime, Framework, ServeRuntime, type Models } from '@appwrite.io/console';
import { BuildRuntime, Framework, type Models } from '@appwrite.io/console';
import { Layout } from '@appwrite.io/pink-svelte';
export let site: Models.Site;
@@ -22,9 +22,13 @@
onMount(async () => {
selectedFramework ??= frameworks.find((framework) => framework.key === site.framework);
installCommand = site?.installCommand ?? selectedFramework.defaultInstallCommand;
buildCommand = site?.buildCommand ?? selectedFramework.defaultBuildCommand;
outputDirectory = site?.outputDirectory ?? selectedFramework.defaultOutputDirectory;
installCommand =
site?.installCommand ?? selectedFramework.adapters[site.adapter].defaultInstallCommand;
buildCommand =
site?.buildCommand ?? selectedFramework.adapters[site.adapter].defaultBuildCommand;
outputDirectory =
site?.outputDirectory ??
selectedFramework.adapters[site.adapter].defaultOutputDirectory;
});
async function updateName() {
@@ -33,13 +37,13 @@
site.$id,
site.name,
selectedFramework.key as Framework,
site.adapter,
site.enabled || undefined,
site.timeout || undefined,
installCommand || undefined,
buildCommand || undefined,
outputDirectory || undefined,
(site?.buildRuntime as BuildRuntime) || undefined,
(site?.serveRuntime as ServeRuntime) || undefined,
site.fallbackFile || undefined,
site.installationId || undefined,
site.providerRepositoryId || undefined,
@@ -103,7 +107,7 @@
id="installCommand"
label="Install command"
bind:value={installCommand}
placeholder={frameworkData.defaultInstallCommand} />
placeholder={frameworkData.adapters[site.adapter].defaultInstallCommand} />
<Button secondary size="s" on:click={() => (installCommand = '')}>Reset</Button>
</Layout.Stack>
<Layout.Stack gap="s" direction="row" alignItems="flex-end">
@@ -111,7 +115,7 @@
id="buildCommand"
label="Build command"
bind:value={buildCommand}
placeholder={frameworkData.defaultBuildCommand} />
placeholder={frameworkData.adapters[site.adapter].defaultBuildCommand} />
<Button secondary size="s" on:click={() => (buildCommand = '')}>Reset</Button>
</Layout.Stack>
<Layout.Stack gap="s" direction="row" alignItems="flex-end">
@@ -119,7 +123,7 @@
id="outputDirectory"
label="Output directory"
bind:value={outputDirectory}
placeholder={frameworkData.defaultOutputDirectory} />
placeholder={frameworkData.adapters[site.adapter].defaultOutputDirectory} />
<Button secondary size="s" on:click={() => (outputDirectory = '')}>Reset</Button>
</Layout.Stack>
</svelte:fragment>
@@ -7,7 +7,7 @@
import { addNotification } from '$lib/stores/notifications';
import { sdk } from '$lib/stores/sdk';
import { onMount } from 'svelte';
import { BuildRuntime, Framework, ServeRuntime, type Models } from '@appwrite.io/console';
import { BuildRuntime, Framework, type Models } from '@appwrite.io/console';
export let site: Models.Site;
let siteName: string = null;
@@ -21,14 +21,14 @@
await sdk.forProject.sites.update(
site.$id,
siteName,
site?.framework as Framework,
site.framework as Framework,
site.adapter,
site.enabled || undefined,
site.timeout || undefined,
site.installCommand || undefined,
site.buildCommand || undefined,
site.outputDirectory || undefined,
(site?.buildRuntime as BuildRuntime) || undefined,
(site?.serveRuntime as ServeRuntime) || undefined,
site.fallbackFile || undefined,
site.installationId || undefined,
site.providerRepositoryId || undefined,
@@ -6,7 +6,7 @@
import { Button, Form, InputChoice, InputText } from '$lib/elements/forms';
import { addNotification } from '$lib/stores/notifications';
import { sdk } from '$lib/stores/sdk';
import { BuildRuntime, Framework, ServeRuntime, type Models } from '@appwrite.io/console';
import { BuildRuntime, Framework, type Models } from '@appwrite.io/console';
import { toLocaleDateTime } from '$lib/helpers/date';
import { onMount } from 'svelte';
import DisconnectRepo from './disconnectRepo.svelte';
@@ -68,13 +68,13 @@
site.$id,
site.name,
site?.framework as Framework,
site.adapter,
site.enabled || undefined,
site.timeout || undefined,
site.installCommand || undefined,
site.buildCommand || undefined,
site.outputDirectory || undefined,
(site?.buildRuntime as BuildRuntime) || undefined,
(site?.serveRuntime as ServeRuntime) || undefined,
site.fallbackFile || undefined,
site.installationId || undefined,
site.providerRepositoryId || undefined,
@@ -7,26 +7,20 @@
import { addNotification } from '$lib/stores/notifications';
import { sdk } from '$lib/stores/sdk';
import { onMount } from 'svelte';
import { BuildRuntime, Framework, ServeRuntime, type Models } from '@appwrite.io/console';
import { BuildRuntime, Framework, type Models } from '@appwrite.io/console';
export let site: Models.Site;
export let frameworks: Models.Framework[];
const framework = frameworks.find((framework) => framework.key === site.framework);
let buildRuntime = site?.buildRuntime;
let serveRuntime = site?.serveRuntime;
let buildRuntimeOptions = framework.buildRuntimes.map((runtime) => ({
label: runtime,
value: runtime
}));
let serveRuntimeOptions = framework.serveRuntimes.map((runtime) => ({
let buildRuntimeOptions = framework.runtimes.map((runtime) => ({
label: runtime,
value: runtime
}));
onMount(async () => {
buildRuntime ??= framework.defaultBuildRuntime;
serveRuntime ??= framework.defaultBuildCommand;
buildRuntime ??= framework.buildRuntime;
});
async function updateRuntime() {
try {
@@ -34,13 +28,13 @@
site.$id,
site.name,
site?.framework as Framework,
site.adapter,
site.enabled || undefined,
site.timeout || undefined,
site.installCommand || undefined,
site.buildCommand || undefined,
site.outputDirectory || undefined,
(buildRuntime as BuildRuntime) || undefined,
(serveRuntime as ServeRuntime) || undefined,
site.fallbackFile || undefined,
site.installationId || undefined,
site.providerRepositoryId || undefined,
@@ -62,8 +56,6 @@
trackError(error, Submit.SiteUpdateTimeout);
}
}
$: console.log('test');
</script>
<Form onSubmit={updateRuntime}>
@@ -83,20 +75,10 @@
options={buildRuntimeOptions}
required
hideRequired />
<InputSelect
label="Serve runtime"
id="serve-runtime"
placeholder="Select runtime"
bind:value={serveRuntime}
options={serveRuntimeOptions}
required
hideRequired />
</svelte:fragment>
<svelte:fragment slot="actions">
<Button
disabled={buildRuntime === site.buildRuntime && serveRuntime === site.serveRuntime}
submit>Update</Button>
<Button disabled={buildRuntime === site.buildRuntime} submit>Update</Button>
</svelte:fragment>
</CardGrid>
</Form>
@@ -7,7 +7,7 @@
import { addNotification } from '$lib/stores/notifications';
import { sdk } from '$lib/stores/sdk';
import { onMount } from 'svelte';
import { BuildRuntime, Framework, ServeRuntime, type Models } from '@appwrite.io/console';
import { BuildRuntime, Framework, type Models } from '@appwrite.io/console';
import InputChoice from '$lib/elements/forms/inputChoice.svelte';
import { Layout } from '@appwrite.io/pink-svelte';
@@ -16,6 +16,7 @@
let fallback = '';
onMount(async () => {
spa = site?.adapter === 'static';
fallback ??= site.fallbackFile;
if (fallback !== undefined) spa = true;
});
@@ -26,13 +27,13 @@
site.$id,
site.name,
site?.framework as Framework,
spa ? 'static' : 'ssr',
site.enabled || undefined,
site.timeout || undefined,
site.installCommand || undefined,
site.buildCommand || undefined,
site.outputDirectory || undefined,
(site?.buildRuntime as BuildRuntime) || undefined,
(site?.serveRuntime as ServeRuntime) || undefined,
fallback,
site.installationId || undefined,
site.providerRepositoryId || undefined,
@@ -7,7 +7,7 @@
import { addNotification } from '$lib/stores/notifications';
import { sdk } from '$lib/stores/sdk';
import { onMount } from 'svelte';
import { BuildRuntime, Framework, ServeRuntime, type Models } from '@appwrite.io/console';
import { BuildRuntime, Framework, type Models } from '@appwrite.io/console';
export let site: Models.Site;
let timeout = 0;
@@ -22,13 +22,13 @@
site.$id,
site.name,
site?.framework as Framework,
site.adapter,
site.enabled || undefined,
timeout || undefined,
site.installCommand || undefined,
site.buildCommand || undefined,
site.outputDirectory || undefined,
(site?.buildRuntime as BuildRuntime) || undefined,
(site?.serveRuntime as ServeRuntime) || undefined,
site.fallbackFile || undefined,
site.installationId || undefined,
site.providerRepositoryId || undefined,