diff --git a/frontend/Dockerfile b/frontend/Dockerfile index 4962709..de209d7 100644 --- a/frontend/Dockerfile +++ b/frontend/Dockerfile @@ -5,7 +5,7 @@ ### Build Step # pull the Node.js Docker image FROM node:24-trixie AS builder -# ENV API_URL=http://api:80 +ENV CI=true ENV API_URL=https://mawoka.eu #Ah, I've noticed that!!! ENV REDIS_URL=redis://localhost:6379 @@ -25,9 +25,10 @@ WORKDIR /usr/src/app # copy the package.json files from local machine to the workdir in container COPY package*.json ./ COPY pnpm-lock.yaml ./ +COPY pnpm-workspace.yaml ./ # run npm install in our local machine -RUN corepack enable && corepack prepare pnpm@10.14.0 --activate && pnpm i +RUN corepack enable && corepack prepare pnpm@11.6 --activate && pnpm ci --ignore-scripts # copy the generated modules and all other files to the container COPY . . @@ -38,12 +39,13 @@ RUN pnpm run build ### Serve Step # pull the Node.js Docker image FROM node:24-trixie-slim +ENV CI=true # change working directory WORKDIR /app COPY --from=builder /usr/src/app/package.json . COPY --from=builder /usr/src/app/pnpm-lock.yaml . -RUN corepack enable && corepack prepare pnpm@10.14.0 --activate && pnpm i +RUN corepack enable && corepack prepare pnpm@11.6 --activate && pnpm ci --ignore-scripts # copy files from previous step COPY --from=builder /usr/src/app/build . COPY --from=builder /usr/src/app/node_modules ./node_modules diff --git a/frontend/pnpm-workspace.yaml b/frontend/pnpm-workspace.yaml index 5f449ce..a6d2db3 100644 --- a/frontend/pnpm-workspace.yaml +++ b/frontend/pnpm-workspace.yaml @@ -1,5 +1,11 @@ # SPDX-FileCopyrightText: 2023 Marlon W (Mawoka) # # SPDX-License-Identifier: MPL-2.0 + +allowBuilds: + esbuild: true + svelte-preprocess: true + '@parcel/watcher': true + onlyBuiltDependencies: - svelte-preprocess diff --git a/frontend/src/lib/config.ts b/frontend/src/lib/config.ts index 7d162b4..c1d0edb 100644 --- a/frontend/src/lib/config.ts +++ b/frontend/src/lib/config.ts @@ -2,7 +2,13 @@ // // SPDX-License-Identifier: MPL-2.0 -export const google_auth_enabled = import.meta.env.VITE_GOOGLE_AUTH_ENABLED === 'true'; -export const github_auth_enabled = import.meta.env.VITE_GITHUB_AUTH_ENABLED === 'true'; -export const captcha_enabled = import.meta.env.VITE_CAPTCHA_ENABLED === 'true'; +// the old prefix: import.meta.env.VITE_ +export const google_auth_enabled = import.meta.env.VITE_GOOGLE_AUTH_ENABLED; +export const github_auth_enabled = import.meta.env.VITE_GITHUB_AUTH_ENABLED; +export const captcha_enabled = import.meta.env.VITE_CAPTCHA_ENABLED; export const custom_oauth_name = import.meta.env.VITE_CUSTOM_OAUTH_NAME; +export const registration_disabled = import.meta.env.VITE_REGISTRATION_DISABLED; +export const hcaptcha_site_key = import.meta.env.VITE_HCAPTCHA; +export const sentry_dsn = import.meta.env.VITE_SENTRY; +export const recaptcha_key = import.meta.env.VITE_RECAPTCHA; +export const plausible_data_url = import.meta.env.VITE_PLAUSIBLE_DATA_URL; diff --git a/frontend/src/lib/navbar.svelte b/frontend/src/lib/navbar.svelte index 0658fa7..8bf586d 100644 --- a/frontend/src/lib/navbar.svelte +++ b/frontend/src/lib/navbar.svelte @@ -13,6 +13,7 @@ SPDX-License-Identifier: MPL-2.0 import { browser } from '$app/environment'; import { beforeNavigate } from '$app/navigation'; import { draw, slide } from 'svelte/transition'; + import { registration_disabled } from './config'; const tippy = createTippy({ arrow: true, @@ -93,7 +94,7 @@ SPDX-License-Identifier: MPL-2.0 {#if $signedIn} {$t('words.logout')} {:else} - {#if !import.meta.env.VITE_REGISTRATION_DISABLED} + {#if registration_disabled} {$t('words.register')} {/if} @@ -322,7 +323,7 @@ SPDX-License-Identifier: MPL-2.0 {#if $signedIn} {$t('words.logout')} {:else} - {#if !import.meta.env.VITE_REGISTRATION_DISABLED} + {#if registration_disabled} {$t('words.register')} {/if} diff --git a/frontend/src/lib/play/join.svelte b/frontend/src/lib/play/join.svelte index c180632..02f431d 100644 --- a/frontend/src/lib/play/join.svelte +++ b/frontend/src/lib/play/join.svelte @@ -12,6 +12,7 @@ SPDX-License-Identifier: MPL-2.0 import { getLocalization } from '$lib/i18n'; import Cookies from 'js-cookie'; import BrownButton from '$lib/components/buttons/brown.svelte'; + import { hcaptcha_site_key, recaptcha_key, sentry_dsn } from '$lib/config'; const { t } = getLocalization(); @@ -30,7 +31,7 @@ SPDX-License-Identifier: MPL-2.0 let custom_field_value = $state(); let captcha_enabled = $state(); - let hcaptchaSitekey = import.meta.env.VITE_HCAPTCHA; + let hcaptchaSitekey = hcaptcha_site_key; let hcaptcha = { execute: async (_a, _b) => ({ response: '' }), // eslint-disable-line @typescript-eslint/no-unused-vars @@ -143,7 +144,7 @@ SPDX-License-Identifier: MPL-2.0 custom_field: custom_field ? custom_field_value : undefined }); } catch (e) { - if (import.meta.env.VITE_SENTRY !== null) { + if (sentry_dsn !== null) { Sentry.captureException(e); } /* alertModal.set({ @@ -154,20 +155,18 @@ SPDX-License-Identifier: MPL-2.0 alert('Captcha failed!'); window.location.reload(); } - } else if (import.meta.env.VITE_RECAPTCHA) { + } else if (recaptcha_key) { // eslint-disable-next-line no-undef grecaptcha.ready(() => { // eslint-disable-next-line no-undef - grecaptcha - .execute(import.meta.env.VITE_RECAPTCHA, { action: 'submit' }) - .then(function (token) { - socket.emit('join_game', { - username: username, - game_pin: game_pin, - captcha: token, - custom_field: custom_field ? custom_field_value : undefined - }); + grecaptcha.execute(recaptcha_key, { action: 'submit' }).then(function (token) { + socket.emit('join_game', { + username: username, + game_pin: game_pin, + captcha: token, + custom_field: custom_field ? custom_field_value : undefined }); + }); }); } } else { @@ -198,10 +197,8 @@ SPDX-License-Identifier: MPL-2.0 {#if captcha_enabled && hcaptchaSitekey} {/if} - {#if import.meta.env.VITE_RECAPTCHA && captcha_enabled} - + {#if recaptcha_key && captcha_enabled} + {/if} diff --git a/frontend/src/routes/+layout.svelte b/frontend/src/routes/+layout.svelte index 408ba3c..e57306b 100644 --- a/frontend/src/routes/+layout.svelte +++ b/frontend/src/routes/+layout.svelte @@ -13,12 +13,12 @@ SPDX-License-Identifier: MPL-2.0 import { initLocalizationContext } from '$lib/i18n'; import { browser } from '$app/environment'; import CommandPalette from '$lib/components/commandpalette.svelte'; + import { plausible_data_url } from '$lib/config'; interface Props { children?: import('svelte').Snippet; } let { children }: Props = $props(); - const plausible_data_url = import.meta.env.VITE_PLAUSIBLE_DATA_URL; if (browser) { pathname.set(window.location.pathname); diff --git a/frontend/src/routes/account/login/oauth_block.svelte b/frontend/src/routes/account/login/oauth_block.svelte index 5b2e0b2..3aff44c 100644 --- a/frontend/src/routes/account/login/oauth_block.svelte +++ b/frontend/src/routes/account/login/oauth_block.svelte @@ -6,6 +6,7 @@ SPDX-License-Identifier: MPL-2.0 {#if google_auth_enabled}