feat: add detection

This commit is contained in:
Arman committed 2025-03-11 16:31:38 +01:00
1 parent 17507c6625
commit 50e31b6237
2 files changed
+50 -15

No files matched your search

@@ -52,7 +52,7 @@
let currentVariable: Partial<Models.Variable>;
let frameworkId = selectedFramework.key;
$: frameworkData = frameworks.find((framework) => framework.key === selectedFramework.key);
$: frameworkData = frameworks.find((framework) => framework.key === selectedFramework?.key);
</script>
<Fieldset legend="Settings">
@@ -81,11 +81,12 @@
id="installCommand"
label="Install command"
bind:value={installCommand}
placeholder={frameworkData?.defaultInstallCommand} />
placeholder={frameworkData?.adapters?.ssr?.installCommand} />
<Button
secondary
size="s"
disabled={frameworkData?.defaultInstallCommand === installCommand}
disabled={frameworkData?.adapters?.ssr?.installCommand ===
installCommand}
on:click={() => (installCommand = '')}>
Reset
</Button>
@@ -95,11 +96,12 @@
id="buildCommand"
label="Build command"
bind:value={buildCommand}
placeholder={frameworkData?.defaultBuildCommand} />
placeholder={frameworkData?.adapters?.ssr?.buildCommand} />
<Button
secondary
size="s"
disabled={frameworkData?.defaultBuildCommand === buildCommand}
disabled={frameworkData?.adapters?.ssr?.buildCommand ===
buildCommand}
on:click={() => (buildCommand = '')}>
Reset
</Button>
@@ -109,11 +111,12 @@
id="outputDirectory"
label="Output directory"
bind:value={outputDirectory}
placeholder={frameworkData?.defaultOutputDirectory} />
placeholder={frameworkData?.adapters?.ssr?.outputDirectory} />
<Button
secondary
size="s"
disabled={frameworkData?.defaultOutputDirectory === outputDirectory}
disabled={frameworkData?.adapters?.ssr?.outputDirectory ===
outputDirectory}
on:click={() => (outputDirectory = '')}>
Reset
</Button>
@@ -15,7 +15,13 @@
import Details from '../../details.svelte';
import ProductionBranch from '$lib/components/git/productionBranchFieldset.svelte';
import Aside from '../../aside.svelte';
import { BuildRuntime, Framework, ID, VCSDeploymentType } from '@appwrite.io/console';
import {
BuildRuntime,
Framework,
ID,
VCSDeploymentType,
VCSDetectionType
} from '@appwrite.io/console';
import type { Models } from '@appwrite.io/console';
import { onMount } from 'svelte';
import Configuration from '../../configuration.svelte';
@@ -46,8 +52,30 @@
installation.set(data.installation);
repository.set(data.repository);
name = data.repository.name;
await detectFramwork();
});
async function detectFramwork() {
try {
const response = await sdk.forProject.vcs.createRepositoryDetection(
$installation.$id,
data.repository.id,
VCSDetectionType.Framework,
rootDir
);
framework = data.frameworks.frameworks.find((f) => f.key === response.framework);
adapter = framework?.adapters[0];
installCommand = adapter?.installCommand;
buildCommand = adapter?.buildCommand;
outputDirectory = adapter?.outputDirectory;
console.log(framework);
console.log(response);
} catch (error) {
console.log(error);
}
}
async function create() {
try {
domain = await buildVerboseDomain(
@@ -119,6 +147,8 @@
trackError(e, Submit.SiteCreate);
}
}
$: console.log(framework);
</script>
<svelte:head>
@@ -160,13 +190,15 @@
installationId={data.installation.$id}
repositoryId={data.repository.id} />
<Configuration
bind:installCommand
bind:buildCommand
bind:outputDirectory
bind:selectedFramework={framework}
bind:variables
frameworks={data.frameworks.frameworks} />
{#key framework.key}
<Configuration
bind:installCommand
bind:buildCommand
bind:outputDirectory
bind:selectedFramework={framework}
bind:variables
frameworks={data.frameworks.frameworks} />
{/key}
</Layout.Stack>
</Form>
<svelte:fragment slot="aside">