mirror of
https://github.com/appwrite/console.git
synced 2026-11-18 20:47:21 +00:00
fix: create deployment
This commit is contained in:
1 parent
468959cba9
commit
275c99d29a
9 files changed
+316
-254
No files matched your search
Generated
+6
@@ -13,6 +13,7 @@
|
||||
"@sentry/svelte": "^7.44.2",
|
||||
"@sentry/tracing": "^7.44.2",
|
||||
"analytics": "^0.8.1",
|
||||
"dayjs": "^1.11.9",
|
||||
"dotenv": "^16.0.3",
|
||||
"echarts": "^5.4.1",
|
||||
"logrocket": "^3.0.1",
|
||||
@@ -3450,6 +3451,11 @@
|
||||
"node": ">=14"
|
||||
}
|
||||
},
|
||||
"node_modules/dayjs": {
|
||||
"version": "1.11.9",
|
||||
"resolved": "https://registry.npmjs.org/dayjs/-/dayjs-1.11.9.tgz",
|
||||
"integrity": "sha512-QvzAURSbQ0pKdIye2txOzNaHmxtUBXerpY0FJsFXUMKbIZeFm5ht1LS/jFsrncjnmtv8HsG0W2g6c0zUjZWmpA=="
|
||||
},
|
||||
"node_modules/debug": {
|
||||
"version": "4.3.4",
|
||||
"resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz",
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
"@sentry/svelte": "^7.44.2",
|
||||
"@sentry/tracing": "^7.44.2",
|
||||
"analytics": "^0.8.1",
|
||||
"dayjs": "^1.11.9",
|
||||
"dotenv": "^16.0.3",
|
||||
"echarts": "^5.4.1",
|
||||
"logrocket": "^3.0.1",
|
||||
|
||||
@@ -1,3 +1,11 @@
|
||||
import { browser } from '$app/environment';
|
||||
import dayjs from 'dayjs';
|
||||
import relativeTime from 'dayjs/plugin/relativeTime';
|
||||
|
||||
if (browser) {
|
||||
dayjs.extend(relativeTime);
|
||||
}
|
||||
|
||||
export const toLocaleDate = (datetime: string) => {
|
||||
const date = new Date(datetime);
|
||||
const options: Intl.DateTimeFormatOptions = {
|
||||
@@ -39,3 +47,7 @@ export const diffDays = (date1: Date, date2: Date) => {
|
||||
const diffTime = Math.abs(date2.getTime() - date1.getTime());
|
||||
return Math.floor(diffTime / (1000 * 60 * 60 * 24));
|
||||
};
|
||||
|
||||
export function timeFromNow(datetime: string): string {
|
||||
return dayjs().to(dayjs(datetime));
|
||||
}
|
||||
@@ -5,10 +5,10 @@
|
||||
DropList,
|
||||
DropListItem,
|
||||
Empty,
|
||||
Status,
|
||||
Heading,
|
||||
PaginationWithLimit,
|
||||
Id
|
||||
Id,
|
||||
Alert
|
||||
} from '$lib/components';
|
||||
import {
|
||||
TableHeader,
|
||||
@@ -19,19 +19,18 @@
|
||||
TableCellText,
|
||||
TableScroll
|
||||
} from '$lib/elements/table';
|
||||
import { execute, func } from './store';
|
||||
import { func } from './store';
|
||||
import { Container } from '$lib/layout';
|
||||
import { base } from '$app/paths';
|
||||
import { app } from '$lib/stores/app';
|
||||
import { calculateSize } from '$lib/helpers/sizeConvertion';
|
||||
import { toLocaleDateTime } from '$lib/helpers/date';
|
||||
import { calculateSize, humanFileSize } from '$lib/helpers/sizeConvertion';
|
||||
import { timeFromNow } from '$lib/helpers/date';
|
||||
import { log } from '$lib/stores/logs';
|
||||
import { invalidate } from '$app/navigation';
|
||||
import { Dependencies } from '$lib/constants';
|
||||
import type { Models } from '@appwrite.io/console';
|
||||
import type { PageData } from './$types';
|
||||
import Delete from './delete.svelte';
|
||||
import Create from './create.svelte';
|
||||
import Activate from './activate.svelte';
|
||||
import { browser } from '$app/environment';
|
||||
import { sdk } from '$lib/stores/sdk';
|
||||
@@ -39,7 +38,8 @@
|
||||
import { timer } from '$lib/actions/timer';
|
||||
import { addNotification } from '$lib/stores/notifications';
|
||||
import { Submit, trackError, trackEvent } from '$lib/actions/analytics';
|
||||
import Alert from '$lib/components/alert.svelte';
|
||||
import { Pill } from '$lib/elements';
|
||||
import Create from './create.svelte';
|
||||
|
||||
export let data: PageData;
|
||||
|
||||
@@ -105,10 +105,7 @@
|
||||
<Container>
|
||||
<div class="u-flex u-gap-12 common-section u-main-space-between">
|
||||
<Heading tag="h2" size="5">Deployments</Heading>
|
||||
<Button on:click={() => (showCreate = true)} event="create_deployment">
|
||||
<span class="icon-plus" aria-hidden="true" />
|
||||
<span class="text">Create deployment</span>
|
||||
</Button>
|
||||
<Create bind:showCreate />
|
||||
</div>
|
||||
{#if data.deployments.total}
|
||||
<div class="common-section">
|
||||
@@ -116,7 +113,7 @@
|
||||
</div>
|
||||
{#if activeDeployment && !$func.live}
|
||||
<div class="u-margin-block-start-8">
|
||||
<Alert isInline={true} type="warning">
|
||||
<Alert isInline type="warning">
|
||||
Some configuration options are not live yet. Redeploy your function to apply
|
||||
latest changes.
|
||||
</Alert>
|
||||
@@ -134,12 +131,10 @@
|
||||
</div>
|
||||
<div>
|
||||
<div class="u-flex u-gap-12 u-cross-center">
|
||||
<p><b>Function ID: </b></p>
|
||||
<Id value={$func.$id}><b>{$func.$id}</b></Id>
|
||||
<p><b>Deployment ID</b></p>
|
||||
</div>
|
||||
|
||||
<div class="u-flex u-gap-12 u-cross-center">
|
||||
<p>Deployment ID:</p>
|
||||
<Id value={$func.deployment}>
|
||||
{$func.deployment}
|
||||
</Id>
|
||||
@@ -147,29 +142,28 @@
|
||||
</div>
|
||||
</div>
|
||||
<svelte:fragment slot="aside">
|
||||
{@const status = activeDeployment.status}
|
||||
{@const fileSize = humanFileSize(activeDeployment.size)}
|
||||
<div class="u-flex u-main-space-between">
|
||||
<div>
|
||||
<p>Created at: {toLocaleDateTime($func.$createdAt)}</p>
|
||||
<p>Updated at: {toLocaleDateTime($func.$updatedAt)}</p>
|
||||
<p>Entrypoint: {activeDeployment?.entrypoint}</p>
|
||||
<p><b>Build time:</b> {calculateTime(activeDeployment.buildTime)}</p>
|
||||
<p><b>Created:</b> {timeFromNow(activeDeployment.$createdAt)}</p>
|
||||
<p><b>Size:</b> {fileSize.value + fileSize.unit}</p>
|
||||
<p><b>Source:</b> <span>Git</span></p>
|
||||
</div>
|
||||
<div class="u-flex u-flex-vertical u-cross-end">
|
||||
<Status status={activeDeployment.status}>
|
||||
{activeDeployment.status}
|
||||
</Status>
|
||||
<p class="text">
|
||||
{calculateTime(activeDeployment.buildTime)}
|
||||
</p>
|
||||
<Pill
|
||||
danger={status === 'failed'}
|
||||
warning={status === 'pending'}
|
||||
success={status === 'completed' || status === 'ready'}
|
||||
info={status === 'processing' || status === 'building'}>
|
||||
<span class="text u-trim">{activeDeployment.status}</span>
|
||||
</Pill>
|
||||
</div>
|
||||
</div>
|
||||
</svelte:fragment>
|
||||
|
||||
<svelte:fragment slot="actions">
|
||||
<Button
|
||||
text
|
||||
on:click={() => {
|
||||
redeploy(activeDeployment);
|
||||
}}>Redeploy</Button>
|
||||
<Button
|
||||
text
|
||||
on:click={() => {
|
||||
@@ -179,10 +173,10 @@
|
||||
}}>
|
||||
Build logs
|
||||
</Button>
|
||||
<a target="_blank" href={'http://' + data.domain.rules[0].domain}>
|
||||
<Button secondary>HTTP Execute</Button>
|
||||
</a>
|
||||
<Button secondary on:click={() => execute.set($func)}>Advanced Execute</Button>
|
||||
<Button text on:click={() => redeploy(activeDeployment)}>Redeploy</Button>
|
||||
<Button secondary external href={'http://' + data.domain.rules[0].domain}>
|
||||
Execute now
|
||||
</Button>
|
||||
</svelte:fragment>
|
||||
</CardGrid>
|
||||
{:else}
|
||||
@@ -200,8 +194,9 @@
|
||||
<TableScroll>
|
||||
<TableHeader>
|
||||
<TableCellHead width={150}>Deployment ID</TableCellHead>
|
||||
<TableCellHead width={140}>Created</TableCellHead>
|
||||
<TableCellHead width={100}>Status</TableCellHead>
|
||||
<TableCellHead width={70}>Source</TableCellHead>
|
||||
<TableCellHead width={180}>Created</TableCellHead>
|
||||
<TableCellHead width={100}>Build Time</TableCellHead>
|
||||
<TableCellHead width={70}>Size</TableCellHead>
|
||||
<TableCellHead width={25} />
|
||||
@@ -209,19 +204,24 @@
|
||||
<TableBody>
|
||||
{#each data.deployments.deployments as deployment, index}
|
||||
{#if deployment.$id !== $func.deployment}
|
||||
{@const status = deployment.status}
|
||||
<TableRow>
|
||||
<TableCell width={150} title="Deployment ID">
|
||||
<Id value={deployment.$id}>{deployment.$id}</Id>
|
||||
</TableCell>
|
||||
<TableCellText width={140} title="Created">
|
||||
{toLocaleDateTime(deployment.$createdAt)}
|
||||
</TableCellText>
|
||||
|
||||
<TableCell width={100} title="Status">
|
||||
<Status status={deployment.status}>
|
||||
{deployment.status}
|
||||
</Status>
|
||||
<Pill
|
||||
danger={status === 'failed'}
|
||||
warning={status === 'pending'}
|
||||
success={status === 'completed' || status === 'ready'}
|
||||
info={status === 'processing' || status === 'building'}>
|
||||
<span class="text u-trim">{status}</span>
|
||||
</Pill>
|
||||
</TableCell>
|
||||
<TableCellText width={70} title="Source">Git</TableCellText>
|
||||
<TableCellText width={140} title="Created">
|
||||
{timeFromNow(deployment.$createdAt)}
|
||||
</TableCellText>
|
||||
|
||||
<TableCellText width={100} title="Build Time">
|
||||
{#if ['processing', 'building'].includes(deployment.status)}
|
||||
@@ -312,9 +312,7 @@
|
||||
text
|
||||
event="empty_documentation"
|
||||
ariaLabel={`create {target}`}>Documentation</Button>
|
||||
<Button secondary on:click={() => (showCreate = true)}>
|
||||
Create deployment
|
||||
</Button>
|
||||
<Create />
|
||||
</div>
|
||||
</Empty>
|
||||
{/if}
|
||||
@@ -330,8 +328,6 @@
|
||||
<PaginationWithLimit name="Deployments" limit={data.limit} offset={data.offset} total={sum} />
|
||||
</Container>
|
||||
|
||||
<Create bind:showCreate />
|
||||
|
||||
{#if selectedDeployment}
|
||||
<Delete {selectedDeployment} bind:showDelete />
|
||||
<Activate {selectedDeployment} bind:showActivate on:activated={handleActivate} />
|
||||
|
||||
@@ -1,208 +1,27 @@
|
||||
<script lang="ts">
|
||||
import { InputChoice, Button, InputFile, FormList } from '$lib/elements/forms';
|
||||
import { Modal, Collapsible, CollapsibleItem, Tabs, Tab, Code } from '$lib/components';
|
||||
import { sdk } from '$lib/stores/sdk';
|
||||
import { createEventDispatcher, onMount } from 'svelte';
|
||||
import { page } from '$app/stores';
|
||||
import GithubLight from '$lib/images/github-illustration-light.svg';
|
||||
import GithubDark from '$lib/images/github-illustration-dark.svg';
|
||||
import { invalidate } from '$app/navigation';
|
||||
import { Dependencies } from '$lib/constants';
|
||||
import { func } from './store';
|
||||
import { Submit, trackEvent, trackError } from '$lib/actions/analytics';
|
||||
import { app } from '$lib/stores/app';
|
||||
import { DropList, DropListItem } from '$lib/components';
|
||||
import { Button } from '$lib/elements/forms';
|
||||
import CreateCli from './createCli.svelte';
|
||||
import CreateGit from './createGit.svelte';
|
||||
import CreateManual from './createManual.svelte';
|
||||
|
||||
export let showCreate = false;
|
||||
|
||||
enum Mode {
|
||||
CLI,
|
||||
Github,
|
||||
Manual
|
||||
}
|
||||
let mode: Mode = Mode.CLI;
|
||||
let active = false;
|
||||
let files: FileList;
|
||||
let lang = 'js';
|
||||
let codeSnippets = {};
|
||||
let os = 'unknown';
|
||||
let error: string = null;
|
||||
|
||||
const functionId = $page.params.function;
|
||||
const dispatch = createEventDispatcher();
|
||||
|
||||
onMount(() => {
|
||||
lang = setLanguage($func.runtime);
|
||||
codeSnippets = setCodeSnippets(lang);
|
||||
os = navigator['userAgentData']?.platform || navigator?.platform || 'unknown';
|
||||
});
|
||||
|
||||
function setLanguage(runtime: string) {
|
||||
if (runtime.includes('node') || runtime.includes('deno')) {
|
||||
return 'js';
|
||||
} else if (runtime.includes('php')) {
|
||||
return 'php';
|
||||
} else if (runtime.includes('python')) {
|
||||
return 'py';
|
||||
} else if (runtime.includes('dart')) {
|
||||
return 'dart';
|
||||
} else if (runtime.includes('dotnet')) {
|
||||
return 'cs';
|
||||
} else if (runtime.includes('ruby')) {
|
||||
return 'rb';
|
||||
} else if (runtime.includes('swift')) {
|
||||
return 'swift';
|
||||
} else if (runtime.includes('kotlin')) {
|
||||
return 'kt';
|
||||
} else if (runtime.includes('java')) {
|
||||
return 'java';
|
||||
}
|
||||
}
|
||||
|
||||
function setCodeSnippets(lang: string) {
|
||||
return {
|
||||
Unix: {
|
||||
code: `appwrite functions createDeployment \\
|
||||
--functionId=${functionId} \\
|
||||
--entrypoint='index.${lang}' \\
|
||||
--code="." \\
|
||||
--activate=true`,
|
||||
language: 'bash'
|
||||
},
|
||||
|
||||
CMD: {
|
||||
code: `appwrite functions createDeployment ^
|
||||
--functionId=${functionId} ^
|
||||
--entrypoint='index.${lang}' ^
|
||||
--code="." ^
|
||||
--activate=true`,
|
||||
language: 'CMD'
|
||||
},
|
||||
PowerShell: {
|
||||
code: `appwrite functions createDeployment ,
|
||||
--functionId=${functionId} ,
|
||||
--entrypoint='index.${lang}' ,
|
||||
--code="." ,
|
||||
--activate=true`,
|
||||
language: 'PowerShell'
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
async function create() {
|
||||
try {
|
||||
await sdk.forProject.functions.createDeployment(functionId, files[0], active);
|
||||
await invalidate(Dependencies.DEPLOYMENTS);
|
||||
files = undefined;
|
||||
active = false;
|
||||
showCreate = false;
|
||||
dispatch('created');
|
||||
trackEvent(Submit.DeploymentCreate);
|
||||
} catch (e) {
|
||||
error = e.message;
|
||||
trackError(e, Submit.DeploymentCreate);
|
||||
}
|
||||
}
|
||||
|
||||
function openCategory(category: string, index: number) {
|
||||
switch (category) {
|
||||
case 'CMD':
|
||||
return os.includes('Win');
|
||||
case 'PowerShell':
|
||||
return os.includes('Win');
|
||||
case 'Unix':
|
||||
return (
|
||||
os === 'unknown' || os.includes('Linux') || os.includes('Mac') || index === 0
|
||||
);
|
||||
default:
|
||||
return index === 0;
|
||||
}
|
||||
}
|
||||
|
||||
$: if (!showCreate) {
|
||||
files = undefined;
|
||||
active = false;
|
||||
error = null;
|
||||
}
|
||||
let showCreateCli = false;
|
||||
let showCreateGit = false;
|
||||
let showCreateManual = false;
|
||||
</script>
|
||||
|
||||
<Modal {error} size="big" bind:show={showCreate} onSubmit={create}>
|
||||
<svelte:fragment slot="header">Create Deployment</svelte:fragment>
|
||||
<Tabs>
|
||||
<Tab on:click={() => (mode = Mode.CLI)} selected={mode === Mode.CLI} event="deploy_cli">
|
||||
CLI
|
||||
</Tab>
|
||||
<Tab
|
||||
on:click={() => (mode = Mode.Github)}
|
||||
selected={mode === Mode.Github}
|
||||
event="deploy_github">
|
||||
GitHub - (Soon)
|
||||
</Tab>
|
||||
<Tab
|
||||
on:click={() => (mode = Mode.Manual)}
|
||||
selected={mode === Mode.Manual}
|
||||
event="deploy_manual">Manual</Tab>
|
||||
</Tabs>
|
||||
{#if mode === Mode.CLI}
|
||||
<p class="text">
|
||||
You can deploy your function from the Appwrite CLI using Unix, CMD, or PowerShell. Check
|
||||
out our Documentation to learn more about <a
|
||||
href="https://appwrite.io/docs/functions#deployFunction"
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
class="link">deploying your functions</a
|
||||
>, or how to install and use the
|
||||
<a
|
||||
href="https://appwrite.io/docs/command-line"
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
class="link">Appwrite CLI</a
|
||||
>.
|
||||
</p>
|
||||
<Collapsible>
|
||||
{#each ['Unix', 'CMD', 'PowerShell'] as category, i}
|
||||
<CollapsibleItem open={openCategory(category, i)}>
|
||||
<svelte:fragment slot="title">{category}</svelte:fragment>
|
||||
<Code
|
||||
withLineNumbers
|
||||
withCopy
|
||||
language="sh"
|
||||
label={codeSnippets[category].language}
|
||||
code={codeSnippets[category].code} />
|
||||
</CollapsibleItem>
|
||||
{/each}
|
||||
</Collapsible>
|
||||
{:else if mode === Mode.Github}
|
||||
<div class="grid-1-1 u-gap-16">
|
||||
{#if $app.themeInUse === 'dark'}
|
||||
<img src={GithubDark} alt="github" />
|
||||
{:else}
|
||||
<img src={GithubLight} alt="github" />
|
||||
{/if}
|
||||
<div class="u-flex u-flex-vertical u-gap-24">
|
||||
<h3 class="body-text-1 u-bold">Coming Soon!</h3>
|
||||
<p>
|
||||
Creating deployments will be easier than ever with our upcoming Git Integration.
|
||||
Just set up a repository and we'll do the rest.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
{:else if mode === Mode.Manual}
|
||||
<FormList>
|
||||
<InputFile
|
||||
label="Gzipped code (tar.gz)"
|
||||
allowedFileExtensions={['gz']}
|
||||
bind:files
|
||||
required={true} />
|
||||
<InputChoice label="Activate deployment after build" id="activate" bind:value={active}>
|
||||
This deployment will be activated after the build is completed.</InputChoice>
|
||||
</FormList>
|
||||
{/if}
|
||||
<svelte:fragment slot="footer">
|
||||
{#if mode === Mode.Manual}
|
||||
<Button secondary on:click={() => (showCreate = false)}>Close</Button>
|
||||
<Button submit>Create</Button>
|
||||
{:else}
|
||||
<Button secondary on:click={() => (showCreate = false)}>Close</Button>
|
||||
{/if}
|
||||
<DropList bind:show={showCreate} placement="bottom-end">
|
||||
<Button on:click={() => (showCreate = true)} event="create_deployment">
|
||||
<span class="icon-plus" aria-hidden="true" />
|
||||
<span class="text">Create deployment</span>
|
||||
</Button>
|
||||
<svelte:fragment slot="list">
|
||||
<DropListItem on:click={() => (showCreateGit = true)}>Git</DropListItem>
|
||||
<DropListItem on:click={() => (showCreateCli = true)}>CLI</DropListItem>
|
||||
<DropListItem on:click={() => (showCreateManual = true)}>Manual</DropListItem>
|
||||
</svelte:fragment>
|
||||
</Modal>
|
||||
</DropList>
|
||||
<CreateCli bind:show={showCreateCli} />
|
||||
<CreateGit bind:show={showCreateGit} />
|
||||
<CreateManual bind:show={showCreateManual} />
|
||||
@@ -0,0 +1,123 @@
|
||||
<script lang="ts">
|
||||
import { Button } from '$lib/elements/forms';
|
||||
import { Modal, Collapsible, CollapsibleItem, Code } from '$lib/components';
|
||||
import { onMount } from 'svelte';
|
||||
import { page } from '$app/stores';
|
||||
import { func } from './store';
|
||||
|
||||
export let show = false;
|
||||
|
||||
let lang = 'js';
|
||||
let codeSnippets = {};
|
||||
let os = 'unknown';
|
||||
|
||||
const functionId = $page.params.function;
|
||||
|
||||
onMount(() => {
|
||||
lang = setLanguage($func.runtime);
|
||||
codeSnippets = setCodeSnippets(lang);
|
||||
os = navigator['userAgentData']?.platform || navigator?.platform || 'unknown';
|
||||
});
|
||||
|
||||
function setLanguage(runtime: string) {
|
||||
if (runtime.includes('node') || runtime.includes('deno')) {
|
||||
return 'js';
|
||||
} else if (runtime.includes('php')) {
|
||||
return 'php';
|
||||
} else if (runtime.includes('python')) {
|
||||
return 'py';
|
||||
} else if (runtime.includes('dart')) {
|
||||
return 'dart';
|
||||
} else if (runtime.includes('dotnet')) {
|
||||
return 'cs';
|
||||
} else if (runtime.includes('ruby')) {
|
||||
return 'rb';
|
||||
} else if (runtime.includes('swift')) {
|
||||
return 'swift';
|
||||
} else if (runtime.includes('kotlin')) {
|
||||
return 'kt';
|
||||
} else if (runtime.includes('java')) {
|
||||
return 'java';
|
||||
}
|
||||
}
|
||||
|
||||
function setCodeSnippets(lang: string) {
|
||||
return {
|
||||
Unix: {
|
||||
code: `appwrite functions createDeployment \\
|
||||
--functionId=${functionId} \\
|
||||
--entrypoint='index.${lang}' \\
|
||||
--code="." \\
|
||||
--activate=true`,
|
||||
language: 'bash'
|
||||
},
|
||||
|
||||
CMD: {
|
||||
code: `appwrite functions createDeployment ^
|
||||
--functionId=${functionId} ^
|
||||
--entrypoint='index.${lang}' ^
|
||||
--code="." ^
|
||||
--activate=true`,
|
||||
language: 'CMD'
|
||||
},
|
||||
PowerShell: {
|
||||
code: `appwrite functions createDeployment ,
|
||||
--functionId=${functionId} ,
|
||||
--entrypoint='index.${lang}' ,
|
||||
--code="." ,
|
||||
--activate=true`,
|
||||
language: 'PowerShell'
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
function openCategory(category: string, index: number) {
|
||||
switch (category) {
|
||||
case 'CMD':
|
||||
return os.includes('Win');
|
||||
case 'PowerShell':
|
||||
return os.includes('Win');
|
||||
case 'Unix':
|
||||
return (
|
||||
os === 'unknown' || os.includes('Linux') || os.includes('Mac') || index === 0
|
||||
);
|
||||
default:
|
||||
return index === 0;
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<Modal size="big" bind:show>
|
||||
<svelte:fragment slot="header">Create Deployment</svelte:fragment>
|
||||
<p class="text">
|
||||
You can deploy your function from the Appwrite CLI using Unix, CMD, or PowerShell. Check out
|
||||
our Documentation to learn more about <a
|
||||
href="https://appwrite.io/docs/functions#deployFunction"
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
class="link">deploying your functions</a
|
||||
>, or how to install and use the
|
||||
<a
|
||||
href="https://appwrite.io/docs/command-line"
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
class="link">Appwrite CLI</a
|
||||
>.
|
||||
</p>
|
||||
<Collapsible>
|
||||
{#each ['Unix', 'CMD', 'PowerShell'] as category, i}
|
||||
<CollapsibleItem open={openCategory(category, i)}>
|
||||
<svelte:fragment slot="title">{category}</svelte:fragment>
|
||||
<Code
|
||||
withLineNumbers
|
||||
withCopy
|
||||
language="sh"
|
||||
label={codeSnippets[category].language}
|
||||
code={codeSnippets[category].code} />
|
||||
</CollapsibleItem>
|
||||
{/each}
|
||||
</Collapsible>
|
||||
<svelte:fragment slot="footer">
|
||||
<Button secondary on:click={() => (show = false)}>Close</Button>
|
||||
</svelte:fragment>
|
||||
</Modal>
|
||||
@@ -0,0 +1,22 @@
|
||||
<script lang="ts">
|
||||
import { Button } from '$lib/elements/forms';
|
||||
import { Modal } from '$lib/components';
|
||||
|
||||
export let show = false;
|
||||
</script>
|
||||
|
||||
<Modal size="big" bind:show>
|
||||
<svelte:fragment slot="header">Create Deployment</svelte:fragment>
|
||||
<p class="text">
|
||||
Deploy your function from the Git provider of your choice. When you push to a connected
|
||||
repository, your function will be deployed. Learn more about <a
|
||||
href="https://appwrite.io/docs/functions-deployment"
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
class="link">function deployments</a
|
||||
>.
|
||||
</p>
|
||||
<svelte:fragment slot="footer">
|
||||
<Button secondary on:click={() => (show = false)}>Close</Button>
|
||||
</svelte:fragment>
|
||||
</Modal>
|
||||
+85
@@ -0,0 +1,85 @@
|
||||
<script lang="ts">
|
||||
import {
|
||||
InputChoice,
|
||||
Button,
|
||||
InputFile,
|
||||
FormList,
|
||||
InputTextarea,
|
||||
InputText
|
||||
} from '$lib/elements/forms';
|
||||
import { Collapsible, CollapsibleItem, Modal } from '$lib/components';
|
||||
import { sdk } from '$lib/stores/sdk';
|
||||
import { createEventDispatcher } from 'svelte';
|
||||
import { page } from '$app/stores';
|
||||
import { invalidate } from '$app/navigation';
|
||||
import { Dependencies } from '$lib/constants';
|
||||
import { Submit, trackEvent, trackError } from '$lib/actions/analytics';
|
||||
|
||||
export let show = false;
|
||||
|
||||
let active = false;
|
||||
let files: FileList;
|
||||
let entrypoint: string = null;
|
||||
let buildCommand: string = null;
|
||||
let error: string = null;
|
||||
|
||||
const functionId = $page.params.function;
|
||||
const dispatch = createEventDispatcher();
|
||||
|
||||
async function create() {
|
||||
try {
|
||||
await sdk.forProject.functions.createDeployment(functionId, files[0], active);
|
||||
await invalidate(Dependencies.DEPLOYMENTS);
|
||||
files = undefined;
|
||||
active = false;
|
||||
show = false;
|
||||
dispatch('created');
|
||||
trackEvent(Submit.DeploymentCreate);
|
||||
} catch (e) {
|
||||
error = e.message;
|
||||
trackError(e, Submit.DeploymentCreate);
|
||||
}
|
||||
}
|
||||
|
||||
$: if (!show) {
|
||||
files = undefined;
|
||||
active = false;
|
||||
error = null;
|
||||
}
|
||||
</script>
|
||||
|
||||
<Modal {error} size="big" bind:show onSubmit={create}>
|
||||
<svelte:fragment slot="header">Create Deployment</svelte:fragment>
|
||||
<FormList>
|
||||
<InputFile
|
||||
label="Gzipped code (tar.gz)"
|
||||
allowedFileExtensions={['gz']}
|
||||
bind:files
|
||||
required={true} />
|
||||
<InputText
|
||||
label="Entrypoint"
|
||||
id="entrypoint"
|
||||
placeholder="Entrypoint"
|
||||
bind:value={entrypoint}
|
||||
required />
|
||||
<Collapsible>
|
||||
<CollapsibleItem>
|
||||
<svelte:fragment slot="title">Build commands</svelte:fragment>
|
||||
<svelte:fragment slot="subtitle">(optional)</svelte:fragment>
|
||||
<FormList>
|
||||
<InputTextarea
|
||||
label="Commands"
|
||||
placeholder="Enter a build commad (e.g. 'npm run build')"
|
||||
id="build"
|
||||
bind:value={buildCommand} />
|
||||
</FormList>
|
||||
</CollapsibleItem>
|
||||
</Collapsible>
|
||||
<InputChoice label="Activate deployment after build" id="activate" bind:value={active}>
|
||||
This deployment will be activated after the build is completed.</InputChoice>
|
||||
</FormList>
|
||||
<svelte:fragment slot="footer">
|
||||
<Button secondary on:click={() => (show = false)}>Close</Button>
|
||||
<Button submit>Create</Button>
|
||||
</svelte:fragment>
|
||||
</Modal>
|
||||
+4
-6
@@ -1,6 +1,6 @@
|
||||
<script lang="ts">
|
||||
import { invalidate } from '$app/navigation';
|
||||
import { EmptySearch, Heading, Id, PaginationWithLimit, Status } from '$lib/components';
|
||||
import { Alert, EmptySearch, Heading, Id, PaginationWithLimit } from '$lib/components';
|
||||
import { Dependencies } from '$lib/constants';
|
||||
import { Pill } from '$lib/elements';
|
||||
import { Button } from '$lib/elements/forms';
|
||||
@@ -20,15 +20,15 @@
|
||||
import { sdk } from '$lib/stores/sdk';
|
||||
import { onDestroy, onMount } from 'svelte';
|
||||
import { func } from '../store';
|
||||
import CreateDeployment from '../create.svelte';
|
||||
import type { Models } from '@appwrite.io/console';
|
||||
import type { PageData } from './$types';
|
||||
import Alert from '$lib/components/alert.svelte';
|
||||
import { project } from '$routes/console/project-[project]/store';
|
||||
import Create from '../create.svelte';
|
||||
|
||||
export let data: PageData;
|
||||
|
||||
let showCreate = false;
|
||||
|
||||
let unsubscribe: { (): void };
|
||||
|
||||
onMount(() => {
|
||||
@@ -128,10 +128,8 @@
|
||||
<Button text external href="https://appwrite.io/docs/functions#execute">
|
||||
Documentation
|
||||
</Button>
|
||||
<Button secondary on:click={() => (showCreate = true)}>Create deployment</Button>
|
||||
<Create bind:showCreate />
|
||||
</div>
|
||||
</EmptySearch>
|
||||
{/if}
|
||||
</Container>
|
||||
|
||||
<CreateDeployment bind:showCreate />
|
||||
Reference in new issue
Block a user