Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/lib/stores/sites.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
import type { Models } from '@appwrite.io/console';

export type FrameworkAdapterWithStartCommand = Models.FrameworkAdapter & {
startCommand?: string;
};

export function getFrameworkIcon(framework: string) {
switch (true) {
case framework.toLocaleLowerCase().includes('sveltekit'):
Expand Down
14 changes: 9 additions & 5 deletions src/lib/stores/uploader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -166,12 +166,14 @@ const createUploader = () => {
code,
buildCommand,
installCommand,
startCommand,
outputDirectory
}: {
siteId: string;
code: File;
buildCommand?: string;
installCommand?: string;
startCommand?: string;
outputDirectory?: string;
}) => {
const newDeployment: UploaderFile = {
Expand All @@ -188,23 +190,25 @@ const createUploader = () => {
n.files.unshift(newDeployment);
return n;
});
const uploadedFile = await temporarySites(
page.params.region,
page.params.project
).createDeployment({
const deploymentPayload = {
siteId,
code,
activate: true,
buildCommand,
installCommand,
startCommand,
outputDirectory,
onProgress: (progress) => {
newDeployment.$id = progress.$id;
newDeployment.progress = progress.progress;
newDeployment.status = progress.progress === 100 ? 'success' : 'pending';
updateFile(progress.$id, newDeployment);
}
});
};
const uploadedFile = await temporarySites(
page.params.region,
page.params.project
).createDeployment(deploymentPayload);
newDeployment.$id = uploadedFile.$id;
newDeployment.progress = 100;
newDeployment.status = 'success';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,9 @@
disabled={shouldDisableDisableAllButton}>Disable all</Button>
</Layout.Stack>
</div>
<Divider />
<div class="protocol-toolbar-divider">
<Divider />
</div>
<div class="protocol-list-content">
<Layout.Stack gap="xs">
{#each $protocols.list as protocol, index}
Expand Down Expand Up @@ -207,7 +209,12 @@

<style>
.protocols-list {
width: 100%;
}

.protocol-list-content {
max-width: 36rem;
padding-top: var(--space-6);
}

.protocol-toolbar {
Expand All @@ -220,10 +227,6 @@
width: 100%;
}

.protocol-list-content {
padding-top: var(--space-6);
}

.protocol-control {
display: flex;
align-items: center;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,33 +3,37 @@
import { Fieldset, Layout, Accordion } from '@appwrite.io/pink-svelte';
import type { Models } from '@appwrite.io/console';
import { iconPath } from '$lib/stores/app';
import { getFrameworkIcon } from '$lib/stores/sites';
import { getFrameworkIcon, type FrameworkAdapterWithStartCommand } from '$lib/stores/sites';
import { EnvironmentVariables } from '$lib/components/variables';

export let frameworks: Models.Framework[];
export let selectedFramework: Models.Framework;
$: frameworkData = frameworks.find((framework) => framework.key === selectedFramework?.key);
$: adapterData =
frameworkData?.adapters.find((adapter) => adapter.key === 'ssr') ??
frameworkData?.adapters.find((adapter) => adapter.key === 'static');
$: adapterData = (frameworkData?.adapters.find((adapter) => adapter.key === 'ssr') ??
frameworkData?.adapters.find(
(adapter) => adapter.key === 'static'
)) as FrameworkAdapterWithStartCommand;

export let variables: Partial<Models.Variable>[] = [];
export let isLoading = false;
export let installCommand = '';
export let buildCommand = '';
export let startCommand = '';
export let outputDirectory = '';

let frameworkId = selectedFramework.key;

$: if (!installCommand || !buildCommand || !outputDirectory) {
$: if (!installCommand || !buildCommand || !startCommand || !outputDirectory) {
installCommand ||= adapterData?.installCommand;
buildCommand ||= adapterData?.buildCommand;
startCommand ||= adapterData?.startCommand;
outputDirectory ||= adapterData?.outputDirectory;
}

$: if (frameworkData) {
installCommand = adapterData?.installCommand;
buildCommand = adapterData?.buildCommand;
startCommand = adapterData?.startCommand;
outputDirectory = adapterData?.outputDirectory;
}
</script>
Expand Down Expand Up @@ -65,7 +69,8 @@
<Button
secondary
size="s"
disabled={adapterData?.installCommand === installCommand}
disabled={(adapterData?.installCommand ?? '') ===
(installCommand ?? '')}
on:click={() => (installCommand = adapterData?.installCommand)}>
Reset
</Button>
Expand All @@ -79,11 +84,30 @@
<Button
secondary
size="s"
disabled={adapterData?.buildCommand === buildCommand}
disabled={(adapterData?.buildCommand ?? '') ===
(buildCommand ?? '')}
on:click={() => (buildCommand = adapterData?.buildCommand)}>
Reset
</Button>
</Layout.Stack>
{#if adapterData?.key === 'ssr'}
<Layout.Stack gap="s" direction="row" alignItems="flex-end">
<InputText
id="startCommand"
label="Start command"
bind:value={startCommand}
placeholder={adapterData?.startCommand ||
'Enter start command'} />
<Button
secondary
size="s"
disabled={(adapterData?.startCommand ?? '') ===
(startCommand ?? '')}
Comment thread
greptile-apps[bot] marked this conversation as resolved.
on:click={() => (startCommand = adapterData?.startCommand)}>
Reset
</Button>
</Layout.Stack>
{/if}
<Layout.Stack gap="s" direction="row" alignItems="flex-end">
<InputText
id="outputDirectory"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import { writable } from 'svelte/store';
import { getLatestTag } from '$lib/helpers/github';
import Link from '$lib/elements/link.svelte';
import type { FrameworkAdapterWithStartCommand } from '$lib/stores/sites';

let {
data
Expand All @@ -45,6 +46,7 @@
let domain = $state('');
let rootDir = $state(data.repository?.rootDirectory || '');
let buildCommand = $state('');
let startCommand = $state('');
let installCommand = $state('');
let outputDirectory = $state('');
let domainIsValid = $state(false);
Expand Down Expand Up @@ -87,6 +89,7 @@
const adapter = fw.adapters[0];
installCommand = adapter.installCommand || '';
buildCommand = adapter.buildCommand || '';
startCommand = (adapter as FrameworkAdapterWithStartCommand).startCommand || '';
outputDirectory = adapter.outputDirectory || '';
}
}
Expand All @@ -103,10 +106,11 @@
// Build configuration - use from URL params or defaults
installCommand = page.url.searchParams.get('install') || '';
buildCommand = page.url.searchParams.get('build') || '';
startCommand = page.url.searchParams.get('start') || '';
outputDirectory = page.url.searchParams.get('output') || '';

// Check if custom commands were provided via URL
hasCustomCommands = !!(installCommand || buildCommand || outputDirectory);
hasCustomCommands = !!(installCommand || buildCommand || startCommand || outputDirectory);

// If no custom commands, auto-fill from framework defaults
if (!hasCustomCommands && data.frameworks) {
Expand All @@ -115,6 +119,7 @@
const adapter = fw.adapters[0];
installCommand = adapter.installCommand || '';
buildCommand = adapter.buildCommand || '';
startCommand = (adapter as FrameworkAdapterWithStartCommand).startCommand || '';
outputDirectory = adapter.outputDirectory || '';
}
}
Expand Down Expand Up @@ -145,6 +150,7 @@
buildRuntime: selectedFramework.buildRuntime,
installCommand: installCommand || undefined,
buildCommand: buildCommand || undefined,
startCommand: startCommand || undefined,
outputDirectory: outputDirectory || undefined,
adapter: framework === Framework.Other ? Adapter.Static : undefined,
providerSilentMode: false
Expand Down Expand Up @@ -272,6 +278,10 @@
label="Build command"
placeholder={buildCommand || 'npm run build'}
bind:value={buildCommand} />
<Input.Text
label="Start command"
placeholder={startCommand || 'npm run start'}
bind:value={startCommand} />
<Input.Text
label="Output directory"
placeholder={outputDirectory || 'dist'}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
timeout: data.site.timeout,
installCommand: data.site.installCommand,
buildCommand: data.site.buildCommand,
startCommand: data.site.startCommand,
outputDirectory: data.site.outputDirectory,
buildRuntime: data.site.buildRuntime as BuildRuntime,
adapter: data.site.adapter as Adapter,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import { currentPlan } from '$lib/stores/organization';
import Domain from '../domain.svelte';
import { uploader } from '$lib/stores/uploader';
import type { FrameworkAdapterWithStartCommand } from '$lib/stores/sites';

export let data;
let showExitModal = false;
Expand All @@ -36,9 +37,10 @@
let framework: Models.Framework =
data.frameworks.frameworks?.find((f) => f.key === 'other') ??
data.frameworks.frameworks?.[0];
let adapter = framework?.adapters[0];
let adapter = framework?.adapters[0] as FrameworkAdapterWithStartCommand;
let installCommand = adapter?.installCommand;
let buildCommand = adapter?.buildCommand;
let startCommand = adapter?.startCommand;
let outputDirectory = adapter?.outputDirectory;
let variables: Partial<Models.Variable>[] = [];
let files: FileList;
Expand Down Expand Up @@ -73,6 +75,7 @@
buildRuntime,
installCommand: installCommand || undefined,
buildCommand: buildCommand || undefined,
startCommand: startCommand || undefined,
outputDirectory: outputDirectory || undefined
});

Expand All @@ -98,6 +101,7 @@
code: files[0],
buildCommand: buildCommand || undefined,
installCommand: installCommand || undefined,
startCommand: startCommand || undefined,
outputDirectory: outputDirectory || undefined
});

Expand Down Expand Up @@ -243,6 +247,7 @@
<Configuration
bind:installCommand
bind:buildCommand
bind:startCommand
bind:outputDirectory
bind:selectedFramework={framework}
bind:variables
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import Domain from '../../domain.svelte';
import { regionalConsoleVariables } from '$routes/(console)/project-[region]-[project]/store';
import { normalizeDetectedVariables, mergeVariables } from '$lib/helpers/variables';
import type { FrameworkAdapterWithStartCommand } from '$lib/stores/sites';

export let data;
let showExitModal = false;
Expand All @@ -38,11 +39,12 @@
let name = '';
let id = ID.unique();
let framework: Models.Framework = data.frameworks.frameworks.find((f) => f.key === 'other');
let adapter = framework?.adapters[0];
let adapter = framework?.adapters[0] as FrameworkAdapterWithStartCommand;
let branch: string;
let rootDir = './';
let installCommand = adapter?.installCommand;
let buildCommand = adapter?.buildCommand;
let startCommand = adapter?.startCommand;
let outputDirectory = adapter?.outputDirectory;
let variables: Partial<Models.Variable>[] = [];
let silentMode = false;
Expand Down Expand Up @@ -81,9 +83,10 @@
if (!framework) {
framework = data.frameworks.frameworks.find((f) => f.key === 'other');
}
adapter = framework?.adapters[0];
adapter = framework?.adapters[0] as FrameworkAdapterWithStartCommand;
installCommand = adapter?.installCommand;
buildCommand = adapter?.buildCommand;
startCommand = adapter?.startCommand;
outputDirectory = adapter?.outputDirectory;
const detectedVariables = normalizeDetectedVariables(response?.variables);
if (detectedVariables.length) {
Expand Down Expand Up @@ -121,6 +124,7 @@
buildRuntime,
installCommand,
buildCommand,
startCommand,
outputDirectory,
installationId: data.installation.$id,
providerRepositoryId: data.repository.id,
Expand Down Expand Up @@ -218,6 +222,7 @@
<Configuration
bind:installCommand
bind:buildCommand
bind:startCommand
bind:outputDirectory
bind:selectedFramework={framework}
bind:variables
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@
timeout: data.site.timeout,
installCommand: data.site.installCommand,
buildCommand: data.site.buildCommand,
startCommand: data.site.startCommand,
outputDirectory: data.site.outputDirectory,
buildRuntime: data.site.buildRuntime as BuildRuntime,
adapter: data.site.adapter as Adapter,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@
timeout: site.timeout || undefined,
installCommand: site.installCommand || undefined,
buildCommand: site.buildCommand || undefined,
startCommand: site.startCommand || undefined,
outputDirectory: site.outputDirectory || undefined,
buildRuntime: (site?.buildRuntime as BuildRuntime) || undefined,
adapter: (site.adapter as Adapter) || undefined,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@
timeout: data.site.timeout,
installCommand: data.site.installCommand,
buildCommand: data.site.buildCommand,
startCommand: data.site.startCommand,
outputDirectory: data.site.outputDirectory,
buildRuntime: data.site.buildRuntime as BuildRuntime,
adapter: data.site.adapter as Adapter,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
timeout: site.timeout || undefined,
installCommand: site.installCommand || undefined,
buildCommand: site.buildCommand || undefined,
startCommand: site.startCommand || undefined,
outputDirectory: site.outputDirectory || undefined,
buildRuntime: (site?.buildRuntime as BuildRuntime) || undefined,
adapter: (site?.adapter as Adapter) || undefined,
Expand Down
Loading
Loading