Skip to content

Commit ee7514c

Browse files
authored
Merge pull request #3156 from appwrite/fix/sites-hide-start-command
fix(sites): keep framework start commands out of the console
2 parents 00ba9b1 + 8fab550 commit ee7514c

6 files changed

Lines changed: 44 additions & 99 deletions

File tree

src/lib/stores/sites.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,3 @@
1-
import type { Models } from '@appwrite.io/console';
2-
3-
export type FrameworkAdapterWithStartCommand = Models.FrameworkAdapter & {
4-
startCommand?: string;
5-
};
6-
71
export function getFrameworkIcon(framework: string) {
82
switch (true) {
93
case framework.toLocaleLowerCase().includes('sveltekit'):

src/routes/(console)/project-[region]-[project]/sites/create-site/configuration.svelte

Lines changed: 4 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,20 @@
33
import { Fieldset, Layout, Accordion } from '@appwrite.io/pink-svelte';
44
import type { Models } from '@appwrite.io/console';
55
import { iconPath } from '$lib/stores/app';
6-
import { getFrameworkIcon, type FrameworkAdapterWithStartCommand } from '$lib/stores/sites';
6+
import { getFrameworkIcon } from '$lib/stores/sites';
77
import { EnvironmentVariables } from '$lib/components/variables';
88
99
export let frameworks: Models.Framework[];
1010
export let selectedFramework: Models.Framework;
1111
$: frameworkData = frameworks.find((framework) => framework.key === selectedFramework?.key);
12-
$: adapterData = (frameworkData?.adapters.find((adapter) => adapter.key === 'ssr') ??
13-
frameworkData?.adapters.find(
14-
(adapter) => adapter.key === 'static'
15-
)) as FrameworkAdapterWithStartCommand;
12+
$: adapterData =
13+
frameworkData?.adapters.find((adapter) => adapter.key === 'ssr') ??
14+
frameworkData?.adapters.find((adapter) => adapter.key === 'static');
1615
1716
export let variables: Partial<Models.Variable>[] = [];
1817
export let isLoading = false;
1918
export let installCommand = '';
2019
export let buildCommand = '';
21-
export let startCommand = '';
2220
export let outputDirectory = '';
2321
2422
let frameworkId = selectedFramework.key;
@@ -28,7 +26,6 @@
2826
$: if (frameworkData && adapterDefaultsKey !== lastAdapterDefaultsKey) {
2927
installCommand = adapterData?.installCommand ?? '';
3028
buildCommand = adapterData?.buildCommand ?? '';
31-
startCommand = adapterData?.startCommand ?? '';
3229
outputDirectory = adapterData?.outputDirectory ?? '';
3330
lastAdapterDefaultsKey = adapterDefaultsKey;
3431
}
@@ -86,24 +83,6 @@
8683
Reset
8784
</Button>
8885
</Layout.Stack>
89-
{#if adapterData?.key === 'ssr'}
90-
<Layout.Stack gap="s" direction="row" alignItems="flex-end">
91-
<InputText
92-
id="startCommand"
93-
label="Start command"
94-
bind:value={startCommand}
95-
placeholder={adapterData?.startCommand ||
96-
'Enter start command'} />
97-
<Button
98-
secondary
99-
size="s"
100-
disabled={(adapterData?.startCommand ?? '') ===
101-
(startCommand ?? '')}
102-
on:click={() => (startCommand = adapterData?.startCommand)}>
103-
Reset
104-
</Button>
105-
</Layout.Stack>
106-
{/if}
10786
<Layout.Stack gap="s" direction="row" alignItems="flex-end">
10887
<InputText
10988
id="outputDirectory"

src/routes/(console)/project-[region]-[project]/sites/create-site/deploy/+page.svelte

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
import { writable } from 'svelte/store';
2828
import { getLatestTag } from '$lib/helpers/github';
2929
import Link from '$lib/elements/link.svelte';
30-
import type { FrameworkAdapterWithStartCommand } from '$lib/stores/sites';
3130
3231
let {
3332
data
@@ -46,7 +45,6 @@
4645
let domain = $state('');
4746
let rootDir = $state(data.repository?.rootDirectory || '');
4847
let buildCommand = $state('');
49-
let startCommand = $state('');
5048
let installCommand = $state('');
5149
let outputDirectory = $state('');
5250
let domainIsValid = $state(false);
@@ -82,19 +80,13 @@
8280
}))
8381
);
8482
85-
const primaryAdapter = $derived.by(
86-
() => data.frameworks.frameworks.find((f) => f.key === framework)?.adapters?.[0]
87-
);
88-
const shouldShowStartCommand = $derived(primaryAdapter?.key === Adapter.Ssr);
89-
9083
$effect(() => {
9184
if (framework && data.frameworks && !hasCustomCommands) {
9285
const fw = data.frameworks.frameworks.find((f) => f.key === framework);
9386
if (fw && fw.adapters && fw.adapters.length > 0) {
9487
const adapter = fw.adapters[0];
9588
installCommand = adapter.installCommand || '';
9689
buildCommand = adapter.buildCommand || '';
97-
startCommand = (adapter as FrameworkAdapterWithStartCommand).startCommand || '';
9890
outputDirectory = adapter.outputDirectory || '';
9991
}
10092
}
@@ -111,11 +103,10 @@
111103
// Build configuration - use from URL params or defaults
112104
installCommand = page.url.searchParams.get('install') || '';
113105
buildCommand = page.url.searchParams.get('build') || '';
114-
startCommand = page.url.searchParams.get('start') || '';
115106
outputDirectory = page.url.searchParams.get('output') || '';
116107
117108
// Check if custom commands were provided via URL
118-
hasCustomCommands = !!(installCommand || buildCommand || startCommand || outputDirectory);
109+
hasCustomCommands = !!(installCommand || buildCommand || outputDirectory);
119110
120111
// If no custom commands, auto-fill from framework defaults
121112
if (!hasCustomCommands && data.frameworks) {
@@ -124,7 +115,6 @@
124115
const adapter = fw.adapters[0];
125116
installCommand = adapter.installCommand || '';
126117
buildCommand = adapter.buildCommand || '';
127-
startCommand = (adapter as FrameworkAdapterWithStartCommand).startCommand || '';
128118
outputDirectory = adapter.outputDirectory || '';
129119
}
130120
}
@@ -155,7 +145,6 @@
155145
buildRuntime: selectedFramework.buildRuntime,
156146
installCommand: installCommand || undefined,
157147
buildCommand: buildCommand || undefined,
158-
startCommand: shouldShowStartCommand ? startCommand || undefined : undefined,
159148
outputDirectory: outputDirectory || undefined,
160149
adapter: framework === Framework.Other ? Adapter.Static : undefined,
161150
providerSilentMode: false
@@ -284,12 +273,6 @@
284273
label="Build command"
285274
placeholder={buildCommand || 'npm run build'}
286275
bind:value={buildCommand} />
287-
{#if shouldShowStartCommand}
288-
<Input.Text
289-
label="Start command"
290-
placeholder={startCommand || 'npm run start'}
291-
bind:value={startCommand} />
292-
{/if}
293276
<Input.Text
294277
label="Output directory"
295278
placeholder={outputDirectory || 'dist'}

src/routes/(console)/project-[region]-[project]/sites/create-site/manual/+page.svelte

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
import { currentPlan } from '$lib/stores/organization';
2727
import Domain from '../domain.svelte';
2828
import { uploader } from '$lib/stores/uploader';
29-
import type { FrameworkAdapterWithStartCommand } from '$lib/stores/sites';
3029
3130
export let data;
3231
let showExitModal = false;
@@ -41,10 +40,9 @@
4140
let framework: Models.Framework =
4241
data.frameworks.frameworks?.find((f) => f.key === 'other') ??
4342
data.frameworks.frameworks?.[0];
44-
let adapter = framework?.adapters[0] as FrameworkAdapterWithStartCommand;
43+
let adapter = framework?.adapters[0];
4544
let installCommand = adapter?.installCommand;
4645
let buildCommand = adapter?.buildCommand;
47-
let startCommand = adapter?.startCommand;
4846
let outputDirectory = adapter?.outputDirectory;
4947
let variables: Partial<Models.Variable>[] = [];
5048
let files: FileList;
@@ -79,7 +77,6 @@
7977
buildRuntime,
8078
installCommand: installCommand || undefined,
8179
buildCommand: buildCommand || undefined,
82-
startCommand: startCommand || undefined,
8380
outputDirectory: outputDirectory || undefined
8481
});
8582
@@ -254,7 +251,6 @@
254251
<Configuration
255252
bind:installCommand
256253
bind:buildCommand
257-
bind:startCommand
258254
bind:outputDirectory
259255
bind:selectedFramework={framework}
260256
bind:variables

src/routes/(console)/project-[region]-[project]/sites/create-site/repositories/repository-[repository]/+page.svelte

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
import Domain from '../../domain.svelte';
2929
import { regionalConsoleVariables } from '$routes/(console)/project-[region]-[project]/store';
3030
import { normalizeDetectedVariables, mergeVariables } from '$lib/helpers/variables';
31-
import type { FrameworkAdapterWithStartCommand } from '$lib/stores/sites';
3231
3332
export let data;
3433
let showExitModal = false;
@@ -39,12 +38,11 @@
3938
let name = '';
4039
let id = ID.unique();
4140
let framework: Models.Framework = data.frameworks.frameworks.find((f) => f.key === 'other');
42-
let adapter = framework?.adapters[0] as FrameworkAdapterWithStartCommand;
41+
let adapter = framework?.adapters[0];
4342
let branch: string;
4443
let rootDir = './';
4544
let installCommand = adapter?.installCommand;
4645
let buildCommand = adapter?.buildCommand;
47-
let startCommand = adapter?.startCommand;
4846
let outputDirectory = adapter?.outputDirectory;
4947
let variables: Partial<Models.Variable>[] = [];
5048
let silentMode = false;
@@ -83,10 +81,9 @@
8381
if (!framework) {
8482
framework = data.frameworks.frameworks.find((f) => f.key === 'other');
8583
}
86-
adapter = framework?.adapters[0] as FrameworkAdapterWithStartCommand;
84+
adapter = framework?.adapters[0];
8785
installCommand = adapter?.installCommand;
8886
buildCommand = adapter?.buildCommand;
89-
startCommand = adapter?.startCommand;
9087
outputDirectory = adapter?.outputDirectory;
9188
const detectedVariables = normalizeDetectedVariables(response?.variables);
9289
if (detectedVariables.length) {
@@ -124,7 +121,6 @@
124121
buildRuntime,
125122
installCommand: installCommand || undefined,
126123
buildCommand: buildCommand || undefined,
127-
startCommand: startCommand || undefined,
128124
outputDirectory: outputDirectory || undefined,
129125
installationId: data.installation.$id,
130126
providerRepositoryId: data.repository.id,
@@ -223,7 +219,6 @@
223219
<Configuration
224220
bind:installCommand
225221
bind:buildCommand
226-
bind:startCommand
227222
bind:outputDirectory
228223
bind:selectedFramework={framework}
229224
bind:variables

src/routes/(console)/project-[region]-[project]/sites/site-[site]/settings/updateBuildSettings.svelte

Lines changed: 36 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,20 @@
77
import { addNotification } from '$lib/stores/notifications';
88
import { sdk } from '$lib/stores/sdk';
99
import { Adapter, BuildRuntime, Framework, type Models } from '@appwrite.io/console';
10-
import { Card, Fieldset, Icon, InlineCode, Layout, Tooltip } from '@appwrite.io/pink-svelte';
10+
import {
11+
Accordion,
12+
Card,
13+
Fieldset,
14+
Icon,
15+
InlineCode,
16+
Layout,
17+
Tooltip
18+
} from '@appwrite.io/pink-svelte';
1119
import { iconPath } from '$lib/stores/app';
1220
import { Link } from '$lib/elements';
1321
import { IconInfo } from '@appwrite.io/pink-icons-svelte';
1422
import { adapterDataList } from './store';
15-
import { getFrameworkIcon, type FrameworkAdapterWithStartCommand } from '$lib/stores/sites';
23+
import { getFrameworkIcon } from '$lib/stores/sites';
1624
import { page } from '$app/state';
1725
1826
let {
@@ -50,9 +58,8 @@
5058
(fallback ?? '') === (site?.fallbackFile ?? '') &&
5159
(adapter ?? '') === (site?.adapter ?? '')
5260
);
53-
let frameworkAdapterData: FrameworkAdapterWithStartCommand = $derived(
54-
(selectedFramework.adapters.find((a) => a.key === adapter) ??
55-
selectedFramework.adapters[0]) as FrameworkAdapterWithStartCommand
61+
let frameworkAdapterData = $derived(
62+
selectedFramework.adapters.find((a) => a.key === adapter) ?? selectedFramework.adapters[0]
5663
);
5764
5865
$effect(() => {
@@ -77,17 +84,19 @@
7784
}
7885
7986
//Update values
80-
const data = (selectedFramework.adapters.find((a) => a.key === adapter) ??
81-
selectedFramework.adapters[0]) as FrameworkAdapterWithStartCommand;
87+
const data =
88+
selectedFramework.adapters.find((a) => a.key === adapter) ??
89+
selectedFramework.adapters[0];
8290
installCommand = data.installCommand;
8391
buildCommand = data.buildCommand;
84-
startCommand = data.startCommand;
8592
outputDirectory = data.outputDirectory;
8693
adapter = data.key as Adapter;
8794
fallback = data.fallbackFile;
95+
startCommand = '';
8896
} else if (hasFrameworkSelectionChanged) {
89-
const data = (selectedFramework.adapters.find((a) => a.key === adapter) ??
90-
selectedFramework.adapters[0]) as FrameworkAdapterWithStartCommand;
97+
const data =
98+
selectedFramework.adapters.find((a) => a.key === adapter) ??
99+
selectedFramework.adapters[0];
91100
const isOriginalAdapter = adapter === site.adapter;
92101
93102
installCommand = isOriginalAdapter
@@ -96,15 +105,13 @@
96105
buildCommand = isOriginalAdapter
97106
? (site?.buildCommand ?? frameworkAdapterData.buildCommand)
98107
: data.buildCommand;
99-
startCommand = isOriginalAdapter
100-
? (site?.startCommand ?? frameworkAdapterData.startCommand)
101-
: data.startCommand;
102108
outputDirectory = isOriginalAdapter
103109
? (site?.outputDirectory ?? frameworkAdapterData.outputDirectory)
104110
: data.outputDirectory;
105111
fallback = isOriginalAdapter
106112
? (site?.fallbackFile ?? data.fallbackFile)
107113
: data.fallbackFile;
114+
startCommand = isOriginalAdapter ? (site?.startCommand ?? '') : '';
108115
}
109116
110117
lastFrameworkAdapterKey = `${selectedFramework.key}:${adapter ?? ''}`;
@@ -162,7 +169,7 @@
162169
timeout: site.timeout || undefined,
163170
installCommand: installCommand || undefined,
164171
buildCommand: buildCommand || undefined,
165-
startCommand: startCommand || undefined,
172+
startCommand: adptr?.key === 'ssr' ? startCommand || undefined : undefined,
166173
outputDirectory: outputDirectory || undefined,
167174
buildRuntime: (site?.buildRuntime as BuildRuntime) || undefined,
168175
adapter: (adptr?.key as Adapter) || undefined,
@@ -193,17 +200,13 @@
193200
}
194201
}
195202
196-
function reset(type: 'installCommand' | 'buildCommand' | 'startCommand' | 'outputDirectory') {
197-
const data = selectedFramework.adapters.find(
198-
(a) => a.key === adapter
199-
) as FrameworkAdapterWithStartCommand;
203+
function reset(type: 'installCommand' | 'buildCommand' | 'outputDirectory') {
204+
const data = selectedFramework.adapters.find((a) => a.key === adapter);
200205
201206
if (type === 'installCommand') {
202207
installCommand = data.installCommand;
203208
} else if (type === 'buildCommand') {
204209
buildCommand = data.buildCommand;
205-
} else if (type === 'startCommand') {
206-
startCommand = data.startCommand;
207210
} else if (type === 'outputDirectory') {
208211
outputDirectory = data.outputDirectory;
209212
}
@@ -332,24 +335,6 @@
332335
Reset
333336
</Button>
334337
</Layout.Stack>
335-
{#if adapter === Adapter.Ssr}
336-
<Layout.Stack gap="s" direction="row" alignItems="flex-end">
337-
<InputText
338-
id="startCommand"
339-
label="Start command"
340-
bind:value={startCommand}
341-
placeholder={frameworkAdapterData?.startCommand ||
342-
'Enter start command'} />
343-
<Button
344-
secondary
345-
size="s"
346-
disabled={(startCommand ?? '') ===
347-
(frameworkAdapterData?.startCommand ?? '')}
348-
on:click={() => reset('startCommand')}>
349-
Reset
350-
</Button>
351-
</Layout.Stack>
352-
{/if}
353338
<Layout.Stack gap="s" direction="row" alignItems="flex-end">
354339
<InputText
355340
id="outputDirectory"
@@ -381,6 +366,19 @@
381366
</Tooltip>
382367
</InputText>
383368
{/if}
369+
{#if adapter === Adapter.Ssr}
370+
<Accordion title="Advanced">
371+
<Layout.Stack gap="l">
372+
Command used to start your SSR server after a successful deploy.
373+
Leave it empty to use the framework default.
374+
<InputText
375+
id="startCommand"
376+
label="Start command"
377+
bind:value={startCommand}
378+
placeholder="Enter start command" />
379+
</Layout.Stack>
380+
</Accordion>
381+
{/if}
384382
</Layout.Stack>
385383
</Fieldset>
386384
</Layout.Stack>

0 commit comments

Comments
 (0)