diff --git a/src/lib/stores/marketplace.ts b/src/lib/stores/marketplace.ts index 1d6f88411..af17c3f83 100644 --- a/src/lib/stores/marketplace.ts +++ b/src/lib/stores/marketplace.ts @@ -88,30 +88,30 @@ export const marketplace: MarketplaceTemplate[] = [ timeout: 15, usecases: ['AI'], runtimes: [ - { - name: 'node-18.0', - commands: 'npm install', - entrypoint: 'src/main.js', - providerRootDirectory: 'node/prompt-chatgpt' - }, - { - name: 'python-3.9', - commands: 'pip install -r requirements.txt', - entrypoint: 'src/main.py', - providerRootDirectory: 'python/prompt_chatgpt' - }, - { - name: 'php-8.0', - commands: 'composer install', - entrypoint: 'src/index.php', - providerRootDirectory: 'php/prompt-chatgpt' - }, - { - name: 'dart-2.17', - commands: 'dart pub get', - entrypoint: 'lib/main.dart', - providerRootDirectory: 'dart/prompt_chatgpt' - } + ...getRuntimes( + TemplateRuntimes.NODE, + 'npm install', + 'src/main.js', + 'node/prompt-chatgpt' + ), + ...getRuntimes( + TemplateRuntimes.PYTHON, + 'pip install -r requirements.txt', + 'src/main.py', + 'python/prompt_chatgpt' + ), + ...getRuntimes( + TemplateRuntimes.PHP, + 'composer install', + 'src/index.php', + 'php/prompt-chatgpt' + ), + ...getRuntimes( + TemplateRuntimes.DART, + 'dart pub get', + 'lib/main.dart', + 'dart/prompt_chatgpt' + ) ], instructions: `For documentation and instructions check out file.`, vcsProvider: 'github', @@ -148,18 +148,18 @@ export const marketplace: MarketplaceTemplate[] = [ timeout: 15, usecases: ['Messaging'], runtimes: [ - { - name: 'node-18.0', - commands: 'npm install && npm run setup', - entrypoint: 'src/main.js', - providerRootDirectory: 'node/discord-command-bot' - }, - { - name: 'python-3.9', - commands: 'pip install -r requirements.txt && python src/setup.py', - entrypoint: 'src/main.py', - providerRootDirectory: 'python/discord_command_bot' - } + ...getRuntimes( + TemplateRuntimes.NODE, + 'npm install && npm run setup', + 'src/main.js', + 'node/discord-command-bot' + ), + ...getRuntimes( + TemplateRuntimes.PYTHON, + 'pip install -r requirements.txt && python src/setup.py', + 'src/main.py', + 'python/discord_command_bot' + ) ], instructions: `For documentation and instructions check out file.`, vcsProvider: 'github', @@ -204,12 +204,12 @@ export const marketplace: MarketplaceTemplate[] = [ timeout: 15, usecases: ['AI'], runtimes: [ - { - name: 'node-18.0', - commands: 'npm install', - entrypoint: 'src/main.js', - providerRootDirectory: 'node/analyze-with-perspectiveapi' - } + ...getRuntimes( + TemplateRuntimes.NODE, + 'npm install', + 'src/main.js', + 'node/analyze-with-perspectiveapi' + ) ], instructions: `For documentation and instructions check out file.`, vcsProvider: 'github', @@ -239,24 +239,24 @@ export const marketplace: MarketplaceTemplate[] = [ timeout: 15, usecases: ['AI'], runtimes: [ - { - name: 'node-18.0', - commands: 'npm install', - entrypoint: 'src/main.js', - providerRootDirectory: 'node/censor-with-redact' - }, - { - name: 'python-3.9', - commands: 'pip install -r requirements.txt', - entrypoint: 'src/main.py', - providerRootDirectory: 'python/censor_with_redact' - }, - { - name: 'dart-2.17', - commands: 'dart pub get', - entrypoint: 'lib/main.dart', - providerRootDirectory: 'dart/censor_with_redact' - } + ...getRuntimes( + TemplateRuntimes.NODE, + 'npm install', + 'src/main.js', + 'node/censor-with-redact' + ), + ...getRuntimes( + TemplateRuntimes.PYTHON, + 'pip install -r requirements.txt', + 'src/main.py', + 'python/censor_with_redact' + ), + ...getRuntimes( + TemplateRuntimes.DART, + 'dart pub get', + 'lib/main.dart', + 'dart/censor_with_redact' + ) ], instructions: `For documentation and instructions check out file.`, vcsProvider: 'github', @@ -285,12 +285,7 @@ export const marketplace: MarketplaceTemplate[] = [ timeout: 15, usecases: ['Utilities'], runtimes: [ - { - name: 'node-18.0', - commands: 'npm install', - entrypoint: 'src/main.js', - providerRootDirectory: 'node/generate-pdf' - } + ...getRuntimes(TemplateRuntimes.NODE, 'npm install', 'src/main.js', 'node/generate-pdf') ], instructions: `For documentation and instructions check out file.`, vcsProvider: 'github', @@ -311,12 +306,12 @@ export const marketplace: MarketplaceTemplate[] = [ timeout: 15, usecases: ['Dev Tools'], runtimes: [ - { - name: 'node-18.0', - commands: 'npm install', - entrypoint: 'src/main.js', - providerRootDirectory: 'node/github-issue-bot' - } + ...getRuntimes( + TemplateRuntimes.NODE, + 'npm install', + 'src/main.js', + 'node/github-issue-bot' + ) ], instructions: `For documentation and instructions check out file.`, vcsProvider: 'github', @@ -353,12 +348,12 @@ export const marketplace: MarketplaceTemplate[] = [ timeout: 15, usecases: ['Utilities'], runtimes: [ - { - name: 'node-18.0', - commands: 'npm install', - entrypoint: 'src/main.js', - providerRootDirectory: 'node/url-shortener' - } + ...getRuntimes( + TemplateRuntimes.NODE, + 'npm install', + 'src/main.js', + 'node/url-shortener' + ) ], instructions: `For documentation and instructions check out file.`, vcsProvider: 'github', @@ -419,24 +414,24 @@ export const marketplace: MarketplaceTemplate[] = [ timeout: 15, usecases: ['Databases'], runtimes: [ - { - name: 'node-18.0', - commands: 'npm install', - entrypoint: 'src/main.js', - providerRootDirectory: 'node/sync-with-algolia' - }, - { - name: 'python-3.9', - commands: 'pip install -r requirements.txt', - entrypoint: 'src/main.py', - providerRootDirectory: 'python/sync_with_algolia' - }, - { - name: 'php-8.0', - commands: 'composer install', - entrypoint: 'src/index.php', - providerRootDirectory: 'php/sync-with-algolia' - } + ...getRuntimes( + TemplateRuntimes.NODE, + 'npm install', + 'src/main.js', + 'node/sync-with-algolia' + ), + ...getRuntimes( + TemplateRuntimes.PYTHON, + 'pip install -r requirements.txt', + 'src/main.py', + 'python/sync_with_algolia' + ), + ...getRuntimes( + TemplateRuntimes.PHP, + 'composer install', + 'src/index.php', + 'php/sync-with-algolia' + ) ], instructions: `For documentation and instructions check out file.`, vcsProvider: 'github', @@ -508,12 +503,12 @@ export const marketplace: MarketplaceTemplate[] = [ timeout: 15, usecases: ['Databases'], runtimes: [ - { - name: 'node-18.0', - commands: 'npm install', - entrypoint: 'src/main.js', - providerRootDirectory: 'node/sync-with-meilisearch' - } + ...getRuntimes( + TemplateRuntimes.NODE, + 'npm install', + 'src/main.js', + 'node/sync-with-meilisearch' + ) ], instructions: `For documentation and instructions check out file.`, vcsProvider: 'github', @@ -592,12 +587,12 @@ export const marketplace: MarketplaceTemplate[] = [ timeout: 15, usecases: ['Messaging'], runtimes: [ - { - name: 'node-18.0', - commands: 'npm install', - entrypoint: 'src/main.js', - providerRootDirectory: 'node/whatsapp-with-vonage' - } + ...getRuntimes( + TemplateRuntimes.NODE, + 'npm install', + 'src/main.js', + 'node/whatsapp-with-vonage' + ) ], instructions: `For documentation and instructions check out file.`, vcsProvider: 'github', @@ -647,12 +642,12 @@ export const marketplace: MarketplaceTemplate[] = [ timeout: 15, usecases: ['Messaging'], runtimes: [ - { - name: 'node-18.0', - commands: 'npm install', - entrypoint: 'src/main.js', - providerRootDirectory: 'node/push-notification-with-fcm' - } + ...getRuntimes( + TemplateRuntimes.NODE, + 'npm install', + 'src/main.js', + 'node/push-notification-with-fcm' + ) ], instructions: `For documentation and instructions check out file.`, vcsProvider: 'github', @@ -702,24 +697,24 @@ export const marketplace: MarketplaceTemplate[] = [ timeout: 15, usecases: ['Utilities'], runtimes: [ - { - name: 'node-18.0', - commands: 'npm install', - entrypoint: 'src/main.js', - providerRootDirectory: 'node/email-contact-form' - }, - { - name: 'python-3.9', - commands: 'pip install -r requirements.txt', - entrypoint: 'src/main.py', - providerRootDirectory: 'python/email_contact_form' - }, - { - name: 'php-8.0', - commands: 'composer install', - entrypoint: 'src/index.php', - providerRootDirectory: 'php/email-contact-form' - } + ...getRuntimes( + TemplateRuntimes.NODE, + 'npm install', + 'src/main.js', + 'node/email-contact-form' + ), + ...getRuntimes( + TemplateRuntimes.PYTHON, + 'pip install -r requirements.txt', + 'src/main.py', + 'python/email_contact_form' + ), + ...getRuntimes( + TemplateRuntimes.PHP, + 'composer install', + 'src/index.php', + 'php/email-contact-form' + ) ], instructions: `For documentation and instructions check out file.`, vcsProvider: 'github', @@ -784,12 +779,12 @@ export const marketplace: MarketplaceTemplate[] = [ timeout: 15, usecases: ['Utilities'], runtimes: [ - { - name: 'node-18.0', - commands: 'npm install', - entrypoint: 'src/main.js', - providerRootDirectory: 'node/subscriptions-with-stripe' - } + ...getRuntimes( + TemplateRuntimes.NODE, + 'npm install', + 'src/main.js', + 'node/subscriptions-with-stripe' + ) ], instructions: `For documentation and instructions check out file.`, vcsProvider: 'github', @@ -840,12 +835,12 @@ export const marketplace: MarketplaceTemplate[] = [ timeout: 15, usecases: ['Utilities'], runtimes: [ - { - name: 'node-18.0', - commands: 'npm install && npm run setup', - entrypoint: 'src/main.js', - providerRootDirectory: 'node/payments-with-stripe' - } + ...getRuntimes( + TemplateRuntimes.NODE, + 'npm install', + 'src/main.js', + 'node/payments-with-stripe' + ) ], instructions: `For documentation and instructions check out file.`, vcsProvider: 'github', diff --git a/src/lib/wizards/functions/cover.svelte b/src/lib/wizards/functions/cover.svelte index 189ed47d2..9a4fe150f 100644 --- a/src/lib/wizards/functions/cover.svelte +++ b/src/lib/wizards/functions/cover.svelte @@ -35,7 +35,10 @@ import { marketplace, type MarketplaceTemplate } from '$lib/stores/marketplace'; import { Button } from '$lib/elements/forms'; import { page } from '$app/stores'; - import { runtimesList } from '$routes/console/project-[project]/functions/store'; + import { + baseRuntimesList, + runtimesList + } from '$routes/console/project-[project]/functions/store'; import { trackEvent } from '$lib/actions/analytics'; import type { Models } from '@appwrite.io/console'; import WizardCover from '$lib/layout/wizardCover.svelte'; @@ -91,7 +94,7 @@ style:--grid-item-size="8rem" style:--grid-item-size-small-screens="9rem" style:--grid-gap=".5rem"> - {#await $runtimesList} + {#await $baseRuntimesList} {#each Array(6) as _i}
  • - Runtimes {$template.runtimes.length} + Runtimes {$baseRuntimes.length}

    - {#each $template.runtimes as runtime} + {#each $baseRuntimes as runtime} {runtime.name} {/each}
    diff --git a/src/routes/console/project-[project]/functions/templates/template-[template]/store.ts b/src/routes/console/project-[project]/functions/templates/template-[template]/store.ts index b39b8545b..a31caa70d 100644 --- a/src/routes/console/project-[project]/functions/templates/template-[template]/store.ts +++ b/src/routes/console/project-[project]/functions/templates/template-[template]/store.ts @@ -3,3 +3,12 @@ import type { MarketplaceTemplate } from '$lib/stores/marketplace'; import { derived } from 'svelte/store'; export const template = derived(page, ($page) => $page.data.template as MarketplaceTemplate); + +export const baseRuntimes = derived(template, ($template) => + $template.runtimes + .map((runtime) => { + const runtimeBase = runtime.name.split('-')[0]; + return { ...runtime, name: runtimeBase }; + }) + .filter((runtime, index, self) => self.findIndex((n) => n.name === runtime.name) === index) +);