From aa5e2edbc53f70dc27019134ef3b8e026fef6424 Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Sun, 20 Feb 2022 14:40:15 +0100 Subject: [PATCH 01/15] feat: Scan for lock files and set right commands --- src/lib/components/templates.ts | 177 ++++++++++++++---- .../[id]/configuration/_BuildPack.svelte | 6 +- .../[id]/configuration/buildpack.svelte | 62 ++++-- .../[id]/configuration/source.svelte | 2 +- 4 files changed, 189 insertions(+), 58 deletions(-) diff --git a/src/lib/components/templates.ts b/src/lib/components/templates.ts index d6029e4d2..bea552812 100644 --- a/src/lib/components/templates.ts +++ b/src/lib/components/templates.ts @@ -1,16 +1,146 @@ -const defaultBuildAndDeploy = { - installCommand: 'yarn install', - buildCommand: 'yarn build', - startCommand: 'yarn start' -}; -export const buildPacks = [ - { +function defaultBuildAndDeploy(packageManager) { + return { + installCommand: + packageManager === 'npm' ? `${packageManager} run install` : `${packageManager} install`, + buildCommand: + packageManager === 'npm' ? `${packageManager} run build` : `${packageManager} build`, + startCommand: + packageManager === 'npm' ? `${packageManager} run start` : `${packageManager} start` + }; +} +export function findBuildPack(pack, packageManager = 'npm') { + const metaData = buildPacks.find((b) => b.name === pack); + if (pack === 'node') { + return { + ...metaData, + installCommand: null, + buildCommand: null, + startCommand: null, + publishDirectory: null, + port: null + }; + } + if (pack === 'static') { + return { + ...metaData, + installCommand: null, + buildCommand: null, + startCommand: null, + publishDirectory: null, + port: 80 + }; + } + if (pack === 'docker') { + return { + ...metaData, + installCommand: null, + buildCommand: null, + startCommand: null, + publishDirectory: null, + port: null + }; + } + if (pack === 'svelte') { + return { + ...metaData, + ...defaultBuildAndDeploy(packageManager), + publishDirectory: 'public', + port: 80 + }; + } + if (pack === 'nestjs') { + return { + ...metaData, + ...defaultBuildAndDeploy(packageManager), + startCommand: + packageManager === 'npm' ? 'npm run start:prod' : `${packageManager} run start:prod`, + publishDirectory: null, + port: 3000 + }; + } + if (pack === 'react') { + return { + ...metaData, + ...defaultBuildAndDeploy(packageManager), + publishDirectory: 'build', + port: 80 + }; + } + if (pack === 'nextjs') { + return { + ...metaData, + ...defaultBuildAndDeploy(packageManager), + publishDirectory: null, + port: 3000 + }; + } + if (pack === 'gatsby') { + return { + ...metaData, + ...defaultBuildAndDeploy(packageManager), + publishDirectory: 'public', + port: 80 + }; + } + if (pack === 'vuejs') { + return { + ...metaData, + ...defaultBuildAndDeploy(packageManager), + publishDirectory: 'dist', + port: 80 + }; + } + if (pack === 'nuxtjs') { + return { + ...metaData, + ...defaultBuildAndDeploy(packageManager), + publishDirectory: null, + port: 3000 + }; + } + if (pack === 'preact') { + return { + ...metaData, + ...defaultBuildAndDeploy(packageManager), + publishDirectory: 'build', + port: 80 + }; + } + if (pack === 'php') { + return { + ...metaData, + installCommand: null, + buildCommand: null, + startCommand: null, + publishDirectory: null, + port: 80 + }; + } + if (pack === 'rust') { + return { + ...metaData, + installCommand: null, + buildCommand: null, + startCommand: null, + publishDirectory: null, + port: 3000 + }; + } + return { name: 'node', + fancyName: 'Node.js', + hoverColor: 'hover:bg-green-700', + color: 'bg-green-700', installCommand: null, buildCommand: null, startCommand: null, publishDirectory: null, - port: null, + port: null + }; +} +export const buildPacks = [ + { + name: 'node', fancyName: 'Node.js', hoverColor: 'hover:bg-green-700', color: 'bg-green-700' @@ -18,103 +148,72 @@ export const buildPacks = [ { name: 'static', - publishDirectory: 'dist', - port: 80, fancyName: 'Static', hoverColor: 'hover:bg-orange-700', color: 'bg-orange-700' }, { name: 'docker', - installCommand: null, - buildCommand: null, - startCommand: null, - publishDirectory: null, - port: null, fancyName: 'Docker', hoverColor: 'hover:bg-sky-700', color: 'bg-sky-700' }, { name: 'svelte', - ...defaultBuildAndDeploy, - publishDirectory: 'public', - port: 80, fancyName: 'Svelte', hoverColor: 'hover:bg-orange-700', color: 'bg-orange-700' }, { name: 'nestjs', - ...defaultBuildAndDeploy, - startCommand: 'yarn start:prod', - port: 3000, fancyName: 'NestJS', hoverColor: 'hover:bg-red-700', color: 'bg-red-700' }, { name: 'react', - ...defaultBuildAndDeploy, - publishDirectory: 'build', - port: 80, fancyName: 'React', hoverColor: 'hover:bg-blue-700', color: 'bg-blue-700' }, { name: 'nextjs', - ...defaultBuildAndDeploy, - port: 3000, fancyName: 'NextJS', hoverColor: 'hover:bg-blue-700', color: 'bg-blue-700' }, { name: 'gatsby', - ...defaultBuildAndDeploy, - publishDirectory: 'public', - port: 80, fancyName: 'Gatsby', hoverColor: 'hover:bg-blue-700', color: 'bg-blue-700' }, { name: 'vuejs', - ...defaultBuildAndDeploy, - publishDirectory: 'dist', - port: 80, fancyName: 'VueJS', hoverColor: 'hover:bg-green-700', color: 'bg-green-700' }, { name: 'nuxtjs', - ...defaultBuildAndDeploy, - port: 3000, fancyName: 'NuxtJS', hoverColor: 'hover:bg-green-700', color: 'bg-green-700' }, { name: 'preact', - ...defaultBuildAndDeploy, - publishDirectory: 'build', - port: 80, fancyName: 'Preact', hoverColor: 'hover:bg-blue-700', color: 'bg-blue-700' }, { name: 'php', - port: 80, fancyName: 'PHP', hoverColor: 'hover:bg-indigo-700', color: 'bg-indigo-700' }, { name: 'rust', - port: 3000, fancyName: 'Rust', hoverColor: 'hover:bg-pink-700', color: 'bg-pink-700' diff --git a/src/routes/applications/[id]/configuration/_BuildPack.svelte b/src/routes/applications/[id]/configuration/_BuildPack.svelte index df04789c1..dadbc9dde 100644 --- a/src/routes/applications/[id]/configuration/_BuildPack.svelte +++ b/src/routes/applications/[id]/configuration/_BuildPack.svelte @@ -3,6 +3,7 @@ import { page } from '$app/stores'; import { post } from '$lib/api'; + import { findBuildPack } from '$lib/components/templates'; import { errorNotification } from '$lib/form'; const { id } = $page.params; @@ -11,10 +12,13 @@ export let buildPack; export let foundConfig; export let scanning; + export let packageManager; async function handleSubmit(name) { try { - const tempBuildPack = JSON.parse(JSON.stringify(buildPack)); + const tempBuildPack = JSON.parse( + JSON.stringify(findBuildPack(buildPack.name, packageManager)) + ); delete tempBuildPack.name; delete tempBuildPack.fancyName; delete tempBuildPack.color; diff --git a/src/routes/applications/[id]/configuration/buildpack.svelte b/src/routes/applications/[id]/configuration/buildpack.svelte index 79f424753..434986fcb 100644 --- a/src/routes/applications/[id]/configuration/buildpack.svelte +++ b/src/routes/applications/[id]/configuration/buildpack.svelte @@ -29,14 +29,16 @@ diff --git a/src/lib/components/Setting.svelte b/src/lib/components/Setting.svelte index 680203c95..c8764bed7 100644 --- a/src/lib/components/Setting.svelte +++ b/src/lib/components/Setting.svelte @@ -15,7 +15,12 @@ -
+
Waiting for the new version to start...'); + toast.push('Update completed.

Waiting for the new version to start...'); let reachable = false; let tries = 0; do { diff --git a/src/routes/applications/[id]/check.json.ts b/src/routes/applications/[id]/check.json.ts index 36e87b616..82fb487ed 100644 --- a/src/routes/applications/[id]/check.json.ts +++ b/src/routes/applications/[id]/check.json.ts @@ -16,7 +16,7 @@ export const post: RequestHandler = async (event) => { const found = await db.isDomainConfigured({ id, fqdn }); if (found) { throw { - message: `Domain ${getDomain(fqdn).replace('www.', '')} is already configured.` + message: `Domain ${getDomain(fqdn).replace('www.', '')} is already used.` }; } return { diff --git a/src/routes/applications/[id]/index.svelte b/src/routes/applications/[id]/index.svelte index 4e487ed9c..bfd9133eb 100644 --- a/src/routes/applications/[id]/index.svelte +++ b/src/routes/applications/[id]/index.svelte @@ -173,81 +173,71 @@ {/if}
-
+
-
- -
+
-
+
-
- -
+
-
+
-
- -
+
-
+
-
- - -
+ +
-
+
-
-
- -
+
+
@@ -255,24 +245,24 @@
Application
-
- -
- +
+
+
+
{#if !staticDeployments.includes(application.buildPack)} -
+
-
- -
-
- {/if} - - {#if !notNodeDeployments.includes(application.buildPack)} -
- -
- -
-
-
- -
- -
-
-
- -
- -
-
- {/if} - -
- -
-
+ {/if} + + {#if !notNodeDeployments.includes(application.buildPack)} +
+ + +
+
+ + +
+
+ + +
+ {/if} + +
+ + +
{#if !notNodeDeployments.includes(application.buildPack)} -
+
-
- - -
+ +
{/if}
diff --git a/src/routes/destinations/[id]/_FoundApp.svelte b/src/routes/destinations/[id]/_FoundApp.svelte index f183388fa..835c121bf 100644 --- a/src/routes/destinations/[id]/_FoundApp.svelte +++ b/src/routes/destinations/[id]/_FoundApp.svelte @@ -61,12 +61,12 @@
Loading...
{:else if app.foundByDomain}
- Domain already configured for + Domain already used for {app.foundName}
{:else if app.foundByRepository}
- Repository already configured for + Repository already used for {app.foundName}
{:else} diff --git a/src/routes/services/[id]/check.json.ts b/src/routes/services/[id]/check.json.ts index 861daee84..9a9193524 100644 --- a/src/routes/services/[id]/check.json.ts +++ b/src/routes/services/[id]/check.json.ts @@ -17,7 +17,7 @@ export const post: RequestHandler = async (event) => { return { status: found ? 500 : 200, body: { - error: found && `Domain ${getDomain(fqdn).replace('www.', '')} is already configured` + error: found && `Domain ${getDomain(fqdn).replace('www.', '')} is already used.` } }; } catch (error) { diff --git a/src/routes/settings/check.json.ts b/src/routes/settings/check.json.ts index 15d91613f..d24dcc0e6 100644 --- a/src/routes/settings/check.json.ts +++ b/src/routes/settings/check.json.ts @@ -16,7 +16,7 @@ export const post: RequestHandler = async (event) => { return { status: found ? 500 : 200, body: { - error: found && `Domain ${fqdn.replace('www.', '')} is already configured` + error: found && `Domain ${fqdn.replace('www.', '')} is already used.` } }; } catch (error) { diff --git a/src/routes/settings/index.json.ts b/src/routes/settings/index.json.ts index bd365d5e4..a1182bb42 100644 --- a/src/routes/settings/index.json.ts +++ b/src/routes/settings/index.json.ts @@ -78,7 +78,7 @@ export const post: RequestHandler = async (event) => { }; if (status === 401) return { status, body }; - const { fqdn, isRegistrationEnabled, dualCerts } = await event.request.json(); + const { fqdn, isRegistrationEnabled, dualCerts, minPort, maxPort } = await event.request.json(); try { const { id, @@ -119,6 +119,9 @@ export const post: RequestHandler = async (event) => { data: { isCoolifyProxyUsed: true } }); } + if (minPort && maxPort) { + await db.prisma.setting.update({ where: { id }, data: { minPort, maxPort } }); + } return { status: 201 diff --git a/src/routes/settings/index.svelte b/src/routes/settings/index.svelte index f86af5e4b..80c3cee80 100644 --- a/src/routes/settings/index.svelte +++ b/src/routes/settings/index.svelte @@ -35,6 +35,9 @@ let isRegistrationEnabled = settings.isRegistrationEnabled; let dualCerts = settings.dualCerts; + let minPort = settings.minPort; + let maxPort = settings.maxPort; + let fqdn = settings.fqdn; let isFqdnSet = !!settings.fqdn; let loading = { @@ -75,7 +78,11 @@ if (fqdn) { await post(`/settings/check.json`, { fqdn }); await post(`/settings.json`, { fqdn }); - return window.location.reload(); + } + if (minPort !== settings.minPort || maxPort !== settings.maxPort) { + await post(`/settings.json`, { minPort, maxPort }); + settings.minPort = minPort; + settings.maxPort = maxPort; } } catch ({ error }) { return errorNotification(error); @@ -112,7 +119,12 @@
-
Domain (FQDN)
+
+
Domain (FQDN)
+ +
+
+
+
+
+
Public Port Range
+
+
+ + - +
@@ -135,7 +168,7 @@ disabled={isFqdnSet} bind:setting={dualCerts} title="Generate SSL for www and non-www?" - description="It will generate certificates for both www and non-www.
You need to have both DNS entries set in advance.

Useful if you expect to have visitors on both." + description="It will generate certificates for both www and non-www.
You need to have both DNS entries set in advance.

Useful if you expect to have visitors on both." on:click={() => !isFqdnSet && changeSettings('dualCerts')} />
From df18b938099c60ee5d90052ea081410cbf78f6b3 Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Tue, 22 Feb 2022 12:56:58 +0100 Subject: [PATCH 13/15] Design day! --- src/lib/components/CopyPasswordField.svelte | 2 +- src/lib/components/Explainer.svelte | 2 +- src/routes/__layout.svelte | 19 +- src/routes/applications/[id]/index.svelte | 51 +++-- .../applications/[id]/secrets/_Secret.svelte | 18 +- .../applications/[id]/secrets/index.svelte | 32 +-- .../databases/[id]/_Databases/_CouchDb.svelte | 10 +- .../[id]/_Databases/_Databases.svelte | 12 +- .../databases/[id]/_Databases/_MongoDB.svelte | 4 +- .../databases/[id]/_Databases/_MySQL.svelte | 10 +- .../[id]/_Databases/_PostgreSQL.svelte | 6 +- .../databases/[id]/_Databases/_Redis.svelte | 2 +- .../destinations/[id]/_LocalDocker.svelte | 128 +++++------ src/routes/destinations/[id]/index.svelte | 5 +- src/routes/new/destination/_Docker.svelte | 64 ++---- src/routes/new/source/_Github.svelte | 57 +++-- src/routes/new/source/_Gitlab.svelte | 83 +++---- .../services/[id]/_Services/_Services.svelte | 35 ++- src/routes/settings/index.svelte | 6 +- src/routes/sources/[id]/_Github.svelte | 46 ++-- src/routes/sources/[id]/_Gitlab.svelte | 216 ++++++++---------- src/routes/sources/[id]/index.svelte | 2 +- src/routes/teams/[id]/index.svelte | 86 ++++--- src/tailwind.css | 4 +- 24 files changed, 418 insertions(+), 482 deletions(-) diff --git a/src/lib/components/CopyPasswordField.svelte b/src/lib/components/CopyPasswordField.svelte index 9a409fb17..cb207b475 100644 --- a/src/lib/components/CopyPasswordField.svelte +++ b/src/lib/components/CopyPasswordField.svelte @@ -29,7 +29,7 @@ {#if !isPasswordField || showPassword} {#if textarea}