From d073a344ea63344e7212ee7e024f43861b4fc9f0 Mon Sep 17 00:00:00 2001 From: Bram Suurd Date: Wed, 25 Jun 2025 17:06:23 +0200 Subject: [PATCH] Enhance InstallCommand component to support Gitea as an alternative source for installation scripts. Added informational alert for Gitea usage and refactored command generation logic to accommodate the new option. --- .../ScriptItems/InstallCommand.tsx | 61 +++++++++++++++---- 1 file changed, 48 insertions(+), 13 deletions(-) diff --git a/frontend/src/app/scripts/_components/ScriptItems/InstallCommand.tsx b/frontend/src/app/scripts/_components/ScriptItems/InstallCommand.tsx index ff95097c1..62dd65535 100644 --- a/frontend/src/app/scripts/_components/ScriptItems/InstallCommand.tsx +++ b/frontend/src/app/scripts/_components/ScriptItems/InstallCommand.tsx @@ -1,17 +1,20 @@ import CodeCopyButton from "@/components/ui/code-copy-button"; import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs"; +import { Alert, AlertDescription } from "@/components/ui/alert"; +import { Info } from "lucide-react"; import { basePath } from "@/config/siteConfig"; import { Script } from "@/lib/types"; import { getDisplayValueFromType } from "../ScriptInfoBlocks"; -const getInstallCommand = (scriptPath = "", isAlpine = false) => { - const url = `https://raw.githubusercontent.com/community-scripts/${basePath}/main/${scriptPath}`; - return isAlpine ? `bash -c "$(curl -fsSL ${url})"` : `bash -c "$(curl -fsSL ${url})"`; +const getInstallCommand = (scriptPath = "", isAlpine = false, useGitea = false) => { + const githubUrl = `https://raw.githubusercontent.com/community-scripts/${basePath}/main/${scriptPath}`; + const giteaUrl = `https://git.community-scripts.org/community-scripts/${basePath}/raw/branch/main/${scriptPath}`; + const url = useGitea ? giteaUrl : githubUrl; + return `bash -c "$(curl -fsSL ${url})"`; }; export default function InstallCommand({ item }: { item: Script }) { const alpineScript = item.install_methods.find((method) => method.type === "alpine"); - const defaultScript = item.install_methods.find((method) => method.type === "default"); const renderInstructions = (isAlpine = false) => ( @@ -49,9 +52,20 @@ export default function InstallCommand({ item }: { item: Script }) { ); - return ( -
- {alpineScript ? ( + const renderGiteaInfo = () => ( + + + + When to use Gitea: GitHub may have issues including slow connections, delayed updates after bug + fixes, no IPv6 support, API rate limits (60/hour). Use our Gitea mirror as a reliable alternative when + experiencing these issues. + + + ); + + const renderScriptTabs = (useGitea = false) => { + if (alpineScript) { + return ( Default @@ -59,19 +73,40 @@ export default function InstallCommand({ item }: { item: Script }) { {renderInstructions()} - {getInstallCommand(defaultScript?.script)} + {getInstallCommand(defaultScript?.script, false, useGitea)} {renderInstructions(true)} - {getInstallCommand(alpineScript.script, true)} + {getInstallCommand(alpineScript.script, true, useGitea)} - ) : defaultScript?.script ? ( + ); + } else if (defaultScript?.script) { + return ( <> {renderInstructions()} - {getInstallCommand(defaultScript.script)} + {getInstallCommand(defaultScript.script, false, useGitea)} - ) : null} + ); + } + return null; + }; + + return ( +
+ + + GitHub + Gitea + + + {renderScriptTabs(false)} + + + {renderGiteaInfo()} + {renderScriptTabs(true)} + +
); -} +} \ No newline at end of file