-
Notifications
You must be signed in to change notification settings - Fork 237
Expand file tree
/
Copy pathupdateBuildCommand.svelte
More file actions
75 lines (70 loc) · 3.07 KB
/
updateBuildCommand.svelte
File metadata and controls
75 lines (70 loc) · 3.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
<script lang="ts">
import { invalidate } from '$app/navigation';
import { Submit, trackError, trackEvent } from '$lib/actions/analytics';
import { CardGrid } from '$lib/components';
import { Dependencies } from '$lib/constants';
import { Button, Form, InputText } from '$lib/elements/forms';
import { addNotification } from '$lib/stores/notifications';
import { sdk } from '$lib/stores/sdk';
import { isValueOfStringEnum } from '$lib/helpers/types';
import { Runtime, type Models } from '@appwrite.io/console';
import { isCloud } from '$lib/system';
import { page } from '$app/state';
export let func: Models.Function;
let buildCommand = func.commands;
async function updateLogging() {
try {
if (!isValueOfStringEnum(Runtime, func.runtime)) {
throw new Error(`Invalid runtime: ${func.runtime}`);
}
await sdk.forProject(page.params.region, page.params.project).functions.update({
functionId: func.$id,
name: func.name,
runtime: func.runtime,
execute: func.execute || undefined,
events: func.events || undefined,
schedule: func.schedule || undefined,
timeout: func.timeout || undefined,
enabled: func.enabled || undefined,
logging: func.logging || undefined,
entrypoint: func.entrypoint || undefined,
commands: buildCommand || undefined,
scopes: func.scopes || undefined,
installationId: func.installationId || undefined,
providerRepositoryId: func.providerRepositoryId || undefined,
providerBranch: func.providerBranch || undefined,
providerSilentMode: func.providerSilentMode || undefined,
providerRootDirectory: func.providerRootDirectory || undefined,
specification: isCloud ? func.specification || undefined : undefined
});
await invalidate(Dependencies.FUNCTION);
addNotification({
type: 'success',
message: 'Build command has been updated'
});
trackEvent(Submit.FunctionUpdateBuildCommand);
} catch (error) {
addNotification({
type: 'error',
message: error.message
});
trackError(error, Submit.FunctionUpdateBuildCommand);
}
}
</script>
<Form onSubmit={updateLogging}>
<CardGrid>
<svelte:fragment slot="title">Build command</svelte:fragment>
Define the command used to build your function before deployment.
<svelte:fragment slot="aside">
<InputText
label="Build command"
id="buildCommand"
placeholder="npm install"
bind:value={buildCommand} />
</svelte:fragment>
<svelte:fragment slot="actions">
<Button disabled={func.commands === buildCommand} submit>Update</Button>
</svelte:fragment>
</CardGrid>
</Form>